summaryrefslogtreecommitdiffstats
path: root/src/windows/identity/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/identity/ui')
-rw-r--r--src/windows/identity/ui/Makefile109
-rw-r--r--src/windows/identity/ui/Makefile.w2k91
-rw-r--r--src/windows/identity/ui/aboutwnd.c154
-rw-r--r--src/windows/identity/ui/aboutwnd.h33
-rw-r--r--src/windows/identity/ui/addrchange.c93
-rw-r--r--src/windows/identity/ui/addrchange.h36
-rw-r--r--src/windows/identity/ui/appglobal.h163
-rw-r--r--src/windows/identity/ui/appver.rc40
-rw-r--r--src/windows/identity/ui/cfg_appear_wnd.c440
-rw-r--r--src/windows/identity/ui/cfg_general_wnd.c424
-rw-r--r--src/windows/identity/ui/cfg_identities_wnd.c1573
-rw-r--r--src/windows/identity/ui/cfg_notif_wnd.c350
-rw-r--r--src/windows/identity/ui/cfg_plugins_wnd.c654
-rw-r--r--src/windows/identity/ui/configwnd.c1243
-rw-r--r--src/windows/identity/ui/configwnd.h88
-rw-r--r--src/windows/identity/ui/credfuncs.c1415
-rw-r--r--src/windows/identity/ui/credfuncs.h95
-rw-r--r--src/windows/identity/ui/credwnd.c5952
-rw-r--r--src/windows/identity/ui/credwnd.h306
-rw-r--r--src/windows/identity/ui/debugfuncs.c256
-rw-r--r--src/windows/identity/ui/debugfuncs.h37
-rw-r--r--src/windows/identity/ui/htwnd.c1311
-rw-r--r--src/windows/identity/ui/htwnd.h57
-rw-r--r--src/windows/identity/ui/images/app_notify_error.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/app_notify_info.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/app_notify_none.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/app_notify_warn.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/app_state_exp.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/app_state_ok.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/app_state_warn.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_applied.icobin1406 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_default.icobin1406 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_deleted.icobin1406 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_mod.icobin1406 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_plugin.icobin9110 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_plugin_dis.icobin8854 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/cfg_plugin_err.icobin8854 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/chpw-dis-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/chpw-dis.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/chpw-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/chpw.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/disabled.icobin2166 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/enabled.icobin2166 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/flag-critical.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/flag-warning.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/flag_expired.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/flag_renewable.bmpbin1334 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/help-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/help.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-delete-dis-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-delete-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-delete-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-delete.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-dis-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-new-dis-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-new-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-new-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-new.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-refresh-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-refresh-sm-dis.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-refresh-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-refresh.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/id.icobin2862 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/ident.pngbin423 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/import-dis.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/import-sm-dis.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/import-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/import.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/khimaira-cfg.bmpbin30056 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/logo_shade.bmpbin30056 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/main_app.icobin25214 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tb-blank-small.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tb-blank.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tb-space.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-delete-dis-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-delete-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-delete-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-delete.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-dis-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-new-dis-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-new-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-new-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-new.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-refresh-dis-sm.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-refresh-dis.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-refresh-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-refresh.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/tk.bmpbin3186 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/vw-refresh-sm.bmpbin822 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/vw-refresh.bmpbin2430 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_collapsed.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_collapsed_hi.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_credtype.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_expanded.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_expanded_hi.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_flag.bmpbin1014 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_stick.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_stick_hi.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_stuck.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/images/wdg_stuck_hi.bmpbin774 -> 0 bytes
-rw-r--r--src/windows/identity/ui/khmapp.h70
-rw-r--r--src/windows/identity/ui/lang/en_us/cmdline.rtfbin1252 -> 0 bytes
-rw-r--r--src/windows/identity/ui/lang/en_us/khapp.rc869
-rw-r--r--src/windows/identity/ui/main.c1075
-rw-r--r--src/windows/identity/ui/mainmenu.c1233
-rw-r--r--src/windows/identity/ui/mainmenu.h68
-rw-r--r--src/windows/identity/ui/mainwnd.c1380
-rw-r--r--src/windows/identity/ui/mainwnd.h82
-rw-r--r--src/windows/identity/ui/makeacceldef.pl29
-rw-r--r--src/windows/identity/ui/makeactiondef.pl29
-rw-r--r--src/windows/identity/ui/netidmgr.exe.manifest.i38622
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.amd64.vc722
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.amd64.vc7.debug22
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.amd64.vc831
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.amd64.vc8.debug31
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.i386.vc722
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.i386.vc7.debug22
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.i386.vc831
-rw-r--r--src/windows/identity/ui/netidmgr.manifest.i386.vc8.debug31
-rw-r--r--src/windows/identity/ui/newcredwnd.c3034
-rw-r--r--src/windows/identity/ui/newcredwnd.h193
-rw-r--r--src/windows/identity/ui/notifier.c3173
-rw-r--r--src/windows/identity/ui/notifier.h69
-rw-r--r--src/windows/identity/ui/passwnd.c133
-rw-r--r--src/windows/identity/ui/passwnd.h39
-rw-r--r--src/windows/identity/ui/propertywnd.c254
-rw-r--r--src/windows/identity/ui/propertywnd.h36
-rw-r--r--src/windows/identity/ui/reqdaemon.c453
-rw-r--r--src/windows/identity/ui/reqdaemon.h42
-rw-r--r--src/windows/identity/ui/resource.h421
-rw-r--r--src/windows/identity/ui/statusbar.c206
-rw-r--r--src/windows/identity/ui/statusbar.h55
-rw-r--r--src/windows/identity/ui/taskbar.c87
-rw-r--r--src/windows/identity/ui/taskbar.h38
-rw-r--r--src/windows/identity/ui/timer.c1015
-rw-r--r--src/windows/identity/ui/timer.h100
-rw-r--r--src/windows/identity/ui/toolbar.c471
-rw-r--r--src/windows/identity/ui/toolbar.h52
-rw-r--r--src/windows/identity/ui/uiconfig.csv273
144 files changed, 0 insertions, 30133 deletions
diff --git a/src/windows/identity/ui/Makefile b/src/windows/identity/ui/Makefile
deleted file mode 100644
index cf20127a3..000000000
--- a/src/windows/identity/ui/Makefile
+++ /dev/null
@@ -1,109 +0,0 @@
-#
-# Copyright (c) 2004 Massachusetts Institute of Technology
-#
-# 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.
-
-
-MODULE=ui
-!include <../config/Makefile.w32>
-
-EXEFILE=$(BINDIR)\netidmgr.exe
-
-MANIFESTFILE=$(BINDIR)\netidmgr.exe.static.manifest
-
-OBJFILES= \
- $(OBJ)\main.obj \
- $(OBJ)\mainmenu.obj \
- $(OBJ)\toolbar.obj \
- $(OBJ)\statusbar.obj \
- $(OBJ)\notifier.obj \
- $(OBJ)\timer.obj \
- $(OBJ)\uiconfig.obj \
- $(OBJ)\mainwnd.obj \
- $(OBJ)\credwnd.obj \
- $(OBJ)\htwnd.obj \
- $(OBJ)\passwnd.obj \
- $(OBJ)\newcredwnd.obj \
- $(OBJ)\propertywnd.obj \
- $(OBJ)\credfuncs.obj \
- $(OBJ)\configwnd.obj \
- $(OBJ)\aboutwnd.obj \
- $(OBJ)\reqdaemon.obj \
- $(OBJ)\addrchange.obj \
- $(OBJ)\debugfuncs.obj \
- $(OBJ)\taskbar.obj \
- $(OBJ)\cfg_general_wnd.obj \
- $(OBJ)\cfg_identities_wnd.obj \
- $(OBJ)\cfg_notif_wnd.obj \
- $(OBJ)\cfg_plugins_wnd.obj \
- $(OBJ)\cfg_appear_wnd.obj
-
-RESFILES= \
- $(OBJ)\khapp.res \
- $(OBJ)\appver.res
-
-!if ("$(CPU)" == "IA64" ) || ("$(CPU)" == "AMD64" ) || ("$(CPU)" == "ALPHA64" )
-LIBFILES=$(LIBDIR)\nidmgr64.lib
-!else
-LIBFILES=$(LIBDIR)\nidmgr32.lib
-!endif
-
-SDKLIBFILES= \
- comctl32.lib \
- shell32.lib \
- htmlhelp.lib \
- iphlpapi.lib \
- shlwapi.lib \
- msimg32.lib \
- ole32.lib
-
-!if "$(APPVER)" != "5.0"
-SDKLIBFILES = $(SDKLIBFILES) uxtheme.lib
-!endif
-
-$(OBJ)\uiconfig.c: uiconfig.csv $(CONFDIR)\csvschema.cfg
- $(CCSV) $** $@
-
-$(OBJ)\khapp.res: lang\en_us\khapp.rc
- $(RC2RES)
-
-$(OBJ)\appver.res: appver.rc
- $(RC2RES)
-
-!if "$(KH_BUILD)"=="RETAIL"
-$(MANIFESTFILE): netidmgr.manifest.$(CPU).$(KH_CLVER)
-!else
-$(MANIFESTFILE): netidmgr.manifest.$(CPU).$(KH_CLVER).debug
-!endif
- $(CP) $** $@
-
-!if ("$(CPU)" == "IA64" ) || ("$(CPU)" == "AMD64" ) || ("$(CPU)" == "ALPHA64" )
-SCLIB=bufferoverflowu.lib
-!else
-SCLIB=
-!endif
-
-$(EXEFILE): $(OBJFILES) $(RESFILES) $(LIBFILES)
- $(EXEGUILINK) $(SDKLIBFILES) $(SCLIB)
- $(_VC_MANIFEST_EMBED_EXE) $(MANIFESTFILE)
- $(_VC_MANIFEST_CLEAN)
-
-all: mkdirs $(MANIFESTFILE) $(EXEFILE)
diff --git a/src/windows/identity/ui/Makefile.w2k b/src/windows/identity/ui/Makefile.w2k
deleted file mode 100644
index a64aea7c3..000000000
--- a/src/windows/identity/ui/Makefile.w2k
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# Copyright (c) 2004 Massachusetts Institute of Technology
-#
-# 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.
-
-
-MODULE=ui
-!include <../config/Makefile.w2k>
-
-EXEFILE=$(BINDIR)\netidmgr.exe
-
-OBJFILES= \
- $(OBJ)\main.obj \
- $(OBJ)\mainmenu.obj \
- $(OBJ)\toolbar.obj \
- $(OBJ)\statusbar.obj \
- $(OBJ)\notifier.obj \
- $(OBJ)\timer.obj \
- $(OBJ)\uiconfig.obj \
- $(OBJ)\mainwnd.obj \
- $(OBJ)\credwnd.obj \
- $(OBJ)\htwnd.obj \
- $(OBJ)\passwnd.obj \
- $(OBJ)\newcredwnd.obj \
- $(OBJ)\propertywnd.obj \
- $(OBJ)\credfuncs.obj \
- $(OBJ)\configwnd.obj \
- $(OBJ)\aboutwnd.obj \
- $(OBJ)\reqdaemon.obj \
- $(OBJ)\addrchange.obj \
- $(OBJ)\debugfuncs.obj \
- $(OBJ)\cfg_general_wnd.obj \
- $(OBJ)\cfg_identities_wnd.obj \
- $(OBJ)\cfg_notif_wnd.obj \
- $(OBJ)\cfg_plugins_wnd.obj \
- $(OBJ)\cfg_appear_wnd.obj
-
-RESFILES= \
- $(OBJ)\khapp.res \
- $(OBJ)\appver.res
-
-!if ("$(CPU)" == "IA64" ) || ("$(CPU)" == "AMD64" ) || ("$(CPU)" == "ALPHA64" )
-LIBFILES=$(LIBDIR)\nidmgr64.lib
-!else
-LIBFILES=$(LIBDIR)\nidmgr32.lib
-!endif
-
-SDKLIBFILES= \
- comctl32.lib \
- shell32.lib \
- htmlhelp.lib \
- iphlpapi.lib \
- shlwapi.lib
-
-$(OBJ)\uiconfig.c: uiconfig.csv $(CONFDIR)\csvschema.cfg
- $(CCSV) $** $@
-
-$(OBJ)\khapp.res: lang\en_us\khapp.rc
- $(RC2RES)
-
-$(OBJ)\appver.res: appver.rc
- $(RC2RES)
-
-!if ("$(CPU)" == "IA64" ) || ("$(CPU)" == "AMD64" ) || ("$(CPU)" == "ALPHA64" )
-SCLIB=bufferoverflowu.lib
-!else
-SCLIB=
-!endif
-
-$(EXEFILE): $(OBJFILES) $(RESFILES) $(LIBFILES)
- $(EXEGUILINK) $(SDKLIBFILES) $(SCLIB)
-
-all: mkdirs $(EXEFILE)
diff --git a/src/windows/identity/ui/aboutwnd.c b/src/windows/identity/ui/aboutwnd.c
deleted file mode 100644
index a9efcfbff..000000000
--- a/src/windows/identity/ui/aboutwnd.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<netidmgr_intver.h>
-#include<tlhelp32.h>
-
-#if DEBUG
-#include<assert.h>
-#endif
-
-INT_PTR CALLBACK
-about_dlg_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- HANDLE hsnap;
- HWND hw;
-
- SetDlgItemText(hwnd, IDC_PRODUCT,
- TEXT(KH_VERSTR_PRODUCT_1033));
- /* retain the original copyright strings */
-#ifdef OVERRIDE_COPYRIGHT
- SetDlgItemText(hwnd, IDC_COPYRIGHT,
- TEXT(KH_VERSTR_COPYRIGHT_1033));
-#endif
- SetDlgItemText(hwnd, IDC_BUILDINFO,
- TEXT(KH_VERSTR_BUILDINFO_1033));
-
- hsnap =
- CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,
- 0);
-
- if (hsnap != INVALID_HANDLE_VALUE) {
- LVCOLUMN lvc;
- MODULEENTRY32 mod;
- RECT r;
-
- hw = GetDlgItem(hwnd, IDC_MODULES);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
-
- GetWindowRect(hw, &r);
- OffsetRect(&r, -r.left, -r.top);
-
- ZeroMemory(&lvc, sizeof(lvc));
- lvc.mask = LVCF_TEXT | LVCF_WIDTH;
-
- lvc.pszText = L"Name";
- lvc.cx = r.right / 4;
-
- ListView_InsertColumn(hw, 0, &lvc);
-
- lvc.pszText = L"Path";
- lvc.cx = (r.right * 3) / 4;
- ListView_InsertColumn(hw, 1, &lvc);
-
- ZeroMemory(&mod, sizeof(mod));
- mod.dwSize = sizeof(mod);
-
- /* done with columns, now for the actual data */
- if (!Module32First(hsnap, &mod))
- goto _done_with_modules;
-
- do {
-
- LVITEM lvi;
- int idx;
-
- ZeroMemory(&lvi, sizeof(lvi));
-
- lvi.mask = LVIF_TEXT;
- lvi.pszText = mod.szModule;
- idx = ListView_InsertItem(hw, &lvi);
-
- lvi.mask = LVIF_TEXT;
- lvi.iItem = idx;
- lvi.iSubItem = 1;
- lvi.pszText = mod.szExePath;
- ListView_SetItem(hw, &lvi);
-
- ZeroMemory(&mod, sizeof(mod));
- mod.dwSize = sizeof(mod);
- } while(Module32Next(hsnap, &mod));
-
- _done_with_modules:
- CloseHandle(hsnap);
- }
-
- khm_add_dialog(hwnd);
- khm_enter_modal(hwnd);
- }
- return FALSE;
-
- case WM_DESTROY:
- khm_del_dialog(hwnd);
- return TRUE;
-
- case WM_CLOSE:
- khm_leave_modal();
- DestroyWindow(hwnd);
- return TRUE;
-
- case WM_COMMAND:
- if (wParam == MAKEWPARAM(IDOK, BN_CLICKED)) {
- khm_leave_modal();
- DestroyWindow(hwnd);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-void
-khm_create_about_window(void) {
- HWND hwnd;
- hwnd = CreateDialog(khm_hInstance,
- MAKEINTRESOURCE(IDD_ABOUT),
- khm_hwnd_main,
- about_dlg_proc);
-
- ShowWindow(hwnd, SW_SHOW);
- /* no need to keep track of the hwnd, since we add it to the
- dialog chain in the dialog procedure */
-}
diff --git a/src/windows/identity/ui/aboutwnd.h b/src/windows/identity/ui/aboutwnd.h
deleted file mode 100644
index 7da709d93..000000000
--- a/src/windows/identity/ui/aboutwnd.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_ABOUTWND_H
-#define __KHIMAIRA_ABOUTWND_H
-
-void
-khm_create_about_window(void);
-
-#endif
diff --git a/src/windows/identity/ui/addrchange.c b/src/windows/identity/ui/addrchange.c
deleted file mode 100644
index 9058ebec7..000000000
--- a/src/windows/identity/ui/addrchange.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<iphlpapi.h>
-
-static HANDLE evt_terminate = NULL;
-static HANDLE h_thread = NULL;
-
-DWORD WINAPI
-addr_change_thread(LPVOID dummy) {
-
- HANDLE h_waits[2];
- HANDLE h_notify;
-
- OVERLAPPED overlap;
- DWORD ret;
-
- PDESCTHREAD(L"Address change waiter", L"App");
-
- ZeroMemory(&overlap, sizeof(overlap));
-
- h_notify = NULL;
- overlap.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-
- do {
- ret = NotifyAddrChange(&h_notify, &overlap);
-
- if (ret != ERROR_IO_PENDING) {
- goto _end_thread; /* some error */
- }
-
- h_waits[0] = overlap.hEvent;
- h_waits[1] = evt_terminate;
-
- ret = WaitForMultipleObjects(2, h_waits, FALSE, INFINITE);
-
- if ( ret == WAIT_OBJECT_0 ) {
- Sleep(3000); /* wait for things to settle down */
- kmq_post_message(KMSG_CRED, KMSG_CRED_ADDR_CHANGE, 0, 0);
- } else {
- goto _end_thread;
- }
- } while(TRUE);
-
- _end_thread:
- ExitThread(0);
-}
-
-void
-khm_addr_change_notifier_init(void) {
- evt_terminate = CreateEvent(NULL, FALSE, FALSE, NULL);
- h_thread = CreateThread(NULL,
- 64 * 4096,
- addr_change_thread,
- NULL,
- 0,
- NULL);
-}
-
-void
-khm_addr_change_notifier_exit(void) {
- if (h_thread && evt_terminate) {
- SetEvent(evt_terminate);
- WaitForSingleObject(h_thread, INFINITE);
-
- CloseHandle(h_thread);
- CloseHandle(evt_terminate);
- }
-}
diff --git a/src/windows/identity/ui/addrchange.h b/src/windows/identity/ui/addrchange.h
deleted file mode 100644
index 2f605af8c..000000000
--- a/src/windows/identity/ui/addrchange.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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_ADDRCHANGE_H
-#define __NETIDMGR_ADDRCHANGE_H
-
-void
-khm_addr_change_notifier_init(void);
-
-void
-khm_addr_change_notifier_exit(void);
-
-#endif
diff --git a/src/windows/identity/ui/appglobal.h b/src/windows/identity/ui/appglobal.h
deleted file mode 100644
index 235826d07..000000000
--- a/src/windows/identity/ui/appglobal.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_APPGLOBAL_H
-#define __KHIMAIRA_APPGLOBAL_H
-
-/* Helpfile */
-#define NIDM_HELPFILE L"netidmgr.chm"
-
-/* global data */
-extern HINSTANCE khm_hInstance;
-extern int khm_nCmdShow;
-extern const wchar_t * khm_facility;
-extern kconf_schema schema_uiconfig[];
-extern khm_ui_4 khm_commctl_version;
-extern const khm_version app_version;
-
-#define IS_COMMCTL6() (khm_commctl_version >= 0x60000)
-
-/* The structure used to send command-line options to a remote
- NetIDMgr session for versions prior to 1.2. */
-typedef struct tag_khm_startup_options_v1 {
- BOOL seen;
- BOOL processing;
-
- BOOL init;
- BOOL import;
- BOOL renew;
- BOOL destroy;
-
- BOOL autoinit;
- BOOL exit;
- BOOL error_exit;
-
- BOOL no_main_window;
-} khm_startup_options_v1;
-
-/* Used on NetIDMgr version 1.2.x */
-typedef struct tag_khm_startup_options_v2 {
- khm_int32 magic; /* set to STARTUP_OPTIONS_MAGIC */
- DWORD cb_size; /* size of structure, in bytes */
-
- BOOL init;
- BOOL import;
- BOOL renew;
- BOOL destroy;
-
- BOOL autoinit;
- BOOL remote_exit;
-
- khm_int32 code;
-} khm_startup_options_v2;
-
-/* Used on NetIDMgr version 1.3.1 and later */
-typedef struct tag_khm_startup_options_v3 {
- struct tag_khm_startup_options_v2 v2opt;
-
- khm_int32 remote_display; /* combination of SOPTS_DISPLAY_* */
-} khm_startup_options_v3;
-
-#define STARTUP_OPTIONS_MAGIC 0x1f280e41
-
-/* The following macros are used with
- tag_khm_startup_options_v3->remote_display */
-
-/* Show (unhide) the main window. */
-#define SOPTS_DISPLAY_SHOW 0x00000001
-
-/* Hide the main window. (Can't be used with SOPTS_DISPLAY_SHOW) */
-#define SOPTS_DISPLAY_HIDE 0x00000002
-
-/* Suppress the default action on the remote end */
-#define SOPTS_DISPLAY_NODEF 0x00000004
-
-/* Used internally. */
-typedef struct tag_khm_startup_options_int {
- khm_boolean seen;
- khm_boolean processing;
- khm_boolean remote; /* is this a remote request? */
-
- khm_boolean init;
- khm_boolean import;
- khm_boolean renew;
- khm_boolean destroy;
-
- khm_boolean autoinit;
- khm_boolean exit;
- khm_boolean remote_exit;
-
- khm_boolean error_exit;
-
- khm_boolean no_main_window;
- khm_int32 display; /* SOPTS_DISPLAY_* */
-
- LONG pending_renewals;
-} khm_startup_options;
-
-extern khm_startup_options khm_startup;
-
-/* Used to query a remote instance of NetIDMgr for the version. */
-typedef struct tag_khm_query_app_version_v1 {
- khm_int32 magic;
-
- khm_int32 code;
-
- khm_version ver_caller;
- khm_version ver_remote;
-
- khm_boolean request_swap;
-} khm_query_app_version;
-
-#define KHM_QUERY_APP_VER_MAGIC 0x38f8c2eb
-
-void khm_add_dialog(HWND dlg);
-void khm_del_dialog(HWND dlg);
-BOOL khm_is_dialog_active(void);
-
-void khm_enter_modal(HWND hwnd);
-void khm_leave_modal(void);
-
-void khm_add_property_sheet(khui_property_sheet * s);
-void khm_del_property_sheet(khui_property_sheet * s);
-
-void khm_init_gui(void);
-void khm_exit_gui(void);
-
-void khm_parse_commandline();
-void khm_register_window_classes(void);
-
-HWND khm_html_help(HWND hwnd, wchar_t * suffix, UINT command, DWORD_PTR data);
-
-WPARAM khm_message_loop_int(khm_boolean * p_exit);
-
-int khm_compare_version(const khm_version * v1, const khm_version * v2);
-
-#define MAX_RES_STRING 1024
-
-#define ELLIPSIS L"..."
-
-#endif
diff --git a/src/windows/identity/ui/appver.rc b/src/windows/identity/ui/appver.rc
deleted file mode 100644
index 324ad5231..000000000
--- a/src/windows/identity/ui/appver.rc
+++ /dev/null
@@ -1,40 +0,0 @@
-
-#include<windows.h>
-#include<netidmgr_intver.h>
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION KH_VERSION_LIST
- PRODUCTVERSION KH_VERSION_LIST
- FILEFLAGSMASK 0x17L
- FILEFLAGS KH_VER_FILEFLAGS
- FILEOS KH_VER_FILEOS
- FILETYPE 0x0L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "CompanyName", KH_VERSTR_COMPANY_1033
- VALUE "FileDescription", "Network Identity Manager"
- VALUE "FileVersion", KH_VERSTR_VERSION_1033
- VALUE "InternalName", "NetIDMgr"
- VALUE "LegalCopyright", KH_VERSTR_COPYRIGHT_1033
- VALUE "OriginalFilename", "netidmgr.exe"
- VALUE "ProductName", "Network Identity Manager"
- VALUE "ProductVersion", KH_VERSTR_PRODUCT_1033
-#ifdef KH_VERSTR_COMMENT_1033
- VALUE "Comment", KH_VERSTR_COMMENT_1033
-#endif
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
diff --git a/src/windows/identity/ui/cfg_appear_wnd.c b/src/windows/identity/ui/cfg_appear_wnd.c
deleted file mode 100644
index 93f72857c..000000000
--- a/src/windows/identity/ui/cfg_appear_wnd.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-
-static int text_sizes[] = {
- 4,6,8,9,10,12,14,16,18
-};
-
-typedef struct tag_dlg_data {
- khui_config_node node;
- HWND hwnd;
- LOGFONT lf_base;
- LOGFONT lf_work;
- HFONT c_font_normal;
- HFONT c_font_bold;
- int size_idx[ARRAYLENGTH(text_sizes)];
-} dlg_data;
-
-static void
-read_params(HWND hwnd, dlg_data * d) {
-
- HDC hdc;
-
- hdc = GetWindowDC(hwnd);
-
- khm_get_cw_element_font(hdc,
- NULL,
- FALSE,
- &d->lf_base);
-
- d->lf_work = d->lf_base;
-
- ReleaseDC(hwnd, hdc);
-}
-
-
-static void
-write_params(dlg_data * d) {
- khm_boolean applied = FALSE;
-
- if (memcmp(&d->lf_work, &d->lf_base, sizeof(LOGFONT))) {
- khm_set_cw_element_font(NULL, &d->lf_work);
- d->lf_base = d->lf_work;
- applied = TRUE;
- }
-
- khui_cfg_set_flags(d->node,
- (applied)? KHUI_CNFLAG_APPLIED: 0,
- KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);
-}
-
-static void
-check_for_modification(dlg_data * d) {
-
- khui_cfg_set_flags(d->node,
- ((memcmp(&d->lf_work, &d->lf_base, sizeof(LOGFONT)))?
- KHUI_CNFLAG_MODIFIED: 0),
- KHUI_CNFLAG_MODIFIED);
-}
-
-static void
-refresh_view(HWND hwnd, dlg_data * d) {
- wchar_t sample[256];
- HFONT hf;
- LOGFONT lf;
-
- LoadString(khm_hInstance, IDS_APR_SAMPLE_TEXT_NORMAL,
- sample, ARRAYLENGTH(sample));
-
- SetDlgItemText(hwnd, IDC_CFG_SAMPLE_NORMAL, sample);
-
- LoadString(khm_hInstance, IDS_APR_SAMPLE_TEXT_SEL,
- sample, ARRAYLENGTH(sample));
-
- SetDlgItemText(hwnd, IDC_CFG_SAMPLE_BOLD, sample);
-
- lf = d->lf_work;
- hf = CreateFontIndirect(&lf);
- if (hf == NULL)
- return;
-
- SendDlgItemMessage(hwnd, IDC_CFG_SAMPLE_NORMAL, WM_SETFONT, (WPARAM) hf, TRUE);
-
- if (d->c_font_normal)
- DeleteObject(d->c_font_normal);
-
- d->c_font_normal = hf;
-
- lf.lfWeight = FW_BOLD;
-
- hf = CreateFontIndirect(&lf);
- if (hf == NULL)
- return;
-
- SendDlgItemMessage(hwnd, IDC_CFG_SAMPLE_BOLD, WM_SETFONT, (WPARAM) hf, TRUE);
-
- if (d->c_font_bold)
- DeleteObject(d->c_font_bold);
-
- d->c_font_bold = hf;
-}
-
-struct sel_update_blob {
- dlg_data * d;
- HDC hdc;
-};
-
-static int CALLBACK
-enum_font_proc(ENUMLOGFONTEXDV * plfe,
- ENUMTEXTMETRIC * pntm,
- DWORD font_type,
- LPARAM lParam) {
- struct sel_update_blob * blob = (struct sel_update_blob *) lParam;
- LOGFONT * plf = &plfe->elfEnumLogfontEx.elfLogFont;
- LRESULT lr;
-
- lr = SendDlgItemMessage(blob->d->hwnd,
- IDC_CFG_FONTS,
- CB_SELECTSTRING,
- (WPARAM) -1,
- (LPARAM) plf->lfFaceName);
-
- if (lr == CB_ERR) {
- SendDlgItemMessage(blob->d->hwnd,
- IDC_CFG_FONTS,
- CB_SELECTSTRING,
- (WPARAM) -1,
- (LPARAM) plfe->elfEnumLogfontEx.elfFullName);
- }
-
- return FALSE;
-}
-
-static void
-update_selection(dlg_data * d, BOOL update_fonts, BOOL update_effects) {
- LOGFONT lf;
- struct sel_update_blob blob;
- HDC hdc;
-
- if (update_fonts) {
-
- ZeroMemory(&lf, sizeof(lf));
-
- lf.lfCharSet = ANSI_CHARSET;
- StringCbCopy(lf.lfFaceName, sizeof(lf.lfFaceName),
- d->lf_work.lfFaceName);
-
- hdc = GetWindowDC(d->hwnd);
-
- blob.d = d;
- blob.hdc = hdc;
-
- EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) enum_font_proc,
- (LPARAM) &blob, 0);
-
- ReleaseDC(d->hwnd, hdc);
- }
-
- if (update_effects) {
- int i;
- HDC hdc;
- int pt_height;
-
- if (d->lf_work.lfWeight >= FW_BOLD)
- CheckDlgButton(d->hwnd, IDC_CFG_BOLD, BST_CHECKED);
- else
- CheckDlgButton(d->hwnd, IDC_CFG_BOLD, BST_UNCHECKED);
-
- if (d->lf_work.lfItalic)
- CheckDlgButton(d->hwnd, IDC_CFG_ITALICS, BST_CHECKED);
- else
- CheckDlgButton(d->hwnd, IDC_CFG_ITALICS, BST_UNCHECKED);
-
- hdc = GetWindowDC(d->hwnd);
-
- pt_height = MulDiv(d->lf_work.lfHeight, 72,
- GetDeviceCaps(hdc, LOGPIXELSY));
-
-
- ReleaseDC(d->hwnd, hdc);
-
- if (pt_height < 0)
- pt_height = - pt_height;
-
- for (i=0; i < ARRAYLENGTH(text_sizes); i++) {
- if (text_sizes[i] >= pt_height)
- break;
- }
-
- if (i >= ARRAYLENGTH(text_sizes))
- i = ARRAYLENGTH(text_sizes) - 1;
-
- SendDlgItemMessage(d->hwnd, IDC_CFG_SIZE, CB_SETCURSEL,
- d->size_idx[i], 0);
- }
-}
-
-static int CALLBACK
-enum_font_families_proc(ENUMLOGFONTEXDV * plfe,
- ENUMTEXTMETRIC * pntm,
- DWORD font_type,
- LPARAM lParam) {
-
- dlg_data * d = (dlg_data *) lParam;
-
- SendDlgItemMessage(d->hwnd, IDC_CFG_FONTS,
- CB_ADDSTRING, 0,
- (LPARAM) plfe->elfEnumLogfontEx.elfLogFont.lfFaceName);
-
- return TRUE;
-}
-
-INT_PTR CALLBACK
-khm_cfg_appearance_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- dlg_data * d;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- HWND hw_cb;
- LOGFONT lf;
- HDC hdc;
- int i;
- wchar_t buf[4];
-
- d = PMALLOC(sizeof(*d));
-#ifdef DEBUG
- assert(d != NULL);
-#endif
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-
- ZeroMemory(d, sizeof(*d));
-
- d->node = (khui_config_node) lParam;
- d->hwnd = hwnd;
-
- read_params(hwnd, d);
-
- hw_cb = GetDlgItem(hwnd, IDC_CFG_FONTS);
-#ifdef DEBUG
- assert(hw_cb);
-#endif
- SendMessage(hw_cb, CB_RESETCONTENT, 0, 0);
-
- ZeroMemory(&lf, sizeof(lf));
- lf.lfCharSet = ANSI_CHARSET;
-
- hdc = GetWindowDC(hwnd);
-
- EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) enum_font_families_proc,
- (LPARAM) d, 0);
-
- ReleaseDC(hwnd, hdc);
-
-
- for (i=0; i < ARRAYLENGTH(text_sizes); i++) {
- LRESULT idx;
-
- StringCbPrintf(buf, sizeof(buf), L"%d", text_sizes[i]);
-
- idx = SendDlgItemMessage(hwnd, IDC_CFG_SIZE,
- CB_ADDSTRING, 0, (LPARAM) buf);
-
- SendDlgItemMessage(hwnd, IDC_CFG_SIZE,
- CB_SETITEMDATA, idx, text_sizes[i]);
-
- d->size_idx[i] = (int) idx;
- }
-
- update_selection(d, TRUE, TRUE);
-
- refresh_view(hwnd, d);
- }
- return FALSE;
-
- case WM_COMMAND:
- d = (dlg_data *) (LONG_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (wParam == MAKEWPARAM(IDC_CFG_FONTS, CBN_SELCHANGE)) {
- LRESULT idx;
- wchar_t facename[LF_FACESIZE];
-
- idx = SendDlgItemMessage(hwnd, IDC_CFG_FONTS,
- CB_GETCURSEL,
- 0, 0);
-
- if (idx == CB_ERR)
- return TRUE;
-
- if (SendDlgItemMessage(hwnd, IDC_CFG_FONTS,
- CB_GETLBTEXTLEN, idx, 0)
- >= ARRAYLENGTH(facename))
- return TRUE;
-
- SendDlgItemMessage(hwnd, IDC_CFG_FONTS,
- CB_GETLBTEXT, idx,
- (LPARAM) facename);
-
- ZeroMemory(d->lf_work.lfFaceName,
- sizeof(d->lf_work.lfFaceName));
-
- StringCbCopy(d->lf_work.lfFaceName,
- sizeof(d->lf_work.lfFaceName),
- facename);
-
- update_selection(d, FALSE, FALSE);
-
- refresh_view(hwnd, d);
-
- check_for_modification(d);
-
- } else if (wParam == MAKEWPARAM(IDC_CFG_BOLD, BN_CLICKED)) {
-
- if (IsDlgButtonChecked(hwnd, IDC_CFG_BOLD) == BST_CHECKED) {
- d->lf_work.lfWeight = FW_BOLD;
- } else {
- d->lf_work.lfWeight = 0;
- }
-
- refresh_view(hwnd, d);
-
- check_for_modification(d);
-
- } else if (wParam == MAKEWPARAM(IDC_CFG_ITALICS, BN_CLICKED)) {
-
- d->lf_work.lfItalic = (BYTE)
- (IsDlgButtonChecked(hwnd, IDC_CFG_ITALICS) == BST_CHECKED);
-
- refresh_view(hwnd, d);
-
- check_for_modification(d);
-
- } else if (wParam == MAKEWPARAM(IDC_CFG_REVERT, BN_CLICKED)) {
- HDC hdc;
-
- hdc = GetWindowDC(hwnd);
-
- khm_get_cw_element_font(hdc, NULL, TRUE, &d->lf_work);
-
- ReleaseDC(hwnd, hdc);
-
- update_selection(d, TRUE, TRUE);
-
- refresh_view(hwnd, d);
-
- check_for_modification(d);
-
- } else if (wParam == MAKEWPARAM(IDC_CFG_SIZE, CBN_SELCHANGE)) {
- HDC hdc;
- LPARAM idx;
- int points;
-
- idx = SendDlgItemMessage(hwnd, IDC_CFG_SIZE,
- CB_GETCURSEL, 0, 0);
- if (idx == CB_ERR)
- return TRUE;
-
- points = (int) SendDlgItemMessage(hwnd, IDC_CFG_SIZE,
- CB_GETITEMDATA, idx, 0);
-
- hdc = GetWindowDC(hwnd);
-
- d->lf_work.lfHeight = -MulDiv(points,
- GetDeviceCaps(hdc, LOGPIXELSY),
- 72);
-
- ReleaseDC(hwnd, hdc);
-
- refresh_view(hwnd, d);
-
- check_for_modification(d);
- }
-
- return TRUE;
-
- case WM_DESTROY:
- d = (dlg_data *) (LONG_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (d) {
- if (d->c_font_bold)
- DeleteObject(d->c_font_bold);
-
- if (d->c_font_normal)
- DeleteObject(d->c_font_normal);
-
- PFREE(d);
- SetWindowLongPtr(hwnd, DWLP_USER, 0);
- }
- return TRUE;
-
- case KHUI_WM_CFG_NOTIFY:
- d = (dlg_data *) (LONG_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
- write_params(d);
- khui_action_trigger(KHUI_ACTION_LAYOUT_RELOAD, NULL);
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/src/windows/identity/ui/cfg_general_wnd.c b/src/windows/identity/ui/cfg_general_wnd.c
deleted file mode 100644
index bb2635855..000000000
--- a/src/windows/identity/ui/cfg_general_wnd.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<shlwapi.h>
-#include<khmapp.h>
-#include<assert.h>
-
-typedef struct tag_cfg_data {
- BOOL auto_init;
- BOOL auto_start;
- BOOL auto_import;
- BOOL keep_running;
- BOOL auto_detect_net;
- BOOL log_to_file;
- BOOL destroy_creds;
- khm_int32 notif_action;
-} cfg_data;
-
-typedef struct tag_dlg_data {
- khui_config_node node;
- cfg_data saved;
- cfg_data work;
-} dlg_data;
-
-static void
-read_params(dlg_data * dd) {
- cfg_data * d;
- khm_handle csp_cw;
- khm_int32 t;
-
- d = &dd->saved;
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ,
- &csp_cw))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- khc_read_int32(csp_cw, L"AutoInit", &t);
- d->auto_init = !!t;
-
- khc_read_int32(csp_cw, L"AutoStart", &t);
- d->auto_start = !!t;
-
- khc_read_int32(csp_cw, L"AutoImport", &t);
- d->auto_import = !!t;
-
- khc_read_int32(csp_cw, L"KeepRunning", &t);
- d->keep_running = !!t;
-
- khc_read_int32(csp_cw, L"AutoDetectNet", &t);
- d->auto_detect_net = !!t;
-
- khc_read_int32(csp_cw, L"LogToFile", &t);
- d->log_to_file = !!t;
-
- khc_read_int32(csp_cw, L"DestroyCredsOnExit", &t);
- d->destroy_creds = !!t;
-
- khc_read_int32(csp_cw, L"NotificationAction", &t);
- d->notif_action = t;
-
- khc_close_space(csp_cw);
-
- dd->work = *d;
-}
-
-static void
-write_params(dlg_data * dd) {
- cfg_data * d, * s;
- khm_handle csp_cw;
- BOOL applied = FALSE;
-
- d = &dd->work;
- s = &dd->saved;
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_WRITE,
- &csp_cw))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- if (!!d->auto_init != !!s->auto_init) {
- khc_write_int32(csp_cw, L"AutoInit", d->auto_init);
- applied = TRUE;
- }
-
- if (!!d->auto_start != !!s->auto_start) {
- khc_write_int32(csp_cw, L"AutoStart", d->auto_start);
- applied = TRUE;
- }
-
- if (!!d->auto_import != !!s->auto_import) {
- khc_write_int32(csp_cw, L"AutoImport", d->auto_import);
- applied = TRUE;
- }
-
- if (!!d->keep_running != !!s->keep_running) {
- khc_write_int32(csp_cw, L"KeepRunning", d->keep_running);
- applied = TRUE;
- }
-
- if (!!d->auto_detect_net != !!s->auto_detect_net) {
- khc_write_int32(csp_cw, L"AutoDetectNet", d->auto_detect_net);
- applied = TRUE;
- }
-
- if (!!d->log_to_file != !!s->log_to_file) {
- khc_write_int32(csp_cw, L"LogToFile", d->log_to_file);
- applied = TRUE;
-
- if (d->log_to_file) {
- khm_start_file_log();
- } else {
- khm_stop_file_log();
- }
- }
-
- if (!!d->destroy_creds != !!s->destroy_creds) {
- khc_write_int32(csp_cw, L"DestroyCredsOnExit", d->destroy_creds);
- applied = TRUE;
- }
-
- if (d->notif_action != s->notif_action) {
- khc_write_int32(csp_cw, L"NotificationAction", d->notif_action);
- applied = TRUE;
- }
-
- khc_close_space(csp_cw);
-
- khui_cfg_set_flags(dd->node,
- (applied) ? KHUI_CNFLAG_APPLIED : 0,
- KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);
-
- *s = *d;
-}
-
-static void
-check_for_modification(dlg_data * dd) {
- cfg_data * d, * s;
- d = &dd->work;
- s = &dd->saved;
-
- if (!!d->auto_init != !!s->auto_init ||
- !!d->auto_start != !!s->auto_start ||
- !!d->auto_import != !!s->auto_import ||
- !!d->keep_running != !!s->keep_running ||
- !!d->auto_detect_net != !!s->auto_detect_net ||
- !!d->log_to_file != !!s->log_to_file ||
- !!d->destroy_creds != !!s->destroy_creds ||
- d->notif_action != s->notif_action) {
-
- khui_cfg_set_flags(dd->node,
- KHUI_CNFLAG_MODIFIED,
- KHUI_CNFLAG_MODIFIED);
-
- } else {
-
- khui_cfg_set_flags(dd->node,
- 0,
- KHUI_CNFLAG_MODIFIED);
-
- }
-}
-
-
-static void
-strip_ampersands(wchar_t * str) {
- wchar_t *f, *t;
-
- for(f = t = str; *f; f++)
- if (*f != L'&')
- *t++ = *f;
-
- *t = L'\0';
-}
-
-static void
-refresh_view(HWND hwnd, dlg_data * d) {
- wchar_t buf[512];
- khm_size i;
-
- CheckDlgButton(hwnd, IDC_CFG_AUTOINIT,
- (d->work.auto_init?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_AUTOSTART,
- (d->work.auto_start?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_AUTOIMPORT,
- (d->work.auto_import?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_KEEPRUNNING,
- (d->work.keep_running?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_NETDETECT,
- (d->work.auto_detect_net?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_LOGTOFILE,
- (d->work.log_to_file?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_DESTROYALL,
- (d->work.destroy_creds?BST_CHECKED:BST_UNCHECKED));
-
- /* we need populate the notification action combo box control and
- set the current selection to match the default action. */
-
- if (n_khm_notifier_actions != (khm_size) SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION,
- CB_GETCOUNT, 0, 0)) {
-
- for (i=0; i < n_khm_notifier_actions; i++) {
- int idx;
-
- khm_get_action_caption(khm_notifier_actions[i],
- buf, sizeof(buf));
-
- strip_ampersands(buf);
-
- idx = (int) SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION,
- CB_INSERTSTRING, i,
- (LPARAM) buf);
-
-#ifdef DEBUG
- if (idx != (int) i) {
- assert(FALSE);
- }
-#endif
- }
- }
-
- for (i=0; i < n_khm_notifier_actions; i++) {
- if (khm_notifier_actions[i] == d->work.notif_action)
- break;
- }
-
- if (i >= n_khm_notifier_actions) {
- d->work.notif_action = khm_notifier_actions[0];
- i = 0;
- }
-
- SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION, CB_SETCURSEL, i, 0);
-
- /* in addition, we correct the label on the trace log control to
- reflect the actual path that is going to get used */
- if (GetDlgItemText(hwnd, IDC_CFG_LOGPATH, buf,
- ARRAYLENGTH(buf)) == 0) {
-
- khm_get_file_log_path(sizeof(buf), buf);
-
- SetDlgItemText(hwnd, IDC_CFG_LOGPATH, buf);
- }
-}
-
-static void
-refresh_data(HWND hwnd, dlg_data * d) {
- int idx;
-
- d->work.auto_init = (IsDlgButtonChecked(hwnd, IDC_CFG_AUTOINIT)
- == BST_CHECKED);
- d->work.auto_start = (IsDlgButtonChecked(hwnd, IDC_CFG_AUTOSTART)
- == BST_CHECKED);
- d->work.auto_import = (IsDlgButtonChecked(hwnd, IDC_CFG_AUTOIMPORT)
- == BST_CHECKED);
- d->work.keep_running = (IsDlgButtonChecked(hwnd, IDC_CFG_KEEPRUNNING)
- == BST_CHECKED);
- d->work.auto_detect_net = (IsDlgButtonChecked(hwnd, IDC_CFG_NETDETECT)
- == BST_CHECKED);
- d->work.log_to_file = (IsDlgButtonChecked(hwnd, IDC_CFG_LOGTOFILE)
- == BST_CHECKED);
- d->work.destroy_creds = (IsDlgButtonChecked(hwnd, IDC_CFG_DESTROYALL)
- == BST_CHECKED);
-
- idx = (int) SendDlgItemMessage(hwnd, IDC_CFG_NOTACTION, CB_GETCURSEL, 0, 0);
- if (idx < 0)
- idx = 0;
- else if (idx >= (int) n_khm_notifier_actions)
- idx = (int) n_khm_notifier_actions - 1;
-
- d->work.notif_action = khm_notifier_actions[idx];
-}
-
-INT_PTR CALLBACK
-khm_cfg_general_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- dlg_data * d;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- d = PMALLOC(sizeof(*d));
-#ifdef DEBUG
- assert(d != NULL);
-#endif
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-
- ZeroMemory(d, sizeof(*d));
-
- d->node = (khui_config_node) lParam;
-
- read_params(d);
-
- refresh_view(hwnd, d);
-
- return FALSE;
-
- case WM_DESTROY:
- d = (dlg_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d) {
- PFREE(d);
- SetWindowLongPtr(hwnd, DWLP_USER, 0);
- }
- return TRUE;
-
- case WM_COMMAND:
- d = (dlg_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (HIWORD(wParam) == BN_CLICKED) {
- if (LOWORD(wParam) == IDC_CFG_SHOWLOG) {
- /* we need to display the logfile */
- wchar_t buf[512];
-
- buf[0] = L'\0';
- khm_get_file_log_path(sizeof(buf), buf);
-
- if (!buf[0] ||
- !PathFileExists(buf)) {
-
- wchar_t title[256];
- wchar_t msg[550];
- wchar_t fmt[256];
-
- LoadString(khm_hInstance, IDS_CFG_LOGF_CS,
- title, ARRAYLENGTH(title));
- LoadString(khm_hInstance, IDS_CFG_LOGF_CSR,
- fmt, ARRAYLENGTH(fmt));
-
- StringCbPrintf(msg, sizeof(msg), fmt, buf);
-
- MessageBox(hwnd, title, msg, MB_OK);
-
- } else {
- wchar_t cmdline[550];
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
-
- StringCbCopy(cmdline, sizeof(cmdline), L"notepad.exe ");
- StringCbCat(cmdline, sizeof(cmdline), L"\"");
- StringCbCat(cmdline, sizeof(cmdline), buf);
- StringCbCat(cmdline, sizeof(cmdline), L"\"");
-
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
- ZeroMemory(&pi, sizeof(pi));
-
- CreateProcess(NULL,
- cmdline,
- NULL, NULL,
- FALSE,
- 0, NULL, NULL,
- &si,
- &pi);
-
- if (pi.hProcess)
- CloseHandle(pi.hProcess);
- if (pi.hThread)
- CloseHandle(pi.hThread);
-
- }
- } else {
- refresh_data(hwnd, d);
- check_for_modification(d);
- }
- } else if (HIWORD(wParam) == CBN_SELCHANGE) {
- refresh_data(hwnd, d);
- check_for_modification(d);
- }
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
-
- case KHUI_WM_CFG_NOTIFY:
- d = (dlg_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
- write_params(d);
- }
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/src/windows/identity/ui/cfg_identities_wnd.c b/src/windows/identity/ui/cfg_identities_wnd.c
deleted file mode 100644
index d419e2837..000000000
--- a/src/windows/identity/ui/cfg_identities_wnd.c
+++ /dev/null
@@ -1,1573 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-#if _WIN32_WINNT >= 0x0501
-#include<uxtheme.h>
-#endif
-
-static khui_config_node
-get_window_node(HWND hwnd) {
- return (khui_config_node) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
-}
-
-static void
-set_window_node(HWND hwnd, khui_config_node node) {
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER,
- (LONG_PTR) node);
-#pragma warning(pop)
-}
-
-static void
-add_subpanels(HWND hwnd,
- khui_config_node ctx_node,
- khui_config_node ref_node) {
-
- HWND hw_tab;
- HWND hw_target;
- khui_config_node sub;
- khui_config_node_reg reg;
- khui_config_init_data idata;
- int idx;
-
- hw_tab = GetDlgItem(hwnd, IDC_CFG_TAB);
- hw_target = GetDlgItem(hwnd, IDC_CFG_TARGET);
-#ifdef DEBUG
- assert(hw_tab);
- assert(hw_target);
-#endif
-
- if (KHM_FAILED(khui_cfg_get_first_subpanel(ref_node, &sub))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- idx = 0;
- while(sub) {
- HWND hwnd_panel;
- TCITEM tci;
- int iid;
-
- khui_cfg_get_reg(sub, &reg);
-
- if ((ctx_node == ref_node && (reg.flags & KHUI_CNFLAG_PLURAL)) ||
- (ctx_node != ref_node && !(reg.flags & KHUI_CNFLAG_PLURAL)))
- goto _next_node;
-
- idata.ctx_node = ctx_node;
- idata.this_node = sub;
- idata.ref_node = ref_node;
-
- hwnd_panel = CreateDialogParam(reg.h_module,
- reg.dlg_template,
- hwnd,
- reg.dlg_proc,
- (LPARAM) &idata);
-
-#ifdef DEBUG
- assert(hwnd_panel);
-#endif
-#if _WIN32_WINNT >= 0x0501
- EnableThemeDialogTexture(hwnd_panel, ETDT_ENABLETAB);
-#endif
-
- ShowWindow(hwnd_panel, SW_HIDE);
-
- ZeroMemory(&tci, sizeof(tci));
-
- tci.mask = TCIF_PARAM | TCIF_TEXT;
- tci.lParam = (LPARAM) sub;
- tci.pszText = (LPWSTR) reg.short_desc;
-
- iid = TabCtrl_InsertItem(hw_tab, 0, &tci);
- idx++;
-
- if (reg.flags & KHUI_CNFLAG_PLURAL) {
- khui_cfg_set_param_inst(sub, ctx_node, iid);
- khui_cfg_set_hwnd_inst(sub, ctx_node, hwnd_panel);
- } else {
- khui_cfg_set_param(sub, iid);
- khui_cfg_set_hwnd(sub, hwnd_panel);
- }
-
- _next_node:
-
- khui_cfg_get_next_release(&sub);
- }
-
- TabCtrl_SetCurSel(hw_tab, 0);
-}
-
-static void
-apply_all(HWND hwnd,
- HWND hw_tab,
- khui_config_node noderef) {
- TCITEM tci;
- HWND hw;
- khui_config_node_reg reg;
- int idx;
- int count;
- BOOL cont = TRUE;
-
- count = TabCtrl_GetItemCount(hw_tab);
-
- for (idx = 0; idx < count && cont; idx++) {
-
- ZeroMemory(&tci, sizeof(tci));
-
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hw_tab,
- idx,
- &tci);
-
-#ifdef DEBUG
- assert(tci.lParam);
-#endif
- khui_cfg_get_reg((khui_config_node) tci.lParam, &reg);
- if (reg.flags & KHUI_CNFLAG_PLURAL)
- hw = khui_cfg_get_hwnd_inst((khui_config_node) tci.lParam,
- noderef);
- else
- hw = khui_cfg_get_hwnd((khui_config_node) tci.lParam);
-#ifdef DEBUG
- assert(hw);
-#endif
-
- SendMessage(hw, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(0, WMCFG_APPLY), (LPARAM) &cont);
- }
-}
-
-static void
-show_tab_panel(HWND hwnd,
- khui_config_node node,
- HWND hw_tab,
- int idx,
- BOOL show) {
- TCITEM tci;
- HWND hw;
- HWND hw_target;
- HWND hw_firstctl;
- RECT r;
- RECT rref;
- khui_config_node_reg reg;
-
- ZeroMemory(&tci, sizeof(tci));
-
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hw_tab,
- idx,
- &tci);
-
-#ifdef DEBUG
- assert(tci.lParam);
-#endif
- khui_cfg_get_reg((khui_config_node) tci.lParam, &reg);
- if (reg.flags & KHUI_CNFLAG_PLURAL)
- hw = khui_cfg_get_hwnd_inst((khui_config_node) tci.lParam,
- node);
- else
- hw = khui_cfg_get_hwnd((khui_config_node) tci.lParam);
-#ifdef DEBUG
- assert(hw);
-#endif
-
- if (!show) {
- ShowWindow(hw, SW_HIDE);
- return;
- }
-
- hw_target = GetDlgItem(hwnd, IDC_CFG_TARGET);
-#ifdef DEBUG
- assert(hw_target);
-#endif
- GetWindowRect(hwnd, &rref);
- GetWindowRect(hw_target, &r);
-
- OffsetRect(&r, -rref.left, -rref.top);
-
- SetWindowPos(hw,
- hw_tab,
- r.left, r.top,
- r.right - r.left, r.bottom - r.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_SHOWWINDOW);
-
- hw_firstctl = GetNextDlgTabItem(hw, NULL, FALSE);
- if (hw_firstctl) {
- SetFocus(hw_firstctl);
- }
-}
-
-static INT_PTR
-handle_cfg_notify(HWND hwnd,
- WPARAM wParam,
- LPARAM lParam) {
- khui_config_node node;
- HWND hw;
-
- node = get_window_node(hwnd);
- if (node == NULL)
- return TRUE;
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
-
- hw = GetDlgItem(hwnd, IDC_CFG_TAB);
-
- apply_all(hwnd,
- hw,
- node);
- }
-
- return TRUE;
-}
-
-static INT_PTR
-handle_notify(HWND hwnd,
- WPARAM wParam,
- LPARAM lParam) {
- LPNMHDR lpnm;
- int i;
-
-
- khui_config_node node;
-
- lpnm = (LPNMHDR) lParam;
- node = get_window_node(hwnd);
- if (node == NULL)
- return FALSE;
-
- if (lpnm->idFrom == IDC_CFG_TAB) {
- switch(lpnm->code) {
- case TCN_SELCHANGING:
- i = TabCtrl_GetCurSel(lpnm->hwndFrom);
-
- show_tab_panel(hwnd,
- node,
- lpnm->hwndFrom,
- i,
- FALSE);
- break;
-
- case TCN_SELCHANGE:
- i = TabCtrl_GetCurSel(lpnm->hwndFrom);
-
- show_tab_panel(hwnd,
- node,
- lpnm->hwndFrom,
- i,
- TRUE);
- break;
- }
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-typedef struct tag_ident_props {
- BOOL monitor;
- BOOL auto_renew;
- BOOL sticky;
-} ident_props;
-
-typedef struct tag_ident_data {
- khm_handle ident;
- wchar_t * idname;
- int lv_idx;
-
- BOOL removed; /* this identity was marked for removal */
- BOOL applied;
- BOOL purged; /* this identity was actually removed */
-
- khm_int32 flags;
-
- ident_props saved;
- ident_props work;
-
- HWND hwnd;
-} ident_data;
-
-typedef struct tag_global_props {
- BOOL monitor;
- BOOL auto_renew;
- BOOL sticky;
-} global_props;
-
-typedef struct tag_idents_data {
- BOOL valid;
-
- ident_data * idents;
- khm_size n_idents;
- khm_size nc_idents;
-#define IDENTS_DATA_ALLOC_INCR 8
-
- /* global options */
- global_props saved;
- global_props work;
- BOOL applied;
-
- int refcount;
-
- HIMAGELIST hi_status;
- int idx_id;
- int idx_default;
- int idx_modified;
- int idx_applied;
- int idx_deleted;
-
- HWND hwnd;
- khui_config_init_data cfg;
-} idents_data;
-
-static idents_data cfg_idents = {FALSE, NULL, 0, 0,
- {0, 0, 0},
- {0, 0, 0},
- FALSE,
-
- 0, NULL };
-
-static void
-read_params_ident(ident_data * d) {
- khm_handle csp_ident;
- khm_handle csp_cw;
- khm_int32 t;
-
- if (KHM_FAILED(kcdb_identity_get_config(d->ident,
- KHM_PERM_READ,
- &csp_ident))) {
- csp_ident = NULL;
- }
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ,
- &csp_cw))) {
- if (csp_ident) {
- khc_shadow_space(csp_ident,
- csp_cw);
- khc_close_space(csp_cw);
- } else {
- csp_ident = csp_cw;
- }
- csp_cw = NULL;
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- d->saved.monitor = TRUE;
- d->saved.auto_renew = TRUE;
- d->saved.sticky = FALSE;
- d->work = d->saved;
-
- if (csp_ident)
- khc_close_space(csp_ident);
-
- return;
- }
-
- if (KHM_FAILED(khc_read_int32(csp_ident, L"Monitor", &t))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- d->saved.monitor = TRUE;
- } else {
- d->saved.monitor = !!t;
- }
-
- if (KHM_FAILED(khc_read_int32(csp_ident, L"AllowAutoRenew", &t))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- d->saved.auto_renew = TRUE;
- } else {
- d->saved.auto_renew = !!t;
- }
-
- if (KHM_FAILED(khc_read_int32(csp_ident, L"Sticky", &t))) {
- d->saved.sticky = FALSE;
- } else {
- d->saved.sticky = !!t;
- }
-
- khc_close_space(csp_ident);
-
- d->work = d->saved;
- d->applied = FALSE;
-}
-
-static void
-write_params_ident(ident_data * d) {
- khm_handle csp_ident;
-
- if (d->saved.monitor == d->work.monitor &&
- d->saved.auto_renew == d->work.auto_renew &&
- d->saved.sticky == d->work.sticky &&
- !d->removed)
- return;
-
- if (KHM_FAILED(kcdb_identity_get_config(d->ident, KHM_PERM_WRITE,
- &csp_ident))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- if (d->removed) {
- khm_handle h = NULL;
- khm_int32 flags = 0;
-
- khc_remove_space(csp_ident);
-
- /* calling kcdb_identity_get_config() will update the
- KCDB_IDENT_FLAG_CONFIG flag for the identity to reflect the
- fact that it nolonger has a configuration. */
- kcdb_identity_get_config(d->ident, 0, &h);
- if (h) {
- /* what the ? */
-#ifdef DEBUG
- assert(FALSE);
-#endif
- khc_close_space(h);
- }
-#ifdef DEBUG
- kcdb_identity_get_flags(d->ident, &flags);
- assert(!(flags & KCDB_IDENT_FLAG_CONFIG));
-#endif
-
- d->purged = TRUE;
-
- } else {
-
- if (d->saved.monitor != d->work.monitor)
- khc_write_int32(csp_ident, L"Monitor", !!d->work.monitor);
-
- if (d->saved.auto_renew != d->work.auto_renew)
- khc_write_int32(csp_ident, L"AllowAutoRenew",
- !!d->work.auto_renew);
-
- if (d->saved.sticky != d->work.sticky) {
- kcdb_identity_set_flags(d->ident,
- (d->work.sticky)?KCDB_IDENT_FLAG_STICKY:0,
- KCDB_IDENT_FLAG_STICKY);
- }
- }
-
- khc_close_space(csp_ident);
-
- d->saved = d->work;
-
- d->applied = TRUE;
-
- if (d->hwnd && !d->removed)
- PostMessage(d->hwnd, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(0, WMCFG_UPDATE_STATE), 0);
-
- khm_refresh_config();
-}
-
-static void
-write_params_idents(void) {
- khm_handle csp_cw = NULL;
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow",
- KHM_FLAG_CREATE, &csp_cw))) {
- if (cfg_idents.work.monitor != cfg_idents.saved.monitor) {
- khc_write_int32(csp_cw, L"DefaultMonitor",
- !!cfg_idents.work.monitor);
- cfg_idents.saved.monitor = cfg_idents.work.monitor;
- cfg_idents.applied = TRUE;
- }
- if (cfg_idents.work.auto_renew != cfg_idents.saved.auto_renew) {
- khc_write_int32(csp_cw, L"DefaultAllowAutoRenew",
- !!cfg_idents.work.auto_renew);
- cfg_idents.saved.auto_renew = cfg_idents.work.auto_renew;
- cfg_idents.applied = TRUE;
- }
- if (cfg_idents.work.sticky != cfg_idents.saved.sticky) {
- khc_write_int32(csp_cw, L"DefaultSticky",
- !!cfg_idents.work.sticky);
- cfg_idents.saved.sticky = cfg_idents.work.sticky;
- cfg_idents.applied = TRUE;
- }
-
- khc_close_space(csp_cw);
- csp_cw = NULL;
- }
-
-#if 0
- for (i=0; i < (int)cfg_idents.n_idents; i++) {
- write_params_ident(&cfg_idents.idents[i]);
- }
-#endif
-
- if (cfg_idents.hwnd)
- PostMessage(cfg_idents.hwnd, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(0, WMCFG_UPDATE_STATE), 0);
-}
-
-static void
-init_idents_data(void) {
- khm_int32 rv;
- wchar_t * t;
- wchar_t * widnames = NULL;
- khm_size cb;
- int n_tries = 0;
- int i;
- khm_handle csp_cw = NULL;
-
- if (cfg_idents.valid)
- return;
-
-#ifdef DEBUG
- assert(cfg_idents.idents == NULL);
- assert(cfg_idents.n_idents == 0);
- assert(cfg_idents.nc_idents == 0);
-#endif
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw))) {
- khm_int32 t;
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultMonitor", &t)))
- cfg_idents.saved.monitor = !!t;
- else
- cfg_idents.saved.monitor = TRUE;
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultAllowAutoRenew", &t)))
- cfg_idents.saved.auto_renew = !!t;
- else
- cfg_idents.saved.auto_renew = TRUE;
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultSticky", &t)))
- cfg_idents.saved.sticky = !!t;
- else
- cfg_idents.saved.sticky = FALSE;
-
- khc_close_space(csp_cw);
- csp_cw = NULL;
-
- } else {
-
- cfg_idents.saved.monitor = TRUE;
- cfg_idents.saved.auto_renew = TRUE;
- cfg_idents.saved.sticky = FALSE;
-
- }
-
- cfg_idents.work = cfg_idents.saved;
- cfg_idents.applied = FALSE;
-
- do {
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_CONFIG,
- KCDB_IDENT_FLAG_CONFIG,
- NULL,
- &cb,
- &cfg_idents.n_idents);
-
- if (rv != KHM_ERROR_TOO_LONG ||
- cfg_idents.n_idents == 0 ||
- cb == 0)
- break;
-
- if (widnames)
- PFREE(widnames);
- widnames = PMALLOC(cb);
-#ifdef DEBUG
- assert(widnames);
-#endif
-
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_CONFIG,
- KCDB_IDENT_FLAG_CONFIG,
- widnames,
- &cb,
- &cfg_idents.n_idents);
- n_tries++;
- } while(KHM_FAILED(rv) &&
- n_tries < 5);
-
- if (KHM_FAILED(rv) ||
- cfg_idents.n_idents == 0) {
- cfg_idents.n_idents = 0;
- goto _cleanup;
- }
-
- cfg_idents.idents = PMALLOC(sizeof(*cfg_idents.idents) *
- cfg_idents.n_idents);
-#ifdef DEBUG
- assert(cfg_idents.idents);
-#endif
- ZeroMemory(cfg_idents.idents,
- sizeof(*cfg_idents.idents) * cfg_idents.n_idents);
- cfg_idents.nc_idents = cfg_idents.n_idents;
-
- i = 0;
- for (t = widnames; t && *t; t = multi_string_next(t)) {
- khm_handle ident;
-
- if (KHM_FAILED(kcdb_identity_create(t, 0, &ident))) {
- cfg_idents.n_idents--;
- continue;
- }
-
- StringCbLength(t, KCDB_IDENT_MAXCB_NAME, &cb);
- cb += sizeof(wchar_t);
-
- cfg_idents.idents[i].idname = PMALLOC(cb);
-#ifdef DEBUG
- assert(cfg_idents.idents[i].idname);
-#endif
- StringCbCopy(cfg_idents.idents[i].idname, cb, t);
-
- cfg_idents.idents[i].ident = ident;
- cfg_idents.idents[i].removed = FALSE;
-
- kcdb_identity_get_flags(ident, &cfg_idents.idents[i].flags);
-#ifdef DEBUG
- assert(cfg_idents.idents[i].flags & KCDB_IDENT_FLAG_CONFIG);
-#endif
-
- read_params_ident(&cfg_idents.idents[i]);
-
- i++;
- /* leave identity held */
- }
-
- _cleanup:
-
- cfg_idents.valid = TRUE;
-
- if (widnames)
- PFREE(widnames);
-}
-
-static void
-free_idents_data(void) {
- int i;
-
- if (!cfg_idents.valid)
- return;
-
- for (i=0; i< (int) cfg_idents.n_idents; i++) {
- if (cfg_idents.idents[i].ident)
- kcdb_identity_release(cfg_idents.idents[i].ident);
- if (cfg_idents.idents[i].idname)
- PFREE(cfg_idents.idents[i].idname);
- }
-
- if (cfg_idents.idents)
- PFREE(cfg_idents.idents);
-
- cfg_idents.idents = NULL;
- cfg_idents.n_idents = 0;
- cfg_idents.nc_idents = 0;
- cfg_idents.valid = FALSE;
-}
-
-static void
-hold_idents_data(void) {
- if (!cfg_idents.valid)
- init_idents_data();
-#ifdef DEBUG
- assert(cfg_idents.valid);
-#endif
- cfg_idents.refcount++;
-}
-
-static void
-release_idents_data(void) {
-#ifdef DEBUG
- assert(cfg_idents.valid);
-#endif
- cfg_idents.refcount--;
-
- if (cfg_idents.refcount == 0)
- free_idents_data();
-}
-
-
-static void
-refresh_data_idents(HWND hwnd) {
- cfg_idents.work.monitor =
- (IsDlgButtonChecked(hwnd, IDC_CFG_MONITOR) == BST_CHECKED);
- cfg_idents.work.auto_renew =
- (IsDlgButtonChecked(hwnd, IDC_CFG_RENEW) == BST_CHECKED);
- cfg_idents.work.sticky =
- (IsDlgButtonChecked(hwnd, IDC_CFG_STICKY) == BST_CHECKED);
-}
-
-static void
-refresh_view_idents_state(HWND hwnd) {
- BOOL modified;
- BOOL applied;
- khm_int32 flags = 0;
-
- applied = cfg_idents.applied;
- modified = (cfg_idents.work.monitor != cfg_idents.saved.monitor ||
- cfg_idents.work.auto_renew != cfg_idents.saved.auto_renew ||
- cfg_idents.work.sticky != cfg_idents.saved.sticky);
-
- if (modified)
- flags |= KHUI_CNFLAG_MODIFIED;
- if (applied)
- flags |= KHUI_CNFLAG_APPLIED;
-
- khui_cfg_set_flags_inst(&cfg_idents.cfg, flags,
- KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);
-}
-
-struct ctrl_row_dimensions {
- RECT enclosure;
- RECT label;
- RECT control;
-};
-
-typedef struct tag_add_ident_data {
- khui_new_creds * nc;
-
- struct ctrl_row_dimensions dim_small;
- struct ctrl_row_dimensions dim_medium;
- struct ctrl_row_dimensions dim_large;
- int row_gap;
-
- int current_y;
- int current_x;
-
- HWND hwnd_last_ctrl;
-} add_ident_data;
-
-void
-get_ctrl_row_metrics(struct ctrl_row_dimensions * dim, HWND hw_lbl, HWND hw_ctl) {
-
- assert(hw_lbl);
- assert(hw_ctl);
-
- GetWindowRect(hw_lbl, &dim->label);
- GetWindowRect(hw_ctl, &dim->control);
-
- UnionRect(&dim->enclosure, &dim->label, &dim->control);
- OffsetRect(&dim->label,
- -dim->enclosure.left,
- -dim->enclosure.top);
- OffsetRect(&dim->control,
- -dim->enclosure.left,
- -dim->enclosure.top);
- OffsetRect(&dim->enclosure,
- -dim->enclosure.left,
- -dim->enclosure.top);
-}
-
-/* dialog box procedure for the "Add new identity" dialog */
-INT_PTR CALLBACK
-khm_cfg_add_ident_proc(HWND hwnd,
- UINT umsg,
- WPARAM wParam,
- LPARAM lParam) {
- add_ident_data * d;
-
- switch(umsg) {
- case WM_INITDIALOG:
- /* we create a new credentials blob and pull in the identity
- selectors from the identity provider. */
- d = PMALLOC(sizeof(*d));
- ZeroMemory(d, sizeof(*d));
-
- khui_cw_create_cred_blob(&d->nc);
-#ifdef DEBUG
- assert(d->nc != NULL);
-#endif
- if (d->nc == NULL) {
- PFREE(d);
- break;
- }
-
- if (KHM_FAILED(kcdb_identpro_get_ui_cb(&d->nc->ident_cb))) {
- /* this should have worked. The only reason it would fail
- is if there is no identity provider or if the identity
- provider does not support providing idnetity
- selectors. */
- khui_cw_destroy_cred_blob(d->nc);
- PFREE(d);
- break;
- }
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-
- /* get metrics for dynamic controls */
- get_ctrl_row_metrics(&d->dim_small,
- GetDlgItem(hwnd, IDC_SM_LBL),
- GetDlgItem(hwnd, IDC_SM_CTL));
- get_ctrl_row_metrics(&d->dim_medium,
- GetDlgItem(hwnd, IDC_MED_LBL),
- GetDlgItem(hwnd, IDC_MED_CTL));
- get_ctrl_row_metrics(&d->dim_large,
- GetDlgItem(hwnd, IDC_LG_LBL),
- GetDlgItem(hwnd, IDC_LG_CTL));
-
- {
- RECT rlbl;
- RECT rctl;
- RECT rwnd;
-
- GetWindowRect(GetDlgItem(hwnd, IDC_SM_LBL),
- &rlbl);
- GetWindowRect(GetDlgItem(hwnd, IDC_SM_CTL),
- &rctl);
- GetWindowRect(hwnd, &rwnd);
-
- OffsetRect(&rlbl, -rwnd.left, -rwnd.top);
- OffsetRect(&rctl, -rwnd.left, -rwnd.top);
-
- d->current_x = rlbl.left;
- d->current_y = rctl.top - GetSystemMetrics(SM_CYCAPTION);
-
- GetWindowRect(GetDlgItem(hwnd, IDC_MED_CTL),
- &rlbl);
- OffsetRect(&rlbl, -rwnd.left, -rwnd.top);
-
- d->row_gap = rlbl.top - rctl.bottom;
- }
-
- d->nc->hwnd = hwnd;
-
- /* now call the UI callback and make it create the
- controls. */
- d->nc->ident_cb(d->nc, WMNC_IDENT_INIT, NULL, 0, 0,
- (LPARAM) hwnd);
-
- break;
-
- case WM_DESTROY:
- d = (add_ident_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- break;
-
- d->nc->ident_cb(d->nc, WMNC_IDENT_EXIT, NULL, 0, 0, 0);
-
- khui_cw_destroy_cred_blob(d->nc);
- PFREE(d);
- SetWindowLongPtr(hwnd, DWLP_USER, 0);
- break;
-
- case KHUI_WM_NC_NOTIFY:
- d = (add_ident_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- break;
-
- switch(HIWORD(wParam)) {
- case WMNC_ADD_CONTROL_ROW:
- {
- khui_control_row * row;
- RECT r_lbl, r_inp, r_enc;
- struct ctrl_row_dimensions * dim;
- HFONT hf;
-
- row = (khui_control_row *) lParam;
-
-#ifdef DEBUG
- assert(row->label);
- assert(row->input);
- assert(d);
-#endif
-
- if (row->size == KHUI_CTRLSIZE_SMALL) {
- dim = &d->dim_small;
- } else if (row->size == KHUI_CTRLSIZE_HALF) {
- dim = &d->dim_medium;
- } else {
- dim = &d->dim_large;
-#ifdef DEBUG
- assert(row->size == KHUI_CTRLSIZE_FULL);
-#endif
- }
-
- CopyRect(&r_enc, &dim->enclosure);
- CopyRect(&r_lbl, &dim->label);
- CopyRect(&r_inp, &dim->control);
-
- OffsetRect(&r_enc, d->current_x, d->current_y);
- OffsetRect(&r_lbl, r_enc.left, r_enc.top);
- OffsetRect(&r_inp, r_enc.left, r_enc.top);
-
- d->current_y += r_enc.bottom - r_enc.top;
-
- hf = (HFONT) SendDlgItemMessage(hwnd, IDOK, WM_GETFONT, 0, 0);
-
- if (row->label) {
- SetWindowPos(row->label,
- ((d->hwnd_last_ctrl != NULL)?
- d->hwnd_last_ctrl :
- HWND_TOP),
- r_lbl.left, r_lbl.top,
- r_lbl.right - r_lbl.left,
- r_lbl.bottom - r_lbl.top,
- SWP_DEFERERASE | SWP_NOACTIVATE |
- SWP_NOOWNERZORDER);
- if (hf)
- SendMessage(row->label, WM_SETFONT,
- (WPARAM) hf,
- TRUE);
- d->hwnd_last_ctrl = row->label;
- }
-
- if (row->input) {
- SetWindowPos(row->input,
- ((d->hwnd_last_ctrl != NULL)?
- d->hwnd_last_ctrl :
- HWND_TOP),
- r_inp.left, r_inp.top,
- r_inp.right - r_inp.left,
- r_inp.bottom - r_inp.top,
- SWP_DEFERERASE | SWP_NOACTIVATE |
- SWP_NOOWNERZORDER);
- if (hf)
- SendMessage(row->input, WM_SETFONT,
- (WPARAM) hf,
- TRUE);
- d->hwnd_last_ctrl = row->input;
- }
- }
- break;
-
- case WMNC_IDENTITY_CHANGE:
- break;
- }
- return TRUE;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK) {
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- wchar_t err_msg[1024];
- khm_handle ident = NULL;
- 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);
-
- if (!d || !d->nc)
- break;
-
- if (d->nc->ident_cb)
- d->nc->ident_cb(d->nc, WMNC_IDENT_PREPROCESS, NULL, 0, 0, 0);
-
- /* check if there was an identity selected */
- if (d->nc->n_identities == 0 ||
- d->nc->identities[0] == NULL) {
-
- StringCbCopy(idname, sizeof(idname), L"");
-
- LoadString(khm_hInstance, IDS_CFG_IDNAME_NON,
- err_msg, ARRAYLENGTH(err_msg));
-
- goto show_failure;
- }
-
- ident = d->nc->identities[0];
- kcdb_identity_hold(ident);
-
- 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,
- &csp_ident))) {
- wchar_t fmt[256];
-
- LoadString(khm_hInstance, IDS_CFG_IDNAME_CCC,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(err_msg, sizeof(err_msg), fmt, rv);
-
- kcdb_identity_release(ident);
- ident = NULL;
-
- goto show_failure;
- }
-
- /* create a value so that the configuration space will
- actually be created in the registry. We don't want
- this new identity to be sticky. */
- khc_write_int32(csp_ident, L"Sticky", 0);
-
- khm_refresh_config();
-
- kcdb_identity_release(ident);
- khc_close_space(csp_ident);
-
- EndDialog(hwnd, 0);
- break;
-
- show_failure:
- {
- wchar_t title[512];
- wchar_t fmt[256];
-
- if (!err_msg[0])
- break;
-
- LoadString(khm_hInstance, IDS_CFG_IDNAME_PRB,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(title, sizeof(title), fmt, idname);
-
- MessageBox(hwnd, err_msg, title, MB_OK | MB_ICONSTOP);
-
- /* don't end the dialog yet */
- break;
- }
- break;
-
- } else if (LOWORD(wParam) == IDCANCEL) {
- EndDialog(hwnd, 1);
- } else {
- d = (add_ident_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (d && d->nc && d->nc->ident_cb) {
- return d->nc->ident_cb(d->nc, WMNC_IDENT_WMSG,
- hwnd, umsg, wParam, lParam);
- }
- }
- break;
- }
-
- return FALSE;
-}
-
-/* dialog procedure for the "general" pane of the "identities"
- configuration node. */
-INT_PTR CALLBACK
-khm_cfg_ids_tab_proc(HWND hwnd,
- UINT umsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- switch(umsg) {
- case WM_INITDIALOG:
- {
- HICON hicon;
-
- hold_idents_data();
-
- cfg_idents.hwnd = hwnd;
- cfg_idents.cfg = *((khui_config_init_data *) lParam);
-
- /* add the status icons */
- if (cfg_idents.hi_status)
- goto _done_with_icons;
-
- cfg_idents.hi_status =
- ImageList_Create(GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- ILC_COLOR8 | ILC_MASK,
- 4,4);
-
- hicon =
- LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_ID),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- cfg_idents.idx_id = ImageList_AddIcon(cfg_idents.hi_status,
- hicon);
-
- DestroyIcon(hicon);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DEFAULT),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- cfg_idents.idx_default = ImageList_AddIcon(cfg_idents.hi_status,
- hicon) + 1;
-
- DestroyIcon(hicon);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_MODIFIED),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- cfg_idents.idx_modified = ImageList_AddIcon(cfg_idents.hi_status,
- hicon) + 1;
-
- DestroyIcon(hicon);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_APPLIED),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- cfg_idents.idx_applied = ImageList_AddIcon(cfg_idents.hi_status,
- hicon) + 1;
-
- DestroyIcon(hicon);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DELETED),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- cfg_idents.idx_deleted = ImageList_AddIcon(cfg_idents.hi_status,
- hicon) + 1;
-
- DestroyIcon(hicon);
-
- _done_with_icons:
-
- CheckDlgButton(hwnd, IDC_CFG_MONITOR,
- (cfg_idents.work.monitor)?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CFG_RENEW,
- (cfg_idents.work.auto_renew)?BST_CHECKED:BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CFG_STICKY,
- (cfg_idents.work.sticky)?BST_CHECKED:BST_UNCHECKED);
-
- }
- return FALSE;
-
- case WM_COMMAND:
-
- if (HIWORD(wParam) == BN_CLICKED) {
- UINT ctrl = LOWORD(wParam);
-
- switch(ctrl) {
- case IDC_CFG_MONITOR:
- case IDC_CFG_RENEW:
- case IDC_CFG_STICKY:
- refresh_data_idents(hwnd);
- break;
-
- case IDC_CFG_ADDIDENT:
- DialogBoxParam(khm_hInstance,
- MAKEINTRESOURCE(IDD_CFG_ADDIDENT),
- hwnd,
- khm_cfg_add_ident_proc,
- (LPARAM) hwnd);
- break;
- }
-
- refresh_view_idents_state(hwnd);
- }
-
- khm_set_dialog_result(hwnd, 0);
- return TRUE;
-
- case KHUI_WM_CFG_NOTIFY:
- {
- switch(HIWORD(wParam)) {
- case WMCFG_APPLY:
- write_params_idents();
- break;
-
- case WMCFG_UPDATE_STATE:
- refresh_view_idents_state(hwnd);
- break;
- }
- }
- return TRUE;
-
- case WM_DESTROY:
- cfg_idents.hwnd = NULL;
-
- if (cfg_idents.hi_status != NULL) {
- ImageList_Destroy(cfg_idents.hi_status);
- cfg_idents.hi_status = NULL;
- }
- release_idents_data();
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* dialog procedure for the "Identities" configuration node */
-INT_PTR CALLBACK
-khm_cfg_identities_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- HWND hw;
- switch(uMsg) {
- case WM_INITDIALOG:
- set_window_node(hwnd, (khui_config_node) lParam);
- add_subpanels(hwnd, (khui_config_node) lParam,
- (khui_config_node) lParam);
- hw = GetDlgItem(hwnd, IDC_CFG_TAB);
- show_tab_panel(hwnd,
- (khui_config_node) lParam,
- hw,
- TabCtrl_GetCurSel(hw),
- TRUE);
- return FALSE;
-
- case WM_DESTROY:
- return 0;
-
- case KHUI_WM_CFG_NOTIFY:
- return handle_cfg_notify(hwnd, wParam, lParam);
-
- case WM_NOTIFY:
- return handle_notify(hwnd, wParam, lParam);
- }
-
- return FALSE;
-}
-
-static ident_data *
-find_ident_by_node(khui_config_node node) {
- khm_size cb;
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- int i;
- khm_handle ident = NULL;
-
- cb = sizeof(idname);
- khui_cfg_get_name(node, idname, &cb);
-
- for (i=0; i < (int)cfg_idents.n_idents; i++) {
- if (!wcscmp(cfg_idents.idents[i].idname, idname))
- break;
- }
-
- 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. */
- if (KHM_FAILED(kcdb_identity_create(idname, 0, &ident)))
- return NULL;
-
- if (cfg_idents.n_idents >= cfg_idents.nc_idents) {
- cfg_idents.nc_idents = UBOUNDSS(cfg_idents.n_idents + 1,
- IDENTS_DATA_ALLOC_INCR,
- IDENTS_DATA_ALLOC_INCR);
-#ifdef DEBUG
- assert(cfg_idents.nc_idents > cfg_idents.n_idents);
-#endif
- cfg_idents.idents = PREALLOC(cfg_idents.idents,
- sizeof(*cfg_idents.idents) *
- cfg_idents.nc_idents);
-#ifdef DEBUG
- assert(cfg_idents.idents);
-#endif
- ZeroMemory(&(cfg_idents.idents[cfg_idents.n_idents]),
- sizeof(*cfg_idents.idents) *
- (cfg_idents.nc_idents - cfg_idents.n_idents));
- }
-
- i = (int) cfg_idents.n_idents;
-
- StringCbLength(idname, KCDB_IDENT_MAXCB_NAME, &cb);
- cb += sizeof(wchar_t);
-
- cfg_idents.idents[i].idname = PMALLOC(cb);
-#ifdef DEBUG
- assert(cfg_idents.idents[i].idname);
-#endif
- StringCbCopy(cfg_idents.idents[i].idname, cb, idname);
-
- cfg_idents.idents[i].ident = ident;
- cfg_idents.idents[i].removed = FALSE;
-
- kcdb_identity_get_flags(ident, &cfg_idents.idents[i].flags);
-#ifdef DEBUG
- assert(cfg_idents.idents[i].flags & KCDB_IDENT_FLAG_CONFIG);
-#endif
-
- read_params_ident(&cfg_idents.idents[i]);
-
- cfg_idents.n_idents++;
-
- /* leave ident held. */
-
- return &cfg_idents.idents[i];
-}
-
-static void
-refresh_view_ident(HWND hwnd, khui_config_node node) {
- ident_data * d;
-
- d = find_ident_by_node(node);
-#ifdef DEBUG
- assert(d);
-#endif
-
- CheckDlgButton(hwnd, IDC_CFG_MONITOR,
- (d->work.monitor? BST_CHECKED: BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_RENEW,
- (d->work.auto_renew? BST_CHECKED: BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_CFG_STICKY,
- (d->work.sticky? BST_CHECKED: BST_UNCHECKED));
-}
-
-static void
-mark_remove_ident(HWND hwnd, khui_config_init_data * idata) {
- ident_data * d;
-
- d = find_ident_by_node(idata->ctx_node);
-#ifdef DEBUG
- assert(d);
-#endif
-
- if (d->removed)
- return;
-
- d->removed = TRUE;
-
- khui_cfg_set_flags_inst(idata, KHUI_CNFLAG_MODIFIED,
- KHUI_CNFLAG_MODIFIED);
-
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), FALSE);
-}
-
-static void
-refresh_data_ident(HWND hwnd, khui_config_init_data * idata) {
- ident_data * d;
-
- d = find_ident_by_node(idata->ctx_node);
-#ifdef DEBUG
- assert(d);
-#endif
-
- if (IsDlgButtonChecked(hwnd, IDC_CFG_MONITOR) == BST_CHECKED)
- d->work.monitor = TRUE;
- else
- d->work.monitor = FALSE;
-
- if (IsDlgButtonChecked(hwnd, IDC_CFG_RENEW) == BST_CHECKED)
- d->work.auto_renew = TRUE;
- else
- d->work.auto_renew = FALSE;
-
- if (IsDlgButtonChecked(hwnd, IDC_CFG_STICKY) == BST_CHECKED)
- d->work.sticky = TRUE;
- else
- d->work.sticky = FALSE;
-
- if (d->work.monitor != d->saved.monitor ||
- d->work.auto_renew != d->saved.auto_renew ||
- d->work.sticky != d->saved.sticky) {
-
- khui_cfg_set_flags_inst(idata, KHUI_CNFLAG_MODIFIED,
- KHUI_CNFLAG_MODIFIED);
-
- } else {
- khui_cfg_set_flags_inst(idata, 0,
- KHUI_CNFLAG_MODIFIED);
- }
-}
-
-/* dialog procedure for the "general" pane of individual identity
- configuration nodes. */
-INT_PTR CALLBACK
-khm_cfg_id_tab_proc(HWND hwnd,
- UINT umsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- khui_config_init_data * idata;
-
- switch(umsg) {
- case WM_INITDIALOG:
- {
- ident_data * d;
-
- hold_idents_data();
-
- idata = (khui_config_init_data *) lParam;
-
- khui_cfg_init_dialog_data(hwnd, idata, 0, NULL, NULL);
-
- refresh_view_ident(hwnd, idata->ctx_node);
-
- d = find_ident_by_node(idata->ctx_node);
- if (d)
- d->hwnd = hwnd;
-#ifdef DEBUG
- else
- assert(FALSE);
-#endif
- }
- return FALSE;
-
- case WM_COMMAND:
- khui_cfg_get_dialog_data(hwnd, &idata, NULL);
-
- if (HIWORD(wParam) == BN_CLICKED) {
- switch(LOWORD(wParam)) {
- case IDC_CFG_MONITOR:
- case IDC_CFG_RENEW:
- case IDC_CFG_STICKY:
-
- refresh_data_ident(hwnd, idata);
- if (cfg_idents.hwnd)
- PostMessage(cfg_idents.hwnd, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(1, WMCFG_UPDATE_STATE), 0);
- break;
-
- case IDC_CFG_REMOVE:
- mark_remove_ident(hwnd, idata);
- if (cfg_idents.hwnd)
- PostMessage(cfg_idents.hwnd, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(1, WMCFG_UPDATE_STATE), 0);
- break;
- }
- }
-
- khm_set_dialog_result(hwnd, 0);
- return TRUE;
-
- case WM_DESTROY:
- {
- ident_data * d;
-
- khui_cfg_get_dialog_data(hwnd, &idata, NULL);
-
- d = find_ident_by_node(idata->ctx_node);
- if (d)
- d->hwnd = NULL;
-
- release_idents_data();
- khui_cfg_free_dialog_data(hwnd);
- khm_set_dialog_result(hwnd, 0);
- }
- return TRUE;
-
- case KHUI_WM_CFG_NOTIFY:
- {
- ident_data * d;
- BOOL * cont;
-
- khui_cfg_get_dialog_data(hwnd, &idata, NULL);
-
- switch (HIWORD(wParam)) {
- case WMCFG_APPLY:
- cont = (BOOL *) lParam;
- d = find_ident_by_node(idata->ctx_node);
- write_params_ident(d);
- 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:
- refresh_view_ident(hwnd, idata->ctx_node);
- refresh_data_ident(hwnd, idata);
- break;
- }
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* dialog procedure for individual identity configuration nodes */
-INT_PTR CALLBACK
-khm_cfg_identity_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- HWND hw;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- khui_config_node refnode = NULL;
-
- set_window_node(hwnd, (khui_config_node) lParam);
-
- khui_cfg_open(NULL, L"KhmIdentities", &refnode);
-#ifdef DEBUG
- assert(refnode != NULL);
-#endif
- add_subpanels(hwnd,
- (khui_config_node) lParam,
- refnode);
-
- hw = GetDlgItem(hwnd, IDC_CFG_TAB);
-
- show_tab_panel(hwnd,
- (khui_config_node) lParam,
- hw,
- TabCtrl_GetCurSel(hw),
- TRUE);
-
- khui_cfg_release(refnode);
- }
- return FALSE;
-
- case WM_DESTROY:
- return 0;
-
- case KHUI_WM_CFG_NOTIFY:
- return handle_cfg_notify(hwnd, wParam, lParam);
-
- case WM_NOTIFY:
- return handle_notify(hwnd, wParam, lParam);
- }
- return FALSE;
-}
diff --git a/src/windows/identity/ui/cfg_notif_wnd.c b/src/windows/identity/ui/cfg_notif_wnd.c
deleted file mode 100644
index 5bb2d6667..000000000
--- a/src/windows/identity/ui/cfg_notif_wnd.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-
-typedef struct tag_notif_data {
- khui_config_node node;
-
- BOOL modified;
-
- BOOL monitor;
- BOOL renew;
- BOOL halflife;
- BOOL warn1;
- BOOL warn2;
-
- khui_tracker tc_renew;
- khui_tracker tc_warn1;
- khui_tracker tc_warn2;
-} notif_data;
-
-static void
-read_params(notif_data * d) {
- khm_handle csp_cw;
- khm_int32 rv;
- khm_int32 t;
-
- rv = khc_open_space(NULL, L"CredWindow", KHM_PERM_READ, &csp_cw);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_read_int32(csp_cw, L"Monitor", &t);
- assert(KHM_SUCCEEDED(rv));
- d->monitor = !!t;
-
- rv = khc_read_int32(csp_cw, L"AllowAutoRenew", &t);
- assert(KHM_SUCCEEDED(rv));
- d->renew = !!t;
-
- rv = khc_read_int32(csp_cw, L"RenewAtHalfLife", &t);
- assert(KHM_SUCCEEDED(rv));
- d->halflife = !!t;
-
- rv = khc_read_int32(csp_cw, L"AllowWarn", &t);
- assert(KHM_SUCCEEDED(rv));
- d->warn1 = !!t;
-
- rv = khc_read_int32(csp_cw, L"AllowCritical", &t);
- assert(KHM_SUCCEEDED(rv));
- d->warn2 = !!t;
-
- rv = khc_read_int32(csp_cw, L"AutoRenewThreshold", &t);
- assert(KHM_SUCCEEDED(rv));
- d->tc_renew.current = t;
-
- rv = khc_read_int32(csp_cw, L"WarnThreshold", &t);
- assert(KHM_SUCCEEDED(rv));
- d->tc_warn1.current = t;
-
- rv = khc_read_int32(csp_cw, L"CriticalThreshold", &t);
- assert(KHM_SUCCEEDED(rv));
- d->tc_warn2.current = t;
-
- rv = khc_read_int32(csp_cw, L"MaxThreshold", &t);
- assert(KHM_SUCCEEDED(rv));
- d->tc_renew.max = t;
- d->tc_warn1.max = t;
- d->tc_warn2.max = t;
-
- rv = khc_read_int32(csp_cw, L"MinThreshold", &t);
- assert(KHM_SUCCEEDED(rv));
- d->tc_renew.min = t;
- d->tc_warn1.min = t;
- d->tc_warn2.min = t;
-
- khc_close_space(csp_cw);
-
- d->modified = FALSE;
-}
-
-static void
-check_for_modification(notif_data * d) {
- notif_data t;
-
- ZeroMemory(&t, sizeof(t));
-
- read_params(&t);
-
- if ((!!d->monitor) != (!!t.monitor) ||
- (!!d->renew) != (!!t.renew) ||
- (!!d->halflife) != (!!t.halflife) ||
- (!!d->warn1) != (!!t.warn1) ||
- (!!d->warn2) != (!!t.warn2) ||
- d->tc_renew.current != t.tc_renew.current ||
- d->tc_warn1.current != t.tc_warn1.current ||
- d->tc_warn2.current != t.tc_warn2.current) {
-
- khui_cfg_set_flags(d->node,
- KHUI_CNFLAG_MODIFIED,
- KHUI_CNFLAG_MODIFIED);
-
- d->modified = TRUE;
-
- } else {
- khui_cfg_set_flags(d->node,
- 0,
- KHUI_CNFLAG_MODIFIED);
-
- d->modified = FALSE;
- }
-}
-
-static void
-write_params(notif_data * d) {
- khm_handle csp_cw;
- khm_int32 rv;
-
- if (!d->modified)
- return;
-
- rv = khc_open_space(NULL, L"CredWindow", KHM_PERM_WRITE, &csp_cw);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"Monitor", d->monitor);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"AllowAutoRenew", d->renew);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"RenewAtHalfLife", d->halflife);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"AllowWarn", d->warn1);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"AllowCritical", d->warn2);
- assert(KHM_SUCCEEDED(rv));
-
-
- rv = khc_write_int32(csp_cw, L"AutoRenewThreshold",
- (khm_int32) d->tc_renew.current);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"WarnThreshold",
- (khm_int32) d->tc_warn1.current);
- assert(KHM_SUCCEEDED(rv));
-
- rv = khc_write_int32(csp_cw, L"CriticalThreshold",
- (khm_int32) d->tc_warn2.current);
- assert(KHM_SUCCEEDED(rv));
-
- khc_close_space(csp_cw);
-
- khui_cfg_set_flags(d->node,
- KHUI_CNFLAG_APPLIED,
- KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);
-
- khm_timer_refresh(hwnd_notifier);
-}
-
-static void
-refresh_view(HWND hwnd, notif_data * d) {
- CheckDlgButton(hwnd, IDC_NOTIF_MONITOR,
- (d->monitor?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_NOTIF_RENEW,
- (d->renew?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_NOTIF_HALFLIFE,
- (d->halflife?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_NOTIF_WARN1,
- (d->warn1?BST_CHECKED:BST_UNCHECKED));
- CheckDlgButton(hwnd, IDC_NOTIF_WARN2,
- (d->warn2?BST_CHECKED:BST_UNCHECKED));
- khui_tracker_refresh(&d->tc_renew);
- khui_tracker_refresh(&d->tc_warn1);
- khui_tracker_refresh(&d->tc_warn2);
- if (!d->monitor) {
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_RENEW), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_HALFLIFE), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN1), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN2), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_RENEW_THR), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN1_THR), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN2_THR), FALSE);
- } else {
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_RENEW), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_HALFLIFE), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN1), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN2), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_RENEW_THR), !!(d->renew));
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN1_THR), !!(d->warn1));
- EnableWindow(GetDlgItem(hwnd, IDC_NOTIF_WARN2_THR), !!(d->warn2));
- }
-}
-
-static void
-refresh_data(HWND hwnd, notif_data * d) {
- d->monitor = (IsDlgButtonChecked(hwnd, IDC_NOTIF_MONITOR)
- == BST_CHECKED);
- d->renew = (IsDlgButtonChecked(hwnd, IDC_NOTIF_RENEW)
- == BST_CHECKED);
- d->halflife = (IsDlgButtonChecked(hwnd, IDC_NOTIF_HALFLIFE)
- == BST_CHECKED);
- d->warn1 = (IsDlgButtonChecked(hwnd, IDC_NOTIF_WARN1)
- == BST_CHECKED);
- d->warn2 = (IsDlgButtonChecked(hwnd, IDC_NOTIF_WARN2)
- == BST_CHECKED);
-
- check_for_modification(d);
-}
-
-INT_PTR CALLBACK
-khm_cfg_notifications_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- notif_data * d;
-
- switch(uMsg) {
- case WM_INITDIALOG: {
- HWND hw;
-
- d = PMALLOC(sizeof(*d));
-#ifdef DEBUG
- assert(d != NULL);
-#endif
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-
- ZeroMemory(d, sizeof(*d));
-
- d->node = (khui_config_node) lParam;
-
- khui_tracker_initialize(&d->tc_renew);
- khui_tracker_initialize(&d->tc_warn1);
- khui_tracker_initialize(&d->tc_warn2);
-
- read_params(d);
-
- hw = GetDlgItem(hwnd, IDC_NOTIF_RENEW_THR);
- khui_tracker_install(hw, &d->tc_renew);
-
- hw = GetDlgItem(hwnd, IDC_NOTIF_WARN1_THR);
- khui_tracker_install(hw, &d->tc_warn1);
-
- hw = GetDlgItem(hwnd, IDC_NOTIF_WARN2_THR);
- khui_tracker_install(hw, &d->tc_warn2);
-
- refresh_view(hwnd, d);
-
- /* normally we should return TRUE, but in this case we return
- FALSE since we don't want to inadvertently steal the focus
- from the treeview. */
- return FALSE;
- }
-
- case WM_COMMAND: {
- d = (notif_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (HIWORD(wParam) == BN_CLICKED) {
- refresh_data(hwnd, d);
- refresh_view(hwnd, d);
-
- check_for_modification(d);
- } else if (HIWORD(wParam) == EN_CHANGE) {
- SetTimer(hwnd, 1, 500, NULL);
- }
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
- }
-
- case WM_TIMER: {
- d = (notif_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- KillTimer(hwnd, 1);
- check_for_modification(d);
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
- }
-
- case WM_DESTROY: {
- d = (notif_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- khui_tracker_kill_controls(&d->tc_renew);
- khui_tracker_kill_controls(&d->tc_warn1);
- khui_tracker_kill_controls(&d->tc_warn2);
-
- PFREE(d);
-
- SetWindowLongPtr(hwnd, DWLP_USER, 0);
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
- }
-
- case KHUI_WM_CFG_NOTIFY: {
- d = (notif_data *) (DWORD_PTR) GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
- write_params(d);
- }
-
- khm_set_dialog_result(hwnd, 0);
-
- return TRUE;
- }
-
- }
-
- return FALSE;
-}
diff --git a/src/windows/identity/ui/cfg_plugins_wnd.c b/src/windows/identity/ui/cfg_plugins_wnd.c
deleted file mode 100644
index dc26f097b..000000000
--- a/src/windows/identity/ui/cfg_plugins_wnd.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-
-#define MAX_PLUGINS 256
-
-typedef struct tag_plugin_data {
- kmm_plugin_info plugin;
- kmm_module_info module;
-} plugin_data;
-
-typedef struct tag_plugin_dlg_data {
- plugin_data * info[MAX_PLUGINS];
- khm_size n_info;
-
- plugin_data * selected;
- HICON plugin_ico;
-} plugin_dlg_data;
-
-void update_dialog_fields(HWND hwnd,
- plugin_dlg_data * d,
- plugin_data * info) {
- wchar_t buf[256];
- UINT resid;
- wchar_t * t;
- khm_handle csp_module = NULL;
-
- d->selected = info;
-
- if (info->plugin.reg.description)
- SetDlgItemText(hwnd, IDC_CFG_DESC, info->plugin.reg.description);
- else {
- wchar_t fmt[128];
-
- LoadString(khm_hInstance, IDS_CFG_NODESC, fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, info->plugin.reg.name);
- SetDlgItemText(hwnd, IDC_CFG_DESC, buf);
- }
-
- switch(info->plugin.state) {
- case KMM_PLUGIN_STATE_FAIL_INIT:
- resid = IDS_PISTATE_FAILINIT;
- break;
-
- case KMM_PLUGIN_STATE_FAIL_UNKNOWN:
- resid = IDS_PISTATE_FAILUNK;
- break;
-
- case KMM_PLUGIN_STATE_FAIL_MAX_FAILURE:
- resid = IDS_PISTATE_FAILMAX;
- break;
-
- case KMM_PLUGIN_STATE_FAIL_NOT_REGISTERED:
- resid = IDS_PISTATE_FAILREG;
- break;
-
- case KMM_PLUGIN_STATE_FAIL_DISABLED:
- resid = IDS_PISTATE_FAILDIS;
- break;
-
- case KMM_PLUGIN_STATE_FAIL_LOAD:
- resid = IDS_PISTATE_FAILLOD;
- break;
-
- case KMM_PLUGIN_STATE_NONE:
- case KMM_PLUGIN_STATE_PLACEHOLDER:
- resid = IDS_PISTATE_PLACEHOLD;
- break;
-
- case KMM_PLUGIN_STATE_REG:
- case KMM_PLUGIN_STATE_PREINIT:
- resid = IDS_PISTATE_REG;
- break;
-
- case KMM_PLUGIN_STATE_HOLD:
- resid = IDS_PISTATE_HOLD;
- break;
-
- case KMM_PLUGIN_STATE_INIT:
- resid = IDS_PISTATE_INIT;
- break;
-
- case KMM_PLUGIN_STATE_RUNNING:
- resid = IDS_PISTATE_RUN;
- break;
-
- case KMM_PLUGIN_STATE_EXITED:
- resid = IDS_PISTATE_EXIT;
- break;
-
- default:
-#ifdef DEBUG
- assert(FALSE);
-#endif
- resid = IDS_PISTATE_FAILUNK;
- }
-
- LoadString(khm_hInstance, resid,
- buf, ARRAYLENGTH(buf));
-
- SetDlgItemText(hwnd, IDC_CFG_STATE, buf);
-
- SendDlgItemMessage(hwnd, IDC_CFG_DEPS,
- LB_RESETCONTENT, 0, 0);
-
- for (t = info->plugin.reg.dependencies; t && *t;
- t = multi_string_next(t)) {
- SendDlgItemMessage(hwnd, IDC_CFG_DEPS,
- LB_INSERTSTRING, (WPARAM) -1, (LPARAM) t);
- }
-
- if (info->plugin.reg.module)
- SetDlgItemText(hwnd, IDC_CFG_MODULE,
- info->plugin.reg.module);
- else
- SetDlgItemText(hwnd, IDC_CFG_MODULE,
- L"");
-
- if (info->module.reg.vendor)
- SetDlgItemText(hwnd, IDC_CFG_VENDOR,
- info->module.reg.vendor);
- else
- SetDlgItemText(hwnd, IDC_CFG_VENDOR,
- L"");
-
- StringCbPrintf(buf, sizeof(buf), L"%u.%u.%u.%u",
- (unsigned int) info->module.product_version.major,
- (unsigned int) info->module.product_version.minor,
- (unsigned int) info->module.product_version.patch,
- (unsigned int) info->module.product_version.aux);
-
- SetDlgItemText(hwnd, IDC_CFG_VERSION, buf);
-
- if (info->plugin.reg.icon) {
- SendDlgItemMessage(hwnd, IDC_CFG_ICON,
- STM_SETICON,
- (WPARAM) info->plugin.reg.icon,
- 0);
- } else {
- SendDlgItemMessage(hwnd, IDC_CFG_ICON,
- STM_SETICON,
- (WPARAM) d->plugin_ico,
- 0);
- }
-
- if (KHM_SUCCEEDED(kmm_get_module_config(info->module.reg.name,
- 0, &csp_module)) &&
- (khc_value_exists(csp_module, L"ImagePath") &
- (KCONF_FLAG_MACHINE | KCONF_FLAG_USER))) {
-
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_UNREGISTER), TRUE);
- } else {
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_UNREGISTER), FALSE);
- }
-
- if (csp_module)
- khc_close_space(csp_module);
-
- if (info->plugin.flags & KMM_PLUGIN_FLAG_DISABLED) {
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_ENABLE), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_DISABLE), FALSE);
- } else {
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_ENABLE), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_DISABLE), TRUE);
- }
-}
-
-#define IDX_PLUGIN_NORMAL 1
-#define IDX_PLUGIN_DISABLED 2
-#define IDX_PLUGIN_ERROR 3
-
-INT_PTR CALLBACK
-khm_cfg_plugins_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- plugin_dlg_data * d;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- kmm_plugin p;
- kmm_plugin pn;
- kmm_module m;
- khm_size i;
- LVCOLUMN lvc;
- RECT r;
- HWND hw;
- wchar_t buf[256];
- HIMAGELIST h_ilist;
- HICON h_icon;
-
- d = PMALLOC(sizeof(*d));
-#ifdef DEBUG
- assert(d);
-#endif
- ZeroMemory(d, sizeof(*d));
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-
- p = NULL;
- i = 0;
- do {
- if (KHM_FAILED(kmm_get_next_plugin(p, &pn)))
- break;
-
- if (p)
- kmm_release_plugin(p);
- p = pn;
-
-#ifdef DEBUG
- assert(d->info[i] == NULL);
-#endif
- d->info[i] = PMALLOC(sizeof(*(d->info[i])));
-#ifdef DEBUG
- assert(d->info[i]);
-#endif
- ZeroMemory(&d->info[i]->plugin,
- sizeof(d->info[i]->plugin));
-
- if (KHM_FAILED(kmm_get_plugin_info_i(p, &d->info[i]->plugin))) {
- PFREE(d->info[i]);
- d->info[i] = NULL;
- break;
- }
-
- ZeroMemory(&d->info[i]->module,
- sizeof(d->info[i]->module));
-
- if (KHM_SUCCEEDED(kmm_load_module(d->info[i]->plugin.reg.module,
- KMM_LM_FLAG_NOLOAD,
- &m))) {
- kmm_get_module_info_i(m, &d->info[i]->module);
- kmm_release_module(m);
- }
-
- i ++;
-
- if (i == MAX_PLUGINS)
- break;
- } while(p);
-
- if (p)
- kmm_release_plugin(p);
-
- d->n_info = i;
-
- /* now populate the list view */
- hw = GetDlgItem(hwnd, IDC_CFG_PLUGINS);
-#ifdef DEBUG
- assert(hw);
-#endif
-
- h_ilist = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- ILC_COLOR8,
- 4, 4);
-
- h_icon = LoadImage(khm_hInstance,
- MAKEINTRESOURCE(IDI_CFG_PLUGIN),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTCOLOR);
-#ifdef DEBUG
- assert(h_icon);
-#endif
- ImageList_AddIcon(h_ilist, h_icon);
- DestroyIcon(h_icon);
-
- h_icon = LoadImage(khm_hInstance,
- MAKEINTRESOURCE(IDI_CFG_PLUGIN_DIS),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTCOLOR);
-#ifdef DEBUG
- assert(h_icon);
-#endif
- ImageList_AddIcon(h_ilist, h_icon);
- DestroyIcon(h_icon);
-
- h_icon = LoadImage(khm_hInstance,
- MAKEINTRESOURCE(IDI_CFG_PLUGIN_ERR),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTCOLOR);
-#ifdef DEBUG
- assert(h_icon);
-#endif
- ImageList_AddIcon(h_ilist, h_icon);
- DestroyIcon(h_icon);
-
- ListView_SetImageList(hw, h_ilist, LVSIL_STATE);
-
- ZeroMemory(&lvc, sizeof(lvc));
-
- lvc.mask = LVCF_TEXT | LVCF_WIDTH;
- GetWindowRect(hw, &r);
- lvc.cx = ((r.right - r.left) * 95) / 100;
- lvc.pszText = buf;
-
- LoadString(khm_hInstance, IDS_CFG_PI_COL_PLUGINS,
- buf, ARRAYLENGTH(buf));
-
- ListView_InsertColumn(hw, 0, &lvc);
-
- for(i=0; i<d->n_info; i++) {
- LVITEM lvi;
-
- ZeroMemory(&lvi, sizeof(lvi));
-
- lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_STATE;
- lvi.lParam = (LPARAM) d->info[i];
- lvi.pszText = d->info[i]->plugin.reg.name;
-
- if (d->info[i]->plugin.flags & KMM_PLUGIN_FLAG_DISABLED) {
- lvi.state = INDEXTOSTATEIMAGEMASK(IDX_PLUGIN_DISABLED);
- } else if (d->info[i]->plugin.state < 0) {
- lvi.state = INDEXTOSTATEIMAGEMASK(IDX_PLUGIN_ERROR);
- } else {
- lvi.state = INDEXTOSTATEIMAGEMASK(IDX_PLUGIN_NORMAL);
- }
-
- ListView_InsertItem(hw, &lvi);
- }
-
- d->plugin_ico =
- (HICON) LoadImage(khm_hInstance,
- MAKEINTRESOURCE(IDI_CFG_PLUGIN),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON),
- LR_DEFAULTCOLOR);
- }
- return FALSE;
-
- case WM_NOTIFY:
- {
- LPNMHDR lpnm;
- HWND hw;
-
- d = (plugin_dlg_data *) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- if (wParam == IDC_CFG_PLUGINS &&
- (lpnm = (LPNMHDR) lParam) &&
- lpnm->code == LVN_ITEMCHANGED) {
-
- LVITEM lvi;
-
- hw = GetDlgItem(hwnd, IDC_CFG_PLUGINS);
-#ifdef DEBUG
- assert(hw);
-#endif
- if (ListView_GetSelectedCount(hw) != 1) {
- SetDlgItemText(hwnd, IDC_CFG_DESC, L"");
- SetDlgItemText(hwnd, IDC_CFG_STATE, L"");
- SetDlgItemText(hwnd, IDC_CFG_MODULE, L"");
- SetDlgItemText(hwnd, IDC_CFG_VENDOR, L"");
- SetDlgItemText(hwnd, IDC_CFG_VERSION, L"");
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_ENABLE), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_DISABLE), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_CFG_UNREGISTER), FALSE);
- SendDlgItemMessage(hwnd, IDC_CFG_DEPS,
- LB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hwnd, IDC_CFG_ICON, STM_SETICON,
- (WPARAM) d->plugin_ico, 0);
- d->selected = NULL;
- } else {
- int idx;
- plugin_data * info;
-
- idx = ListView_GetNextItem(hw, -1, LVNI_SELECTED);
-#ifdef DEBUG
- assert(idx != -1);
-#endif
- ZeroMemory(&lvi, sizeof(lvi));
- lvi.iItem = idx;
- lvi.iSubItem = 0;
- lvi.mask = LVIF_PARAM;
-
- ListView_GetItem(hw, &lvi);
-#ifdef DEBUG
- assert(lvi.lParam != 0);
-#endif
- info = (plugin_data *) lvi.lParam;
-
- update_dialog_fields(hwnd, d, info);
- }
- }
- }
- return TRUE;
-
- case WM_COMMAND:
- {
-
- d = (plugin_dlg_data *) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- return FALSE;
-
- switch (wParam) {
- case MAKEWPARAM(IDC_CFG_ENABLE, BN_CLICKED):
- if (d->selected != NULL) {
- khui_alert * alert = NULL;
- wchar_t buf[KHUI_MAXCCH_MESSAGE];
- wchar_t fmt[KHUI_MAXCCH_MESSAGE];
- kmm_plugin p;
-
- khui_alert_create_empty(&alert);
-
- LoadString(khm_hInstance, IDS_CFG_P_ENBCNFT,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, d->selected->plugin.reg.name);
- khui_alert_set_title(alert, buf);
-
- LoadString(khm_hInstance, IDS_CFG_P_ENBCNFM,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, d->selected->plugin.reg.name);
- khui_alert_set_message(alert, buf);
-
- khui_alert_set_severity(alert, KHERR_INFO);
-
- khui_alert_show_modal(alert);
-
- kmm_enable_plugin(d->selected->plugin.h_plugin, TRUE);
-
- khui_alert_release(alert);
-
- p = d->selected->plugin.h_plugin;
- kmm_hold_plugin(p);
- kmm_release_plugin_info_i(&d->selected->plugin);
- kmm_get_plugin_info_i(p, &d->selected->plugin);
- kmm_release_plugin(p);
-
- update_dialog_fields(hwnd, d, d->selected);
- }
- break;
-
- case MAKEWPARAM(IDC_CFG_DISABLE, BN_CLICKED):
- if (d->selected != NULL) {
- khui_alert * alert = NULL;
- wchar_t buf[KHUI_MAXCCH_MESSAGE];
- wchar_t fmt[KHUI_MAXCCH_MESSAGE];
- wchar_t depends[KHUI_MAXCCH_MESSAGE];
- khm_size i;
- kmm_plugin p;
-
- khui_alert_create_empty(&alert);
-#ifdef DEBUG
- assert(alert);
-#endif
- if (alert == NULL)
- break;
-
- LoadString(khm_hInstance, IDS_CFG_P_DELCNFT,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, d->selected->plugin.reg.name);
- khui_alert_set_title(alert, buf);
-
- LoadString(khm_hInstance, IDS_CFG_P_DELCNFM,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, d->selected->plugin.reg.name);
- khui_alert_set_message(alert, buf);
-
- depends[0] = L'\0';
-
- for (i=0; i<d->n_info; i++) {
- wchar_t * t;
-
- t = d->info[i]->plugin.reg.dependencies;
-
- while(t) {
- if (!wcscmp(t, d->selected->plugin.reg.name)) {
- if (depends[0])
- StringCbCat(depends, sizeof(depends), L", ");
- StringCbCat(depends, sizeof(depends),
- d->info[i]->plugin.reg.name);
- break;
- }
- t = multi_string_next(t);
- }
- }
-
- if (depends[0]) {
- LoadString(khm_hInstance, IDS_CFG_P_DELCNFS,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, depends);
- khui_alert_set_suggestion(alert, buf);
- } else {
- LoadString(khm_hInstance, IDS_CFG_P_DELNDEP,
- buf, ARRAYLENGTH(buf));
- khui_alert_set_suggestion(alert, buf);
- }
-
- khui_alert_add_command(alert, KHUI_PACTION_YES);
- khui_alert_add_command(alert, KHUI_PACTION_NO);
-
- khui_alert_set_severity(alert, KHERR_WARNING);
-
- if (KHM_SUCCEEDED(khui_alert_show_modal(alert)) &&
- alert->response == KHUI_PACTION_YES) {
- kmm_enable_plugin(d->selected->plugin.h_plugin, FALSE);
- }
-
- khui_alert_release(alert);
-
- p = d->selected->plugin.h_plugin;
- kmm_hold_plugin(p);
- kmm_release_plugin_info_i(&d->selected->plugin);
- kmm_get_plugin_info_i(p, &d->selected->plugin);
- kmm_release_plugin(p);
-
- update_dialog_fields(hwnd, d, d->selected);
- }
- break;
-
- case MAKEWPARAM(IDC_CFG_UNREGISTER, BN_CLICKED):
- {
- khui_alert * alert = NULL;
- wchar_t buf[KHUI_MAXCCH_MESSAGE];
- wchar_t fmt[KHUI_MAXCCH_MESSAGE];
- wchar_t plist[KHUI_MAXCCH_MESSAGE];
- khm_size i;
-
- if (d->selected == NULL) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- break;
- }
-
- khui_alert_create_empty(&alert);
-
- LoadString(khm_hInstance, IDS_CFG_P_UNRCNFT,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt,
- d->selected->plugin.reg.name);
-
- khui_alert_set_title(alert, buf);
-
- LoadString(khm_hInstance, IDS_CFG_P_UNRCNFM,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt,
- d->selected->plugin.reg.name);
-
- khui_alert_set_message(alert, buf);
-
- plist[0] = L'\0';
- for (i=0; i < d->n_info; i++) {
- if (!wcscmp(d->info[i]->module.reg.name,
- d->selected->module.reg.name)) {
- if (plist[0])
- StringCbCat(plist, sizeof(plist), L", ");
- StringCbCat(plist, sizeof(plist),
- d->info[i]->plugin.reg.name);
- }
- }
-
-#ifdef DEBUG
- /* there should have been at least one plugin */
- assert(plist[0]);
-#endif
-
- LoadString(khm_hInstance, IDS_CFG_P_UNRCNFS,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, plist);
- khui_alert_set_suggestion(alert, buf);
-
- khui_alert_add_command(alert, KHUI_PACTION_YES);
- khui_alert_add_command(alert, KHUI_PACTION_NO);
-
- khui_alert_set_severity(alert, KHERR_WARNING);
-
- if (KHM_SUCCEEDED(khui_alert_show_modal(alert)) &&
- alert->response == KHUI_PACTION_YES) {
- kmm_unregister_module(d->selected->module.reg.name, 0);
-
- update_dialog_fields(hwnd, d, d->selected);
- }
- }
- break;
-
- case MAKEWPARAM(IDC_CFG_REGISTER, BN_CLICKED):
- {
-
- }
- break;
- }
- }
- return TRUE;
-
- case WM_DESTROY:
- {
- khm_size i;
-
- d = (plugin_dlg_data *) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
-#ifdef DEBUG
- assert(d);
-#endif
- if (d == NULL)
- return TRUE;
-
- for (i=0; i<d->n_info; i++) {
-#ifdef DEBUG
- assert(d->info[i]);
-#endif
- kmm_release_plugin_info_i(&d->info[i]->plugin);
- kmm_release_module_info_i(&d->info[i]->module);
- PFREE(d->info[i]);
- }
-
- PFREE(d);
- SetWindowLongPtr(hwnd, DWLP_USER, 0);
-
- khm_set_dialog_result(hwnd, 0);
- }
- return TRUE;
- }
- return FALSE;
-}
diff --git a/src/windows/identity/ui/configwnd.c b/src/windows/identity/ui/configwnd.c
deleted file mode 100644
index cf3cdfdd0..000000000
--- a/src/windows/identity/ui/configwnd.c
+++ /dev/null
@@ -1,1243 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-
-static HWND cfgui_hwnd = NULL;
-
-typedef struct tag_cfgui_wnd_data {
- khui_config_node current;
- HWND hw_current;
- HWND hw_generic_pane;
- HBRUSH hbr_white;
- HFONT hf_title;
- khui_bitmap kbmp_logo;
- HIMAGELIST hi_status;
- BOOL modified;
- int idx_default;
- int idx_modified;
- int idx_applied;
-} cfgui_wnd_data;
-
-static cfgui_wnd_data *
-cfgui_get_wnd_data(HWND hwnd) {
- return (cfgui_wnd_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
-}
-
-static void
-cfgui_set_wnd_data(HWND hwnd, cfgui_wnd_data * d) {
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-}
-
-static void
-cfgui_add_node(cfgui_wnd_data * d,
- HWND hwtv,
- khui_config_node node,
- khui_config_node parent,
- BOOL sorted) {
-
- khui_config_node_reg reg;
- khui_config_node c;
- wchar_t wbuf[256];
- const wchar_t * short_desc;
- TVINSERTSTRUCT s;
- HTREEITEM hItem;
-
- if (node) {
- khui_cfg_get_reg(node, &reg);
- short_desc = reg.short_desc;
- } else {
- short_desc = wbuf;
- LoadString(khm_hInstance, IDS_CFG_ROOT_NAME,
- wbuf, ARRAYLENGTH(wbuf));
- reg.flags = 0;
- }
-
- ZeroMemory(&s, sizeof(s));
-
- s.hParent = (node)?
- (HTREEITEM) khui_cfg_get_param(parent):
- TVI_ROOT;
-
- s.hInsertAfter = (sorted)? TVI_SORT: TVI_FIRST;
-
- s.itemex.mask =
- TVIF_CHILDREN |
- TVIF_PARAM |
- TVIF_TEXT |
- TVIF_STATE;
-
- {
- khui_config_node n;
-
- if (KHM_SUCCEEDED(khui_cfg_get_first_child(node,
- &n))) {
- s.itemex.cChildren = 1;
- s.itemex.state = TVIS_EXPANDED;
- s.itemex.stateMask = TVIS_EXPANDED;
- khui_cfg_release(n);
- } else {
- s.itemex.cChildren = 0;
- s.itemex.state = 0;
- s.itemex.stateMask = TVIS_EXPANDED;
- }
-
- s.itemex.state |= INDEXTOSTATEIMAGEMASK(d->idx_default);
- s.itemex.stateMask |= TVIS_STATEIMAGEMASK;
- }
-
- s.itemex.lParam = (LPARAM) node;
- khui_cfg_hold(node);
-
- s.itemex.pszText = (LPWSTR) short_desc;
-
- hItem = TreeView_InsertItem(hwtv, &s);
-
- khui_cfg_set_param(node, (LPARAM) hItem);
-
- if (KHM_SUCCEEDED(khui_cfg_get_first_child(node,
- &c))) {
- do {
- cfgui_add_node(d, hwtv, c, node,
- !!(reg.flags & KHUI_CNFLAG_SORT_CHILDREN));
- } while (KHM_SUCCEEDED(khui_cfg_get_next_release(&c)));
- }
-}
-
-static void
-cfgui_initialize_dialog(HWND hwnd) {
- cfgui_wnd_data * d;
- HWND hwtv;
- HWND hwtitle;
- HFONT hf;
- HDC hdc;
- HICON hicon;
-
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- return;
-
- /* create and fill the image list for the treeview */
-
- d->hi_status = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
- ILC_COLOR8 | ILC_MASK,
- 4,4);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DEFAULT),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- /* note that we can't use index 0 because that is used to indicate
- that there is no state image for the node */
- do {
- d->idx_default = ImageList_AddIcon(d->hi_status, hicon);
- } while(d->idx_default == 0);
-
- DestroyIcon(hicon);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_MODIFIED),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- d->idx_modified = ImageList_AddIcon(d->hi_status, hicon);
-
- DestroyIcon(hicon);
-
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_APPLIED),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
-
- d->idx_applied = ImageList_AddIcon(d->hi_status, hicon);
-
- DestroyIcon(hicon);
-
- /* now for the treeview */
- hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
-
- TreeView_SetImageList(hwtv, d->hi_status, TVSIL_STATE);
-
- cfgui_add_node(d, hwtv, NULL, NULL, FALSE);
-
- hdc = GetDC(hwnd);
- hf = CreateFont(-MulDiv(12,
- GetDeviceCaps(hdc, LOGPIXELSY),
- 72),
- 0, /* nWidth */
- 0, /* nEscapement */
- 0, /* nOrientation */
- FW_BOLD, /* fnWeight */
- TRUE, /* fdwItalic */
- FALSE, /* fdwUnderline */
- FALSE, /* fdwStrikeOut */
- DEFAULT_CHARSET, /* fdwCharSet */
- OUT_DEFAULT_PRECIS, /* fdwOutputPrecision */
- CLIP_DEFAULT_PRECIS, /* fdwClipPrecision */
- DEFAULT_QUALITY, /* fdwQuality */
- FF_SWISS | DEFAULT_PITCH, /* pitch&family */
- NULL); /* face */
- ReleaseDC(hwnd, hdc);
-
- d->hf_title = hf;
-
- hwtitle = GetDlgItem(hwnd, IDC_CFG_TITLE);
-
- SendMessage(hwtitle,
- WM_SETFONT,
- (WPARAM) hf,
- (LPARAM) FALSE);
-}
-
-static void
-cfgui_free_node(HWND hwtv, HTREEITEM hItem) {
- TVITEMEX iex;
- HTREEITEM hChItem;
-
- ZeroMemory(&iex, sizeof(iex));
-
- iex.mask = TVIF_PARAM;
- iex.hItem = hItem;
-
- if (TreeView_GetItem(hwtv, &iex)) {
- khui_config_node node;
-
- node = (khui_config_node) iex.lParam;
- khui_cfg_release(node);
- }
-
- hChItem = TreeView_GetChild(hwtv, hItem);
- while(hChItem) {
- cfgui_free_node(hwtv, hChItem);
-
- hChItem = TreeView_GetNextSibling(hwtv, hChItem);
- }
-}
-
-static void
-cfgui_uninitialize_dialog(HWND hwnd) {
- cfgui_wnd_data * d;
- HWND hwtv;
-
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- return;
-
- hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
-
- cfgui_free_node(hwtv, TreeView_GetRoot(hwtv));
-
- if (d->hf_title)
- DeleteObject(d->hf_title);
-
- if (d->hi_status)
- ImageList_Destroy(d->hi_status);
-}
-
-static HWND
-cfgui_create_config_node_window(HWND hwnd, khui_config_node node) {
- khui_config_node_reg reg;
- khm_int32 rv;
- HWND hw_new;
-
- khui_config_node parent;
-
- if (KHM_SUCCEEDED(khui_cfg_get_parent(node, &parent))) {
- HWND hwp;
-
- hwp = khui_cfg_get_hwnd(parent);
-
- if (hwp == NULL)
- cfgui_create_config_node_window(hwnd, parent);
-
- khui_cfg_release(parent);
- }
-
- rv = khui_cfg_get_reg(node, &reg);
-#ifdef DEBUG
- assert(KHM_SUCCEEDED(rv));
-#endif
- hw_new = CreateDialogParam(reg.h_module,
- reg.dlg_template,
- hwnd,
- reg.dlg_proc,
- (LPARAM) node);
-#ifdef DEBUG
- assert(hw_new);
-#endif
- khui_cfg_set_hwnd(node, hw_new);
-
- return hw_new;
-}
-
-static void
-cfgui_activate_node(HWND hwnd, khui_config_node node) {
-
- cfgui_wnd_data * d;
- HTREEITEM hItem;
- HWND hw_new;
- HWND hwtv;
-
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- return;
-
- hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
- hItem = (HTREEITEM) khui_cfg_get_param(node);
-
-#ifdef DEBUG
- assert(hItem);
- assert(hwtv);
-#endif
-
- if (node == NULL) {
- hw_new = d->hw_generic_pane;
- } else {
-
- hw_new = khui_cfg_get_hwnd(node);
-
- if (hw_new == NULL) {
- hw_new = cfgui_create_config_node_window(hwnd, node);
- }
- }
-
- if (hw_new == d->hw_current)
- return; /* nothing to do */
-
- {
- RECT r_title;
- RECT r_pane;
- HWND hw;
-
- if (d->hw_current)
- ShowWindow(d->hw_current, SW_HIDE);
-
- hw = GetDlgItem(hwnd, IDC_CFG_TITLE);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r_title);
-
- hw = GetDlgItem(hwnd, IDC_CFG_PANE);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r_pane);
-
- OffsetRect(&r_pane, -r_title.left, -r_title.top);
-
- SetWindowPos(hw_new,
- hwtv,
- r_pane.left, r_pane.top,
- r_pane.right - r_pane.left,
- r_pane.bottom - r_pane.top,
- SWP_NOOWNERZORDER |
- SWP_SHOWWINDOW |
- SWP_NOACTIVATE);
- }
-
- if (node == NULL) {
- wchar_t wbuf[256];
-
- LoadString(khm_hInstance, IDS_CFG_ROOT_TITLE,
- wbuf, ARRAYLENGTH(wbuf));
-
- SetDlgItemText(hwnd, IDC_CFG_TITLE, wbuf);
- } else {
- khm_int32 rv;
- khui_config_node_reg reg;
-
- rv = khui_cfg_get_reg(node, &reg);
-#ifdef DEBUG
- assert(KHM_SUCCEEDED(rv));
-#endif
- SetDlgItemText(hwnd, IDC_CFG_TITLE, reg.long_desc);
- }
-
- d->hw_current = hw_new;
- d->current = node;
-
- TreeView_SelectItem(hwtv, hItem);
-}
-
-static BOOL
-cfgui_check_mod_state(khui_config_node node) {
- khm_int32 flags;
- khui_config_node c = NULL;
- BOOL rv = FALSE;
-
- flags = khui_cfg_get_flags(node);
-
- if (flags & KHUI_CNFLAG_MODIFIED)
- return TRUE;
-
- if (KHM_FAILED(khui_cfg_get_first_child(node, &c)))
- return FALSE;
-
- while(c) {
- rv = (rv || cfgui_check_mod_state(c));
- khui_cfg_get_next_release(&c);
- }
-
- return rv;
-}
-
-static void
-cfgui_apply_settings(khui_config_node node) {
- HWND hwnd;
- khui_config_node c;
- khm_int32 flags;
-
- hwnd = khui_cfg_get_hwnd(node);
- flags = khui_cfg_get_flags(node);
-
- if (hwnd && (flags & KHUI_CNFLAG_MODIFIED)) {
- SendMessage(hwnd, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(0, WMCFG_APPLY),
- (LPARAM) node);
- }
-
- if (KHM_FAILED(khui_cfg_get_first_child(node, &c)))
- return;
-
- while (c) {
- cfgui_apply_settings(c);
- khui_cfg_get_next_release(&c);
- }
-}
-
-static void
-cfgui_remove_item(HWND hwtv,
- HTREEITEM hItem) {
- khui_config_node node;
- HTREEITEM hChild;
- TVITEMEX itemex;
-
- for (hChild = TreeView_GetChild(hwtv, hItem);
- hChild;
- hChild = TreeView_GetChild(hwtv, hItem)) {
-
- cfgui_remove_item(hwtv, hChild);
-
- }
-
- ZeroMemory(&itemex, sizeof(itemex));
-
- itemex.mask = TVIF_PARAM;
- itemex.hItem = hItem;
-
- TreeView_GetChild(hwtv, &itemex);
-
- node = (khui_config_node) itemex.lParam;
-
- if (node) {
- HWND hw;
- hw = khui_cfg_get_hwnd(node);
-
- if (hw)
- DestroyWindow(hw);
-
- khui_cfg_release(node);
- }
-
- TreeView_DeleteItem(hwtv, hItem);
-}
-
-struct cfgui_child_info {
- HTREEITEM hItem;
- khui_config_node node;
- BOOL checked;
-};
-
-#define CI_ALLOC_INCR 8
-
-static void
-cfgui_sync_node(cfgui_wnd_data * d,
- HWND hwtv,
- khui_config_node c,
- HTREEITEM hItem) {
- khui_config_node child;
- HTREEITEM hChild;
- struct cfgui_child_info * childinfo = NULL;
- khm_size n_childinfo = 0;
- khm_size nc_childinfo = 0;
- khm_size i;
-
- /* first, get the list of children from the treeview control */
- for (hChild = TreeView_GetChild(hwtv, hItem);
- hChild;
- hChild = TreeView_GetNextSibling(hwtv, hChild)) {
-
- if (n_childinfo >= nc_childinfo) {
- nc_childinfo = UBOUNDSS(n_childinfo + 1,
- CI_ALLOC_INCR, CI_ALLOC_INCR);
-#ifdef DEBUG
- assert(nc_childinfo > n_childinfo);
-#endif
- childinfo = PREALLOC(childinfo,
- sizeof(*childinfo) * nc_childinfo);
-#ifdef DEBUG
- assert(childinfo);
-#endif
- }
-
- ZeroMemory(&childinfo[n_childinfo],
- sizeof(childinfo[n_childinfo]));
-
- childinfo[n_childinfo].hItem = hChild;
- childinfo[n_childinfo].checked = FALSE;
- n_childinfo++;
- }
-
- /* now, go through the list of actual nodes and make sure they
- match up */
- child = NULL;
- for (khui_cfg_get_first_child(c, &child);
- child;
- khui_cfg_get_next_release(&child)) {
-
- hChild = (HTREEITEM) khui_cfg_get_param(child);
-
- for (i=0; i < n_childinfo; i++) {
- if (childinfo[i].hItem == hChild)
- break;
- }
-
- if (i < n_childinfo) {
- childinfo[i].checked = TRUE;
- } else {
- /* add it to the list, so we can create the node in the
- tree view control later. */
- if (n_childinfo >= nc_childinfo) {
- nc_childinfo = UBOUNDSS(n_childinfo + 1,
- CI_ALLOC_INCR, CI_ALLOC_INCR);
-#ifdef DEBUG
- assert(nc_childinfo > n_childinfo);
-#endif
- childinfo = PREALLOC(childinfo,
- sizeof(*childinfo) * nc_childinfo);
-#ifdef DEBUG
- assert(childinfo);
-#endif
- }
-
- ZeroMemory(&childinfo[n_childinfo],
- sizeof(childinfo[n_childinfo]));
-
- childinfo[n_childinfo].node = child;
- khui_cfg_hold(child);
- n_childinfo++;
- }
- }
-
- /* by this point, the childinfo list contains items of the
- following forms:
-
- 1. childinfo[i].hItem != NULL && childinfo[i].checked == TRUE
-
- Corresponds to a tree view item that has a matching
- configuration node. Nothing to do here.
-
- 2. childinfo[i].hItem != NULL && childinfo[i].checked == FALSE
-
- Corresponds to a tree view item that has no matching
- configuration node. These should be removed.
-
- 3. childinfo[i].hItem == NULL && childinfo[i].node != NULL
-
- Corresponds to a configuration node that has no matching
- tree view item. These nodes should be added.
- */
-
- /* first do the removals */
- for (i=0; i < n_childinfo; i++) {
- if (childinfo[i].hItem == NULL)
- break; /* nothing more to see from this point
- on */
- if (!childinfo[i].checked) {
- /* remove! */
- cfgui_remove_item(hwtv, childinfo[i].hItem);
- }
- }
-
- /* continue from where the previous loop left off */
- for (; i < n_childinfo; i++) {
-#ifdef DEBUG
- assert(childinfo[i].hItem == NULL);
- assert(childinfo[i].node != NULL);
-#endif
-
- cfgui_add_node(d, hwtv, childinfo[i].node, c, FALSE);
-
- khui_cfg_release(childinfo[i].node);
- childinfo[i].node = NULL;
- }
-
- if (childinfo)
- PFREE(childinfo);
-
- /* finally recurse through to the next level */
- for (hChild = TreeView_GetChild(hwtv, hItem);
- hChild;
- hChild = TreeView_GetNextSibling(hwtv, hChild)) {
-
- TVITEMEX itemex;
-
- ZeroMemory(&itemex, sizeof(itemex));
-
- itemex.mask = TVIF_PARAM;
- itemex.hItem = hChild;
-
- TreeView_GetItem(hwtv, &itemex);
-
- if (itemex.lParam) {
- child = (khui_config_node) itemex.lParam;
-
- cfgui_sync_node(d, hwtv, child, hChild);
- }
- }
-}
-
-static void
-cfgui_sync_node_list(cfgui_wnd_data * d, HWND hwnd) {
- HWND hwtv;
- HTREEITEM hItem;
-
- hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
- hItem = TreeView_GetRoot(hwtv);
-
- cfgui_sync_node(d, hwtv, NULL, hItem);
-}
-
-static void
-cfgui_update_state(HWND hwnd,
- khm_int32 flags,
- khui_config_node node) {
- cfgui_wnd_data * d;
- HWND hwtv;
- HTREEITEM hItem;
- TVITEMEX itx;
- int idx;
-
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- return;
-
- hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
- hItem = (HTREEITEM) khui_cfg_get_param(node);
-
- ZeroMemory(&itx, sizeof(itx));
-
- if (flags & KHUI_CNFLAG_MODIFIED)
- idx = d->idx_modified;
- else if (flags & KHUI_CNFLAG_APPLIED)
- idx = d->idx_applied;
- else
- idx = d->idx_default;
-
- itx.hItem = hItem;
- itx.mask = TVIF_STATE;
- itx.state = INDEXTOSTATEIMAGEMASK(idx);
- itx.stateMask = TVIS_STATEIMAGEMASK;
-
- TreeView_SetItem(hwtv, &itx);
-
- if(cfgui_check_mod_state(NULL)) {
- EnableWindow(GetDlgItem(hwnd, IDAPPLY), TRUE);
- } else {
- EnableWindow(GetDlgItem(hwnd, IDAPPLY), FALSE);
- }
-}
-
-
-/* dialog procedure for the generic dialog */
-static INT_PTR CALLBACK
-cfgui_dlgproc_generic(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- cfgui_wnd_data * d;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- d = (cfgui_wnd_data *) lParam;
- cfgui_set_wnd_data(hwnd, d);
- return TRUE;
-
- case WM_CTLCOLORSTATIC:
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- break;
-
- return (BOOL)(DWORD_PTR) d->hbr_white;
-
- case WM_ERASEBKGND:
- {
- HDC hdc = (HDC) wParam;
- RECT r_client;
- RECT r_logo;
- RECT r_fill;
-
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- break;
-
- GetClientRect(hwnd, &r_client);
- SetRectEmpty(&r_logo);
-
- r_logo.right = d->kbmp_logo.cx;
- r_logo.bottom = d->kbmp_logo.cy;
-
- OffsetRect(&r_logo,
- r_client.right - r_logo.right,
- r_client.bottom - r_logo.bottom);
-
- khui_draw_bitmap(hdc,
- r_logo.left,
- r_logo.top,
- &d->kbmp_logo);
-
- r_fill.left = 0;
- r_fill.top = 0;
- r_fill.right = r_logo.left;
- r_fill.bottom = r_client.bottom;
- FillRect(hdc, &r_fill, d->hbr_white);
-
- r_fill.left = r_logo.left;
- r_fill.right = r_client.right;
- r_fill.bottom = r_logo.top;
- FillRect(hdc, &r_fill, d->hbr_white);
-
- SetWindowLongPtr(hwnd, DWLP_MSGRESULT, (LONG) TRUE);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static INT_PTR CALLBACK
-cfgui_dlgproc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- khui_config_node node;
- cfgui_wnd_data * d;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- node = (khui_config_node) lParam;
-
- khui_cfg_clear_params();
-
- khui_cfg_set_configui_handle(hwnd);
-
- d = PMALLOC(sizeof(*d));
- ZeroMemory(d, sizeof(*d));
-
- d->hbr_white = CreateSolidBrush(RGB(255,255,255));
-
- d->hw_generic_pane =
- CreateDialogParam(khm_hInstance,
- MAKEINTRESOURCE(IDD_CFG_GENERIC),
- hwnd,
- cfgui_dlgproc_generic,
- (LPARAM) d);
-
- khui_bitmap_from_hbmp(&d->kbmp_logo,
- LoadImage(
- khm_hInstance,
- MAKEINTRESOURCE(IDB_LOGO_OPAQUE),
- IMAGE_BITMAP,
- 0,
- 0,
- LR_DEFAULTCOLOR));
-
- cfgui_set_wnd_data(hwnd, d);
-
- cfgui_initialize_dialog(hwnd);
-
- cfgui_activate_node(hwnd, node);
-
- khm_add_dialog(hwnd);
- khm_enter_modal(hwnd);
-
- return TRUE;
-
- case WM_DESTROY:
- cfgui_hwnd = NULL;
-
- khui_cfg_set_configui_handle(NULL);
-
- cfgui_uninitialize_dialog(hwnd);
-
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- break;
-
- khui_delete_bitmap(&d->kbmp_logo);
- DeleteObject(d->hbr_white);
-
- cfgui_set_wnd_data(hwnd, NULL);
-
- khm_del_dialog(hwnd);
-
- SetForegroundWindow(khm_hwnd_main);
-
- PFREE(d);
-
- return FALSE;
-
- case WM_NOTIFY:
- {
- LPNMHDR lpnm;
- LPNMTREEVIEW lptv;
- LPNMTVGETINFOTIP lpgi;
- khui_config_node node;
-
- lpnm = (LPNMHDR) lParam;
-
- switch (lpnm->code) {
- case TVN_SELCHANGED:
- lptv = (LPNMTREEVIEW) lParam;
- cfgui_activate_node(hwnd,
- (khui_config_node)
- lptv->itemNew.lParam);
- return TRUE;
-
- case TVN_GETINFOTIP:
- lpgi = (LPNMTVGETINFOTIP) lParam;
- node = (khui_config_node) lpgi->lParam;
-
- if (node) {
- khm_int32 flags = 0;
-
- flags = khui_cfg_get_flags(node);
-
- if (flags & KHUI_CNFLAG_MODIFIED) {
- LoadString(khm_hInstance, IDS_CFG_IT_MOD,
- lpgi->pszText, lpgi->cchTextMax);
- } else if (flags & KHUI_CNFLAG_APPLIED) {
- LoadString(khm_hInstance, IDS_CFG_IT_APP,
- lpgi->pszText, lpgi->cchTextMax);
- } else {
- LoadString(khm_hInstance, IDS_CFG_IT_NONE,
- lpgi->pszText, lpgi->cchTextMax);
- }
- } else {
- StringCchCopy(lpgi->pszText, lpgi->cchTextMax, L"");
- }
-
- return TRUE;
- }
- }
- return TRUE;
-
- case WM_CTLCOLORSTATIC:
- {
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- break;
-
- return (BOOL)(DWORD_PTR) d->hbr_white;
- }
- /* implicit break */
-
- case WM_COMMAND:
- switch(wParam) {
- case MAKEWPARAM(IDCANCEL, BN_CLICKED):
- khm_leave_modal();
- DestroyWindow(hwnd);
- break;
-
- case MAKEWPARAM(IDAPPLY, BN_CLICKED):
- cfgui_apply_settings(NULL);
- break;
-
- case MAKEWPARAM(IDOK, BN_CLICKED):
- cfgui_apply_settings(NULL);
- khm_leave_modal();
- DestroyWindow(hwnd);
- break;
- }
- return TRUE;
-
- case KHUI_WM_CFG_NOTIFY:
- switch(HIWORD(wParam)) {
- case WMCFG_SHOW_NODE:
- cfgui_activate_node(hwnd, (khui_config_node) lParam);
- break;
-
- case WMCFG_UPDATE_STATE:
- cfgui_update_state(hwnd, LOWORD(wParam),
- (khui_config_node) lParam);
- break;
-
- case WMCFG_SYNC_NODE_LIST:
- d = cfgui_get_wnd_data(hwnd);
- if (d == NULL)
- break;
-
- cfgui_sync_node_list(d, hwnd);
- break;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-cfgui_create_window(khui_config_node node) {
-#ifdef DEBUG
- assert(cfgui_hwnd == NULL);
-#endif
-
- khm_refresh_config();
-
- cfgui_hwnd = CreateDialogParam(khm_hInstance,
- MAKEINTRESOURCE(IDD_CFG_MAIN),
- khm_hwnd_main,
- cfgui_dlgproc,
- (LPARAM) node);
-#ifdef DEBUG
- assert(cfgui_hwnd != NULL);
-#endif
- ShowWindow(cfgui_hwnd,SW_SHOW);
-}
-
-static void
-cfgui_destroy_window(void) {
- if (cfgui_hwnd)
- DestroyWindow(cfgui_hwnd);
- /* cfgui_hwnd will be set to NULL in the dialog proc */
-}
-
-void
-khm_show_config_pane(khui_config_node node) {
- if (cfgui_hwnd != NULL) {
- SendMessage(cfgui_hwnd, KHUI_WM_CFG_NOTIFY,
- MAKEWPARAM(0, WMCFG_SHOW_NODE),
- (LPARAM) node);
- } else {
- cfgui_create_window(node);
- }
-}
-
-void khm_refresh_config(void) {
- khm_size cb;
- khm_size n_idents;
- wchar_t * idents = NULL;
- wchar_t * t;
- khm_int32 rv;
- int n_tries = 0;
- khui_config_node cfg_ids = NULL;
- khui_config_node cfg_r = NULL;
- khui_config_node cfg_iter = NULL;
- khui_menu_def * omenu;
- khm_boolean refresh_menu = FALSE;
-
- do {
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_CONFIG,
- KCDB_IDENT_FLAG_CONFIG,
- NULL,
- &cb,
- &n_idents);
-
- if (rv != KHM_ERROR_TOO_LONG ||
- n_idents == 0)
- return;
-
- if (idents)
- PFREE(idents);
- idents = PMALLOC(cb);
-#ifdef DEBUG
- assert(idents);
-#endif
-
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_CONFIG,
- KCDB_IDENT_FLAG_CONFIG,
- idents,
- &cb,
- &n_idents);
-
- n_tries++;
- } while(KHM_FAILED(rv) &&
- n_tries < 5);
-
- if (KHM_FAILED(rv))
- goto _cleanup;
-
- if (KHM_FAILED(khui_cfg_open(NULL,
- L"KhmIdentities",
- &cfg_ids)))
- goto _cleanup;
-
- for(t = idents; t && *t; t = multi_string_next(t)) {
- khui_config_node cfg_id = NULL;
-
- rv = khui_cfg_open(cfg_ids,
- t,
- &cfg_id);
-
- if (KHM_FAILED(rv)) {
- khui_config_node_reg reg;
- wchar_t wshort[KHUI_MAXCCH_SHORT_DESC];
- wchar_t wlong[KHUI_MAXCCH_LONG_DESC];
- wchar_t wfmt[KHUI_MAXCCH_SHORT_DESC];
-
- ZeroMemory(&reg, sizeof(reg));
-
- reg.name = t;
- reg.short_desc = wshort;
- reg.long_desc = wlong;
- reg.h_module = khm_hInstance;
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_IDENTITY);
- reg.dlg_proc = khm_cfg_identity_proc;
- reg.flags = 0;
-
- LoadString(khm_hInstance, IDS_CFG_IDENTITY_SHORT,
- wfmt, ARRAYLENGTH(wfmt));
- StringCbPrintf(wshort, sizeof(wshort), wfmt, t);
-
- LoadString(khm_hInstance, IDS_CFG_IDENTITY_LONG,
- wfmt, ARRAYLENGTH(wfmt));
- StringCbPrintf(wlong, sizeof(wlong), wfmt, t);
-
- khui_cfg_register(cfg_ids,
- &reg);
- } else {
- khui_cfg_release(cfg_id);
- }
- }
-
- for (khui_cfg_get_first_child(cfg_ids, &cfg_iter);
- cfg_iter;
- khui_cfg_get_next_release(&cfg_iter)) {
-
- wchar_t cfgname[KCDB_IDENT_MAXCCH_NAME];
- khm_size cb;
- khm_handle tident = NULL;
- khm_int32 tflags = 0;
-
- cb = sizeof(cfgname);
- khui_cfg_get_name(cfg_iter, cfgname, &cb);
-
- if (KHM_FAILED(kcdb_identity_create(cfgname, 0, &tident)) ||
- KHM_FAILED(kcdb_identity_get_flags(tident, &tflags)) ||
- !(tflags & KCDB_IDENT_FLAG_ACTIVE) ||
- !(tflags & KCDB_IDENT_FLAG_CONFIG)) {
-
- /* this configuration node needs to be removed */
-
- khui_cfg_remove(cfg_iter);
- }
-
- if (tident)
- kcdb_identity_release(tident);
- }
-
- /* Now iterate through the root level configuration nodes and make
- sure we have a menu item for each of them. */
- if (KHM_FAILED(khui_cfg_get_first_child(NULL, &cfg_r)))
- goto _cleanup;
-
- omenu = khui_find_menu(KHUI_MENU_OPTIONS);
- if (omenu == NULL)
- goto _cleanup;
-
- khui_action_lock();
-
- do {
- khm_int32 action;
- khm_int32 flags;
- khui_action * paction;
- wchar_t cname[KHUI_MAXCCH_NAME];
- wchar_t wshort[KHUI_MAXCCH_SHORT_DESC];
- khm_size cb;
- khm_handle sub;
- khui_config_node_reg reg;
-
- flags = khui_cfg_get_flags(cfg_r);
- if (flags & KHUI_CNFLAG_SYSTEM)
- goto _next_cfg;
-
- cb = sizeof(cname);
- if (KHM_FAILED(khui_cfg_get_name(cfg_r, cname, &cb))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- goto _next_cfg;
- }
-
- paction = khui_find_named_action(cname);
-
- if (!paction) {
- khui_cfg_get_reg(cfg_r, &reg);
-
- kmq_create_hwnd_subscription(khm_hwnd_main, &sub);
-
- StringCbCopy(wshort, sizeof(wshort), reg.short_desc);
- StringCbCat(wshort, sizeof(wshort), L" ...");
-
- action = khui_action_create(cname,
- wshort,
- reg.long_desc,
- (void *) CFGACTION_MAGIC,
- KHUI_ACTIONTYPE_TRIGGER,
- sub);
-
- if (action == 0) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- goto _next_cfg;
- }
-
- khui_menu_insert_action(omenu, (khm_size) -1, action, 0);
-
- refresh_menu = TRUE;
- }
-
- _next_cfg:
- if (KHM_FAILED(khui_cfg_get_next_release(&cfg_r)))
- break;
- } while(cfg_r);
-
- khui_action_unlock();
-
- if (refresh_menu) {
- khui_refresh_actions();
- }
-
- _cleanup:
- if (cfg_ids)
- khui_cfg_release(cfg_ids);
-
- if (cfg_r)
- khui_cfg_release(cfg_r);
-
- if (idents)
- PFREE(idents);
-}
-
-void khm_init_config(void) {
- wchar_t wshort[KHUI_MAXCCH_SHORT_DESC];
- wchar_t wlong[KHUI_MAXCCH_LONG_DESC];
- khui_config_node_reg reg;
- khui_config_node node;
-
- reg.short_desc = wshort;
- reg.long_desc = wlong;
- reg.h_module = khm_hInstance;
- reg.flags = KHUI_CNFLAG_SYSTEM;
-
- reg.name = L"KhmGeneral";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_GENERAL);
- reg.dlg_proc = khm_cfg_general_proc;
- LoadString(khm_hInstance, IDS_CFG_GENERAL_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_GENERAL_LONG,
- wlong, ARRAYLENGTH(wlong));
-
- khui_cfg_register(NULL, &reg);
-
- reg.name = L"KhmAppear";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_APPEAR);
- reg.dlg_proc = khm_cfg_appearance_proc;
- LoadString(khm_hInstance, IDS_CFG_APPEAR_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_APPEAR_LONG,
- wlong, ARRAYLENGTH(wlong));
-
- khui_cfg_register(NULL, &reg);
-
- reg.name = L"KhmIdentities";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_IDENTITIES);
- reg.dlg_proc = khm_cfg_identities_proc;
- LoadString(khm_hInstance, IDS_CFG_IDENTITIES_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_IDENTITIES_LONG,
- wlong, ARRAYLENGTH(wlong));
-
- khui_cfg_register(NULL, &reg);
-
- node = NULL;
- khui_cfg_open(NULL, L"KhmIdentities", &node);
-#ifdef DEBUG
- assert(node);
-#endif
-
- reg.name = L"KhmIdentitiesTab";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_IDS_TAB);
- reg.dlg_proc = khm_cfg_ids_tab_proc;
- LoadString(khm_hInstance, IDS_CFG_IDS_TAB_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_IDS_TAB_LONG,
- wlong, ARRAYLENGTH(wlong));
- reg.flags = KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_SYSTEM;
-
- khui_cfg_register(node, &reg);
-
- reg.name = L"KhmIdentitiesTabPlural";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_ID_TAB);
- reg.dlg_proc = khm_cfg_id_tab_proc;
- LoadString(khm_hInstance, IDS_CFG_ID_TAB_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_ID_TAB_LONG,
- wlong, ARRAYLENGTH(wlong));
- reg.flags = KHUI_CNFLAG_PLURAL | KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_SYSTEM;
-
- khui_cfg_register(node, &reg);
-
- reg.flags = KHUI_CNFLAG_SYSTEM;
- khui_cfg_release(node);
-
- reg.name = L"KhmNotifications";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_NOTIF);
- reg.dlg_proc = khm_cfg_notifications_proc;
- LoadString(khm_hInstance, IDS_CFG_NOTIF_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_NOTIF_LONG,
- wlong, ARRAYLENGTH(wlong));
-
- khui_cfg_register(NULL, &reg);
-
- reg.name = L"KhmPlugins";
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_PLUGINS);
- reg.dlg_proc = khm_cfg_plugins_proc;
- LoadString(khm_hInstance, IDS_CFG_PLUGINS_SHORT,
- wshort, ARRAYLENGTH(wshort));
- LoadString(khm_hInstance, IDS_CFG_PLUGINS_LONG,
- wlong, ARRAYLENGTH(wlong));
-
- khui_cfg_register(NULL, &reg);
-}
-
-void khm_exit_config(void) {
-}
diff --git a/src/windows/identity/ui/configwnd.h b/src/windows/identity/ui/configwnd.h
deleted file mode 100644
index c1bacb21c..000000000
--- a/src/windows/identity/ui/configwnd.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_CONFIGWND_H
-#define __KHIMAIRA_CONFIGWND_H
-
-#define CFGACTION_MAGIC 0x38f8
-
-void
-khm_show_config_pane(khui_config_node node);
-
-void khm_init_config(void);
-void khm_exit_config(void);
-
-void khm_refresh_config(void);
-
-/* window procedures for other configuration windows */
-INT_PTR CALLBACK
-khm_cfg_general_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_identities_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_identity_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_id_tab_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_ids_tab_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_notifications_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_plugins_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-INT_PTR CALLBACK
-khm_cfg_appearance_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-#endif
diff --git a/src/windows/identity/ui/credfuncs.c b/src/windows/identity/ui/credfuncs.c
deleted file mode 100644
index af0386313..000000000
--- a/src/windows/identity/ui/credfuncs.c
+++ /dev/null
@@ -1,1415 +0,0 @@
-/*
- * 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
- * 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<khmapp.h>
-#include<assert.h>
-
-static BOOL in_dialog = FALSE;
-static CRITICAL_SECTION cs_dialog;
-static HANDLE in_dialog_evt = NULL;
-static LONG init_dialog = 0;
-static khm_int32 dialog_result = 0;
-static wchar_t dialog_identity[KCDB_IDENT_MAXCCH_NAME];
-static khui_new_creds * dialog_nc = NULL;
-
-static void
-dialog_sync_init(void) {
- if (InterlockedIncrement(&init_dialog) == 1) {
-#ifdef DEBUG
- assert(in_dialog_evt == NULL);
- assert(in_dialog == FALSE);
-#endif
-
- InitializeCriticalSection(&cs_dialog);
-
- in_dialog_evt = CreateEvent(NULL,
- TRUE,
- TRUE,
- L"DialogCompletionEvent");
- } else {
- InterlockedDecrement(&init_dialog);
- if (in_dialog_evt == NULL) {
- Sleep(100);
- }
- }
-}
-
-BOOL
-khm_cred_begin_dialog(void) {
- BOOL rv;
-
- dialog_sync_init();
-
- EnterCriticalSection(&cs_dialog);
-
- if (in_dialog) {
- rv = FALSE;
-
- /* if a dialog is being displayed and we got a another request
- to show one, we bring the existing one to the
- foreground. */
- if (dialog_nc && dialog_nc->hwnd) {
- khm_int32 t = 0;
-
- if (KHM_SUCCEEDED(khc_read_int32(NULL,
- L"CredWindow\\Windows\\NewCred\\ForceToTop",
- &t)) &&
- t != 0) {
-
- khm_activate_main_window();
-
- SetWindowPos(dialog_nc->hwnd, HWND_TOP, 0, 0, 0, 0,
- (SWP_NOMOVE | SWP_NOSIZE));
- }
- }
-
- } else {
- rv = TRUE;
- in_dialog = TRUE;
- ResetEvent(in_dialog_evt);
- }
-
- LeaveCriticalSection(&cs_dialog);
- return rv;
-}
-
-void
-khm_cred_end_dialog(khui_new_creds * nc) {
- dialog_sync_init();
-
- EnterCriticalSection(&cs_dialog);
- if (in_dialog) {
- in_dialog = FALSE;
- SetEvent(in_dialog_evt);
- }
- dialog_result = nc->result;
-#ifdef DEBUG
- assert(dialog_nc == nc);
-#endif
- dialog_nc = NULL;
- if (nc->subtype == KMSG_CRED_NEW_CREDS &&
- nc->n_identities > 0 &&
- nc->identities[0]) {
- khm_size cb;
-
- cb = sizeof(dialog_identity);
- if (KHM_FAILED(kcdb_identity_get_name(nc->identities[0],
- dialog_identity,
- &cb)))
- dialog_identity[0] = 0;
- } else {
- dialog_identity[0] = 0;
- }
- LeaveCriticalSection(&cs_dialog);
-}
-
-BOOL
-khm_cred_is_in_dialog(void) {
- BOOL rv;
-
- dialog_sync_init();
-
- EnterCriticalSection(&cs_dialog);
- rv = in_dialog;
- LeaveCriticalSection(&cs_dialog);
-
- return rv;
-}
-
-khm_int32
-khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result,
- wchar_t * ident, khm_size cb_ident) {
- khm_int32 rv;
-
- dialog_sync_init();
-
- EnterCriticalSection(&cs_dialog);
- if (!in_dialog)
- rv = KHM_ERROR_NOT_FOUND;
- else {
- DWORD dw;
-
- do {
- LeaveCriticalSection(&cs_dialog);
-
- dw = WaitForSingleObject(in_dialog_evt, timeout);
-
- EnterCriticalSection(&cs_dialog);
-
- if (!in_dialog) {
- rv = KHM_ERROR_SUCCESS;
- if (result) {
- *result = dialog_result;
- }
- if (ident) {
- StringCbCopy(ident, cb_ident, dialog_identity);
- }
- break;
- } else if(dw == WAIT_TIMEOUT) {
- rv = KHM_ERROR_TIMEOUT;
- break;
- }
- } while(TRUE);
- }
- LeaveCriticalSection(&cs_dialog);
-
- return rv;
-}
-
-/* Completion handler for KMSG_CRED messages. We control the overall
- logic of credentials acquisition and other operations here. Once a
- credentials operation is triggered, each successive message
- completion notification will be used to dispatch the messages for
- the next step in processing the operation. */
-void KHMAPI
-kmsg_cred_completion(kmq_message *m)
-{
- khui_new_creds * nc;
-
-#ifdef DEBUG
- assert(m->type == KMSG_CRED);
-#else
- if(m->type != KMSG_CRED)
- return; /* huh? */
-#endif
-
- switch(m->subtype) {
- case KMSG_CRED_PASSWORD:
- /* fallthrough */
- case KMSG_CRED_NEW_CREDS:
- /* Cred types have attached themselves. Trigger the next
- phase. */
- kmq_post_message(KMSG_CRED, KMSG_CRED_DIALOG_SETUP, 0,
- m->vparam);
- break;
-
- case KMSG_CRED_RENEW_CREDS:
- nc = (khui_new_creds *) m->vparam;
-
- /* khm_cred_dispatch_process_message() deals with the case
- where there are no credential types that wants to
- participate in this operation. */
- khm_cred_dispatch_process_message(nc);
- break;
-
- case KMSG_CRED_DIALOG_SETUP:
- nc = (khui_new_creds *) m->vparam;
-
- khm_prep_newcredwnd(nc->hwnd);
-
- /* all the controls have been created. Now initialize them */
- if (nc->n_types > 0) {
- kmq_post_subs_msg(nc->type_subs,
- nc->n_types,
- KMSG_CRED,
- KMSG_CRED_DIALOG_PRESTART,
- 0,
- m->vparam);
- } else {
- PostMessage(nc->hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_PROCESS_COMPLETE), 0);
- }
- break;
-
- case KMSG_CRED_DIALOG_PRESTART:
- /* all prestart stuff is done. Now to activate the dialog */
- nc = (khui_new_creds *) m->vparam;
- khm_show_newcredwnd(nc->hwnd);
-
- kmq_post_subs_msg(nc->type_subs,
- nc->n_types,
- KMSG_CRED,
- KMSG_CRED_DIALOG_START,
- 0,
- m->vparam);
- /* at this point, the dialog window takes over. We let it run
- the show until KMSG_CRED_DIALOG_END is posted by the dialog
- procedure. */
- break;
-
- case KMSG_CRED_PROCESS:
- /* a wave of these messages have completed. We should check
- if there's more */
- nc = (khui_new_creds *) m->vparam;
-
- /* if we are done processing all the plug-ins, then check if
- there were any errors reported. Otherwise we dispatch
- another set of messages. */
- if(!khm_cred_dispatch_process_level(nc)) {
-
- if(kherr_is_error()) {
- khui_alert * alert;
- kherr_event * evt;
- kherr_context * ctx;
- wchar_t ws_tfmt[512];
- wchar_t w_idname[KCDB_IDENT_MAXCCH_NAME];
- wchar_t ws_title[ARRAYLENGTH(ws_tfmt) + KCDB_IDENT_MAXCCH_NAME];
- khm_size cb;
-
- /* For renewals, we suppress the error message for the
- following case:
-
- - The renewal was for an identity
-
- - There are no identity credentials for the
- identity (no credentials that have the same type
- as the identity provider). */
-
- if (nc->subtype == KMSG_CRED_RENEW_CREDS &&
- nc->ctx.scope == KHUI_SCOPE_IDENT &&
- nc->ctx.identity != NULL) {
- khm_handle tcs = NULL; /* credential set */
- khm_size count = 0;
- khm_int32 id_ctype = KCDB_CREDTYPE_INVALID;
- khm_int32 delta = 0;
-
- kcdb_identity_get_type(&id_ctype);
- kcdb_credset_create(&tcs);
- kcdb_credset_collect(tcs, NULL,
- nc->ctx.identity,
- id_ctype,
- &delta);
- kcdb_credset_get_size(tcs, &count);
- kcdb_credset_delete(tcs);
-
- if (count == 0) {
- goto done_with_op;
- }
- }
-
- ctx = kherr_peek_context();
- evt = kherr_get_err_event(ctx);
- kherr_evaluate_event(evt);
-
- khui_alert_create_empty(&alert);
-
- if (nc->subtype == KMSG_CRED_NEW_CREDS) {
-
- khui_alert_set_type(alert, KHUI_ALERTTYPE_ACQUIREFAIL);
-
- cb = sizeof(w_idname);
- if (nc->n_identities == 0 ||
- KHM_FAILED(kcdb_identity_get_name(nc->identities[0],
- w_idname, &cb))) {
- /* an identity could not be determined */
- LoadString(khm_hInstance, IDS_NC_FAILED_TITLE,
- ws_title, ARRAYLENGTH(ws_title));
- } else {
- LoadString(khm_hInstance, IDS_NC_FAILED_TITLE_I,
- ws_tfmt, ARRAYLENGTH(ws_tfmt));
- StringCbPrintf(ws_title, sizeof(ws_title),
- ws_tfmt, w_idname);
- khui_alert_set_ctx(alert,
- KHUI_SCOPE_IDENT,
- nc->identities[0],
- KCDB_CREDTYPE_INVALID,
- NULL);
- }
-
- } else if (nc->subtype == KMSG_CRED_PASSWORD) {
-
- khui_alert_set_type(alert, KHUI_ALERTTYPE_CHPW);
-
- cb = sizeof(w_idname);
- if (nc->n_identities == 0 ||
- KHM_FAILED(kcdb_identity_get_name(nc->identities[0],
- w_idname, &cb))) {
- LoadString(khm_hInstance, IDS_NC_PWD_FAILED_TITLE,
- ws_title, ARRAYLENGTH(ws_title));
- } else {
- LoadString(khm_hInstance, IDS_NC_PWD_FAILED_TITLE_I,
- ws_tfmt, ARRAYLENGTH(ws_tfmt));
- StringCbPrintf(ws_title, sizeof(ws_title),
- ws_tfmt, w_idname);
- khui_alert_set_ctx(alert,
- KHUI_SCOPE_IDENT,
- nc->identities[0],
- KCDB_CREDTYPE_INVALID,
- NULL);
- }
-
- } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {
-
- khui_alert_set_type(alert, KHUI_ALERTTYPE_RENEWFAIL);
-
- cb = sizeof(w_idname);
- if (nc->ctx.identity == NULL ||
- KHM_FAILED(kcdb_identity_get_name(nc->ctx.identity,
- w_idname, &cb))) {
- LoadString(khm_hInstance, IDS_NC_REN_FAILED_TITLE,
- ws_title, ARRAYLENGTH(ws_title));
- } else {
- LoadString(khm_hInstance, IDS_NC_REN_FAILED_TITLE_I,
- ws_tfmt, ARRAYLENGTH(ws_tfmt));
- StringCbPrintf(ws_title, sizeof(ws_title),
- ws_tfmt, w_idname);
- khui_alert_set_ctx(alert,
- KHUI_SCOPE_IDENT,
- nc->ctx.identity,
- KCDB_CREDTYPE_INVALID,
- NULL);
- }
-
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- khui_alert_set_title(alert, ws_title);
- khui_alert_set_severity(alert, evt->severity);
-
- if(!evt->long_desc)
- khui_alert_set_message(alert, evt->short_desc);
- else
- khui_alert_set_message(alert, evt->long_desc);
-
- if(evt->suggestion)
- khui_alert_set_suggestion(alert, evt->suggestion);
-
- if (nc->subtype == KMSG_CRED_RENEW_CREDS &&
- nc->ctx.identity != NULL) {
-
- khm_int32 n_cmd;
-
- n_cmd = khm_get_identity_new_creds_action(nc->ctx.identity);
-
- if (n_cmd != 0) {
- khui_alert_add_command(alert, n_cmd);
- khui_alert_add_command(alert, KHUI_PACTION_CLOSE);
-
- khui_alert_set_flags(alert, KHUI_ALERT_FLAG_DISPATCH_CMD,
- KHUI_ALERT_FLAG_DISPATCH_CMD);
- }
- }
-
- khui_alert_show(alert);
- khui_alert_release(alert);
-
- kherr_release_context(ctx);
-
- kherr_clear_error();
- }
-
- done_with_op:
-
- if (nc->subtype == KMSG_CRED_RENEW_CREDS) {
- kmq_post_message(KMSG_CRED, KMSG_CRED_END, 0,
- m->vparam);
- } else {
- PostMessage(nc->hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_PROCESS_COMPLETE),
- 0);
- }
- }
- break;
-
- case KMSG_CRED_END:
- /* all is done. */
- {
- khui_new_creds * nc;
- khm_boolean continue_cmdline = TRUE;
-
- nc = (khui_new_creds *) m->vparam;
-
- if (nc->subtype == KMSG_CRED_NEW_CREDS ||
- nc->subtype == KMSG_CRED_PASSWORD) {
-
- khm_cred_end_dialog(nc);
-
- } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {
-
- /* if this is a renewal that was triggered while we
- were processing the commandline, then we need to
- update the pending renewal count. */
-
- if (khm_startup.processing) {
- LONG renewals;
- renewals = InterlockedDecrement(&khm_startup.pending_renewals);
-
- if (renewals != 0) {
- continue_cmdline = FALSE;
- }
- }
- }
-
- khui_cw_destroy_cred_blob(nc);
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);
-
- if (continue_cmdline)
- kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0);
- }
- break;
-
- /* property sheet stuff */
-
- case KMSG_CRED_PP_BEGIN:
- /* all the pages should have been added by now. Just send out
- the precreate message */
- kmq_post_message(KMSG_CRED, KMSG_CRED_PP_PRECREATE, 0,
- m->vparam);
- break;
-
- case KMSG_CRED_PP_END:
- kmq_post_message(KMSG_CRED, KMSG_CRED_PP_DESTROY, 0,
- m->vparam);
- break;
-
- case KMSG_CRED_DESTROY_CREDS:
-#ifdef DEBUG
- assert(m->vparam != NULL);
-#endif
- khui_context_release((khui_action_context *) m->vparam);
- PFREE(m->vparam);
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);
-
- kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0);
- break;
-
- case KMSG_CRED_IMPORT:
- {
- khm_boolean continue_cmdline = FALSE;
- LONG pending_renewals;
-
- /* once an import operation ends, we have to trigger a
- renewal so that other plug-ins that didn't participate
- in the import operation can have a chance at getting
- the necessary credentials.
-
- If we are in the middle of processing the commandline,
- we have to be a little bit careful. We can't issue a
- commandline conituation message right now because the
- import action is still ongoing (since the renewals are
- part of the action). Once the renewals have completed,
- the completion handler will automatically issue a
- commandline continuation message. However, if there
- were no identities to renew, then we have to issue the
- message ourselves.
- */
-
- InterlockedIncrement(&khm_startup.pending_renewals);
-
- khm_cred_renew_all_identities();
-
- pending_renewals = InterlockedDecrement(&khm_startup.pending_renewals);
-
- if (pending_renewals == 0 && khm_startup.processing)
- kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0);
- }
- break;
-
- case KMSG_CRED_REFRESH:
- kcdb_identity_refresh_all();
- break;
- }
-}
-
-void khm_cred_import(void)
-{
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_IMPORT);
- _describe();
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_IMPORT, 0, 0);
-
- _end_task();
-}
-
-void khm_cred_set_default(void)
-{
- khui_action_context ctx;
- khm_int32 rv;
-
- khui_context_get(&ctx);
-
- if (ctx.identity) {
- rv = kcdb_identity_set_default(ctx.identity);
- }
-
- khui_context_release(&ctx);
-}
-
-void khm_cred_set_default_identity(khm_handle identity)
-{
- kcdb_identity_set_default(identity);
-}
-
-void khm_cred_destroy_creds(khm_boolean sync, khm_boolean quiet)
-{
- khui_action_context * pctx;
-
- pctx = PMALLOC(sizeof(*pctx));
-#ifdef DEBUG
- assert(pctx);
-#endif
-
- khui_context_get(pctx);
-
- if(pctx->scope == KHUI_SCOPE_NONE && !quiet) {
- /* this really shouldn't be necessary once we start enabling
- and disbling actions based on context */
- wchar_t title[256];
- wchar_t message[256];
-
- LoadString(khm_hInstance,
- IDS_ALERT_NOSEL_TITLE,
- title,
- ARRAYLENGTH(title));
-
- LoadString(khm_hInstance,
- IDS_ALERT_NOSEL,
- message,
- ARRAYLENGTH(message));
-
- khui_alert_show_simple(title,
- message,
- KHERR_WARNING);
-
- khui_context_release(pctx);
- PFREE(pctx);
-
- return;
- }
-
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_DESTROY_CREDS);
- _describe();
-
- if (sync)
- kmq_send_message(KMSG_CRED,
- KMSG_CRED_DESTROY_CREDS,
- 0,
- (void *) pctx);
- else
- kmq_post_message(KMSG_CRED,
- KMSG_CRED_DESTROY_CREDS,
- 0,
- (void *) pctx);
-
- _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_all_identities(void)
-{
- khm_size count;
- khm_size cb = 0;
- khm_size n_idents = 0;
- khm_int32 rv;
- wchar_t * ident_names = NULL;
- wchar_t * this_ident;
-
- kcdb_credset_get_size(NULL, &count);
-
- /* if there are no credentials, we just skip over the renew
- action. */
-
- if (count == 0)
- return;
-
- ident_names = NULL;
-
- while (TRUE) {
- if (ident_names) {
- PFREE(ident_names);
- ident_names = NULL;
- }
-
- cb = 0;
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_EMPTY, 0,
- NULL,
- &cb, &n_idents);
-
- if (n_idents == 0 || rv != KHM_ERROR_TOO_LONG ||
- cb == 0)
- break;
-
- ident_names = PMALLOC(cb);
- ident_names[0] = L'\0';
-
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_EMPTY, 0,
- ident_names,
- &cb, &n_idents);
-
- if (KHM_SUCCEEDED(rv))
- break;
- }
-
- if (ident_names) {
- for (this_ident = ident_names;
- this_ident && *this_ident;
- this_ident = multi_string_next(this_ident)) {
- khm_handle ident;
-
- if (KHM_FAILED(kcdb_identity_create(this_ident, 0,
- &ident)))
- continue;
-
- khm_cred_renew_identity(ident);
-
- kcdb_identity_release(ident);
- }
-
- PFREE(ident_names);
- ident_names = NULL;
- }
-}
-
-void khm_cred_renew_identity(khm_handle identity)
-{
- khui_new_creds * c;
-
- khui_cw_create_cred_blob(&c);
-
- c->subtype = KMSG_CRED_RENEW_CREDS;
- c->result = KHUI_NC_RESULT_PROCESS;
- khui_context_create(&c->ctx,
- KHUI_SCOPE_IDENT,
- identity,
- KCDB_CREDTYPE_INVALID,
- NULL);
-
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_RENEW_CREDS);
- _describe();
-
- /* if we are calling this while processing startup actions, we
- need to keep track of how many we have issued. */
- if (khm_startup.processing) {
- InterlockedIncrement(&khm_startup.pending_renewals);
- }
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_RENEW_CREDS, 0, (void *) c);
-
- _end_task();
-}
-
-void khm_cred_renew_cred(khm_handle cred)
-{
- khui_new_creds * c;
-
- khui_cw_create_cred_blob(&c);
-
- c->subtype = KMSG_CRED_RENEW_CREDS;
- c->result = KHUI_NC_RESULT_PROCESS;
- khui_context_create(&c->ctx,
- KHUI_SCOPE_CRED,
- NULL,
- KCDB_CREDTYPE_INVALID,
- cred);
-
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_RENEW_CREDS);
- _describe();
-
- /* if we are calling this while processing startup actions, we
- need to keep track of how many we have issued. */
- if (khm_startup.processing) {
- InterlockedIncrement(&khm_startup.pending_renewals);
- }
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_RENEW_CREDS, 0, (void *) c);
-
- _end_task();
-}
-
-void khm_cred_renew_creds(void)
-{
- khui_new_creds * c;
-
- khui_cw_create_cred_blob(&c);
- c->subtype = KMSG_CRED_RENEW_CREDS;
- c->result = KHUI_NC_RESULT_PROCESS;
- khui_context_get(&c->ctx);
-
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_RENEW_CREDS);
- _describe();
-
- /* if we are calling this while processing startup actions, we
- need to keep track of how many we have issued. */
- if (khm_startup.processing) {
- InterlockedIncrement(&khm_startup.pending_renewals);
- }
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_RENEW_CREDS, 0, (void *) c);
-
- _end_task();
-}
-
-void khm_cred_change_password(wchar_t * title)
-{
- khui_new_creds * nc;
- LPNETID_DLGINFO pdlginfo;
- khm_size cb;
-
- if (!khm_cred_begin_dialog())
- return;
-
- khui_cw_create_cred_blob(&nc);
- nc->subtype = KMSG_CRED_PASSWORD;
- dialog_nc = nc;
-
- khui_context_get(&nc->ctx);
-
- kcdb_identpro_get_ui_cb((void *) &nc->ident_cb);
-
- assert(nc->ident_cb);
-
- if (title) {
-
- if (SUCCEEDED(StringCbLength(title, KHUI_MAXCB_TITLE, &cb))) {
- cb += sizeof(wchar_t);
-
- nc->window_title = PMALLOC(cb);
-#ifdef DEBUG
- assert(nc->window_title);
-#endif
- StringCbCopy(nc->window_title, cb, title);
- }
- } else if (nc->ctx.cb_vparam == sizeof(NETID_DLGINFO) &&
- (pdlginfo = nc->ctx.vparam) &&
- pdlginfo->size == NETID_DLGINFO_V1_SZ &&
- pdlginfo->in.title[0] &&
- SUCCEEDED(StringCchLength(pdlginfo->in.title,
- NETID_TITLE_SZ,
- &cb))) {
-
- cb = (cb + 1) * sizeof(wchar_t);
- nc->window_title = PMALLOC(cb);
-#ifdef DEBUG
- assert(nc->window_title);
-#endif
- StringCbCopy(nc->window_title, cb, pdlginfo->in.title);
- }
-
- khm_create_newcredwnd(khm_hwnd_main, nc);
-
- if (nc->hwnd != NULL) {
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_PASSWORD);
- _describe();
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_PASSWORD, 0,
- (void *) nc);
-
- _end_task();
- } else {
- khui_cw_destroy_cred_blob(nc);
- }
-}
-
-void
-khm_cred_obtain_new_creds_for_ident(khm_handle ident, wchar_t * title)
-{
- khui_action_context ctx;
-
- if (ident == NULL)
- khm_cred_obtain_new_creds(title);
-
- khui_context_get(&ctx);
-
- khui_context_set(KHUI_SCOPE_IDENT,
- ident,
- KCDB_CREDTYPE_INVALID,
- NULL,
- NULL,
- 0,
- NULL);
-
- khm_cred_obtain_new_creds(title);
-
- khui_context_set_indirect(&ctx);
-
- khui_context_release(&ctx);
-}
-
-void khm_cred_obtain_new_creds(wchar_t * title)
-{
- khui_new_creds * nc;
- LPNETID_DLGINFO pdlginfo;
- khm_size cb;
-
- if (!khm_cred_begin_dialog())
- return;
-
- khui_cw_create_cred_blob(&nc);
- nc->subtype = KMSG_CRED_NEW_CREDS;
- dialog_nc = nc;
-
- khui_context_get(&nc->ctx);
-
- kcdb_identpro_get_ui_cb((void *) &nc->ident_cb);
-
- if (nc->ident_cb == NULL) {
- wchar_t title[256];
- wchar_t msg[512];
- wchar_t suggestion[512];
- khui_alert * a;
-
- LoadString(khm_hInstance, IDS_ERR_TITLE_NO_IDENTPRO,
- title, ARRAYLENGTH(title));
- LoadString(khm_hInstance, IDS_ERR_MSG_NO_IDENTPRO,
- msg, ARRAYLENGTH(msg));
- LoadString(khm_hInstance, IDS_ERR_SUGG_NO_IDENTPRO,
- suggestion, ARRAYLENGTH(suggestion));
-
- khui_alert_create_simple(title,
- msg,
- KHERR_ERROR,
- &a);
- khui_alert_set_suggestion(a, suggestion);
-
- khui_alert_show(a);
-
- khui_alert_release(a);
-
- khui_context_release(&nc->ctx);
- nc->result = KHUI_NC_RESULT_CANCEL;
- khm_cred_end_dialog(nc);
- khui_cw_destroy_cred_blob(nc);
- return;
- }
-
- if (title) {
- if (SUCCEEDED(StringCbLength(title, KHUI_MAXCB_TITLE, &cb))) {
- cb += sizeof(wchar_t);
-
- nc->window_title = PMALLOC(cb);
-#ifdef DEBUG
- assert(nc->window_title);
-#endif
- StringCbCopy(nc->window_title, cb, title);
- }
- } else if (nc->ctx.cb_vparam == sizeof(NETID_DLGINFO) &&
- (pdlginfo = nc->ctx.vparam) &&
- pdlginfo->size == NETID_DLGINFO_V1_SZ &&
- pdlginfo->in.title[0] &&
- SUCCEEDED(StringCchLength(pdlginfo->in.title,
- NETID_TITLE_SZ,
- &cb))) {
-
- cb = (cb + 1) * sizeof(wchar_t);
- nc->window_title = PMALLOC(cb);
-#ifdef DEBUG
- assert(nc->window_title);
-#endif
- StringCbCopy(nc->window_title, cb, pdlginfo->in.title);
- }
-
- khm_create_newcredwnd(khm_hwnd_main, nc);
-
- if (nc->hwnd != NULL) {
- _begin_task(KHERR_CF_TRANSITIVE);
- _report_sr0(KHERR_NONE, IDS_CTX_NEW_CREDS);
- _describe();
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_NEW_CREDS, 0,
- (void *) nc);
-
- _end_task();
- } else {
- khui_context_release(&nc->ctx);
- nc->result = KHUI_NC_RESULT_CANCEL;
- khm_cred_end_dialog(nc);
- khui_cw_destroy_cred_blob(nc);
- }
-}
-
-/* this is called by khm_cred_dispatch_process_message and the
- kmsg_cred_completion to initiate and continue checked broadcasts of
- KMSG_CRED_DIALOG_PROCESS messages.
-
- Returns TRUE if more KMSG_CRED_DIALOG_PROCESS messages were
- posted. */
-BOOL khm_cred_dispatch_process_level(khui_new_creds *nc)
-{
- khm_size i,j;
- khm_handle subs[KHUI_MAX_NCTYPES];
- int n_subs = 0;
- BOOL cont = FALSE;
- khui_new_creds_by_type *t, *d;
-
- /* at each level, we dispatch a wave of notifications to plug-ins
- who's dependencies are all satisfied */
- EnterCriticalSection(&nc->cs);
-
- /* if any types have already completed, we mark them are processed
- and skip them */
- for (i=0; i < nc->n_types; i++) {
- t = nc->types[i];
- if(t->flags & KHUI_NC_RESPONSE_COMPLETED)
- t->flags |= KHUI_NCT_FLAG_PROCESSED;
- }
-
- for(i=0; i<nc->n_types; i++) {
- t = nc->types[i];
-
- if((t->flags & KHUI_NCT_FLAG_PROCESSED) ||
- (t->flags & KHUI_NC_RESPONSE_COMPLETED))
- continue;
-
- for(j=0; j<t->n_type_deps; j++) {
- if(KHM_FAILED(khui_cw_find_type(nc, t->type_deps[j], &d)))
- break;
-
- if(!(d->flags & KHUI_NC_RESPONSE_COMPLETED))
- break;
- }
-
- if(j<t->n_type_deps) /* there are unmet dependencies */
- continue;
-
- /* all dependencies for this type have been met. */
- subs[n_subs++] = kcdb_credtype_get_sub(t->type);
- t->flags |= KHUI_NCT_FLAG_PROCESSED;
- cont = TRUE;
- }
-
- LeaveCriticalSection(&nc->cs);
-
- /* the reason why we are posting messages in batches is because
- when the message has completed we know that all the types that
- have the KHUI_NCT_FLAG_PROCESSED set have completed processing.
- Otherwise we have to individually track each message and update
- the type */
- if(n_subs > 0)
- kmq_post_subs_msg(subs, n_subs, KMSG_CRED, KMSG_CRED_PROCESS, 0,
- (void *) nc);
-
- return cont;
-}
-
-void
-khm_cred_dispatch_process_message(khui_new_creds *nc)
-{
- khm_size i;
- BOOL pending;
- wchar_t wsinsert[512];
- khm_size cbsize;
-
- /* see if there's anything to do. We can check this without
- obtaining a lock */
- if(nc->n_types == 0 ||
- (nc->subtype == KMSG_CRED_NEW_CREDS &&
- nc->n_identities == 0) ||
- (nc->subtype == KMSG_CRED_PASSWORD &&
- nc->n_identities == 0))
- goto _terminate_job;
-
- /* check dependencies and stuff first */
- EnterCriticalSection(&nc->cs);
- for(i=0; i<nc->n_types; i++) {
- nc->types[i]->flags &= ~ KHUI_NCT_FLAG_PROCESSED;
- }
- LeaveCriticalSection(&nc->cs);
-
- /* Consindering all that can go wrong here and the desire to
- handle errors here separately from others, we create a new task
- for the purpose of tracking the credentials acquisition
- process. */
- _begin_task(KHERR_CF_TRANSITIVE);
-
- /* Describe the context */
- if(nc->subtype == KMSG_CRED_NEW_CREDS) {
- cbsize = sizeof(wsinsert);
- kcdb_identity_get_name(nc->identities[0], wsinsert, &cbsize);
-
- _report_sr1(KHERR_NONE, IDS_CTX_PROC_NEW_CREDS,
- _cstr(wsinsert));
- _resolve();
- } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {
- cbsize = sizeof(wsinsert);
-
- if (nc->ctx.scope == KHUI_SCOPE_IDENT)
- kcdb_identity_get_name(nc->ctx.identity, wsinsert, &cbsize);
- else if (nc->ctx.scope == KHUI_SCOPE_CREDTYPE) {
- if (nc->ctx.identity != NULL)
- kcdb_identity_get_name(nc->ctx.identity, wsinsert,
- &cbsize);
- else
- kcdb_credtype_get_name(nc->ctx.cred_type, wsinsert,
- &cbsize);
- } else if (nc->ctx.scope == KHUI_SCOPE_CRED) {
- kcdb_cred_get_name(nc->ctx.cred, wsinsert, &cbsize);
- } else {
- StringCbCopy(wsinsert, sizeof(wsinsert), L"(?)");
- }
-
- _report_sr1(KHERR_NONE, IDS_CTX_PROC_RENEW_CREDS,
- _cstr(wsinsert));
- _resolve();
- } else if (nc->subtype == KMSG_CRED_PASSWORD) {
- cbsize = sizeof(wsinsert);
- kcdb_identity_get_name(nc->identities[0], wsinsert, &cbsize);
-
- _report_sr1(KHERR_NONE, IDS_CTX_PROC_PASSWORD,
- _cstr(wsinsert));
- _resolve();
- } else {
- assert(FALSE);
- }
-
- _describe();
-
- pending = khm_cred_dispatch_process_level(nc);
-
- _end_task();
-
- if(!pending)
- goto _terminate_job;
-
- return;
-
- _terminate_job:
- if (nc->subtype == KMSG_CRED_RENEW_CREDS)
- kmq_post_message(KMSG_CRED, KMSG_CRED_END, 0, (void *) nc);
- else
- PostMessage(nc->hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_PROCESS_COMPLETE), 0);
-}
-
-void
-khm_cred_process_startup_actions(void) {
- khm_handle defident = NULL;
-
- if (!khm_startup.processing)
- return;
-
- if (khm_startup.init ||
- khm_startup.renew ||
- khm_startup.destroy ||
- khm_startup.autoinit) {
- kcdb_identity_get_default(&defident);
- }
-
- /* For asynchronous actions, we trigger the action and then exit
- the loop. Once the action completes, the completion handler
- will trigger a continuation message which will result in this
- function getting called again. Then we can proceed with the
- rest of the startup actions. */
- do {
- if (khm_startup.init) {
-
- khm_cred_obtain_new_creds_for_ident(defident, NULL);
- khm_startup.init = FALSE;
- break;
- }
-
- if (khm_startup.import) {
- khm_cred_import();
- khm_startup.import = FALSE;
-
- /* we also set the renew command to false here because we
- trigger a renewal for all the identities at the end of
- the import operation anyway. */
- khm_startup.renew = FALSE;
- break;
- }
-
- if (khm_startup.renew) {
- LONG pending_renewals;
-
- /* if there are no credentials, we just skip over the
- renew action. */
-
- khm_startup.renew = FALSE;
-
- InterlockedIncrement(&khm_startup.pending_renewals);
-
- khm_cred_renew_all_identities();
-
- pending_renewals = InterlockedDecrement(&khm_startup.pending_renewals);
-
- if (pending_renewals != 0)
- break;
-
- /* if there were no pending renewals, then we just fall
- through. This means that either there were no
- identities to renew, or all the renewals completed. If
- all the renewals completed, then the commandline
- contiuation message wasn't triggered. Either way, we
- must fall through if the count is zero. */
- }
-
- if (khm_startup.destroy) {
-
- khm_startup.destroy = FALSE;
-
- if (defident) {
- khm_cred_destroy_identity(defident);
- break;
- }
- }
-
- if (khm_startup.autoinit) {
- khm_size count = 0;
- khm_handle credset = NULL;
- khm_int32 ctype_ident = KCDB_CREDTYPE_INVALID;
- khm_int32 delta = 0;
-
- khm_startup.autoinit = FALSE;
-
- kcdb_credset_create(&credset);
- kcdb_identity_get_type(&ctype_ident);
-
- kcdb_credset_collect(credset, NULL,
- defident, ctype_ident,
- &delta);
-
- kcdb_credset_get_size(credset, &count);
-
- kcdb_credset_delete(credset);
-
- if (count == 0) {
- if (defident)
- khui_context_set(KHUI_SCOPE_IDENT,
- defident,
- KCDB_CREDTYPE_INVALID,
- NULL, NULL, 0,
- NULL);
- else
- khui_context_reset();
-
- khm_cred_obtain_new_creds(NULL);
- break;
- }
- }
-
- if (khm_startup.exit) {
- PostMessage(khm_hwnd_main,
- WM_COMMAND,
- MAKEWPARAM(KHUI_ACTION_EXIT, 0), 0);
- khm_startup.exit = FALSE;
- break;
- }
-
- if (khm_startup.display & SOPTS_DISPLAY_HIDE) {
- khm_hide_main_window();
- } else if (khm_startup.display & SOPTS_DISPLAY_SHOW) {
- khm_show_main_window();
- }
- khm_startup.display = 0;
-
- /* when we get here, then we are all done with the command
- line stuff */
- khm_startup.processing = FALSE;
- khm_startup.remote = FALSE;
-
- kmq_post_message(KMSG_ACT, KMSG_ACT_END_CMDLINE, 0, 0);
- } while(FALSE);
-
- if (defident)
- kcdb_identity_release(defident);
-}
-
-void
-khm_cred_begin_startup_actions(void) {
- khm_handle csp_cw;
-
- if (khm_startup.seen)
- return;
-
- if (!khm_startup.remote &&
- KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw))) {
-
- khm_int32 t = 0;
-
- khc_read_int32(csp_cw, L"Autoinit", &t);
- if (t)
- khm_startup.autoinit = TRUE;
-
- t = 0;
- khc_read_int32(csp_cw, L"AutoImport", &t);
- if (t)
- khm_startup.import = TRUE;
-
- khc_close_space(csp_cw);
-
- }
-
- /* if this is a remote request, and no specific options were
- specified other than --renew, then we perform the default
- action, as if the user clicked on the tray icon. */
- if (khm_startup.remote &&
- !khm_startup.exit &&
- !khm_startup.destroy &&
- !khm_startup.autoinit &&
- !khm_startup.init &&
- !khm_startup.remote_exit &&
- !khm_startup.import &&
- !khm_startup.display) {
-
- khm_int32 def_action = khm_get_default_notifier_action();
-
- if (def_action > 0) {
- khui_action_trigger(def_action, NULL);
- }
- }
-
- khm_startup.seen = TRUE;
- khm_startup.processing = TRUE;
-
- khm_cred_process_startup_actions();
-}
-
-void
-khm_cred_refresh(void) {
- kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, NULL);
-}
-
-void
-khm_cred_addr_change(void) {
- khm_handle csp_cw = NULL;
- khm_int32 check_net = 0;
-
- wchar_t * ids = NULL;
- wchar_t * t;
- khm_size cb;
- khm_size n_idents;
-
- FILETIME ft_now;
- FILETIME ft_exp;
- FILETIME ft_issue;
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow",
- 0, &csp_cw))) {
- khc_read_int32(csp_cw, L"AutoDetectNet", &check_net);
-
- khc_close_space(csp_cw);
- }
-
- if (!check_net)
- return;
-
- while(TRUE) {
- if (ids)
- PFREE(ids);
- ids = NULL;
-
- if (kcdb_identity_enum(KCDB_IDENT_FLAG_VALID |
- KCDB_IDENT_FLAG_RENEWABLE,
- KCDB_IDENT_FLAG_VALID |
- KCDB_IDENT_FLAG_RENEWABLE,
- NULL,
- &cb,
- &n_idents) != KHM_ERROR_TOO_LONG)
- break;
-
- ids = PMALLOC(cb);
-
- if (KHM_SUCCEEDED
- (kcdb_identity_enum(KCDB_IDENT_FLAG_VALID |
- KCDB_IDENT_FLAG_RENEWABLE,
- KCDB_IDENT_FLAG_VALID |
- KCDB_IDENT_FLAG_RENEWABLE,
- ids,
- &cb,
- &n_idents)))
- break;
- }
-
- if (!ids)
- return;
-
- GetSystemTimeAsFileTime(&ft_now);
-
- for (t=ids; t && *t; t = multi_string_next(t)) {
- khm_handle ident;
-
-
- if (KHM_FAILED
- (kcdb_identity_create(t, 0, &ident)))
- continue;
-
- cb = sizeof(ft_issue);
-
- if (KHM_SUCCEEDED
- (kcdb_identity_get_attr(ident, KCDB_ATTR_ISSUE, NULL,
- &ft_issue, &cb)) &&
-
- (cb = sizeof(ft_exp)) &&
- KHM_SUCCEEDED
- (kcdb_identity_get_attr(ident, KCDB_ATTR_EXPIRE, NULL,
- &ft_exp, &cb)) &&
-
- CompareFileTime(&ft_now, &ft_exp) < 0) {
-
- khm_int64 i_issue;
- khm_int64 i_exp;
- khm_int64 i_now;
-
- i_issue = FtToInt(&ft_issue);
- i_exp = FtToInt(&ft_exp);
- i_now = FtToInt(&ft_now);
-
- if (i_now > (i_issue + i_exp) / 2) {
-
- khm_cred_renew_identity(ident);
-
- }
- }
-
- kcdb_identity_release(ident);
- }
-}
diff --git a/src/windows/identity/ui/credfuncs.h b/src/windows/identity/ui/credfuncs.h
deleted file mode 100644
index 051679647..000000000
--- a/src/windows/identity/ui/credfuncs.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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
- * 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 __KHIMAIRA_CREDFUNCS_H
-#define __KHIMAIRA_CREDFUNCS_H
-
-void KHMAPI
-kmsg_cred_completion(kmq_message *m);
-
-void
-khm_cred_destroy_creds(khm_boolean sync,
- khm_boolean quiet);
-
-void
-khm_cred_destroy_identity(khm_handle identity);
-
-void
-khm_cred_renew_all_identities(void);
-
-void
-khm_cred_renew_identity(khm_handle identity);
-
-void
-khm_cred_renew_cred(khm_handle cred);
-
-void
-khm_cred_renew_creds(void);
-
-void
-khm_cred_obtain_new_creds(wchar_t * window_title);
-
-void
-khm_cred_obtain_new_creds_for_ident(khm_handle ident, wchar_t * title);
-
-void
-khm_cred_set_default(void);
-
-void khm_cred_set_default_identity(khm_handle identity);
-
-void
-khm_cred_change_password(wchar_t * window_title);
-
-void
-khm_cred_dispatch_process_message(khui_new_creds *nc);
-
-BOOL
-khm_cred_dispatch_process_level(khui_new_creds *nc);
-
-BOOL
-khm_cred_is_in_dialog(void);
-
-khm_int32
-khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result,
- wchar_t * ident, khm_size cb_ident);
-
-void
-khm_cred_begin_startup_actions(void);
-
-void
-khm_cred_process_startup_actions(void);
-
-void
-khm_cred_refresh(void);
-
-void
-khm_cred_addr_change(void);
-
-void
-khm_cred_import(void);
-
-#endif
diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c
deleted file mode 100644
index f7d7ca15e..000000000
--- a/src/windows/identity/ui/credwnd.c
+++ /dev/null
@@ -1,5952 +0,0 @@
-/*
- * 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
- * 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<khmapp.h>
-#include<prsht.h>
-#include<assert.h>
-
-ATOM khui_credwnd_cls;
-khm_int32 khui_cw_flag_id;
-
-khm_int32 attr_to_action[KCDB_ATTR_MAX_ID + 1];
-
-/* forward declarations */
-static void
-cw_select_row_creds(khui_credwnd_tbl * tbl, int row, int selected);
-
-static void
-cw_set_row_context(khui_credwnd_tbl * tbl, int row);
-
-static void
-cw_update_outline(khui_credwnd_tbl * tbl);
-
-static void
-cw_update_selection_state(khui_credwnd_tbl * tbl);
-
-static void
-cw_select_row(khui_credwnd_tbl * tbl, int row, WPARAM wParam);
-
-
-khm_int32 bHideWatermarks = 0;
-
-void
-khm_set_cw_element_font(wchar_t * name, LOGFONT * pfont) {
- khm_handle csp_cw = NULL;
- wchar_t * element_name;
-
- if (name == NULL)
- element_name = L"FontBase";
- else
- element_name = name;
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_WRITE,
- &csp_cw)))
- return;
-
- khc_write_binary(csp_cw, element_name, pfont, sizeof(LOGFONT));
-
- khc_close_space(csp_cw);
-}
-
-void
-khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default, LOGFONT * pfont) {
- khm_handle csp_cw = NULL;
- khm_size cb;
- wchar_t * element_name;
- khm_boolean try_derive = FALSE;
-
- if (name == NULL)
- element_name = L"FontBase";
- else
- element_name = name;
-
- if (use_default)
- goto _use_defaults;
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", 0,
- &csp_cw)))
- goto _use_defaults;
-
- cb = sizeof(LOGFONT);
- if (KHM_FAILED(khc_read_binary(csp_cw, element_name, pfont,
- &cb)) ||
- cb != sizeof(LOGFONT)) {
- try_derive = TRUE;
- }
-
- if (try_derive) {
- cb = sizeof(LOGFONT);
- if (!name ||
- KHM_FAILED(khc_read_binary(csp_cw, L"FontBase", pfont,
- &cb)) ||
- cb != sizeof(LOGFONT)) {
- khc_close_space(csp_cw);
- goto _use_defaults;
- }
-
- if (!wcscmp(name, L"FontHeaderBold") ||
- !wcscmp(name, L"FontBold")) {
-
- pfont->lfWeight = FW_BOLD;
-
- }
- }
-
- khc_close_space(csp_cw);
-
- return;
-
- _use_defaults:
-
- ZeroMemory(pfont, sizeof(*pfont));
-
- if (name == NULL) {
- LOGFONT lf = {
- 0,0,
- 0,0,
- FW_THIN,
- FALSE,
- FALSE,
- FALSE,
- DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- FF_SWISS,
- L"MS Shell Dlg"};
-
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
-
- *pfont = lf;
-
- } else if (!wcscmp(name, L"FontHeader")) {
- LOGFONT lf = {
- 0,0,
- 0,0,
- FW_THIN,
- FALSE,
- FALSE,
- FALSE,
- DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- FF_SWISS,
- L"MS Shell Dlg"};
-
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
-
- *pfont = lf;
-
- } else if (!wcscmp(name, L"FontHeaderBold")) {
- LOGFONT lf = {
- 0,0,
- 0,0,
- FW_BOLD,
- FALSE,
- FALSE,
- FALSE,
- DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- FF_SWISS,
- L"MS Shell Dlg"};
-
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
-
- *pfont = lf;
-
- } else if (!wcscmp(name, L"FontNormal")) {
- LOGFONT lf = {
- 0,0,
- 0,0,
- FW_THIN,
- FALSE,
- FALSE,
- FALSE,
- DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- FF_SWISS,
- L"MS Shell Dlg"};
-
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
-
- *pfont = lf;
-
- } else if (!wcscmp(name, L"FontBold")) {
- LOGFONT lf = {
- 0,0,
- 0,0,
- FW_BOLD,
- FALSE,
- FALSE,
- FALSE,
- DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- FF_SWISS,
- L"MS Shell Dlg"};
-
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
-
- *pfont = lf;
-
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-}
-
-void
-cw_refresh_attribs(HWND hwnd) {
- khm_int32 act;
- kcdb_attrib * attrib;
- khui_menu_def * menu;
- khm_int32 i;
-
- menu = khui_find_menu(KHUI_MENU_COLUMNS);
-#ifdef DEBUG
- assert(menu);
-#endif
-
- for (i=0; i <= KCDB_ATTR_MAX_ID; i++) {
- if (KHM_FAILED(kcdb_attrib_get_info(i, &attrib))) {
- if (attr_to_action[i] != 0) {
- /* the action should be removed */
- khui_menu_remove_action(menu, attr_to_action[i]);
- khui_action_delete(attr_to_action[i]);
- attr_to_action[i] = 0;
- }
- } else {
- if (attr_to_action[i] == 0 &&
- !(attrib->flags & KCDB_ATTR_FLAG_HIDDEN) &&
- (attrib->short_desc || attrib->long_desc)) {
- /* new action */
- khm_handle sub = NULL;
-
- kmq_create_hwnd_subscription(hwnd, &sub);
-
- act = khui_action_create(attrib->name,
- (attrib->short_desc?
- attrib->short_desc: attrib->long_desc),
- NULL,
- (void *)(UINT_PTR) i,
- KHUI_ACTIONTYPE_TOGGLE,
- sub);
-
- attr_to_action[i] = act;
-
- khui_menu_insert_action(menu, 5000, act, 0);
- }
-
- kcdb_attrib_release_info(attrib);
- }
- }
-}
-
-khm_int32
-cw_get_custom_attr_id(wchar_t * s)
-{
- if(!wcscmp(s, CW_CANAME_FLAGS))
- return CW_CA_FLAGS;
- if(!wcscmp(s, CW_CANAME_TYPEICON))
- return CW_CA_TYPEICON;
- return 0;
-}
-
-const wchar_t *
-cw_get_custom_attr_string(khm_int32 attr_id)
-{
- if (attr_id == CW_CA_FLAGS)
- return CW_CANAME_FLAGS;
- if (attr_id == CW_CA_TYPEICON)
- return CW_CANAME_TYPEICON;
- return NULL;
-}
-
-void
-cw_save_view(khui_credwnd_tbl * tbl, wchar_t * view_name) {
- wchar_t * col_list = NULL;
- khm_size cb_col_list;
- khm_handle csp_cw = NULL;
- khm_handle csp_views = NULL;
- khm_handle csp_view = NULL;
- khm_handle csp_cols = NULL;
- khm_size cb;
- int i;
-
- if (tbl->n_cols == 0)
- return;
-
- cb_col_list = (KCONF_MAXCB_NAME + 1) * tbl->n_cols;
-
- col_list = PMALLOC(cb_col_list);
-#ifdef DEBUG
- assert(col_list);
-#endif
-
- if (!col_list)
- goto _cleanup;
-
- multi_string_init(col_list, cb_col_list);
-
- /* if we aren't saving to a specific view, and the view has been
- customized, then we save it to "Custom_0", unless we are in the
- mini mode, in which case we save it to "Custom_1" */
- if (!view_name && (tbl->flags & KHUI_CW_TBL_CUSTVIEW)) {
- if (!(tbl->flags & KHUI_CW_TBL_EXPIDENT)) {
- view_name = L"Custom_0";
- } else {
- view_name = L"Custom_1";
- }
- }
-
- if (view_name) {
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow",
- KHM_PERM_READ | KHM_PERM_WRITE, &csp_cw)))
- goto _cleanup;
-
- if (KHM_FAILED(khc_open_space(csp_cw, L"Views", KHM_PERM_READ, &csp_views)))
- goto _cleanup;
-
- if (KHM_FAILED(khc_open_space(csp_views, view_name,
- KHM_PERM_WRITE | KHM_FLAG_CREATE,
- &csp_view)))
- goto _cleanup;
-
- /* if we are switching to a custom view, then we should mark
- that as the default. */
- if (tbl->flags & KHUI_CW_TBL_CUSTVIEW) {
- khc_write_string(csp_cw, ((!(tbl->flags & KHUI_CW_TBL_EXPIDENT))?
- L"DefaultView":
- L"DefaultViewMini"), view_name);
- }
-
- } else {
- csp_view = tbl->csp_view;
- }
-
- if (!csp_view)
- goto _cleanup;
-
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
- khc_write_int32(csp_view, L"ExpandedIdentity", 1);
- } else {
- khm_int32 t;
- if (KHM_SUCCEEDED(khc_read_int32(csp_view, L"ExpandedIdentity", &t)) && t)
- khc_write_int32(csp_view, L"ExpandedIdentity", 0);
- }
-
- if (tbl->flags & KHUI_CW_TBL_NOHEADER) {
- khc_write_int32(csp_view, L"NoHeader", 1);
- } else {
- khm_int32 t;
- if (KHM_SUCCEEDED(khc_read_int32(csp_view, L"NoHeader", &t)) && t)
- khc_write_int32(csp_view, L"NoHeader", 0);
- }
-
- if (KHM_FAILED(khc_open_space(csp_view, L"Columns",
- KHM_PERM_WRITE | KHM_FLAG_CREATE,
- &csp_cols)))
- goto _cleanup;
-
- for (i=0; i < tbl->n_cols; i++) {
- const wchar_t * attr_name;
- kcdb_attrib * attrib = NULL;
- khm_handle csp_col = NULL;
-
- if (tbl->cols[i].attr_id < 0) {
- attr_name = cw_get_custom_attr_string(tbl->cols[i].attr_id);
- } else {
- if (KHM_FAILED(kcdb_attrib_get_info(tbl->cols[i].attr_id,
- &attrib))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- goto _clean_col;
- }
-
- attr_name = attrib->name;
- }
-#ifdef DEBUG
- assert(attr_name);
-#endif
-
- cb = cb_col_list;
- multi_string_append(col_list, &cb, attr_name);
-
- if (KHM_FAILED(khc_open_space(csp_cols, attr_name,
- KHM_PERM_WRITE | KHM_FLAG_CREATE,
- &csp_col)))
- goto _clean_col;
-
- khc_write_int32(csp_col, L"Width", tbl->cols[i].width);
- khc_write_int32(csp_col, L"SortIndex", tbl->cols[i].sort_index);
- khc_write_int32(csp_col, L"Flags", tbl->cols[i].flags);
-
- _clean_col:
-
- if (csp_col)
- khc_close_space(csp_col);
-
- if (attrib)
- kcdb_attrib_release_info(attrib);
- }
-
- khc_write_multi_string(csp_view, L"ColumnList", col_list);
-
- {
- khm_version v = app_version;
-
- khc_write_binary(csp_view, L"_AppVersion", &v, sizeof(v));
- }
-
- _cleanup:
-
- if (view_name) {
- if (csp_view)
- khc_close_space(csp_view);
-
- if (csp_views)
- khc_close_space(csp_views);
-
- if (csp_cw)
- khc_close_space(csp_cw);
- }
-
- if (csp_cols)
- khc_close_space(csp_cols);
-
- if (col_list)
- PFREE(col_list);
-}
-
-static COLORREF
-cw_mix_colors(COLORREF c1, COLORREF c2, int alpha) {
- int r = (GetRValue(c1) * alpha + GetRValue(c2) * (255 - alpha)) / 255;
- int g = (GetGValue(c1) * alpha + GetGValue(c2) * (255 - alpha)) / 255;
- int b = (GetBValue(c1) * alpha + GetBValue(c2) * (255 - alpha)) / 255;
-
-#ifdef DEBUG
- assert(alpha >= 0 && alpha < 256);
-#endif
-
- return RGB(r,g,b);
-}
-
-static COLORREF
-cw_get_theme_color(khm_handle hc, const wchar_t * name, COLORREF ref_color) {
- khm_int32 t;
- COLORREF c;
- int alpha;
-
- if (KHM_FAILED(khc_read_int32(hc, name, &t))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return ref_color;
- }
-
- alpha = ((t >> 24) & 0xff);
- c = (COLORREF) (t & 0xffffff);
- return cw_mix_colors(ref_color, c, alpha);
-}
-
-void
-cw_load_view(khui_credwnd_tbl * tbl, wchar_t * view, HWND hwnd) {
- khm_handle hc_cw = NULL;
- khm_handle hc_vs = NULL;
- khm_handle hc_v = NULL;
- khm_handle hc_cs = NULL;
- khm_handle hc_c = NULL;
- wchar_t buf[KCONF_MAXCCH_NAME];
- wchar_t * clist = NULL;
- khm_size cbsize;
- wchar_t * iter = NULL;
- int i;
- HDC hdc;
- LOGFONT log_font;
- khm_int32 t;
- const wchar_t * viewval;
- khm_boolean reopen_csp = FALSE;
-
- tbl->hwnd = hwnd;
-
- if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
- viewval = L"DefaultViewMini";
- else
- viewval = L"DefaultView";
-
- if(KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ | KHM_PERM_WRITE,
- &hc_cw)))
- return;
-
- khc_read_int32(hc_cw, L"HideWatermarks", &bHideWatermarks);
-
- if(KHM_FAILED(khc_open_space(hc_cw, L"Views", KHM_PERM_READ, &hc_vs)))
- goto _exit;
-
- if(!view) {
- cbsize = sizeof(buf);
- if(KHM_FAILED(khc_read_string(hc_cw, viewval, buf, &cbsize)))
- goto _exit;
- view = buf;
- } else {
- khc_write_string(hc_cw, viewval, view);
- }
-
- /* in addition, if we are loading the default view, we should
- also check the appropriate menu item */
-
- if (!wcscmp(view, L"ByIdentity"))
- khui_check_radio_action(khui_find_menu(KHUI_MENU_LAYOUT),
- KHUI_ACTION_LAYOUT_ID);
- else if (!wcscmp(view, L"ByLocation"))
- khui_check_radio_action(khui_find_menu(KHUI_MENU_LAYOUT),
- KHUI_ACTION_LAYOUT_LOC);
- else if (!wcscmp(view, L"ByType"))
- khui_check_radio_action(khui_find_menu(KHUI_MENU_LAYOUT),
- KHUI_ACTION_LAYOUT_TYPE);
- else if (!wcscmp(view, L"Custom_0"))
- khui_check_radio_action(khui_find_menu(KHUI_MENU_LAYOUT),
- KHUI_ACTION_LAYOUT_CUST);
- else {
- /* do nothing */
- }
-
- if (KHM_FAILED(khc_read_int32(hc_cw, L"ViewAllIdents", &tbl->view_all_idents)))
- tbl->view_all_idents = 0;
-
- khui_check_action(KHUI_ACTION_VIEW_ALL_IDS, tbl->view_all_idents);
-
- kmq_post_message(KMSG_ACT, KMSG_ACT_REFRESH, 0, 0);
-
- if(KHM_FAILED(khc_open_space(hc_vs, view, 0, &hc_v)))
- goto _exit;
-
- /* view data is very sensitive to version changes. We need to
- check if this configuration data was created with this version
- of NetIDMgr. If not, we switch to using a schema handle. */
- {
- khm_version this_v = app_version;
- khm_version cfg_v;
-
- cbsize = sizeof(cfg_v);
- if (KHM_FAILED(khc_read_binary(hc_v, L"_AppVersion", &cfg_v, &cbsize)) ||
- khm_compare_version(&cfg_v, &this_v) != 0) {
-
- khc_close_space(hc_v);
-
- if (KHM_FAILED(khc_open_space(hc_vs, view, KCONF_FLAG_SCHEMA,
- &hc_v)) &&
- (wcscmp(view, L"Custom_1") ||
- KHM_FAILED(khc_open_space(hc_vs, L"CompactIdentity",
- KCONF_FLAG_SCHEMA, &hc_v)))) {
- goto _exit;
- }
-
- reopen_csp = TRUE;
- }
- }
-
- tbl->csp_view = hc_v;
-
- if(KHM_FAILED(khc_open_space(hc_v, L"Columns",
- KHM_PERM_READ | (reopen_csp ? KCONF_FLAG_SCHEMA : 0),
- &hc_cs)))
- goto _exit;
-
- cbsize = 0;
- if(khc_read_multi_string(hc_v, L"ColumnList", NULL, &cbsize) != KHM_ERROR_TOO_LONG)
- goto _exit;
-
- /* temporary */
- clist = PMALLOC(cbsize);
-
- if(KHM_FAILED(khc_read_multi_string(hc_v, L"ColumnList", clist, &cbsize)))
- goto _exit;
-
- tbl->n_cols = (int) multi_string_length_n(clist);
- tbl->n_total_cols = UBOUNDSS(tbl->n_cols,
- KHUI_CW_COL_INITIAL, KHUI_CW_COL_INCREMENT);
- tbl->cols = PMALLOC(sizeof(khui_credwnd_col) * tbl->n_total_cols);
- ZeroMemory(tbl->cols, sizeof(khui_credwnd_col) * tbl->n_total_cols);
-
- tbl->flags &= ~(KHUI_CW_TBL_CUSTVIEW | KHUI_CW_TBL_COLSKIP);
-
- if (KHM_SUCCEEDED(khc_read_int32(hc_v, L"ExpandedIdentity", &t)) && t) {
- tbl->flags |= KHUI_CW_TBL_EXPIDENT;
- } else {
- tbl->flags &= ~KHUI_CW_TBL_EXPIDENT;
- }
-
- if (KHM_SUCCEEDED(khc_read_int32(hc_v, L"NoHeader", &t)) && t) {
- tbl->flags |= KHUI_CW_TBL_NOHEADER;
- } else {
- tbl->flags &= ~KHUI_CW_TBL_NOHEADER;
- }
-
- iter = clist;
- i = 0;
- while(iter) {
- khm_int32 attr_id;
-
- attr_id = cw_get_custom_attr_id(iter);
- if(!attr_id) {
- /* a KCDB attribute */
- if(KHM_FAILED(kcdb_attrib_get_id(iter, &attr_id))) {
- tbl->flags |= KHUI_CW_TBL_COLSKIP;
- goto _skip_col;
- }
-
- if(kcdb_attrib_describe(attr_id, NULL,
- &cbsize, KCDB_TS_SHORT) != KHM_ERROR_TOO_LONG ||
- cbsize == 0) {
- tbl->flags |= KHUI_CW_TBL_COLSKIP;
- goto _skip_col;
- }
-
- tbl->cols[i].title = PMALLOC(cbsize);
- kcdb_attrib_describe(attr_id, tbl->cols[i].title, &cbsize, KCDB_TS_SHORT);
-
- if (attr_id >= 0 &&
- attr_id <= KCDB_ATTR_MAX_ID &&
- attr_to_action[attr_id]) {
- khui_check_action(attr_to_action[attr_id], TRUE);
- }
-
- } else {
- /* All current custom attributes are represented by icons,
- not names */
- tbl->cols[i].title = NULL;
- }
-
- tbl->cols[i].attr_id = attr_id;
-
- if(KHM_SUCCEEDED(khc_open_space(hc_cs, iter,
- KHM_PERM_READ | (reopen_csp ? KCONF_FLAG_SCHEMA : 0),
- &hc_c))) {
- if(KHM_FAILED(khc_read_int32(hc_c, L"Flags", &(tbl->cols[i].flags))))
- tbl->cols[i].flags = 0;
- if(KHM_FAILED(khc_read_int32(hc_c, L"Width", &(tbl->cols[i].width))))
- tbl->cols[i].width = 100;
- if(KHM_FAILED(khc_read_int32(hc_c, L"SortIndex",
- &(tbl->cols[i].sort_index))))
- tbl->cols[i].sort_index = -1;
- khc_close_space(hc_c);
- hc_c = NULL;
- } else {
- tbl->cols[i].flags = 0;
- tbl->cols[i].width = -1;
- tbl->cols[i].sort_index = -1;
- }
- i++;
-_skip_col:
- iter = multi_string_next(iter);
- }
-
- /* refresh the menus since we checked a few items */
- kmq_post_message(KMSG_ACT, KMSG_ACT_REFRESH, 0, 0);
-
- /* adjust the number of columns. We may have skipped columns due to
- inconsistencies above */
- tbl->n_cols = i;
-
- /* now that all the columns have been loaded, load the view
- parameters */
- if(KHM_FAILED(khc_read_int32(hc_v, L"PaddingHorizontal", &(tbl->hpad))))
- khc_read_int32(hc_cw, L"PaddingHorizontal", &(tbl->hpad));
- if(KHM_FAILED(khc_read_int32(hc_v, L"PaddingVertical", &(tbl->vpad))))
- khc_read_int32(hc_cw, L"PaddingVertical", &(tbl->vpad));
- if(KHM_FAILED(khc_read_int32(hc_v, L"PaddingHeader", &(tbl->hpad_h))))
- khc_read_int32(hc_cw, L"PaddingHeader", &(tbl->hpad_h));
- if(KHM_FAILED(khc_read_int32(hc_v, L"WarnThreshold", &(tbl->threshold_warn))))
- khc_read_int32(hc_cw, L"WarnThreshold", &(tbl->threshold_warn));
- if(KHM_FAILED(khc_read_int32(hc_v, L"CriticalThreshold",
- &(tbl->threshold_critical))))
- khc_read_int32(hc_cw, L"CriticalThreshold",
- &(tbl->threshold_critical));
-
- /* and the font resources and stuff */
-
- tbl->flags |= KHUI_CW_TBL_INITIALIZED | KHUI_CW_TBL_COL_DIRTY | KHUI_CW_TBL_ACTIVE;
-
- hdc = GetWindowDC(hwnd);
-
- khm_get_cw_element_font(hdc, L"FontHeader", FALSE, &log_font);
- tbl->hf_header = CreateFontIndirect(&log_font);
-
- if(tbl->hf_header && tbl->hwnd_header)
- SendMessage(tbl->hwnd_header, WM_SETFONT, (WPARAM) tbl->hf_header, 0);
-
- khm_get_cw_element_font(hdc, L"FontHeaderBold", FALSE, &log_font);
- tbl->hf_bold_header = CreateFontIndirect(&log_font);
-
-
- khm_get_cw_element_font(hdc, L"FontNormal", FALSE, &log_font);
- tbl->hf_normal = CreateFontIndirect(&log_font);
-
- khm_get_cw_element_font(hdc, L"FontBold", FALSE, &log_font);
- tbl->hf_bold = CreateFontIndirect(&log_font);
-
- ReleaseDC(hwnd, hdc);
-
- khui_bitmap_from_hbmp(&(tbl->kbm_logo_shade),
- LoadImage(khm_hInstance,
- MAKEINTRESOURCE(IDB_LOGO_SHADE),
- IMAGE_BITMAP,
- 0,
- 0,
- LR_DEFAULTCOLOR));
-
- {
-
-#define SEL_ALPHA 50
-
- khm_handle hc_themes = NULL;
- khm_handle hc_theme = NULL;
-
- COLORREF bg_s = 0;
- COLORREF bg_normal = 0;
- COLORREF bg_gray = 0;
- COLORREF bg_hdr = 0;
- COLORREF bg_hdr_cred = 0;
- COLORREF bg_hdr_warn = 0;
- COLORREF bg_hdr_crit = 0;
- COLORREF bg_hdr_exp = 0;
-
- COLORREF bg_hdr_s = 0;
- COLORREF bg_hdr_cred_s = 0;
- COLORREF bg_hdr_warn_s = 0;
- COLORREF bg_hdr_crit_s = 0;
- COLORREF bg_hdr_exp_s = 0;
-
- cbsize = sizeof(buf);
- if (KHM_SUCCEEDED(khc_read_string(hc_cw, L"DefaultTheme", buf, &cbsize)) &&
- KHM_SUCCEEDED(khc_open_space(hc_cw, L"Themes", KHM_PERM_READ, &hc_themes)) &&
- KHM_SUCCEEDED(khc_open_space(hc_themes, buf, KHM_PERM_READ, &hc_theme))) {
-
- bg_s = cw_get_theme_color(hc_theme, L"ClrSelection", 0);
- bg_normal = cw_get_theme_color(hc_theme, L"ClrBackground", 0);
- bg_gray = cw_get_theme_color(hc_theme, L"ClrGray", 0);
- bg_hdr = cw_get_theme_color(hc_theme, L"ClrHeader", 0);
- bg_hdr_cred = cw_get_theme_color(hc_theme, L"ClrHeaderCred", 0);
- bg_hdr_warn = cw_get_theme_color(hc_theme, L"ClrHeaderWarn", 0);
- bg_hdr_crit = cw_get_theme_color(hc_theme, L"ClrHeaderCrit", 0);
- bg_hdr_exp = cw_get_theme_color(hc_theme, L"ClrHeaderExp", 0);
- bg_hdr_s = cw_get_theme_color(hc_theme, L"ClrHeaderSel", bg_s);
- bg_hdr_cred_s = cw_get_theme_color(hc_theme, L"ClrHeaderCredSel", bg_s);
- bg_hdr_warn_s = cw_get_theme_color(hc_theme, L"ClrHeaderWarnSel", bg_s);
- bg_hdr_crit_s = cw_get_theme_color(hc_theme, L"ClrHeaderCritSel", bg_s);
- bg_hdr_exp_s = cw_get_theme_color(hc_theme, L"ClrHeaderExpSel", bg_s);
-
- tbl->cr_normal = cw_get_theme_color(hc_theme, L"ClrText", 0);
- tbl->cr_s = cw_get_theme_color(hc_theme, L"ClrTextSel", bg_s);
- tbl->cr_hdr_outline = cw_get_theme_color(hc_theme, L"ClrHeaderOutline", 0);
- tbl->cr_hdr_normal = cw_get_theme_color(hc_theme, L"ClrTextHeader", 0);
- tbl->cr_hdr_s = cw_get_theme_color(hc_theme, L"ClrTextHeaderSel", bg_s);
- tbl->cr_hdr_gray = cw_get_theme_color(hc_theme, L"ClrTextHeaderGray", 0);
- tbl->cr_hdr_gray_s = cw_get_theme_color(hc_theme, L"ClrTextHeaderGraySel", bg_s);
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- if (hc_theme)
- khc_close_space(hc_theme);
- if (hc_themes)
- khc_close_space(hc_themes);
- hc_theme = hc_themes = NULL;
-
- if (khm_main_wnd_mode == KHM_MAIN_WND_MINI) {
- bg_hdr = bg_normal;
- tbl->cr_hdr_outline = bg_gray;
- }
-
- tbl->hb_normal = CreateSolidBrush(bg_normal);
- tbl->hb_grey = CreateSolidBrush(bg_gray);
- tbl->hb_s = CreateSolidBrush(cw_mix_colors(bg_s, bg_normal, SEL_ALPHA));
-
- tbl->hb_hdr_bg = CreateSolidBrush(bg_hdr);
- tbl->hb_hdr_bg_cred = CreateSolidBrush(bg_hdr_cred);
- tbl->hb_hdr_bg_warn = CreateSolidBrush(bg_hdr_warn);
- tbl->hb_hdr_bg_crit = CreateSolidBrush(bg_hdr_crit);
- tbl->hb_hdr_bg_exp = CreateSolidBrush(bg_hdr_exp);
-
- tbl->hb_hdr_bg_s = CreateSolidBrush(bg_s);
- tbl->hb_hdr_bg_cred_s = CreateSolidBrush(bg_hdr_cred_s);
- tbl->hb_hdr_bg_warn_s = CreateSolidBrush(bg_hdr_warn_s);
- tbl->hb_hdr_bg_crit_s = CreateSolidBrush(bg_hdr_crit_s);
- tbl->hb_hdr_bg_exp_s = CreateSolidBrush(bg_hdr_exp_s);
- }
-
- tbl->ilist = khui_create_ilist(KHUI_SMICON_CX, KHUI_SMICON_CY-1, 20, 8, 0);
- {
- HBITMAP hbm;
-
-#define ADD_BITMAP(i) \
- hbm = LoadImage(khm_hInstance, MAKEINTRESOURCE(i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); \
- if(hbm) { \
- khui_ilist_add_masked_id(tbl->ilist, hbm, KHUI_TOOLBAR_BGCOLOR, i); \
- DeleteObject(hbm); \
- }
-
- ADD_BITMAP(IDB_WDG_COLLAPSE);
- ADD_BITMAP(IDB_WDG_EXPAND);
- ADD_BITMAP(IDB_ID_SM);
- ADD_BITMAP(IDB_ID_DIS_SM);
-
- ADD_BITMAP(IDB_TK_NEW_SM);
- ADD_BITMAP(IDB_TK_REFRESH_SM);
- ADD_BITMAP(IDB_WDG_COLLAPSE_HI);
- ADD_BITMAP(IDB_WDG_EXPAND_HI);
-
- ADD_BITMAP(IDB_WDG_FLAG);
- ADD_BITMAP(IDB_WDG_CREDTYPE);
- ADD_BITMAP(IDB_FLAG_WARN);
- ADD_BITMAP(IDB_FLAG_EXPIRED);
-
- ADD_BITMAP(IDB_FLAG_CRITICAL);
- ADD_BITMAP(IDB_FLAG_RENEW);
- ADD_BITMAP(IDB_WDG_STUCK);
- ADD_BITMAP(IDB_WDG_STUCK_HI);
-
- ADD_BITMAP(IDB_WDG_STICK);
- ADD_BITMAP(IDB_WDG_STICK_HI);
- ADD_BITMAP(IDB_TK_SM);
-
-#undef ADD_BITMAP
- }
-
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
- tbl->hi_lg_ident = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON),
- LR_DEFAULTCOLOR);
- }
-
- tbl->cursor_row = -1;
- tbl->scr_left = 0;
- tbl->scr_top = 0;
- tbl->ext_height = 0;
- tbl->ext_width = 0;
-
- if (reopen_csp) {
- khc_close_space(hc_v);
-
- hc_v = NULL;
-
- khc_open_space(hc_vs, view, 0, &hc_v);
-
- tbl->csp_view = hc_v;
- }
-
-_exit:
- if(hc_cw)
- khc_close_space(hc_cw);
- if(hc_vs)
- khc_close_space(hc_vs);
- if(hc_cs)
- khc_close_space(hc_cs);
- if(clist)
- PFREE(clist);
- /* we leave hc_v held, because tbl->csp_view is the same handle.
- We keep that open until the view is unloaded. */
-}
-
-khui_credwnd_ident *
-cw_find_ident(khui_credwnd_tbl * tbl, khm_handle ident) {
- khm_size i;
-
- for (i=0; i < tbl->n_idents; i++) {
- if (kcdb_identity_is_equal(ident, tbl->idents[i].ident))
- break;
- }
-
- if (i < tbl->n_idents)
- return &tbl->idents[i];
- else
- return NULL;
-}
-
-khm_int32 KHMAPI
-cw_credset_iter_func(khm_handle cred, void * rock) {
- khui_credwnd_tbl * tbl = (khui_credwnd_tbl *) rock;
- khm_handle ident = NULL;
- khm_size i;
- khui_credwnd_ident * cwi = NULL;
- khm_int32 cred_credtype = KCDB_CREDTYPE_INVALID;
- khm_int32 cred_flags = 0;
-
- kcdb_cred_get_identity(cred, &ident);
-
- if (ident == NULL)
- goto _cleanup;
-
- for (i=0; i < tbl->n_idents; i++) {
- if (kcdb_identity_is_equal(ident, tbl->idents[i].ident))
- break;
- }
-
- if (i >= tbl->n_idents) {
- khm_size cb;
-
- /* need to add this one */
- if (tbl->n_idents == tbl->nc_idents) {
- tbl->nc_idents = UBOUNDSS(tbl->n_idents + 1,
- CW_IDENT_ALLOC_INCR,
- CW_IDENT_ALLOC_INCR);
-#ifdef DEBUG
- assert(tbl->nc_idents > tbl->n_idents);
-#endif
- tbl->idents = PREALLOC(tbl->idents, sizeof(tbl->idents[0]) * tbl->nc_idents);
-#ifdef DEBUG
- assert(tbl->idents);
-#endif
- ZeroMemory(&tbl->idents[tbl->n_idents],
- sizeof(tbl->idents[0]) * (tbl->nc_idents - tbl->n_idents));
- }
-
- i = tbl->n_idents;
- cwi = &tbl->idents[tbl->n_idents++];
-
- ZeroMemory(cwi, sizeof(*cwi));
-
- cwi->ident = ident;
- kcdb_identity_hold(ident);
-
- cb = sizeof(cwi->name);
- kcdb_identity_get_name(ident, cwi->name, &cb);
- }
-
- cwi = &tbl->idents[i];
-
- /* this is the first time we are seeing this identity. */
- if (cwi->credcount == 0) {
- khm_size cb;
-
- cb = sizeof(cwi->credtype);
- if (KHM_SUCCEEDED(kcdb_identity_get_attr(ident, KCDB_ATTR_TYPE, NULL,
- &cwi->credtype, &cb))) {
- cwi->credtype_name[0] = L'\0';
-
- cb = sizeof(cwi->credtype_name);
- if (KHM_FAILED(kcdb_identity_get_attr(ident, KCDB_ATTR_TYPE_NAME, NULL,
- &cwi->credtype_name, &cb))) {
- cb = sizeof(cwi->credtype_name);
- kcdb_credtype_describe(cwi->credtype, cwi->credtype_name,
- &cb, KCDB_TS_SHORT);
- }
- } else {
- cwi->credtype = KCDB_CREDTYPE_INVALID;
- cwi->credtype_name[0] = L'\0';
- }
-
- cb = sizeof(cwi->ft_expire);
- if (KHM_FAILED(kcdb_identity_get_attr(ident, KCDB_ATTR_EXPIRE, NULL,
- &cwi->ft_expire, &cb))) {
- cwi->ft_expire = IntToFt(0);
- }
-
- kcdb_identity_get_flags(cwi->ident, &cwi->ident_flags);
- }
-
- cwi->credcount++;
-
- kcdb_cred_get_type(cred, &cred_credtype);
- if (cred_credtype >= 0 && cred_credtype == cwi->credtype) {
- cwi->id_credcount++;
-
- kcdb_cred_get_flags(cred, &cred_flags);
- if (cred_flags & KCDB_CRED_FLAG_INITIAL) {
- cwi->init_credcount++;
- }
- }
-
- _cleanup:
- if (ident)
- kcdb_identity_release(ident);
-
- return KHM_ERROR_SUCCESS;
-}
-
-void
-cw_update_creds(khui_credwnd_tbl * tbl)
-{
- kcdb_cred_comp_field * fields;
- kcdb_cred_comp_order comp_order;
- int i;
- khm_int32 n;
- khm_int32 delta;
- khm_handle hc;
- khm_int32 flags;
-
- if(!tbl->credset) {
- if(KHM_FAILED(kcdb_credset_create(&(tbl->credset))))
- return;
- }
-
- kcdb_credset_purge(tbl->credset);
-
- kcdb_identity_refresh_all();
-
- kcdb_credset_collect(
- tbl->credset,
- NULL,
- NULL,
- KCDB_CREDTYPE_ALL,
- &delta);
-
- /* now we need to figure out how to sort the credentials */
- fields = PMALLOC(sizeof(kcdb_cred_comp_field) * tbl->n_cols);
- ZeroMemory(fields, sizeof(kcdb_cred_comp_field) * tbl->n_cols);
-
- for(i=0, n=0; i<tbl->n_cols; i++) {
- if((tbl->cols[i].flags & KHUI_CW_COL_SORT_INC) ||
- (tbl->cols[i].flags & KHUI_CW_COL_SORT_DEC) ||
- (tbl->cols[i].flags & KHUI_CW_COL_GROUP)) {
- int si;
- /* we need to sort by this column */
- si = tbl->cols[i].sort_index;
-
- if(si < 0 || si >= (int) tbl->n_cols)
- {
- /* this shouldn't happen */
- tbl->cols[i].flags &= ~(KHUI_CW_COL_SORT_INC |
- KHUI_CW_COL_SORT_DEC |
- KHUI_CW_COL_GROUP);
- continue;
- }
-
- fields[si].attrib = tbl->cols[i].attr_id;
- if(tbl->cols[i].flags & KHUI_CW_COL_SORT_DEC)
- fields[si].order = KCDB_CRED_COMP_DECREASING;
- else
- fields[si].order = KCDB_CRED_COMP_INCREASING;
-
- /* special case. if we are sorting by name, we group
- initial tickets before non-initial tickets.
-
- Also, if we are sorting by credential type name, then
- we allow the primary credential type first before
- others. */
-
- if (fields[si].attrib == KCDB_ATTR_NAME ||
- fields[si].attrib == KCDB_ATTR_TYPE_NAME)
- fields[si].order |= KCDB_CRED_COMP_INITIAL_FIRST;
-
- if(si >= n)
- n = si+1;
- }
- }
-
- /* we assume that the sort order is sane */
- /*TODO: don't assume; check if the sort order is sane */
-
- comp_order.nFields = n;
- comp_order.fields = fields;
-
- kcdb_credset_sort(tbl->credset,
- kcdb_cred_comp_generic,
- (void *) &comp_order);
-
- /* also, if new credentials were added, initialize the UI flag
- attribute to 0 */
- if(delta & KCDB_DELTA_ADD) {
- khm_size s;
-
- kcdb_credset_get_size(tbl->credset, &s);
- for(i=0;i< (int) s;i++) {
- if(KHM_FAILED(kcdb_credset_get_cred(tbl->credset,
- (khm_int32) i, &hc)))
- continue; /* lost a race */
- if(KHM_FAILED(kcdb_cred_get_attr(hc, khui_cw_flag_id, NULL,
- NULL, NULL))) {
- flags = 0;
- kcdb_cred_set_attr(hc, khui_cw_flag_id, &flags, sizeof(flags));
- }
- kcdb_cred_release(hc);
- }
- }
-
- /* refresh the per-identity information */
- for (i=0; i < (int) tbl->n_idents; i++) {
- tbl->idents[i].credcount = 0;
- tbl->idents[i].id_credcount = 0;
- tbl->idents[i].init_credcount = 0;
- tbl->idents[i].credtype_name[0] = L'\0';
- tbl->idents[i].credtype = KCDB_CREDTYPE_INVALID;
- tbl->idents[i].ft_expire = IntToFt(0);
- }
-
- kcdb_credset_apply(tbl->credset, cw_credset_iter_func, (void *) tbl);
-
- if (fields)
- PFREE(fields);
-}
-
-void
-cw_del_outline(khui_credwnd_outline *o) {
- khui_credwnd_outline * c;
- if(!o)
- return;
-
- /* the outline object is still in a list */
- if(o->next || o->prev)
- return;
-
- if(o->header)
- PFREE(o->header);
-
- if ((o->flags & KHUI_CW_O_DATAALLOC) &&
- o->data)
- PFREE(o->data);
-
- if ((o->flags & KHUI_CW_O_RELIDENT) &&
- o->data)
- kcdb_identity_release((khm_handle) o->data);
-
- LPOP(&(o->children), &c);
- while(c) {
- cw_del_outline(c);
- LPOP(&(o->children), &c);
- }
-
- ZeroMemory(o, sizeof(*o));
- PFREE(o);
-}
-
-khui_credwnd_outline *
-cw_new_outline_node(wchar_t * heading) {
- khui_credwnd_outline * o;
- size_t cblen;
-
- o = PMALLOC(sizeof(khui_credwnd_outline));
- ZeroMemory(o, sizeof(khui_credwnd_outline));
-
- if(SUCCEEDED(StringCbLength(heading, KHUI_MAXCB_HEADING, &cblen))) {
- cblen += sizeof(wchar_t);
- o->header = PMALLOC(cblen);
- StringCbCopy(o->header, cblen, heading);
- }
- o->start = -1;
-
- return o;
-}
-
-/* buf is a handle to a credential or an identity. the kcdb_buf_*
- functions work with either. */
-khm_int32
-cw_get_buf_exp_flags(khui_credwnd_tbl * tbl, khm_handle buf)
-{
- khm_int32 flags;
- long s;
- FILETIME ft_expire;
- FILETIME ft_current;
- FILETIME ft_difference;
- khm_size cbsize;
-
- cbsize = sizeof(ft_expire);
- if(KHM_FAILED(kcdb_buf_get_attr(buf, KCDB_ATTR_EXPIRE, NULL,
- &ft_expire, &cbsize)))
- return 0;
-
- GetSystemTimeAsFileTime(&ft_current);
- ft_difference = FtSub(&ft_expire, &ft_current);
-
- s = FtIntervalToSeconds(&ft_difference);
-
- flags = 0;
- if(s < 0)
- flags = CW_EXPSTATE_EXPIRED;
- else if(s < tbl->threshold_critical)
- flags = CW_EXPSTATE_CRITICAL;
- else if(s < tbl->threshold_warn)
- flags = CW_EXPSTATE_WARN;
- else
- flags = CW_EXPSTATE_NONE;
-
- return flags;
-}
-
-VOID CALLBACK
-cw_timer_proc(HWND hwnd,
- UINT uMsg,
- UINT_PTR idEvent,
- DWORD dwTime)
-{
- khui_credwnd_tbl * tbl;
- khui_credwnd_row * r;
- khm_int32 nflags;
- int nr;
- long ms;
- FILETIME ft;
- khm_size cbsize;
- int timer_set = 0;
-
- KillTimer(hwnd, idEvent);
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return;
-
- r = (khui_credwnd_row *) idEvent;
- nr = (int)(r - tbl->rows);
-
- if(nr < 0 || nr >= tbl->n_rows)
- return;
-
- r->flags &= ~KHUI_CW_ROW_TIMERSET;
-
- if(r->flags & KHUI_CW_ROW_CRED) {
-
- nflags = cw_get_buf_exp_flags(tbl, (khm_handle) r->data);
- if((r->flags & CW_EXPSTATE_MASK) != nflags) {
- /* flags have changed */
- /* the outline needs to be updated */
- cw_update_outline(tbl);
- InvalidateRect(tbl->hwnd, NULL, FALSE);
- } else {
- /* just invalidate the row */
- RECT rc,rr,ri;
-
- GetClientRect(tbl->hwnd, &rc);
- rc.top += tbl->header_height;
-
- rr = r->r_ext;
- OffsetRect(&rr, 0, tbl->header_height - tbl->scr_top);
-
- if(IntersectRect(&ri, &rc, &rr))
- InvalidateRect(tbl->hwnd, &ri, FALSE);
-
- cbsize = sizeof(ft);
- if(KHM_SUCCEEDED(kcdb_cred_get_attr((khm_handle) r->data,
- KCDB_ATTR_TIMELEFT, NULL,
- &ft, &cbsize))) {
- ms = FtIntervalMsToRepChange(&ft);
- if(ms > 0) {
- SetTimer(tbl->hwnd, (UINT_PTR) r, ms + 100, cw_timer_proc);
- timer_set = 1;
- }
- }
-
- if (timer_set)
- r->flags |= KHUI_CW_ROW_TIMERSET;
- }
- } else {
- khui_credwnd_outline * o;
- khui_credwnd_ident * cwi;
- FILETIME ft_now;
-
- o = (khui_credwnd_outline *) r->data;
-
- /* we only handle timers for header rows if :
-
- 1. The table is displaying expanded identity information
- 2. The row displaying an expanded view
- 3. The relevant outline object is for an identity
-
- If these conditions aren't met, it is because we lost a
- race killing this timer while switching modes.
- */
- if (!(tbl->flags & KHUI_CW_TBL_EXPIDENT) ||
- !(r->flags & KHUI_CW_ROW_EXPVIEW) ||
- !(o->attr_id == KCDB_ATTR_ID))
-
- return;
-
- nflags = cw_get_buf_exp_flags(tbl, (khm_handle) o->data);
- if ((o->flags & CW_EXPSTATE_MASK) != nflags) {
- cw_update_outline(tbl);
- InvalidateRect(tbl->hwnd, NULL, FALSE);
- } else {
- RECT rc, rr, ri;
-
- GetClientRect(tbl->hwnd, &rc);
- rc.top += tbl->header_height;
-
- rr = r->r_ext;
- OffsetRect(&rr, 0, tbl->header_height - tbl->scr_top);
-
- if (IntersectRect(&ri, &rc, &rr))
- InvalidateRect(tbl->hwnd, &ri, FALSE);
-
- cwi = cw_find_ident(tbl, o->data);
-
- GetSystemTimeAsFileTime(&ft_now);
- if (CompareFileTime(&cwi->ft_expire, &ft_now) > 0) {
- ft = FtSub(&cwi->ft_expire, &ft_now);
- ms = FtIntervalMsToRepChange(&ft);
- if (ms > 0) {
- SetTimer(tbl->hwnd, (UINT_PTR) r, ms + 100, cw_timer_proc);
- timer_set = 1;
- }
- }
-
- if (timer_set)
- r->flags |= KHUI_CW_ROW_TIMERSET;
- }
- }
-}
-
-void
-cw_set_tbl_row_cred(khui_credwnd_tbl * tbl,
- int row,
- khm_handle cred,
- int col)
-{
- FILETIME ft;
- long ms;
- khm_size cbsize;
-
- if((int) tbl->n_total_rows <= row) {
- /* we need to resize the allocation */
- khui_credwnd_row * newrows;
- int newsize;
-
- newsize = UBOUNDSS(row+1,KHUI_CW_ROW_INITIAL, KHUI_CW_ROW_INCREMENT);
- newrows = PMALLOC(sizeof(khui_credwnd_row) * newsize);
- memcpy(newrows, tbl->rows, sizeof(khui_credwnd_row) * tbl->n_rows);
- PFREE(tbl->rows);
- tbl->rows = newrows;
- tbl->n_total_rows = newsize;
- }
-
- tbl->rows[row].col = col;
- tbl->rows[row].data = cred;
- tbl->rows[row].flags = KHUI_CW_ROW_CRED;
-
- /* Set any required timer events */
- cbsize = sizeof(ft);
- if(KHM_SUCCEEDED(kcdb_cred_get_attr(cred, KCDB_ATTR_TIMELEFT, NULL, &ft, &cbsize))) {
- ms = FtIntervalMsToRepChange(&ft);
- if(ms > 0) {
- SetTimer(tbl->hwnd, (UINT_PTR) &(tbl->rows[row]), ms + 100, cw_timer_proc);
- tbl->rows[row].flags |= KHUI_CW_ROW_TIMERSET;
- }
- }
-}
-
-void
-cw_set_tbl_row_header(khui_credwnd_tbl * tbl,
- int row, int col,
- khui_credwnd_outline * o)
-{
- if((int) tbl->n_total_rows <= row) {
- /* we need to resize the allocation */
- khui_credwnd_row * newrows;
- int newsize;
-
- newsize = UBOUNDSS(row+1,KHUI_CW_ROW_INITIAL, KHUI_CW_ROW_INCREMENT);
- newrows = PMALLOC(sizeof(khui_credwnd_row) * newsize);
- memcpy(newrows, tbl->rows, sizeof(khui_credwnd_row) * tbl->n_rows);
- PFREE(tbl->rows);
- tbl->rows = newrows;
- tbl->n_total_rows = newsize;
- }
-
- tbl->rows[row].col = col;
- tbl->rows[row].data = (khm_handle) o;
- tbl->rows[row].flags = KHUI_CW_ROW_HEADER;
- if(o->flags & KHUI_CW_O_SELECTED)
- tbl->rows[row].flags |= KHUI_CW_ROW_SELECTED;
-
- /* if we are showing expanded identity information, we need to set
- a timer so that we can update the identity row when the
- identity changes. */
- if ((tbl->flags & KHUI_CW_TBL_EXPIDENT) &&
- tbl->cols[col].attr_id == KCDB_ATTR_ID_NAME) {
-
- khui_credwnd_ident * cwi;
-
- tbl->rows[row].flags |= KHUI_CW_ROW_EXPVIEW;
-
- cwi = cw_find_ident(tbl, o->data);
- if (cwi && FtToInt(&cwi->ft_expire) != 0) {
- FILETIME ft;
- FILETIME ft_now;
-
- ft = cwi->ft_expire;
- GetSystemTimeAsFileTime(&ft_now);
-
- if (CompareFileTime(&ft, &ft_now) > 0) {
- long ms;
-
- ft = FtSub(&ft, &ft_now);
- ms = FtIntervalMsToRepChange(&ft);
- if (ms > 0) {
- SetTimer(tbl->hwnd, (UINT_PTR) &(tbl->rows[row]), ms + 100,
- cw_timer_proc);
- tbl->rows[row].flags |= KHUI_CW_ROW_TIMERSET;
- }
- }
- }
- }
-}
-
-static int
-iwcscmp(const void * p1, const void * p2) {
- const wchar_t * s1 = *(wchar_t **) p1;
- const wchar_t * s2 = *(wchar_t **) p2;
-
- return wcscmp(s1, s2);
-}
-
-#define MAX_GROUPING 256
-
-static void
-cw_update_outline(khui_credwnd_tbl * tbl)
-{
- int i,j,n_rows;
- int level;
- int visible;
- khm_size n_creds = 0;
- khm_handle prevcred = NULL;
- khm_handle thiscred = NULL;
- /* grouping[0..n_grouping-1] are the columns that we are going to
- group the display by. Say we are grouping by identity and then
- by type, then grouping[0]=col# of identity and grouping[1]=col#
- of type */
- khm_int32 grouping[MAX_GROUPING];
- khui_credwnd_outline * ol = NULL;
- int n_grouping;
- wchar_t buf[256];
- khm_size cbbuf;
- khm_int32 flags;
- int selected;
-
- /* this is called after calling cw_update_creds, so we assume
- that the credentials are all loaded and sorted according to
- grouping rules */
-
- /* if the columns have changed, then any outline info we have
- cached are unreliable */
- if(tbl->flags & KHUI_CW_TBL_COL_DIRTY) {
- khui_credwnd_outline * o;
- LPOP(&(tbl->outline), &o);
- while(o) {
- cw_del_outline(o);
- LPOP(&(tbl->outline), &o);
- }
- tbl->n_rows = 0;
- }
-
- /* Otherwise, we should reset the outline indices. Just the first
- level is enough */
- if (tbl->outline) {
- khui_credwnd_outline * o;
-
- o = tbl->outline;
- while(o) {
- o->start = -1;
- o = LNEXT(o);
- }
- }
-
- /* determine the grouping order */
- n_grouping = min(MAX_GROUPING, tbl->n_cols);
- for(i=0; i < n_grouping; i++)
- grouping[i] = -1;
- n_grouping = 0;
-
- for(i=0; i < (int) tbl->n_cols; i++) {
- /* since cw_update_creds has run, the KHUI_CW_COL_GROUP flag
- only exists for columns that has a valid sort_index */
- if(tbl->cols[i].flags & KHUI_CW_COL_GROUP) {
-#ifdef DEBUG
- assert(tbl->cols[i].sort_index < MAX_GROUPING);
-#endif
- if (tbl->cols[i].sort_index >= MAX_GROUPING)
- continue;
-
- grouping[tbl->cols[i].sort_index] = i;
- if(n_grouping <= tbl->cols[i].sort_index)
- n_grouping = tbl->cols[i].sort_index + 1;
- }
- }
-
- /* if we have sorted by an index without grouping by it, we can't
- establish any grouping beyond that index. */
- for(i=0; i < n_grouping; i++) {
- if(grouping[i] == -1)
- break;
- }
- n_grouping = i;
-
- if(!tbl->rows) {
- /* we haven't allocated memory yet */
- tbl->n_total_rows = KHUI_CW_ROW_INITIAL;
- tbl->n_rows = 0;
- tbl->rows = PMALLOC(sizeof(khui_credwnd_row) * tbl->n_total_rows);
- } else {
- /* kill any pending timers */
- for(i=0; i < (int) tbl->n_rows; i++)
- if(tbl->rows[i].flags & KHUI_CW_ROW_TIMERSET) {
- KillTimer(tbl->hwnd, (UINT_PTR) &(tbl->rows[i]));
- tbl->rows[i].flags &= ~KHUI_CW_ROW_TIMERSET;
- }
- }
-
- if(KHM_FAILED(kcdb_credset_get_size(tbl->credset, &n_creds)))
- goto _exit;
-
- n_rows = 0;
- prevcred = NULL;
- ol = NULL;
-
- for(i=0; i < (int) n_creds; i++) {
- if(KHM_FAILED(kcdb_credset_get_cred(tbl->credset, i, &thiscred)))
- continue;
-
- /* if this credential appears to be the same as another for
- this view, we skip it. */
- if(prevcred && n_grouping > 0) {
- for(j=0; j < (int) tbl->n_cols; j++) {
- if(kcdb_creds_comp_attr(prevcred, thiscred,
- tbl->cols[j].attr_id))
- break;
- }
-
- if(j >= (int) tbl->n_cols) {
- if (n_rows > 0) {
- tbl->rows[n_rows - 1].idx_end = i;
- }
- continue;
- }
- }
-
- if(!prevcred)
- level = 0;
- else {
- for(j=0; j < n_grouping; j++) {
- /* determine the grouping level at which thiscred
- differs from prevcred */
- if(kcdb_creds_comp_attr(prevcred,thiscred,
- tbl->cols[grouping[j]].attr_id))
- break;
- }
- level = j;
- }
-
- /* now we have to walk up until we get to the parent of the
- outline level we should be in */
- while(ol && ol->level >= level) {
-
- /* we are closing this outline level. */
- ol->length = n_rows - ol->start;
- ol->idx_end = i - 1;
-
- if ((ol->flags & KHUI_CW_O_SELECTED) &&
- ol->length > 0) {
- tbl->n_rows = n_rows;
- cw_select_row_creds(tbl, ol->start, TRUE);
- }
-
- ol = TPARENT(ol);
- }
-
- if(ol) {
- visible = (ol->flags & KHUI_CW_O_VISIBLE) &&
- (ol->flags & KHUI_CW_O_EXPAND);
- selected = !!(ol->flags & KHUI_CW_O_SELECTED);
- } else {
- visible = TRUE;
- selected = FALSE;
- }
-
- /* now ol points to an outline node at the next highest level
- or is NULL if level = 0 */
-
- for(j=level; j < n_grouping; j++) {
- khui_credwnd_outline * to;
- /* now we search for an outline object at the next level
- which matches the heading */
- cbbuf = sizeof(buf);
- buf[0] = L'\0';
- if(KHM_FAILED
- (kcdb_cred_get_attr_string(thiscred,
- tbl->cols[grouping[j]].attr_id,
- buf, &cbbuf, 0))) {
- cbbuf = sizeof(wchar_t);
- buf[0] = L'\0';
- }
-
- if(ol)
- to = TFIRSTCHILD(ol);
- else
- to = tbl->outline;
-
- while(to) {
- if(!wcscmp(buf, to->header))
- break;
- to = LNEXT(to);
- }
-
- if(to) {
- /* found it */
- ol = to;
- } else {
- /* not found. create */
- to = cw_new_outline_node(buf);
- if(ol) {
- TADDCHILD(ol, to);
- } else {
- LPUSH(&(tbl->outline), to);
- }
- ol = to;
- ol->flags = KHUI_CW_O_EXPAND;
- ol->level = j;
- ol->col = grouping[j];
-
- if(tbl->cols[grouping[j]].attr_id == KCDB_ATTR_ID_NAME) {
- khm_handle h;
- if(KHM_SUCCEEDED(kcdb_identity_create(buf, 0, &h))) {
- ol->attr_id = KCDB_ATTR_ID;
- ol->data = (void *) h;
-
- /* the outline only lasts as long as the
- credential, and the credential has a hold
- on the identity. */
- kcdb_identity_release(h);
- }
- else
- ol->data = 0;
- } else if(tbl->cols[grouping[j]].attr_id ==
- KCDB_ATTR_TYPE_NAME) {
- khm_int32 t;
-
- ol->attr_id = KCDB_ATTR_TYPE;
- if(KHM_SUCCEEDED(kcdb_cred_get_type(thiscred, &t)))
- ol->data = (void *)(ssize_t) t;
- else
- ol->data = (void *)(ssize_t) KCDB_CREDTYPE_INVALID;
- } else {
- khm_int32 rv;
- khm_int32 alt_id;
- kcdb_attrib * attrib;
-
- rv =
- kcdb_attrib_get_info(tbl->cols[grouping[j]].attr_id,
- &attrib);
- assert(KHM_SUCCEEDED(rv));
-
- if (attrib->flags & KCDB_ATTR_FLAG_ALTVIEW)
- alt_id = attrib->alt_id;
- else
- alt_id = tbl->cols[grouping[j]].attr_id;
-
- ol->attr_id = alt_id;
-
- kcdb_attrib_release_info(attrib);
-
- rv = kcdb_cred_get_attr(thiscred,
- alt_id,
- NULL,
- NULL,
- &cbbuf);
- if (rv != KHM_ERROR_TOO_LONG || cbbuf == 0) {
- ol->data = NULL;
- } else {
- ol->data = PMALLOC(cbbuf);
- assert(ol->data);
- rv = kcdb_cred_get_attr(thiscred,
- alt_id,
- NULL,
- ol->data,
- &cbbuf);
- assert(KHM_SUCCEEDED(rv));
- ol->cb_data = cbbuf;
- ol->flags |= KHUI_CW_O_DATAALLOC;
- }
- }
- }
-
- /* now ol points at the node at level j we want to be
- in */
- ol->start = n_rows;
- ol->length = 0;
- ol->idx_start = i;
- ol->idx_end = i;
- ol->flags &= ~(CW_EXPSTATE_MASK |
- KHUI_CW_O_SHOWFLAG |
- KHUI_CW_O_STICKY |
- KHUI_CW_O_EMPTY);
-
- /* if the outline node is for an identity, then we have to
- check the expiration state for the identity. */
-
- if (ol->attr_id == KCDB_ATTR_ID) {
- khm_handle ident = (khm_handle) ol->data;
-
- flags = cw_get_buf_exp_flags(tbl, ident);
-
- if (flags) {
- ol->flags |= flags;
- ol->flags |= KHUI_CW_O_SHOWFLAG;
- } else if (grouping[j] == tbl->n_cols - 1) {
- /* if we aren't showing any creds under this
- outline level, we should also show any
- flags. */
- ol->flags |= KHUI_CW_O_SHOWFLAG;
- }
- }
-
- if (grouping[j] == tbl->n_cols - 1) {
- ol->flags |= KHUI_CW_O_NOOUTLINE;
- } else {
- ol->flags &= ~KHUI_CW_O_NOOUTLINE;
- }
-
- if(selected) {
- ol->flags |= KHUI_CW_O_SELECTED;
- }
- if(visible) {
- cw_set_tbl_row_header(tbl, n_rows, grouping[j], ol);
- n_rows ++;
- ol->flags |= KHUI_CW_O_VISIBLE;
- } else {
- ol->flags &= ~KHUI_CW_O_VISIBLE;
- }
- visible = visible && (ol->flags & KHUI_CW_O_EXPAND);
- selected = (selected || (ol->flags & KHUI_CW_O_SELECTED));
- }
-
- /* we need to do this here too just in case we were already at
- the level we were supposed to be in */
- if (ol) {
- visible = visible && (ol->flags & KHUI_CW_O_EXPAND);
- selected = (selected || (ol->flags & KHUI_CW_O_SELECTED));
- }
-
- if(visible && n_grouping > 0 &&
- grouping[n_grouping - 1] < tbl->n_cols - 1) {
- khm_int32 c_flags;
-
- cw_set_tbl_row_cred(tbl, n_rows, thiscred,
- grouping[n_grouping-1]);
-
- flags = cw_get_buf_exp_flags(tbl, thiscred);
- if(flags) {
- tbl->rows[n_rows].flags |= flags;
- }
-
- kcdb_cred_get_flags(thiscred, &c_flags);
- if(selected ||
- (c_flags & KCDB_CRED_FLAG_SELECTED)) {
- tbl->rows[n_rows].flags |= KHUI_CW_ROW_SELECTED;
- }
-
- tbl->rows[n_rows].idx_start = i;
- tbl->rows[n_rows].idx_end = i;
-
- n_rows++;
- }
-
- if(prevcred)
- kcdb_cred_release(prevcred);
- prevcred = thiscred;
- }
-
- while(ol) {
- /* close all open outline levels */
-
- ol->length = n_rows - ol->start;
- ol->idx_end = i - 1;
-
- if ((ol->flags & KHUI_CW_O_SELECTED) &&
- ol->length > 0) {
- tbl->n_rows = n_rows;
- cw_select_row_creds(tbl, ol->start, TRUE);
- }
-
- ol = TPARENT(ol);
- }
-
- if(prevcred) {
- kcdb_cred_release(prevcred);
- prevcred = NULL;
- }
-
- /* Add any default identities with no credentials and sticky
- identities that we haven't seen yet */
- if (n_grouping > 0 &&
- tbl->cols[grouping[0]].attr_id == KCDB_ATTR_ID_NAME) {
-
- khui_credwnd_outline * o;
- wchar_t * idnames = NULL;
- wchar_t * t;
- khm_size n_idents;
- khm_size cb_names;
- wchar_t ** idarray = NULL;
- int i;
-
- khm_int32 and_flags = 0;
- khm_int32 eq_flags = 0;
-
- /* see if the default identity is in the list */
- {
- khm_handle id_def = NULL;
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- khm_size cb;
- khm_int32 flags;
-
- if (KHM_FAILED(kcdb_identity_get_default(&id_def))) {
- goto done_with_defident;
- }
-
- kcdb_identity_get_flags(id_def, &flags);
- cb = sizeof(idname);
- kcdb_identity_get_name(id_def, idname, &cb);
-
- for (o = tbl->outline; o; o = LNEXT(o)) {
- if (!wcscmp(idname, o->header))
- break;
- }
-
- if (o == NULL) {
- o = cw_new_outline_node(idname);
- LPUSH(&tbl->outline, o);
- o->flags = KHUI_CW_O_RELIDENT;
- o->level = 0;
- o->col = grouping[0];
- o->data = id_def;
- o->attr_id = KCDB_ATTR_ID;
- o->start = -1;
- } else {
- kcdb_identity_release(id_def);
- }
-
- if (o->start != -1)
- goto done_with_defident;
-
- o->flags &= ~(KHUI_CW_O_SHOWFLAG |
- KHUI_CW_O_NOOUTLINE |
- KHUI_CW_O_STICKY);
- o->flags |= KHUI_CW_O_EXPAND | KHUI_CW_O_VISIBLE | KHUI_CW_O_EMPTY;
-
- if (flags & KCDB_IDENT_FLAG_STICKY)
- o->flags |= KHUI_CW_O_STICKY;
-
- o->start = n_rows;
- o->length = 1;
- o->idx_start = (khm_size) -1;
- o->idx_end = (khm_size) -1;
-
- if (grouping[0] == tbl->n_cols - 1)
- o->flags |= KHUI_CW_O_NOOUTLINE;
-
- cw_set_tbl_row_header(tbl, n_rows, grouping[0], o);
-
- n_rows ++;
-
- done_with_defident:
- ;
- }
-
- if (tbl->view_all_idents) {
- and_flags = 0;
- eq_flags = 0;
- } else {
- and_flags = KCDB_IDENT_FLAG_STICKY;
- eq_flags = KCDB_IDENT_FLAG_STICKY;
- }
-
- if (kcdb_identity_enum(and_flags,
- eq_flags,
- NULL,
- &cb_names,
- &n_idents) != KHM_ERROR_TOO_LONG ||
- n_idents == 0 ||
- cb_names == 0)
- goto _cleanup_sticky;
-
- idnames = PMALLOC(cb_names);
- idarray = PMALLOC(n_idents * sizeof(*idarray));
-#ifdef DEBUG
- assert(idnames);
- assert(idarray);
-#endif
-
- if (KHM_FAILED(kcdb_identity_enum(and_flags,
- eq_flags,
- idnames,
- &cb_names,
- &n_idents)))
- goto _cleanup_sticky;
-
- for (i=0, t=idnames; t && *t; t = multi_string_next(t), i++) {
- idarray[i] = t;
- }
-
- qsort(idarray, n_idents, sizeof(*idarray), iwcscmp);
-
- for (i=0; i < (int) n_idents; i++) {
- khm_handle h;
- khm_int32 f_sticky;
- khm_int32 flags;
-
- if (KHM_FAILED(kcdb_identity_create(idarray[i],
- KCDB_IDENT_FLAG_CREATE, &h)))
- continue;
-
- kcdb_identity_get_flags(h, &flags);
-
- if (flags & KCDB_IDENT_FLAG_STICKY)
- f_sticky = KHUI_CW_O_STICKY;
- else
- f_sticky = 0;
-
- for (o = tbl->outline; o; o = LNEXT(o)) {
- if (!wcscmp(idarray[i], o->header))
- break;
- }
-
- if (o) {
- /* found it */
- if (o->start != -1) /* already visible? */
- continue;
- o->flags &= (KHUI_CW_O_RELIDENT | KHUI_CW_O_SELECTED);
- o->flags |= f_sticky | KHUI_CW_O_VISIBLE | KHUI_CW_O_EMPTY;
-
- if (!kcdb_identity_is_equal(o->data, h)) {
- if (o->flags & KHUI_CW_O_RELIDENT)
- kcdb_identity_release(o->data);
- o->data = h;
- o->flags |= KHUI_CW_O_RELIDENT;
- kcdb_identity_hold(h);
- }
- } else {
- /* not found. create */
- o = cw_new_outline_node(idarray[i]);
- LPUSH(&tbl->outline, o);
- o->flags = f_sticky | KHUI_CW_O_VISIBLE | KHUI_CW_O_EMPTY | KHUI_CW_O_RELIDENT;
- o->level = 0;
- o->col = grouping[0];
- o->data = h;
- kcdb_identity_hold(h);
- o->attr_id = KCDB_ATTR_ID;
- }
-
- if (grouping[0] == tbl->n_cols - 1)
- o->flags |= KHUI_CW_O_NOOUTLINE;
-
- kcdb_identity_release(h);
-
- o->flags &= ~KHUI_CW_O_EXPAND;
- o->start = n_rows;
- o->length = 1;
- o->idx_start = (khm_size) -1;
- o->idx_end = (khm_size) -1;
-
- cw_set_tbl_row_header(tbl, n_rows, grouping[0], o);
-
- n_rows ++;
- }
-
- _cleanup_sticky:
- if (idnames)
- PFREE(idnames);
- if (idarray)
- PFREE(idarray);
- }
-
- tbl->n_rows = n_rows;
- tbl->flags |= KHUI_CW_TBL_ROW_DIRTY;
-
- tbl->flags &= ~KHUI_CW_TBL_COL_DIRTY;
-
- if (tbl->cursor_row >= tbl->n_rows)
- tbl->cursor_row = tbl->n_rows - 1;
- if (tbl->cursor_row < 0)
- tbl->cursor_row = 0;
-
-_exit:
-
- {
- khm_handle def_ident = NULL;
- khm_int32 def_expstate = 0;
- khm_boolean def_empty = TRUE;
-
- kcdb_identity_get_default(&def_ident);
- if (def_ident) {
- khui_credwnd_ident * cwi;
-
- cwi = cw_find_ident(tbl, def_ident);
- if (cwi) {
- def_empty = (cwi->id_credcount == 0);
- }
-
- def_expstate = cw_get_buf_exp_flags(tbl, def_ident);
- }
-
- if (def_empty)
- khm_notify_icon_expstate(KHM_NOTIF_EMPTY);
- else if ((def_expstate & CW_EXPSTATE_EXPIRED) == CW_EXPSTATE_EXPIRED)
- khm_notify_icon_expstate(KHM_NOTIF_EXP);
- else if ((def_expstate & CW_EXPSTATE_WARN) == CW_EXPSTATE_WARN ||
- (def_expstate & CW_EXPSTATE_CRITICAL) == CW_EXPSTATE_CRITICAL)
- khm_notify_icon_expstate(KHM_NOTIF_WARN);
- else
- khm_notify_icon_expstate(KHM_NOTIF_OK);
- }
-}
-
-void
-cw_unload_view(khui_credwnd_tbl * tbl)
-{
-#define SafeDeleteObject(o) \
- do { \
- if(o) { \
- DeleteObject(o); \
- o = NULL; \
- } \
- } while(0)
-
- SafeDeleteObject(tbl->hf_header);
- SafeDeleteObject(tbl->hf_normal);
- SafeDeleteObject(tbl->hf_bold);
- SafeDeleteObject(tbl->hf_bold_header);
-
- SafeDeleteObject(tbl->hb_grey);
- SafeDeleteObject(tbl->hb_normal);
- SafeDeleteObject(tbl->hb_s);
-
- SafeDeleteObject(tbl->hb_hdr_bg);
- SafeDeleteObject(tbl->hb_hdr_bg_crit);
- SafeDeleteObject(tbl->hb_hdr_bg_exp);
- SafeDeleteObject(tbl->hb_hdr_bg_warn);
- SafeDeleteObject(tbl->hb_hdr_bg_cred);
-
- SafeDeleteObject(tbl->hb_hdr_bg_s);
- SafeDeleteObject(tbl->hb_hdr_bg_crit_s);
- SafeDeleteObject(tbl->hb_hdr_bg_exp_s);
- SafeDeleteObject(tbl->hb_hdr_bg_warn_s);
- SafeDeleteObject(tbl->hb_hdr_bg_cred_s);
-
-#undef SafeDeleteObject
-
- if (tbl->hi_lg_ident) {
- DestroyIcon(tbl->hi_lg_ident);
- tbl->hi_lg_ident = NULL;
- }
-
- if(tbl->credset) {
- kcdb_credset_delete(tbl->credset);
- tbl->credset = NULL;
- }
- if(tbl->ilist) {
- khui_delete_ilist(tbl->ilist);
- tbl->ilist = NULL;
- }
-
- if(tbl->cols) {
- int i;
-
- for(i=0; i < tbl->n_cols; i++) {
- if(tbl->cols[i].title)
- PFREE(tbl->cols[i].title);
- Header_DeleteItem(tbl->hwnd_header, 0);
-
- if (tbl->cols[i].attr_id >= 0 &&
- tbl->cols[i].attr_id <= KCDB_ATTR_MAX_ID &&
- attr_to_action[tbl->cols[i].attr_id]) {
-
- khui_check_action(attr_to_action[tbl->cols[i].attr_id], FALSE);
-
- }
- }
- PFREE(tbl->cols);
- tbl->cols = NULL;
- tbl->n_cols = 0;
- tbl->n_total_cols = 0;
-
- kmq_post_message(KMSG_ACT, KMSG_ACT_REFRESH, 0, 0);
- }
-
- if(tbl->rows) {
- PFREE(tbl->rows);
- tbl->rows = NULL;
- tbl->n_rows = 0;
- tbl->n_total_rows = 0;
- }
-
- khui_delete_bitmap(&tbl->kbm_logo_shade);
-
- if (tbl->csp_view) {
- khc_close_space(tbl->csp_view);
- tbl->csp_view = NULL;
- }
-
- tbl->cell_height = 0; /* recalculate cell height next time */
-
- if (tbl->idents) {
- khm_size i;
-
- for (i=0; i < tbl->n_idents; i++) {
- if (tbl->idents[i].ident) {
- kcdb_identity_release(tbl->idents[i].ident);
- }
- }
-
- PFREE(tbl->idents);
- tbl->idents = NULL;
- tbl->n_idents = 0;
- tbl->nc_idents = 0;
- }
-}
-
-void
-cw_hditem_from_tbl_col(khui_credwnd_col * col, HDITEM *phi)
-{
- size_t cchsize;
-
- phi->mask = HDI_FORMAT | HDI_LPARAM | HDI_WIDTH;
- if(cw_is_custom_attr(col->attr_id)) {
- if(col->attr_id == CW_CA_FLAGS) {
- phi->fmt = 0;
- } else if(col->attr_id == CW_CA_TYPEICON) {
- phi->fmt = 0;
- } else {
- /* what the? */
- /*TODO: throw up and die */
- }
- } else {
- phi->mask |= HDI_TEXT;
- phi->pszText = col->title;
- StringCchLength(col->title, KCDB_MAXCCH_SHORT_DESC, &cchsize);
- phi->cchTextMax = (int) cchsize;
- phi->fmt = HDF_CENTER | HDF_STRING;
- }
- phi->lParam = col->attr_id;
-#if (_WIN32_WINNT >= 0x501)
- if (IS_COMMCTL6()) {
- if(col->flags & KHUI_CW_COL_SORT_INC) {
- phi->fmt |= HDF_SORTUP;
- } else if(col->flags & KHUI_CW_COL_SORT_DEC) {
- phi->fmt |= HDF_SORTDOWN;
- }
- }
-#endif
- if(col->width < 0) {
- /*TODO: come up with a better way to handle this case */
- col->width = 200;
- }
- phi->cxy = col->width;
-}
-
-int
-cw_get_cell_height(HDC hdc, HFONT hf) {
- SIZE size;
- size_t cbbuf;
- wchar_t buf[64];
- HFONT hfold = NULL;
-
- if (hf)
- hfold = SelectFont(hdc, hf);
-
- LoadString(khm_hInstance, IDS_SAMPLE_STRING, buf, sizeof(buf)/sizeof(buf[0]));
- StringCchLength(buf, sizeof(buf)/sizeof(buf[0]), &cbbuf);
- GetTextExtentPoint32(hdc, buf, (int) cbbuf, &size);
-
- if (hf)
- SelectFont(hdc, hfold);
-
- return size.cy;
-}
-
-int
-cw_update_header_column_width(khui_credwnd_tbl * tbl, int c) {
- int idx;
- HDITEM hi;
-
-#ifdef DEBUG
- assert(c >= 0 && c < tbl->n_cols);
-#endif
-
- if (tbl->hwnd_header == NULL)
- return 0;
-
- idx = Header_OrderToIndex(tbl->hwnd_header, c);
- ZeroMemory(&hi, sizeof(hi));
- hi.mask = HDI_WIDTH;
- hi.cxy = tbl->cols[c].width;
- return Header_SetItem(tbl->hwnd_header, idx, &hi);
-}
-
-/* returns a bitmask indicating which measures were changed */
-int
-cw_update_extents(khui_credwnd_tbl * tbl,
- khm_boolean update_scroll) {
- int ext_x = 0;
- int ext_y = 0;
- int i;
- int filler_col = -1;
- int fill_adjusted = 0;
-
- recompute_columns:
-
- ext_x = 0;
- for(i=0; i < (int) tbl->n_cols; i++) {
- tbl->cols[i].x = ext_x;
- if (tbl->cols[i].flags & KHUI_CW_COL_FILLER) {
- if (filler_col == -1)
- filler_col = i;
- }
- ext_x += tbl->cols[i].width;
- }
-
- if (filler_col != -1 && !fill_adjusted) {
- RECT r;
- int delta;
-
- GetClientRect(tbl->hwnd, &r);
-
- /* we decrement the width so that the width data area is
- strictly less than the width of the client area. Windows
- doesn't disable a scrollbar unless the range is strictly
- less than the page size. */
- delta = ((r.right - r.left) - 1) - ext_x;
-
- if (tbl->cols[filler_col].width + delta <= GetSystemMetrics(SM_CXSMICON)) {
- tbl->cols[filler_col].width = GetSystemMetrics(SM_CXICON);
- } else {
- tbl->cols[filler_col].width += delta;
- }
-
- cw_update_header_column_width(tbl, filler_col);
-
- fill_adjusted = 1;
- goto recompute_columns;
- }
-
- if(!tbl->cell_height) {
- HDC dc;
- int maxheight = 0;
- int height;
-
- dc = GetWindowDC(tbl->hwnd);
-
- maxheight = cw_get_cell_height(dc, tbl->hf_normal);
- height = cw_get_cell_height(dc, tbl->hf_bold);
- if (height > maxheight)
- maxheight = height;
- height = cw_get_cell_height(dc, tbl->hf_header);
- if (height > maxheight)
- maxheight = height;
- height = cw_get_cell_height(dc, tbl->hf_bold_header);
- if (height > maxheight)
- maxheight = height;
-
- ReleaseDC(tbl->hwnd, dc);
-
- tbl->cell_height = height + tbl->vpad * 2;
- }
-
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
- RECT r;
-
- ext_y = 0;
- r.left = 0;
- r.right = ext_x;
-
- for (i=0; i < (int) tbl->n_rows; i++) {
- r.top = ext_y;
- if (tbl->rows[i].flags & KHUI_CW_ROW_EXPVIEW) {
- ext_y += tbl->cell_height * CW_EXP_ROW_MULT;
- } else {
- ext_y += tbl->cell_height;
- }
- r.bottom = ext_y;
- tbl->rows[i].r_ext = r;
- }
- } else {
- RECT r;
-
- r.left = 0;
- r.right = ext_x;
-
- for (i=0; i < (int) tbl->n_rows; i++) {
- r.top = i * tbl->cell_height;
- r.bottom = r.top + tbl->cell_height;
-
- tbl->rows[i].r_ext = r;
- }
-
- ext_y = (int) tbl->n_rows * tbl->cell_height;
- }
-
- tbl->ext_width = ext_x;
- tbl->ext_height = ext_y;
-
- /* useful in the future when implementing variable height rows.
- The KHUI_CW_TBL_ROW_DIRTY bit indicates that the rows have
- changed and that the y extent has to be recalculated. */
- tbl->flags &= ~KHUI_CW_TBL_ROW_DIRTY;
-
- if(update_scroll) {
- RECT r;
- int cl_w;
- int cl_h;
- SCROLLINFO si;
- WINDOWPOS pw;
- HDLAYOUT hdl;
-
- /* update the header control first */
-
- retry_update_scroll:
- GetClientRect(tbl->hwnd, &r);
-
- cl_w = r.right - r.left;
- cl_h = (r.bottom - r.top);
- cl_h -= tbl->header_height;
-
- if(tbl->scr_top < 0 || tbl->ext_height < cl_h)
- tbl->scr_top = 0;
- else if(tbl->scr_top > tbl->ext_height - cl_h)
- tbl->scr_top = tbl->ext_height - cl_h;
- if(tbl->scr_left < 0 || tbl->ext_width < cl_w)
- tbl->scr_left = 0;
- else if(tbl->scr_left > tbl->ext_width - cl_w)
- tbl->scr_left = tbl->ext_width - cl_w;
-
- /* adjustments for scrolling */
- r.left -= tbl->scr_left;
- r.right = max(tbl->ext_width + r.left, r.right);
-
- hdl.prc = &r;
- hdl.pwpos = &pw;
-
- Header_Layout(tbl->hwnd_header, &hdl);
-
- if(tbl->header_height == 0) {
- tbl->header_height = pw.cy;
- goto retry_update_scroll;
- } else
- tbl->header_height = pw.cy;
-
- SetWindowPos(
- tbl->hwnd_header,
- pw.hwndInsertAfter,
- pw.x,
- pw.y,
- pw.cx,
- pw.cy,
- pw.flags);
-
- si.cbSize = sizeof(si);
- si.nMin = 0;
- si.nMax = tbl->ext_height;
- si.nPage = cl_h;
- si.nPos = tbl->scr_top;
- si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
- SetScrollInfo(tbl->hwnd, SB_VERT, &si, TRUE);
-
- si.cbSize = sizeof(si);
- si.nMin = 0;
- si.nMax = tbl->ext_width;
- si.nPage = cl_w;
- si.nPos = tbl->scr_left;
- si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
- SetScrollInfo(tbl->hwnd, SB_HORZ, &si, TRUE);
- }
-
- return 0;
-}
-
-void
-cw_insert_header_cols(khui_credwnd_tbl * tbl) {
- HWND hdr;
- HDITEM hi;
- int i;
-
- hdr = tbl->hwnd_header;
-
- for(i=0; i < (int) tbl->n_cols; i++) {
- cw_hditem_from_tbl_col(&(tbl->cols[i]), &hi);
- Header_InsertItem(hdr, 512, &hi);
- }
-}
-
-#define CW_ER_BLANK 0
-#define CW_ER_GREY 1
-#define CW_ER_SEL 2
-
-#pragma warning(push)
-#pragma warning(disable: 4701)
-void
-cw_erase_rect(HDC hdc,
- khui_credwnd_tbl * tbl,
- RECT * r_wnd,
- RECT * r_erase,
- int type)
-{
- RECT rlogo;
- RECT ri;
- RECT t;
- BOOL rie;
- HBRUSH hbr;
-
- switch(type) {
- case CW_ER_BLANK:
- hbr = tbl->hb_normal;
- break;
-
- case CW_ER_GREY:
- hbr = tbl->hb_grey;
- break;
-
- case CW_ER_SEL:
- hbr = tbl->hb_s;
- break;
-
- default:
- return;
- }
-
- if(tbl->kbm_logo_shade.cx != -1 && type == CW_ER_BLANK) {
- rlogo.left = r_wnd->right - tbl->kbm_logo_shade.cx;
- rlogo.right = r_wnd->right;
- rlogo.top = r_wnd->bottom - tbl->kbm_logo_shade.cy;
- rlogo.bottom = r_wnd->bottom;
- if (bHideWatermarks) {rie = FALSE;}
- else {rie = IntersectRect(&ri, r_erase, &rlogo);}
- } else {
- ZeroMemory(&rlogo, sizeof(rlogo));
- ZeroMemory(&ri, sizeof(ri));
- rie = FALSE;
- }
-
- if(!rie) {
- FillRect(hdc, r_erase, hbr);
- } else {
- HDC hdcb = CreateCompatibleDC(hdc);
- HBITMAP hbmold = SelectObject(hdcb, tbl->kbm_logo_shade.hbmp);
-
- BitBlt(hdc, ri.left, ri.top, ri.right - ri.left, ri.bottom - ri.top,
- hdcb, ri.left - rlogo.left, ri.top - rlogo.top, SRCCOPY);
-
- SelectObject(hdcb, hbmold);
- DeleteDC(hdcb);
-
- if(r_erase->top < ri.top && r_erase->left < ri.left) {
- t.left = r_erase->left;
- t.top = r_erase->top;
- t.right = ri.left;
- t.bottom = ri.top;
- FillRect(hdc, &t, hbr);
- }
-
- if(r_erase->left < ri.left) {
- t.left = r_erase->left;
- t.top = ri.top;
- t.right = ri.left;
- t.bottom = ri.bottom;
- FillRect(hdc, &t, hbr);
- }
-
- if(r_erase->top < ri.top) {
- t.left = ri.left;
- t.top = r_erase->top;
- t.right = ri.right;
- t.bottom = ri.top;
- FillRect(hdc, &t, hbr);
- }
- }
-}
-#pragma warning(pop)
-
-void
-cw_draw_header(HDC hdc,
- khui_credwnd_tbl * tbl,
- int row,
- RECT * r)
-{
- int colattr;
- HPEN pl, pold;
- khui_credwnd_row * cr;
- khui_credwnd_outline * o;
- int selected = 0;
- khm_int32 idf = 0;
- khui_credwnd_ident * cwi = NULL;
-
- /* each header consists of a couple of widgets and some text */
- /* we need to figure out the background color first */
-
- cr = &(tbl->rows[row]);
- o = (khui_credwnd_outline *) cr->data;
-
- colattr = tbl->cols[cr->col].attr_id;
-
- if (colattr == KCDB_ATTR_ID_NAME) {
- khm_handle ident = o->data;
-
- kcdb_identity_get_flags(ident, &idf);
- cwi = cw_find_ident(tbl, ident);
- }
-
- selected = o->flags & KHUI_CW_O_SELECTED;
-
- {
- HBRUSH hbr;
-
- if(selected) {
- if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_EXPIRED)
- hbr = tbl->hb_hdr_bg_exp_s;
- else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_CRITICAL)
- hbr = tbl->hb_hdr_bg_crit_s;
- else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_WARN)
- hbr = tbl->hb_hdr_bg_warn_s;
- else if ((colattr == KCDB_ATTR_ID_NAME) && !(o->flags & KHUI_CW_O_EMPTY) &&
- cwi && cwi->id_credcount > 0)
- hbr = tbl->hb_hdr_bg_cred_s;
- else
- hbr = tbl->hb_hdr_bg_s;
- } else {
- if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_EXPIRED)
- hbr = tbl->hb_hdr_bg_exp;
- else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_CRITICAL)
- hbr = tbl->hb_hdr_bg_crit;
- else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_WARN)
- hbr = tbl->hb_hdr_bg_warn;
- else if ((colattr == KCDB_ATTR_ID_NAME) && !(o->flags & KHUI_CW_O_EMPTY) &&
- cwi && cwi->id_credcount > 0)
- hbr = tbl->hb_hdr_bg_cred;
- else
- hbr = tbl->hb_hdr_bg;
- }
-
- FillRect(hdc, r, hbr);
- }
-
- /* draw the background */
- pl = CreatePen(PS_SOLID, 0, tbl->cr_hdr_outline);
- pold = SelectObject(hdc, pl);
- MoveToEx(hdc, r->left, r->bottom - 1, NULL);
- LineTo(hdc,r->right,r->bottom - 1);
- SelectObject(hdc, pold);
- DeleteObject(pl);
-
- if (!(o->flags & KHUI_CW_O_NOOUTLINE) &&
- !(o->flags & KHUI_CW_O_EMPTY)) {
- if((tbl->mouse_state & CW_MOUSE_WOUTLINE) &&
- tbl->mouse_row == row) {
- if(o->flags & KHUI_CW_O_EXPAND) {
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND_HI,
- hdc, r->left,
- (r->top + r->bottom - KHUI_SMICON_CY) / 2, 0);
- } else {
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE_HI,
- hdc, r->left,
- (r->top + r->bottom - KHUI_SMICON_CY) / 2, 0);
- }
- } else {
- if(o->flags & KHUI_CW_O_EXPAND) {
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND,
- hdc, r->left,
- (r->top + r->bottom - KHUI_SMICON_CY) / 2, 0);
- } else {
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE,
- hdc, r->left,
- (r->top + r->bottom - KHUI_SMICON_CY) / 2, 0);
- }
- }
-
- r->left += KHUI_SMICON_CX * 3 / 2;
- } else if (!(o->flags & KHUI_CW_O_NOOUTLINE)) {
- r->left += KHUI_SMICON_CX * 3 / 2;
- }
-
- /* try to draw the icon, if there is one */
- if(colattr == KCDB_ATTR_ID_NAME) {
-
- khui_ilist_draw_id(tbl->ilist,
- (((tbl->mouse_state & CW_MOUSE_WSTICKY) &&
- tbl->mouse_row == row)?
- ((idf & KCDB_IDENT_FLAG_STICKY)?
- IDB_WDG_STUCK_HI:
- IDB_WDG_STICK_HI):
- ((idf & KCDB_IDENT_FLAG_STICKY)?
- IDB_WDG_STUCK:
- IDB_WDG_STICK)),
- hdc,
- r->left,
- (r->top + r->bottom - KHUI_SMICON_CY) / 2, 0);
-
- r->left += KHUI_SMICON_CX * 3 / 2;
-
- /* the TRUE part of the 'if' is for drawing large icons. It's
- disabled for now until we have new icons. */
- if ((cr->flags & KHUI_CW_ROW_EXPVIEW) && FALSE) {
- int cx = GetSystemMetrics(SM_CXICON);
- int cy = GetSystemMetrics(SM_CYICON);
-
- DrawIcon(hdc, r->left, (r->top + r->bottom - cy) / 2, tbl->hi_lg_ident);
-
- r->left += cx + KHUI_SMICON_CX / 2;
-
- } else {
- khui_ilist_draw_id(tbl->ilist,
- (((o->flags & KHUI_CW_O_EMPTY) ||
- cwi == NULL || cwi->id_credcount == 0)?
- IDB_ID_DIS_SM:
- IDB_ID_SM),
- hdc,
- r->left,
- (r->top + r->bottom - KHUI_SMICON_CY) / 2, 0);
- r->left += KHUI_SMICON_CX * 3 / 2 ;
- }
- }
-
-
- if (!(cr->flags & KHUI_CW_ROW_EXPVIEW)) {
-
- SetTextAlign(hdc, TA_BOTTOM | TA_LEFT);
-
- if(selected)
- SetTextColor(hdc, tbl->cr_hdr_s);
- else
- SetTextColor(hdc, tbl->cr_hdr_normal);
-
- TextOut(hdc, r->left, r->bottom - tbl->vpad, o->header, (int) wcslen(o->header));
-
- if (colattr == KCDB_ATTR_ID_NAME &&
- (idf & KCDB_IDENT_FLAG_DEFAULT)) {
- wchar_t defstr[64];
- SIZE size;
-
- LoadString(khm_hInstance, IDS_CW_DEFAULT,
- defstr, ARRAYLENGTH(defstr));
-
- GetTextExtentPoint32(hdc, o->header, (int) wcslen(o->header),
- &size);
-
- r->left += size.cx + KHUI_SMICON_CX * 2;
-
- TextOut(hdc, r->left, r->bottom - tbl->vpad,
- defstr, (int) wcslen(defstr));
- }
- } else {
-
- RECT tr;
- int len;
- wchar_t typestr[128];
- int cx_id;
- SIZE size;
-
- /* expanded view */
-#ifdef DEBUG
- assert(colattr == KCDB_ATTR_ID_NAME);
-#endif
-
- CopyRect(&tr, r);
- tr.bottom -= (tr.bottom - tr.top) / 2; /* drawing two lines of text */
-
- if (selected)
- SetTextColor(hdc, tbl->cr_hdr_s);
- else
- SetTextColor(hdc, tbl->cr_hdr_normal);
-
- len = (int) wcslen(o->header);
- DrawText(hdc, o->header, len, &tr, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
- GetTextExtentPoint32(hdc, o->header, (int) len, &size);
- cx_id = size.cx;
-
- typestr[0] = L'\0';
-
- if ((idf & KCDB_IDENT_FLAG_DEFAULT)) {
- if (cwi && cwi->credtype_name[0]) {
- wchar_t fmt[64];
-
- LoadString(khm_hInstance, IDS_CW_DEFAULTTF,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(typestr, sizeof(typestr), fmt,
- cwi->credtype_name);
- } else {
- LoadString(khm_hInstance, IDS_CW_DEFAULT,
- typestr, ARRAYLENGTH(typestr));
- }
- } else if (cwi && cwi->credtype_name[0]) {
- wchar_t fmt[64];
-
- LoadString(khm_hInstance, IDS_CW_TYPEF,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(typestr, sizeof(typestr), fmt,
- cwi->credtype_name);
- }
-
- if (typestr[0]) {
- int cx_str;
-
- len = (int) wcslen(typestr);
- GetTextExtentPoint32(hdc, typestr, (int) len, &size);
- cx_str = size.cx + KHUI_SMICON_CX / 2;
-
- tr.left = max(tr.right - cx_str, tr.left + cx_id + KHUI_SMICON_CX * 2);
- if (selected)
- SetTextColor(hdc, tbl->cr_hdr_s);
- else
- SetTextColor(hdc, tbl->cr_hdr_normal);
- DrawText(hdc, typestr, len, &tr, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
- }
-
- CopyRect(&tr, r);
- tr.top += (tr.bottom - tr.top) / 2;
-
- if (1) {
- wchar_t buf[128];
- khui_credwnd_ident * cwi;
-
- buf[0] = L'\0';
- cwi = cw_find_ident(tbl, o->data);
-
- if (cwi) {
-#ifdef SHOW_CREDENTIAL_COUNTS
- if (cwi->credcount == 0)
- LoadString(khm_hInstance, IDS_IDEXPDISP_NOCRED,
- buf, ARRAYLENGTH(buf));
- else if (cwi->credcount == 1)
- LoadString(khm_hInstance, IDS_IDEXPDISP_1CRED,
- buf, ARRAYLENGTH(buf));
- else {
- wchar_t fmt[128];
- LoadString(khm_hInstance, IDS_IDEXPDISP_NCRED,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, (int) cwi->credcount);
- }
-#else
- if (FtToInt(&cwi->ft_expire) != 0) {
- FILETIME ft_now;
-
- GetSystemTimeAsFileTime(&ft_now);
- if (CompareFileTime(&cwi->ft_expire, &ft_now) > 0) {
- wchar_t fmt[64];
- wchar_t intstr[128];
- FILETIME ft;
- khm_size cb;
-
- ft = FtSub(&cwi->ft_expire, &ft_now);
- intstr[0] = L'\0';
- cb = sizeof(intstr);
- FtIntervalToString(&ft, intstr, &cb);
-
- LoadString(khm_hInstance, IDS_CW_EXPIREF,
- fmt, ARRAYLENGTH(fmt));
- StringCbPrintf(buf, sizeof(buf), fmt, intstr);
- } else {
- LoadString(khm_hInstance, IDS_CW_EXPIRED,
- buf, ARRAYLENGTH(buf));
- }
- }
-#endif
-
- len = (int) wcslen(buf);
-
- if (selected)
- SetTextColor(hdc, tbl->cr_hdr_s);
- else
- SetTextColor(hdc, tbl->cr_hdr_normal);
- DrawText(hdc, buf, len, &tr, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
- }
- }
- }
-}
-
-LRESULT
-cw_handle_header_msg(khui_credwnd_tbl * tbl, LPNMHEADER ph) {
- HDITEM hi;
-
- switch(ph->hdr.code) {
- /*TODO:Make it track smoother */
- case HDN_BEGINTRACK:
- {
- ZeroMemory(&hi, sizeof(hi));
- hi.mask = HDI_ORDER;
- Header_GetItem(tbl->hwnd_header, ph->iItem, &hi);
-
- if (tbl->cols[hi.iOrder].flags & (KHUI_CW_COL_FIXED_WIDTH |
- KHUI_CW_COL_FILLER))
- return TRUE;
- else
- return FALSE;
- }
-
- case HDN_TRACK:
- return FALSE;
-
- case HDN_ENDTRACK:
- {
- hi.mask = HDI_ORDER;
- Header_GetItem(ph->hdr.hwndFrom, ph->iItem, &hi);
- if(ph->pitem->cxy != tbl->cols[hi.iOrder].width) {
- tbl->cols[hi.iOrder].width = ph->pitem->cxy;
- cw_update_extents(tbl, TRUE);
- InvalidateRect(tbl->hwnd, NULL, FALSE);
- }
- }
- break;
-
- case HDN_BEGINDRAG:
- {
-
- ZeroMemory(&hi, sizeof(hi));
- hi.mask = HDI_ORDER;
- Header_GetItem(tbl->hwnd_header, ph->iItem, &hi);
-
- if (tbl->cols[hi.iOrder].flags & KHUI_CW_COL_FIXED_POS) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
- break;
-
- case HDN_ENDDRAG:
- {
- int drag_start_index;
- int drag_end_index;
- int i;
- khui_credwnd_col tcol;
- int sort_index = 0;
- khm_int32 old_flags;
-
- if (ph->pitem == NULL)
- return TRUE;
-
- hi.mask = HDI_ORDER;
- Header_GetItem(tbl->hwnd_header, ph->iItem, &hi);
- drag_start_index = hi.iOrder;
- drag_end_index = ph->pitem->iOrder;
-
- /* the user dragged the column which was at drag_start_index
- to drag_end_index. */
-
- if (drag_end_index == drag_start_index)
- return TRUE;
-
- /* we don't allow dragging in to the "fixed" area. */
- for (i=0; i < tbl->n_cols; i++) {
- if (!(tbl->cols[i].flags & KHUI_CW_COL_FIXED_POS))
- break;
- }
-
- if (drag_end_index <= i)
- return TRUE;
-
- tcol = tbl->cols[drag_start_index];
- if (drag_end_index < drag_start_index) {
- MoveMemory(&tbl->cols[drag_end_index + 1],
- &tbl->cols[drag_end_index],
- sizeof(tbl->cols[0]) *
- (drag_start_index - drag_end_index));
- } else {
- MoveMemory(&tbl->cols[drag_start_index],
- &tbl->cols[drag_start_index + 1],
- sizeof(tbl->cols[0]) *
- (drag_end_index - drag_start_index));
- }
- tbl->cols[drag_end_index] = tcol;
-
- old_flags = tbl->cols[drag_end_index].flags;
-
- if (drag_end_index < tbl->n_cols - 1) {
- khm_int32 tflags = tbl->cols[drag_end_index + 1].flags;
-
- if (tflags & KHUI_CW_COL_GROUP) {
- tbl->cols[drag_end_index].flags |= KHUI_CW_COL_GROUP;
- }
-
- if ((tflags & (KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC)) &&
- !(old_flags & (KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC)))
- tbl->cols[drag_end_index].flags |= KHUI_CW_COL_SORT_INC;
- }
-
- if (drag_end_index > 0) {
- khm_int32 tflags = tbl->cols[drag_end_index - 1].flags;
-
- if (!(tflags & KHUI_CW_COL_GROUP))
- tbl->cols[drag_end_index].flags &= ~KHUI_CW_COL_GROUP;
-
- if (!(tflags & (KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC)))
- tbl->cols[drag_end_index].flags &=
- ~(KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC);
- }
-
- if (old_flags != tbl->cols[drag_end_index].flags) {
- cw_hditem_from_tbl_col(&tbl->cols[drag_end_index], &hi);
- hi.mask = HDI_FORMAT;
- Header_SetItem(tbl->hwnd_header, ph->iItem, &hi);
- }
-
- if ((old_flags ^ tbl->cols[drag_end_index].flags) &
- KHUI_CW_COL_GROUP)
- tbl->flags |= KHUI_CW_TBL_COL_DIRTY;
-
- for (i=0; i < tbl->n_cols; i++) {
- if (tbl->cols[i].attr_id < 0)
- continue;
-
- if (tbl->cols[i].flags &
- (KHUI_CW_COL_GROUP |
- KHUI_CW_COL_SORT_INC |
- KHUI_CW_COL_SORT_DEC))
- tbl->cols[i].sort_index = sort_index++;
- else
- break;
- }
-
- tbl->flags |= KHUI_CW_TBL_CUSTVIEW;
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, FALSE);
-
- return FALSE;
- }
- break;
-
- case HDN_ITEMCLICK:
- {
- int idx;
- int hidx;
-
- hi.mask = HDI_ORDER;
- Header_GetItem(tbl->hwnd_header, ph->iItem, &hi);
- idx = hi.iOrder;
-
- if (idx < 0 || idx >= tbl->n_cols)
- return FALSE;
-
- if (tbl->cols[idx].flags & KHUI_CW_COL_META)
- return FALSE;
-
- if (tbl->cols[idx].flags &
- (KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC)) {
-
- tbl->cols[idx].flags ^=
- (KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC);
-
- cw_hditem_from_tbl_col(&tbl->cols[idx], &hi);
- hi.mask = HDI_FORMAT;
- Header_SetItem(tbl->hwnd_header, ph->iItem, &hi);
-
- } else {
- int i;
- int sort_idx = 0;
-
- for (i=0; i <= idx; i++) {
- if (tbl->cols[i].attr_id < 0)
- continue;
-
- if (!(tbl->flags &
- (KHUI_CW_COL_SORT_INC | KHUI_CW_COL_SORT_DEC))) {
- tbl->cols[i].flags |= KHUI_CW_COL_SORT_INC;
-
- cw_hditem_from_tbl_col(&tbl->cols[i], &hi);
- hi.mask = HDI_FORMAT;
- hidx = Header_OrderToIndex(tbl->hwnd_header, i);
- Header_SetItem(tbl->hwnd_header, hidx, &hi);
- }
-
- tbl->cols[i].sort_index = sort_idx++;
- }
- }
-
- tbl->flags |= KHUI_CW_TBL_CUSTVIEW;
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, FALSE);
-
- }
- break;
-
- case HDN_ITEMDBLCLICK:
- {
- int idx;
- int hidx;
-
- hi.mask = HDI_ORDER;
- Header_GetItem(tbl->hwnd_header, ph->iItem, &hi);
- idx = hi.iOrder;
-
- if (idx == 0 || idx >= tbl->n_cols)
- return FALSE;
-
- if (tbl->cols[idx].flags & KHUI_CW_COL_GROUP) {
- /* we are removing grouping from this level */
-
- int i;
-
- for (i=idx; i < tbl->n_cols; i++) {
- if (!(tbl->cols[i].flags & KHUI_CW_COL_GROUP))
- break;
-
- tbl->cols[i].flags &= ~KHUI_CW_COL_GROUP;
-
- cw_hditem_from_tbl_col(&tbl->cols[idx], &hi);
- hi.mask = HDI_FORMAT;
- hidx = Header_OrderToIndex(tbl->hwnd_header, i);
- Header_SetItem(tbl->hwnd_header, hidx, &hi);
- }
-
-#if 0
- } else if (tbl->cols[idx].flags &
- (KHUI_CW_COL_SORT_INC |
- KHUI_CW_COL_SORT_DEC)) {
- int i;
-
- /* remove the sort condition from a column */
-
- for (i=idx; i < tbl->n_cols; i++) {
- if (!tbl->cols[i].flags &
- (KHUI_CW_COL_SORT_INC |
- KHUI_CW_COL_SORT_DEC))
- break;
-
- tbl->cols[i].flags &=
- ~(KHUI_CW_COL_SORT_INC |
- KHUI_CW_COL_SORT_DEC);
-
- cw_hditem_from_tbl_col(&tbl->cols[idx], &hi);
- hi.mask = HDI_FORMAT;
- hidx = Header_OrderToIndex(tbl->hwnd_header, i);
- Header_SetItem(tbl->hwnd_header, hidx, &hi);
- }
-#endif
- } else {
- int i;
- int sort_index = 0;
-
- for (i=0; i <= idx; i++) {
- if (tbl->cols[i].attr_id < 0)
- continue;
-
- if (!(tbl->cols[i].flags & KHUI_CW_COL_GROUP)) {
- tbl->cols[i].flags |= KHUI_CW_COL_GROUP;
-
- if (!(tbl->cols[i].flags &
- (KHUI_CW_COL_SORT_INC |
- KHUI_CW_COL_SORT_DEC)))
- tbl->cols[i].flags |= KHUI_CW_COL_SORT_INC;
-
- cw_hditem_from_tbl_col(&tbl->cols[i], &hi);
- hi.mask = HDI_FORMAT;
- hidx = Header_OrderToIndex(tbl->hwnd_header, i);
- Header_SetItem(tbl->hwnd_header, hidx, &hi);
- }
-
- tbl->cols[i].sort_index = sort_index++;
- }
- }
-
- tbl->flags |= KHUI_CW_TBL_COL_DIRTY;
- tbl->flags |= KHUI_CW_TBL_CUSTVIEW;
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, FALSE);
- }
- break;
-
- case NM_CUSTOMDRAW:
- {
- LPNMCUSTOMDRAW cd;
- int idx;
-
- cd = (LPNMCUSTOMDRAW) ph;
- switch(cd->dwDrawStage) {
- case CDDS_PREPAINT:
- return CDRF_NOTIFYITEMDRAW;
-
- case CDDS_ITEMPREPAINT:
- return CDRF_NOTIFYPOSTPAINT;
-
- case CDDS_ITEMPOSTPAINT:
- if(cd->lItemlParam == CW_CA_FLAGS)
- idx = IDB_WDG_FLAG;
- else if(cd->lItemlParam == CW_CA_TYPEICON)
- idx = IDB_WDG_CREDTYPE;
- else
- idx = -1;
-
- khui_ilist_draw_id(tbl->ilist, idx, cd->hdc, cd->rc.left, cd->rc.top, 0);
- return 0;
- }
- }
- break;
- }
- return 0;
-}
-
-LRESULT
-cw_wm_create(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
-
- kmq_subscribe_hwnd(KMSG_CRED, hwnd);
- kmq_subscribe_hwnd(KMSG_KCDB, hwnd);
- kmq_subscribe_hwnd(KMSG_KMM, hwnd);
-
- /* freed in cw_wm_destroy */
- tbl = PMALLOC(sizeof(*tbl));
- ZeroMemory(tbl, sizeof(*tbl));
-
- /* some versions of VC generate portability warnings for
- SetWindowLongPtr */
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, 0, (LONG_PTR) tbl);
-#pragma warning(pop)
-
- cw_refresh_attribs(hwnd);
-
- tbl->hwnd_header = CreateWindowEx(
- 0,
- WC_HEADER,
- (LPWSTR) NULL,
- WS_CHILD | HDS_BUTTONS |
- HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK |
- HDS_DRAGDROP
-#if (_WIN32_WINNT >= 0x501)
- | ((IS_COMMCTL6())?HDS_FLAT:0)
-#endif
- ,
- 0,0,0,0,hwnd, (HMENU) 0, khm_hInstance, NULL);
-
- cw_load_view(tbl, NULL /* default view */, hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
- cw_update_extents(tbl, FALSE);
-
- {
- RECT rect;
- WINDOWPOS pw;
- HDLAYOUT hdl;
-
- hdl.prc = &rect;
- hdl.pwpos = &pw;
- GetClientRect(hwnd, &rect);
-
- Header_Layout(tbl->hwnd_header, &hdl);
-
- SetWindowPos(
- tbl->hwnd_header,
- pw.hwndInsertAfter,
- pw.x,
- pw.y,
- pw.cx,
- pw.cy,
- pw.flags | SWP_SHOWWINDOW);
- }
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-LRESULT
-cw_wm_destroy(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
-
- kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);
- kmq_unsubscribe_hwnd(KMSG_KCDB, hwnd);
- kmq_unsubscribe_hwnd(KMSG_KMM, hwnd);
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
-
- if (tbl) {
- cw_save_view(tbl, NULL);
-
- cw_unload_view(tbl);
-
- PFREE(tbl);
- SetWindowLongPtr(hwnd, 0, 0);
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-/* handles WM_PAINT and WM_PRINTCLIENT */
-LRESULT
-cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
- HDC hdc = NULL;
- PAINTSTRUCT ps;
- RECT r,rh;
- HFONT hf_old = NULL;
- int row_s, row_e;
- int col_s, col_e;
- int i,j,x,y,xs,xe,ys,ye;
- int flag_col = -1;
- int d_x = -1;
- int selected = 0;
- int rowheight = 0;
- BOOL has_dc = FALSE;
- BOOL has_updaterect = TRUE;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- goto _exit;
-
- if (wParam != 0) {
- /* we assume that if wParam != 0, then that contains a device
- context for us to draw in. Otherwise, we have to call
- BeginPaint() to get one. */
- hdc = (HDC) wParam;
- has_dc = TRUE;
- }
-
- if (!has_dc && !GetUpdateRect(hwnd, &r, FALSE)) {
- has_updaterect = FALSE;
- }
-
- if (!has_dc) {
- if (has_updaterect)
- hdc = BeginPaint(hwnd, &ps);
- else
- hdc = GetDC(hwnd);
- }
-
- if(tbl->hf_normal)
- hf_old = SelectFont(hdc, tbl->hf_normal);
- SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_NOUPDATECP);
- SetBkMode(hdc, TRANSPARENT);
-
- GetClientRect(hwnd,&r);
- r.top += tbl->header_height;
-
- if(tbl->n_rows) {
- /* remove the notification window if there is one */
- if(tbl->hwnd_notif) {
- DestroyWindow(tbl->hwnd_notif);
- tbl->hwnd_notif = NULL;
- }
- /* we compute the visible area in terms of rows and columns */
- /* row_s : first visible row */
- /* col_s : first visible column */
- /* row_e : last visible row */
- /* col_e : last visible column */
- /* ys : top edge of first visible row */
- /* xs : left edge of first visible column */
-
- /* We *NEED* all the meta columns to be on the left */
-
- row_s = 0;
- ys = 0;
- row_e = (int) tbl->n_rows;
- x = 0;
- col_s = -1;
- col_e = -1;
- xs = 0;
- for(i=0; i < (int) tbl->n_cols; i++) {
- if(col_e == -1 && x >= tbl->scr_left + (r.right - r.left)) {
- col_e = i;
- }
- if(tbl->cols[i].attr_id == CW_CA_FLAGS)
- flag_col = i;
- if(d_x == -1 && !cw_is_custom_attr(tbl->cols[i].attr_id))
- d_x = x;
- x += tbl->cols[i].width;
- if(col_s == -1 && x > tbl->scr_left) {
- col_s = i;
- xs = tbl->cols[i].x;
- }
- }
-
- if(col_e == -1)
- col_e = i;
-
- if(col_s == -1)
- col_s = i;
-
- if(d_x != -1)
- d_x += r.left - tbl->scr_left;
-
- xs += r.left - tbl->scr_left;
- ys += r.top - tbl->scr_top;
- xe = r.left + tbl->ext_width - tbl->scr_left;
- ye = r.top + tbl->ext_height - tbl->scr_top;
-
- /* now draw */
- y = ys;
- for(i=row_s; i < row_e; i++) {
- selected = tbl->rows[i].flags & KHUI_CW_ROW_SELECTED;
- rowheight = (tbl->rows[i].flags & KHUI_CW_ROW_EXPVIEW)? tbl->cell_height * CW_EXP_ROW_MULT : tbl->cell_height;
-
- if(tbl->cursor_row == i) {
- if (tbl->rows[i].flags & KHUI_CW_ROW_HEADER)
- SelectFont(hdc, tbl->hf_bold_header);
- else
- SelectFont(hdc, tbl->hf_bold);
- } else if (tbl->rows[i].flags & KHUI_CW_ROW_HEADER) {
- SelectFont(hdc, tbl->hf_header);
- }
-
- x = xs;
- if(tbl->rows[i].flags & KHUI_CW_ROW_HEADER) {
- rh.left = xs;
- rh.right = xs;
- for(j=col_s; j < tbl->rows[i].col; j++)
- rh.right += tbl->cols[j].width;
- rh.top = y;
- rh.bottom = y + rowheight;
- if(rh.right > rh.left) {
- cw_erase_rect(hdc, tbl, &r, &rh, (selected)?CW_ER_SEL:CW_ER_BLANK);
- }
- rh.left = rh.right;
- rh.right = xe;
-
- cw_draw_header(hdc, tbl, i, &rh);
- }
-
- if(selected)
- SetTextColor(hdc, tbl->cr_s);
- else
- SetTextColor(hdc, tbl->cr_normal);
-
- x = xs;
- rh.top = y;
- rh.bottom = y + rowheight;
- for(j=col_s; j < col_e; x += tbl->cols[j++].width) {
- wchar_t buf[256];
- khm_size cbbuf;
-
- rh.left = x;
- rh.right = x + tbl->cols[j].width;
-
- if(!cw_is_custom_attr(tbl->cols[j].attr_id)) {
- if(!(tbl->rows[i].flags & KHUI_CW_ROW_HEADER)) {
- cw_erase_rect(hdc, tbl, &r, &rh, (selected)?CW_ER_SEL:CW_ER_BLANK);
-
- if(j > tbl->rows[i].col) {
- cbbuf = sizeof(buf);
- if(KHM_FAILED(kcdb_cred_get_attr_string((khm_handle) tbl->rows[i].data,
- tbl->cols[j].attr_id, buf,
- &cbbuf, KCDB_TS_SHORT)))
- continue;
-
- rh.left += tbl->hpad;
- rh.right -= tbl->hpad;
-
- SetTextAlign(hdc, 0);
- DrawText(hdc, buf, (int)((cbbuf / sizeof(wchar_t)) - 1), &rh,
- DT_LEFT | DT_VCENTER | DT_NOCLIP | DT_SINGLELINE | DT_END_ELLIPSIS);
- }
- }
- } else {
- cw_erase_rect(hdc, tbl, &r, &rh, (selected)?CW_ER_SEL:CW_ER_BLANK);
-
- if(tbl->cols[j].attr_id == CW_CA_FLAGS) {
- khui_credwnd_outline * o;
- khm_int32 flag;
-
- if(tbl->rows[i].flags & KHUI_CW_ROW_HEADER) {
- o = ((khui_credwnd_outline *) tbl->rows[i].data);
- if(o->flags & KHUI_CW_O_SHOWFLAG)
- flag = o->flags;
- else
- flag = 0;
- } else {
- flag = tbl->rows[i].flags;
- }
-
- flag &= CW_EXPSTATE_MASK;
-
- if(flag == CW_EXPSTATE_WARN) {
- khui_ilist_draw_id(tbl->ilist, IDB_FLAG_WARN, hdc, x, y, 0);
- } else if(flag == CW_EXPSTATE_CRITICAL) {
- khui_ilist_draw_id(tbl->ilist, IDB_FLAG_CRITICAL, hdc, x, y, 0);
- } else if(flag == CW_EXPSTATE_EXPIRED) {
- khui_ilist_draw_id(tbl->ilist, IDB_FLAG_EXPIRED, hdc, x, y, 0);
- } else if(!(tbl->rows[i].flags & KHUI_CW_ROW_HEADER)) {
- khm_int32 flags;
-
- if (KHM_SUCCEEDED(kcdb_cred_get_flags((khm_handle) tbl->rows[i].data, &flags)) &&
- (flags & KCDB_CRED_FLAG_RENEWABLE)) {
- khui_ilist_draw_id(tbl->ilist,
- IDB_FLAG_RENEW,
- hdc,
- x, y, 0);
- } else {
- khui_ilist_draw_id(tbl->ilist,
- IDB_TK_SM,
- hdc,
- x, y, 0);
- }
- }
- }
- }
- }
-
- if(tbl->cursor_row == i) {
- rh.left = tbl->scr_left;
- rh.right = tbl->scr_left + tbl->ext_width;
- DrawFocusRect(hdc, &rh);
- }
-
- if (tbl->cursor_row == i ||
- (tbl->rows[i].flags & KHUI_CW_ROW_HEADER)) {
- SelectFont(hdc, tbl->hf_normal);
- }
-
- y += rowheight;
-
- }
-
- if(xe < r.right) {
- rh.left = xe;
- rh.right = r.right;
- rh.top = r.top;
- rh.bottom = r.bottom;
-
- cw_erase_rect(hdc, tbl, &r, &rh, CW_ER_BLANK);
- }
-
- if(ye < r.bottom) {
- rh.left = r.left;
- rh.right = (xe < r.right)?xe:r.right;
- rh.top = ye;
- rh.bottom = r.bottom;
-
- cw_erase_rect(hdc, tbl, &r, &rh, CW_ER_BLANK);
- }
-
- } else {
- wchar_t buf[512];
- cw_erase_rect(hdc, tbl, &r, &r, CW_ER_BLANK);
-
- if(tbl->hwnd_notif == NULL) {
- LoadString(khm_hInstance, IDS_NO_CREDS, buf, sizeof(buf)/sizeof(buf[0]));
- tbl->hwnd_notif = khm_create_htwnd(
- tbl->hwnd,
- buf,
- r.left,r.top,r.right - r.left,tbl->cell_height * 4,
- 0, /* This can be WS_EX_TRANSPARENT, but
- we don't fully support it yet. */
- WS_VISIBLE);
- if(tbl->hwnd_notif) {
- SendMessage(tbl->hwnd_notif, WM_SETFONT, (WPARAM) tbl->hf_normal, (LPARAM) FALSE);
- ShowWindow(tbl->hwnd_notif, SW_SHOW);
- }
- }
- }
-
- if(tbl->hf_normal)
- SelectFont(hdc, hf_old);
-
- if (!has_dc) {
- if (has_updaterect)
- EndPaint(hwnd,&ps);
- else
- ReleaseDC(hwnd, hdc);
- }
-
- _exit:
- return TRUE;
-}
-
-LRESULT
-cw_wm_size(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- RECT rect;
- khui_credwnd_tbl * tbl;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl) {
- cw_update_extents(tbl, TRUE);
-
- GetClientRect(hwnd, &rect);
-
- if(tbl->hwnd_notif) {
- SetWindowPos(tbl->hwnd_notif,
- tbl->hwnd_header,
- rect.left,
- tbl->header_height,
- rect.right - rect.left,
- tbl->cell_height * 4,
- 0);
- }
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-LRESULT
-cw_wm_notify(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
- LPNMHDR pnmh;
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- pnmh = (LPNMHDR) lParam;
- if(pnmh->hwndFrom == tbl->hwnd_header) {
- LPNMHEADER ph;
- ph = (LPNMHEADER) lParam;
- return cw_handle_header_msg(tbl, ph);
- }
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-static void cw_pp_begin(khui_property_sheet * s);
-static void cw_pp_precreate(khui_property_sheet * s);
-static void cw_pp_end(khui_property_sheet * s);
-static void cw_pp_destroy(khui_property_sheet *ps);
-
-LRESULT
-cw_kmq_wm_dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- kmq_message * m;
- khm_int32 rv = KHM_ERROR_SUCCESS;
- khui_credwnd_tbl * tbl;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
-
- kmq_wm_begin(lParam, &m);
-
- if (tbl == NULL)
- goto _skip_message;
-
- if(m->type == KMSG_CRED) {
- switch (m->subtype) {
- case KMSG_CRED_ROOTDELTA:
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
- cw_select_row(tbl, tbl->cursor_row, 0);
- InvalidateRect(hwnd, NULL, FALSE);
- break;
-
- case KMSG_CRED_PP_BEGIN:
- cw_pp_begin((khui_property_sheet *) m->vparam);
- break;
-
- case KMSG_CRED_PP_PRECREATE:
- cw_pp_precreate((khui_property_sheet *) m->vparam);
- break;
-
- case KMSG_CRED_PP_END:
- cw_pp_end((khui_property_sheet *) m->vparam);
- break;
-
- case KMSG_CRED_PP_DESTROY:
- cw_pp_destroy((khui_property_sheet *) m->vparam);
- break;
- }
- } else if (m->type == KMSG_KCDB) {
- if (m->subtype == KMSG_KCDB_IDENT &&
- m->uparam == KCDB_OP_MODIFY) {
-
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
- cw_set_row_context(tbl, tbl->cursor_row);
- InvalidateRect(hwnd, NULL, FALSE);
-
- }
- else if (m->subtype == KMSG_KCDB_IDENT &&
- m->uparam == KCDB_OP_NEW_DEFAULT) {
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- khm_size cb;
- khm_handle defid = NULL;
-
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- InvalidateRect(hwnd, NULL, FALSE);
-
- cb = sizeof(idname);
-
- if (KHM_SUCCEEDED(kcdb_identity_get_default(&defid)) &&
- defid != NULL &&
- KHM_SUCCEEDED(kcdb_identity_get_name(defid, idname, &cb)) &&
- idname[0] != L'\0') {
-
- khm_notify_icon_tooltip(idname);
-
- } else {
-
- LoadString(khm_hInstance, IDS_NOTIFY_READY,
- idname, ARRAYLENGTH(idname));
- khm_notify_icon_tooltip(idname);
- }
-
- if (defid)
- kcdb_identity_release(defid);
- }
- else if (m->subtype == KMSG_KCDB_ATTRIB &&
- (m->uparam == KCDB_OP_INSERT ||
- m->uparam == KCDB_OP_DELETE)) {
-
- cw_refresh_attribs(hwnd);
-
- }
- } else if (m->type == KMSG_KMM &&
- m->subtype == KMSG_KMM_I_DONE) {
-
- if (tbl->flags & KHUI_CW_TBL_COLSKIP) {
- wchar_t cname[KCONF_MAXCCH_NAME];
- khm_size cb;
-
- cname[0] = L'\0';
-
- if (tbl->csp_view) {
- cb = sizeof(cname);
- khc_get_config_space_name(tbl->csp_view,
- cname,
- &cb);
- }
-
- cw_unload_view(tbl);
-
- cw_load_view(tbl, ((cname[0])?cname: NULL), hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_selection_state(tbl);
- cw_update_extents(tbl, TRUE);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
- }
-
- } else if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_ACTIVATE) {
- /* a column selector menu item was activated */
-
- khm_int32 attr_id;
- khm_int32 action;
- khui_action * paction;
- int i;
- int first_non_fixed = -1;
-
- action = m->uparam;
- paction = khui_find_action(action);
-
- if (paction == NULL)
- goto _skip_action;
-
- attr_id = (khm_int32)(INT_PTR) paction->data;
-
- if (attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)
- goto _skip_action;
-
- for (i=0; i < tbl->n_cols; i++) {
- if (tbl->cols[i].attr_id >= 0 &&
- first_non_fixed == -1)
- first_non_fixed = i;
-
- if (tbl->cols[i].attr_id == attr_id)
- break;
- }
-
- if (first_non_fixed == i &&
- i == tbl->n_cols - 1) {
- /* this is the only non-fixed column. We don't allow
- deleting it, althoguh there's nothing wrong with doing
- so other than not being very useful. */
- goto _skip_action;
- }
-
- if (i < tbl->n_cols) {
- khm_int32 sort_index;
-
- /* we need to remove a column */
-
- Header_DeleteItem(tbl->hwnd_header, i);
- sort_index = tbl->cols[i].sort_index;
-
- if (tbl->cols[i].title)
- PFREE(tbl->cols[i].title);
- tbl->cols[i].title = NULL;
-
- if (i < tbl->n_cols - 1) {
- MoveMemory(&tbl->cols[i], &tbl->cols[i+1],
- sizeof(tbl->cols[0]) * (tbl->n_cols - (i + 1)));
- }
- tbl->n_cols--;
-
- /* fix the sort index */
- if (sort_index >= 0) {
- for (i=0; i < tbl->n_cols; i++) {
- if (tbl->cols[i].sort_index > sort_index)
- tbl->cols[i].sort_index--;
- }
- }
-
- tbl->flags |= KHUI_CW_TBL_COL_DIRTY;
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- khui_check_action(attr_to_action[attr_id], FALSE);
-
- tbl->flags |= KHUI_CW_TBL_CUSTVIEW;
-
- } else {
- /* we need to add a column */
- wchar_t buf[KCDB_MAXCCH_SHORT_DESC];
- khm_size cb;
- khm_int32 idx = tbl->n_cols;
- HDITEM hi;
-
- /* for now, we only allow KHUI_CW_COL_INITIAL columns */
- if (tbl->n_rows == tbl->n_total_rows)
- goto _skip_action;
-
- cb = sizeof(buf);
- if (KHM_FAILED(kcdb_attrib_describe(attr_id,
- buf,
- &cb,
- KCDB_TS_SHORT)))
- goto _skip_action;
-
- tbl->cols[idx].attr_id = attr_id;
- tbl->cols[idx].width = 100;
- tbl->cols[idx].x = -1;
- tbl->cols[idx].flags = 0;
- tbl->cols[idx].sort_index = -1;
- tbl->cols[idx].title = PMALLOC(cb);
-#ifdef DEBUG
- assert(tbl->cols[idx].title);
-#endif
- if (!tbl->cols[idx].title)
- goto _skip_action;
-
- StringCbCopy(tbl->cols[idx].title,
- cb,
- buf);
-
- tbl->n_cols++;
-
- cw_hditem_from_tbl_col(&(tbl->cols[idx]), &hi);
- Header_InsertItem(tbl->hwnd_header, 512, &hi);
-
- tbl->flags |= KHUI_CW_TBL_COL_DIRTY;
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- khui_check_action(attr_to_action[attr_id], TRUE);
-
- tbl->flags |= KHUI_CW_TBL_CUSTVIEW;
- }
-
- kmq_post_message(KMSG_ACT, KMSG_ACT_REFRESH, 0, 0);
-
- _skip_action:
- ;
- }
-
- _skip_message:
-
- return kmq_wm_end(m, rv);
-}
-
-static void
-cw_select_outline_level(khui_credwnd_outline * o,
- BOOL select)
-{
- while(o) {
- if (select)
- o->flags |= KHUI_CW_O_SELECTED;
- else
- o->flags &= ~KHUI_CW_O_SELECTED;
- cw_select_outline_level(TFIRSTCHILD(o), select);
- o = LNEXT(o);
- }
-}
-
-static void
-cw_select_outline(khui_credwnd_outline * o,
- BOOL select)
-{
- if (select)
- o->flags |= KHUI_CW_O_SELECTED;
- else
- o->flags &= ~KHUI_CW_O_SELECTED;
-}
-
-static void
-cw_select_row_creds(khui_credwnd_tbl * tbl, int row, int selected) {
-
- khm_size j;
- khm_size idx_start, idx_end;
-
-#ifdef DEBUG
- assert(row >= 0 && row < tbl->n_rows);
-#endif
-
- if (row >= tbl->n_rows)
- return;
-
- if (tbl->rows[row].flags & KHUI_CW_ROW_HEADER) {
- khui_credwnd_outline * o;
-
- o = (khui_credwnd_outline *) tbl->rows[row].data;
- idx_start = o->idx_start;
- idx_end = o->idx_end;
- } else {
- idx_start = tbl->rows[row].idx_start;
- idx_end = tbl->rows[row].idx_end;
- }
-
- if (idx_start == -1 || idx_end == -1)
- return;
-
- for (j = idx_start; j <= idx_end; j++) {
- khm_handle cred = NULL;
-
- kcdb_credset_get_cred(tbl->credset, (khm_int32) j, &cred);
-
- if (cred) {
- kcdb_cred_set_flags(cred, ((selected)?KCDB_CRED_FLAG_SELECTED:0),
- KCDB_CRED_FLAG_SELECTED);
- kcdb_cred_release(cred);
- }
- }
-}
-
-static void
-cw_unselect_all(khui_credwnd_tbl * tbl)
-{
- int i;
-
- for(i=0; i<tbl->n_rows; i++) {
- tbl->rows[i].flags &= ~KHUI_CW_ROW_SELECTED;
-
- cw_select_row_creds(tbl, i, FALSE);
- }
-
- cw_select_outline_level(tbl->outline, FALSE);
-}
-
-static void
-cw_update_cred_row_selection_state(khui_credwnd_tbl * tbl,
- int row) {
- khm_int32 flags;
- khm_size idx_start, idx_end;
- khm_size k;
- khm_boolean found_selected = FALSE;
- khm_boolean found_unselected = FALSE;
- khm_boolean row_select = TRUE;
-
-#ifdef DEBUG
- assert(row >= 0 && row < tbl->n_rows);
-#endif
- if (row < 0 || row >= tbl->n_rows)
- return;
-
- idx_start = tbl->rows[row].idx_start;
- idx_end = tbl->rows[row].idx_end;
-
- for (k = idx_start; k <= idx_end && select; k++) {
- khm_handle cred = NULL;
-
- if (KHM_SUCCEEDED(kcdb_credset_get_cred(tbl->credset, (khm_int32) k,
- &cred))) {
- kcdb_cred_get_flags(cred, &flags);
- if (!(flags & KCDB_CRED_FLAG_SELECTED)) {
- found_unselected = TRUE;
- row_select = FALSE;
- } else {
- found_selected = TRUE;
- }
- kcdb_cred_release(cred);
- } else {
- row_select = FALSE;
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
- }
-
- if (row_select)
- tbl->rows[row].flags |= KHUI_CW_ROW_SELECTED;
- else
- tbl->rows[row].flags &= ~KHUI_CW_ROW_SELECTED;
-
- if (found_selected && found_unselected) {
- /* if there were selected and unselected credentials
- associated with the same row, we need to set the selection
- state of all of them to match what the user is going to
- see. */
- cw_select_row_creds(tbl, row, row_select);
- }
-}
-
-static void
-cw_update_outline_selection_state(khui_credwnd_tbl * tbl,
- khui_credwnd_outline * o)
-{
- khm_boolean select = TRUE;
- int j;
-
- for (j = o->start + 1; j < o->start + o->length; j++) {
- if (tbl->rows[j].flags & KHUI_CW_ROW_HEADER) {
- cw_update_outline_selection_state(tbl,
- (khui_credwnd_outline *)
- tbl->rows[j].data);
- } else {
- cw_update_cred_row_selection_state(tbl, j);
- }
-
- if (!(tbl->rows[j].flags & KHUI_CW_ROW_SELECTED)) {
- select = FALSE;
- }
-
- if (tbl->rows[j].flags & KHUI_CW_ROW_HEADER) {
- j += ((khui_credwnd_outline *) tbl->rows[j].data)->length - 1;
- }
- }
-
- /* special case : the header has been collapsed and we are just
- using one row. In this case, the for loop above will do
- nothing. */
-
- if (o->length == 1) {
- select = !!(o->flags & KHUI_CW_O_SELECTED);
- } else {
- cw_select_outline(o, select);
- }
-
- if (select) {
- tbl->rows[o->start].flags |= KHUI_CW_ROW_SELECTED;
- } else {
- tbl->rows[o->start].flags &= ~KHUI_CW_ROW_SELECTED;
- }
-}
-
-static void
-cw_update_selection_state(khui_credwnd_tbl * tbl)
-{
- int i;
-
- for (i=0; i < tbl->n_rows; i++) {
- if (tbl->rows[i].flags & KHUI_CW_ROW_HEADER) {
- khui_credwnd_outline * o;
-
- o = (khui_credwnd_outline *) tbl->rows[i].data;
-
- cw_update_outline_selection_state(tbl, o);
-
- i += o->length - 1;
- } else {
- cw_update_cred_row_selection_state(tbl, i);
- }
- }
-}
-
-/* Examine the current row and set the UI context */
-static void
-cw_set_row_context(khui_credwnd_tbl * tbl, int row)
-{
- khui_credwnd_outline * o;
- BOOL set_context = TRUE;
-
- if (row < 0 || row >= (int) tbl->n_rows) {
- if (tbl->n_rows > 0)
- row = 0;
- else {
- khui_context_reset();
- return;
- }
- }
-
- if (tbl->rows[row].flags & KHUI_CW_ROW_HEADER) {
-
- o = (khui_credwnd_outline *) tbl->rows[row].data;
-
- if (tbl->cols[o->col].attr_id == KCDB_ATTR_ID_NAME) {
- if (TPARENT(o) != NULL) {
- khui_credwnd_outline * op;
-
- op = TPARENT(o);
-
- if (tbl->cols[op->col].attr_id == KCDB_ATTR_TYPE_NAME &&
- TPARENT(op) == NULL) {
- /* selected a credential type */
- khui_context_set(KHUI_SCOPE_CREDTYPE,
- (khm_handle) o->data,
- (khm_int32) (DWORD_PTR) op->data,
- NULL,
- NULL,
- 0,
- tbl->credset);
- } else {
- /* we can't narrow it down using the standard set
- of scopes. We consider this to be an identity
- selection because the user right-clicked on an
- identity header. */
- khui_context_set(KHUI_SCOPE_IDENT,
- (khm_handle) o->data,
- KCDB_CREDTYPE_INVALID,
- NULL,
- NULL,
- 0,
- tbl->credset);
- }
- } else {
- /* The user clicked on an identity header. Even
- though not all credentials belonging to the
- identity maybe within the scope right now, we still
- consider this to be an identity scope. */
- khui_context_set(KHUI_SCOPE_IDENT,
- (khm_handle) o->data,
- KCDB_CREDTYPE_INVALID,
- NULL,
- NULL,
- 0,
- tbl->credset);
- }
- } else if (tbl->cols[o->col].attr_id == KCDB_ATTR_TYPE_NAME) {
- if (TPARENT(o) == NULL) {
- /* selected an entire cred type */
- khui_context_set(KHUI_SCOPE_CREDTYPE,
- NULL,
- (khm_int32) (DWORD_PTR) o->data,
- NULL,
- NULL,
- 0,
- tbl->credset);
- } else {
- khui_credwnd_outline * op;
-
- op = TPARENT(o);
- if (tbl->cols[op->col].attr_id == KCDB_ATTR_ID_NAME) {
- /* credtype under an identity. Even though not
- all the credentials of this credtype belonging
- to this identity might be within the scope, we
- still consider this to be a type selection
- under a specific identity. */
- khui_context_set(KHUI_SCOPE_CREDTYPE,
- (khm_handle) op->data,
- (khm_int32) (DWORD_PTR) o->data,
- NULL,
- NULL,
- 0,
- tbl->credset);
- } else {
- set_context = FALSE;
- }
- }
- } else {
- set_context = FALSE;
- }
-
- if (!set_context) {
- /* woohoo. cred group. yay. */
- khui_header headers[KHUI_MAX_HEADERS];
- khm_size n_headers = 0;
-
- do {
- headers[n_headers].attr_id =
- o->attr_id;
- if (tbl->cols[o->col].attr_id ==
- KCDB_ATTR_ID_NAME) {
- headers[n_headers].data = &(o->data);
- headers[n_headers].cb_data = sizeof(khm_handle);
- } else if (tbl->cols[o->col].attr_id ==
- KCDB_ATTR_TYPE_NAME) {
- headers[n_headers].data = &(o->data);
- headers[n_headers].cb_data = sizeof(khm_int32);
- } else {
- headers[n_headers].data = o->data;
- headers[n_headers].cb_data = o->cb_data;
- }
-
- n_headers++;
-
- o = TPARENT(o);
- } while(o);
-
- khui_context_set(KHUI_SCOPE_GROUP,
- NULL,
- KCDB_CREDTYPE_INVALID,
- NULL,
- headers,
- n_headers,
- tbl->credset);
- }
-
- } else {
- khm_handle cred;
-
- cred = (khm_handle) tbl->rows[row].data;
-
- khui_context_set(KHUI_SCOPE_CRED,
- NULL,
- KCDB_CREDTYPE_INVALID,
- cred,
- NULL,
- 0,
- tbl->credset);
- }
-}
-
-static void
-cw_select_all(khui_credwnd_tbl * tbl)
-{
- int i;
-
- for(i=0; i<tbl->n_rows; i++) {
- tbl->rows[i].flags |= KHUI_CW_ROW_SELECTED;
- cw_select_row_creds(tbl, i, TRUE);
- }
-
- cw_select_outline_level(tbl->outline, TRUE);
-
- cw_update_selection_state(tbl);
-
- cw_set_row_context(tbl, tbl->cursor_row);
-
- InvalidateRect(tbl->hwnd, NULL, FALSE);
-}
-
-static void
-cw_select_row(khui_credwnd_tbl * tbl, int row, WPARAM wParam)
-{
- int i;
- BOOL toggle;
- BOOL extend;
- int group_begin;
- int group_end;
-
- if (wParam & MK_CONTROL) {
- toggle = TRUE;
- extend = FALSE;
- } else if (wParam & MK_SHIFT) {
- toggle = FALSE;
- extend = TRUE;
- } else {
- toggle = FALSE;
- extend = FALSE;
- }
-
- if (row < 0 || row >= (int) tbl->n_rows)
- return;
-
- if (tbl->rows[row].flags & KHUI_CW_ROW_HEADER) {
- khui_credwnd_outline * o;
-
- o = (khui_credwnd_outline *) tbl->rows[row].data;
-
- group_begin = o->start;
- group_end = o->start + o->length - 1;
- } else {
- group_begin = row;
- group_end = row;
- }
-
- if (!toggle && !extend) {
- /* selecting a single row */
- cw_unselect_all(tbl);
-
- tbl->cursor_row = row;
- tbl->anchor_row = row;
-
- for (i = group_begin; i <= group_end; i++) {
- tbl->rows[i].flags |= KHUI_CW_ROW_SELECTED;
- if (tbl->rows[i].flags & KHUI_CW_ROW_HEADER)
- cw_select_outline((khui_credwnd_outline *) tbl->rows[i].data, TRUE);
- cw_select_row_creds(tbl, i, TRUE);
- }
- } else if (toggle) {
- BOOL select;
-
- tbl->cursor_row = row;
- tbl->anchor_row = row;
-
- select = !(tbl->rows[row].flags & KHUI_CW_ROW_SELECTED);
-
- for (i = group_begin; i <= group_end; i++) {
- if (select)
- tbl->rows[i].flags |= KHUI_CW_ROW_SELECTED;
- else
- tbl->rows[i].flags &= ~KHUI_CW_ROW_SELECTED;
-
- if (tbl->rows[i].flags & KHUI_CW_ROW_HEADER)
- cw_select_outline((khui_credwnd_outline *) tbl->rows[i].data, select);
-
- cw_select_row_creds(tbl, i, select);
- }
- } else if (extend) {
- int range_begin;
- int range_end;
-
- cw_unselect_all(tbl);
-
- range_begin = min(row, tbl->anchor_row);
- range_end = max(row, tbl->anchor_row);
-
- for (i = range_begin; i <= range_end; i++) {
- tbl->rows[i].flags |= KHUI_CW_ROW_SELECTED;
-
- if (tbl->rows[i].flags & KHUI_CW_ROW_HEADER)
- cw_select_outline((khui_credwnd_outline *) tbl->rows[i].data, TRUE);
-
- cw_select_row_creds(tbl, i, TRUE);
- }
-
- tbl->cursor_row = row;
- }
-
- cw_update_selection_state(tbl);
-
- cw_set_row_context(tbl, tbl->cursor_row);
-
- InvalidateRect(tbl->hwnd, NULL, FALSE);
-}
-
-static void
-cw_toggle_outline_state(khui_credwnd_tbl * tbl,
- khui_credwnd_outline * o) {
-
- int old_range_begin;
- int old_range_end;
- int new_range_begin;
- int new_range_end;
-
- old_range_begin = o->start;
- old_range_end = o->start + o->length - 1;
-
- o->flags ^= KHUI_CW_O_EXPAND;
-
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
-
- new_range_begin = o->start;
- new_range_end = o->start + o->length - 1;
-
- if (tbl->cursor_row > old_range_end) {
- tbl->cursor_row -= old_range_end - new_range_end;
- } else if (tbl->cursor_row >= old_range_begin &&
- tbl->cursor_row <= old_range_end) {
- tbl->cursor_row = new_range_begin;
- }
-
- if (tbl->anchor_row > old_range_end) {
- tbl->anchor_row -= old_range_end - new_range_end;
- } else if (tbl->anchor_row >= old_range_begin &&
- tbl->anchor_row <= old_range_end) {
- tbl->anchor_row = new_range_begin;
- }
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
-}
-
-LRESULT cw_properties(HWND hwnd);
-
-LRESULT
-cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
- int x,y;
- RECT r;
- int row;
- int col;
- int i;
- int nm_state,nm_row,nm_col;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- /* we are basically trying to capture events where the mouse is
- hovering over one of the 'hotspots'. There are two kinds of
- hotspots one is the little widget thinggy that you click on to
- expand or collapse an outline. The other is a text cell that
- is partially concealed. */
-
- x = GET_X_LPARAM(lParam);
- y = GET_Y_LPARAM(lParam);
- x += tbl->scr_left;
- y += tbl->scr_top - tbl->header_height;
-
- row = -1;
-
- for (i=0; i < tbl->n_rows; i++) {
- if (y >= tbl->rows[i].r_ext.top &&
- y < tbl->rows[i].r_ext.bottom) {
- row = i;
- break;
- }
- }
-
- col = -1;
- nm_state = CW_MOUSE_NONE;
- nm_row = nm_col = -1;
-
- for(i=0; i < (int) tbl->n_cols; i++) {
- if(x >= tbl->cols[i].x &&
- x < tbl->cols[i].x + tbl->cols[i].width) {
- col = i;
- break;
- }
- }
-
- if(wParam & MK_LBUTTON)
- nm_state = CW_MOUSE_LDOWN;
-
- if(row >= 0 && row < (int) tbl->n_rows) {
- nm_state |= CW_MOUSE_ROW;
- nm_row = row;
- nm_col = col;
- if(tbl->rows[row].flags & KHUI_CW_ROW_HEADER) {
- khui_credwnd_outline * o;
-
- o = (khui_credwnd_outline *) tbl->rows[row].data;
-
- /* are we on a widget then? */
- x -= tbl->cols[o->col].x;
-
- if (!(o->flags & KHUI_CW_O_NOOUTLINE)) {
- if(x >= 0 && x < KHUI_SMICON_CX) /* hit */ {
- nm_state |= CW_MOUSE_WOUTLINE | CW_MOUSE_WIDGET;
- } else if (tbl->cols[tbl->rows[row].col].attr_id ==
- KCDB_ATTR_ID_NAME &&
- col == tbl->rows[row].col &&
- x >= KHUI_SMICON_CX * 3 / 2 &&
- x < KHUI_SMICON_CX * 5 / 2){
- nm_state |= CW_MOUSE_WSTICKY | CW_MOUSE_WIDGET;
- } else if (tbl->cols[tbl->rows[row].col].attr_id ==
- KCDB_ATTR_ID_NAME &&
- col == tbl->rows[row].col &&
- x >= KHUI_SMICON_CX * 3 &&
- x < KHUI_SMICON_CX * 4) {
- nm_state |= CW_MOUSE_WICON | CW_MOUSE_WIDGET;
- }
- } else if (tbl->cols[o->col].attr_id == KCDB_ATTR_ID_NAME) {
- if (col == tbl->rows[row].col &&
- x >= 0 &&
- x < KHUI_SMICON_CX){
-
- nm_state |= CW_MOUSE_WSTICKY | CW_MOUSE_WIDGET;
-
- } else if (col == tbl->rows[row].col &&
- x >= KHUI_SMICON_CX * 3 / 2 &&
- x < KHUI_SMICON_CX * 5 / 2) {
- nm_state |= CW_MOUSE_WICON | CW_MOUSE_WIDGET;
- }
- }
- }
- }
-
- /* did the user drag the cursor off the current row? */
- if((tbl->mouse_state & CW_MOUSE_LDOWN) &&
- (nm_row != tbl->mouse_row)) {
- nm_state &= ~CW_MOUSE_WMASK;
- }
-
- if(!(nm_state & CW_MOUSE_LDOWN) &&
- (tbl->mouse_state & CW_MOUSE_LDOWN) &&
- tbl->mouse_row == nm_row) {
-
- if((nm_state & CW_MOUSE_WOUTLINE) &&
- (tbl->mouse_state & CW_MOUSE_WOUTLINE)) {
- /* click on an outline widget */
- khui_credwnd_outline * o;
-
- o = (khui_credwnd_outline *) tbl->rows[nm_row].data;
- tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WOUTLINE;
-
- cw_toggle_outline_state(tbl, o);
-
- return 0;
- } else if ((nm_state & CW_MOUSE_WSTICKY) &&
- (tbl->mouse_state & CW_MOUSE_WSTICKY)) {
-
- khui_credwnd_outline * o;
- khm_handle ident;
- khm_int32 idf = 0;
-
- o = tbl->rows[nm_row].data;
- ident = o->data;
-
- kcdb_identity_get_flags(ident, &idf);
- idf &= KCDB_IDENT_FLAG_STICKY;
- kcdb_identity_set_flags(ident, (idf ^ KCDB_IDENT_FLAG_STICKY),
- KCDB_IDENT_FLAG_STICKY);
-
- tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WSTICKY;
-
- khm_refresh_identity_menus();
-
- return 0;
- } else if ((nm_state & CW_MOUSE_WICON) &&
- (tbl->mouse_state & CW_MOUSE_WICON)) {
- /* click on an row icon */
- cw_select_row(tbl, nm_row, wParam);
- cw_properties(hwnd);
- } else {
- /* click on a row */
- cw_select_row(tbl, nm_row, wParam);
-
- if (tbl->mouse_col == nm_col &&
- nm_col >= 0 &&
- tbl->cols[nm_col].attr_id == CW_CA_FLAGS &&
- !(tbl->rows[nm_row].flags & KHUI_CW_ROW_HEADER)) {
- /* clicked on a cred icon */
-
- cw_properties(hwnd);
- }
- }
- }
-
- /* ok, now if we are changing state, we need to invalidate a few
- regions */
- if (((tbl->mouse_state ^ nm_state) & (CW_MOUSE_WIDGET |
- CW_MOUSE_WOUTLINE |
- CW_MOUSE_WSTICKY)) ||
- tbl->mouse_row != nm_row) {
-
- if(tbl->mouse_state & CW_MOUSE_WOUTLINE) {
- r.left = tbl->cols[tbl->mouse_col].x - tbl->scr_left;
- r.top = tbl->mouse_row * tbl->cell_height +
- tbl->header_height - tbl->scr_top;
- r.right = r.left + KHUI_SMICON_CX;
- r.bottom = r.top + tbl->cell_height;
- InvalidateRect(tbl->hwnd, &r, TRUE);
- }
- if(tbl->mouse_state & CW_MOUSE_WSTICKY) {
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
-
- if (tbl->mouse_row >= 0 && tbl->mouse_row < tbl->n_rows) {
- r = tbl->rows[tbl->mouse_row].r_ext;
- OffsetRect(&r, -tbl->scr_left, tbl->header_height - tbl->scr_top);
- r.right = r.left + KHUI_SMICON_CX;
- InvalidateRect(tbl->hwnd, &r, TRUE);
- }
-
- } else {
- r.left = KHUI_SMICON_CX * 3 / 2 +
- tbl->cols[tbl->mouse_col].x - tbl->scr_left;
- r.top = tbl->mouse_row * tbl->cell_height +
- tbl->header_height - tbl->scr_top;
- r.right = r.left + KHUI_SMICON_CX;
- r.bottom = r.top + tbl->cell_height;
- }
- InvalidateRect(tbl->hwnd, &r, TRUE);
- }
-
- if ((tbl->mouse_state & nm_state) & CW_MOUSE_LDOWN) {
- if (tbl->mouse_row == nm_row)
- tbl->mouse_col = nm_col;
- } else {
- tbl->mouse_col = nm_col;
- tbl->mouse_row = nm_row;
- }
- tbl->mouse_state = nm_state;
-
- /* same code block as above */
- if(tbl->mouse_state & CW_MOUSE_WOUTLINE) {
- r.left = tbl->cols[tbl->mouse_col].x - tbl->scr_left;
- r.top = tbl->mouse_row * tbl->cell_height +
- tbl->header_height - tbl->scr_top;
- r.right = r.left + KHUI_SMICON_CX;
- r.bottom = r.top + tbl->cell_height;
- InvalidateRect(tbl->hwnd, &r, TRUE);
- }
- if(tbl->mouse_state & CW_MOUSE_WSTICKY) {
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
-
- if (tbl->mouse_row >= 0 && tbl->mouse_row < tbl->n_rows) {
- r = tbl->rows[tbl->mouse_row].r_ext;
- OffsetRect(&r, -tbl->scr_left, tbl->header_height - tbl->scr_top);
- r.right = r.left + KHUI_SMICON_CX;
- InvalidateRect(tbl->hwnd, &r, TRUE);
- }
-
- } else {
- r.left = KHUI_SMICON_CX * 3 / 2 +
- tbl->cols[tbl->mouse_col].x - tbl->scr_left;
- r.top = tbl->mouse_row * tbl->cell_height +
- tbl->header_height - tbl->scr_top;
- r.right = r.left + KHUI_SMICON_CX;
- r.bottom = r.top + tbl->cell_height;
- }
- InvalidateRect(tbl->hwnd, &r, TRUE);
- }
- } else if(tbl->mouse_state != nm_state) {
-
- if ((tbl->mouse_state & nm_state) & CW_MOUSE_LDOWN) {
- if (tbl->mouse_row == nm_row) {
- tbl->mouse_col = nm_col;
- tbl->mouse_state = nm_state;
- }
- } else {
- tbl->mouse_col = nm_col;
- tbl->mouse_row = nm_row;
- tbl->mouse_state = nm_state;
- }
- }
-
- /* if it was a double click, also show the property
- window */
- if (uMsg == WM_LBUTTONDBLCLK) {
- cw_properties(hwnd);
- }
-
- return 0;
-}
-
-LRESULT
-cw_wm_hscroll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
- SCROLLINFO si;
- RECT cr;
- RECT lr;
- RECT sr;
- int dx;
- int newpos;
-
- tbl = (khui_credwnd_tbl *) (LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- GetClientRect(hwnd, &cr);
- dx = tbl->scr_left;
-
- switch(LOWORD(wParam)) {
- case SB_LEFT:
- newpos = 0;
- break;
-
- case SB_RIGHT:
- newpos = tbl->ext_width;
- break;
-
- case SB_LINELEFT:
- newpos = tbl->scr_left - (tbl->ext_width / 12);
- break;
-
- case SB_LINERIGHT:
- newpos = tbl->scr_left + (tbl->ext_width / 12);
- break;
-
- case SB_PAGELEFT:
- newpos = tbl->scr_left - (cr.right - cr.left);
- break;
-
- case SB_PAGERIGHT:
- newpos = tbl->scr_left + (cr.right - cr.left);
- break;
-
- case SB_THUMBTRACK:
- case SB_THUMBPOSITION:
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_TRACKPOS;
- GetScrollInfo(hwnd, SB_HORZ, &si);
-
- newpos = si.nTrackPos;
- break;
-
- default:
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
-
- //cr.top += tbl->header_height;
- tbl->scr_left = newpos;
- cw_update_extents(tbl, TRUE);
-
- dx -= tbl->scr_left;
-
- /* exclude the watermark */
- lr.bottom = cr.bottom;
- lr.right = cr.right;
- lr.top = max(cr.bottom - tbl->kbm_logo_shade.cy, cr.top);
- lr.left = max(cr.right - tbl->kbm_logo_shade.cx, cr.left);
-
- if(cr.top < lr.top && cr.left < cr.right) {
- sr.left = cr.left;
- sr.right = cr.right;
- sr.top = cr.top;
- sr.bottom = lr.top;
- ScrollWindowEx(
- hwnd,
- dx,
- 0,
- &sr,
- &sr,
- NULL,
- NULL,
- SW_INVALIDATE | SW_SCROLLCHILDREN);
- }
-
- if(cr.left < lr.left && lr.top < lr.bottom) {
- sr.left = cr.left;
- sr.right = lr.left;
- sr.top = lr.top;
- sr.bottom = lr.bottom;
- ScrollWindowEx(
- hwnd,
- dx,
- 0,
- &sr,
- &sr,
- NULL,
- NULL,
- SW_INVALIDATE | SW_SCROLLCHILDREN);
- }
-
- if(lr.top < lr.bottom && lr.left < lr.right) {
- InvalidateRect(hwnd, &lr, FALSE);
- }
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-static void
-cw_vscroll_to_pos(HWND hwnd, khui_credwnd_tbl * tbl, int newpos) {
- RECT cr;
- RECT sr;
- RECT lr;
- int dy;
-
- GetClientRect(hwnd, &cr);
- cr.top += tbl->header_height;
- dy = tbl->scr_top;
-
- tbl->scr_top = newpos;
- cw_update_extents(tbl, TRUE);
-
- dy -= tbl->scr_top;
-
- /* exclude watermark */
- lr.bottom = cr.bottom;
- lr.right = cr.right;
- lr.top = max(cr.bottom - tbl->kbm_logo_shade.cy, cr.top);
- lr.left = max(cr.right - tbl->kbm_logo_shade.cx, cr.left);
-
- if(cr.left < lr.left && cr.top < cr.bottom) {
- sr.left = cr.left;
- sr.right = lr.left;
- sr.top = cr.top;
- sr.bottom = cr.bottom;
- ScrollWindowEx(
- hwnd,
- 0,
- dy,
- &sr,
- &sr,
- NULL,
- NULL,
- SW_INVALIDATE);
- }
-
- if(lr.left < lr.right && cr.top < lr.top) {
- sr.left = lr.left;
- sr.right = lr.right;
- sr.top = cr.top;
- sr.bottom = lr.top;
- ScrollWindowEx(
- hwnd,
- 0,
- dy,
- &sr,
- &sr,
- NULL,
- NULL,
- SW_INVALIDATE);
- }
-
- if(lr.top < lr.bottom && lr.left < lr.right) {
- InvalidateRect(hwnd, &lr, FALSE);
- }
-}
-
-LRESULT
-cw_wm_vscroll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
- SCROLLINFO si;
- int newpos;
- RECT cr;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- GetClientRect(hwnd, &cr);
- cr.top += tbl->header_height;
-
- switch(LOWORD(wParam)) {
- case SB_LEFT:
- newpos = 0;
- break;
-
- case SB_BOTTOM:
- newpos = tbl->ext_height;
- break;
-
- case SB_LINEUP:
- newpos = tbl->scr_top - (tbl->ext_height / 12);
- break;
-
- case SB_LINEDOWN:
- newpos = tbl->scr_top + (tbl->ext_height / 12);
- break;
-
- case SB_PAGEUP:
- newpos = tbl->scr_top - (cr.bottom - cr.top);
- break;
-
- case SB_PAGEDOWN:
- newpos = tbl->scr_top + (cr.bottom - cr.top);
- break;
-
- case SB_THUMBTRACK:
- case SB_THUMBPOSITION:
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_TRACKPOS;
- GetScrollInfo(hwnd, SB_VERT, &si);
-
- newpos = si.nTrackPos;
- break;
-
- default:
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
-
- cw_vscroll_to_pos(hwnd, tbl, newpos);
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-static void
-cw_ensure_row_visible(HWND hwnd, khui_credwnd_tbl * tbl, int row) {
- RECT r;
- int newpos;
-
- if (row < 0)
- row = 0;
- else if (row >= (int) tbl->n_rows)
- row = (int) tbl->n_rows - 1;
-
- GetClientRect(hwnd, &r);
- r.top += tbl->header_height;
-
- if (row * tbl->cell_height < tbl->scr_top) {
- newpos = row * tbl->cell_height;
- } else if ((row + 1) * tbl->cell_height
- > tbl->scr_top + (r.bottom - r.top)) {
- newpos = ((row + 1) * tbl->cell_height) - (r.bottom - r.top);
- } else
- return;
-
- cw_vscroll_to_pos(hwnd, tbl, newpos);
-}
-
-static INT_PTR CALLBACK
-cw_pp_ident_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- khui_property_sheet * s;
-
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- PROPSHEETPAGE * p;
- khm_handle ident;
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- khm_size t;
- khm_int32 i;
-
- p = (PROPSHEETPAGE *) lParam;
- s = (khui_property_sheet *) p->lParam;
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);
-#pragma warning(pop)
-
- ident = s->identity;
-
- t = sizeof(idname);
- kcdb_identity_get_name(ident, idname, &t);
- SetDlgItemText(hwnd, IDC_PP_IDNAME, idname);
-
- kcdb_identity_get_flags(ident, &i);
-
- CheckDlgButton(hwnd, IDC_PP_IDDEF,
- ((i & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:
- BST_UNCHECKED));
-
- /* if it's default, you can't change it further */
- if (i & KCDB_IDENT_FLAG_DEFAULT) {
- EnableWindow(GetDlgItem(hwnd, IDC_PP_IDDEF), FALSE);
- }
-
- CheckDlgButton(hwnd, IDC_PP_IDSEARCH,
- ((i & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:
- BST_UNCHECKED));
-
- CheckDlgButton(hwnd, IDC_PP_STICKY,
- ((i & KCDB_IDENT_FLAG_STICKY)?BST_CHECKED:
- BST_UNCHECKED));
-
- khui_property_wnd_set_record(GetDlgItem(hwnd, IDC_PP_PROPLIST),
- ident);
- }
- return TRUE;
-
- case WM_COMMAND:
- s = (khui_property_sheet *) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (s == NULL)
- return 0;
-
- switch(wParam) {
- case MAKEWPARAM(IDC_PP_IDDEF, BN_CLICKED):
- /* fallthrough */
- case MAKEWPARAM(IDC_PP_STICKY, BN_CLICKED):
-
- if (s->status != KHUI_PS_STATUS_NONE)
- PropSheet_Changed(s->hwnd, hwnd);
- return TRUE;
-
- case MAKEWPARAM(IDC_PP_CONFIG, BN_CLICKED):
- {
- khui_config_node cfg_id = NULL;
- khui_config_node cfg_ids = NULL;
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- khm_size cb;
- khm_int32 rv;
-
- khm_refresh_config();
-
- rv = khui_cfg_open(NULL,
- L"KhmIdentities",
- &cfg_ids);
-
- if (KHM_FAILED(rv))
- return TRUE;
-
- cb = sizeof(idname);
- if (KHM_SUCCEEDED(kcdb_identity_get_name(s->identity,
- idname,
- &cb))) {
- rv = khui_cfg_open(cfg_ids,
- idname,
- &cfg_id);
- }
-
- if (cfg_id)
- khm_show_config_pane(cfg_id);
- else
- khm_show_config_pane(cfg_ids);
-
- if (cfg_ids)
- khui_cfg_release(cfg_ids);
- if (cfg_id)
- khui_cfg_release(cfg_id);
- }
- return TRUE;
- }
- return FALSE;
-
- case WM_NOTIFY:
- {
- LPPSHNOTIFY lpp;
- khm_int32 flags;
-
- lpp = (LPPSHNOTIFY) lParam;
- s = (khui_property_sheet *) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (s == NULL)
- return 0;
-
- switch(lpp->hdr.code) {
- case PSN_APPLY:
- flags = 0;
- if (IsDlgButtonChecked(hwnd, IDC_PP_STICKY) == BST_CHECKED)
- flags |= KCDB_IDENT_FLAG_STICKY;
- if (IsDlgButtonChecked(hwnd, IDC_PP_IDDEF) == BST_CHECKED)
- flags |= KCDB_IDENT_FLAG_DEFAULT;
-
- kcdb_identity_set_flags(s->identity, flags,
- KCDB_IDENT_FLAG_STICKY |
- KCDB_IDENT_FLAG_DEFAULT);
- khm_refresh_identity_menus();
- return TRUE;
-
- case PSN_RESET:
- kcdb_identity_get_flags(s->identity, &flags);
-
- CheckDlgButton(hwnd,
- IDC_PP_IDDEF,
- ((flags & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:
- BST_UNCHECKED));
-
- /* if it's default, you can't change it further */
- if (flags & KCDB_IDENT_FLAG_DEFAULT) {
- EnableWindow(GetDlgItem(hwnd, IDC_PP_IDDEF), FALSE);
- }
-
- CheckDlgButton(hwnd, IDC_PP_IDSEARCH,
- ((flags & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:BST_UNCHECKED));
-
- CheckDlgButton(hwnd, IDC_PP_STICKY,
- ((flags & KCDB_IDENT_FLAG_STICKY)?BST_CHECKED:BST_UNCHECKED));
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
-}
-
-static INT_PTR CALLBACK
-cw_pp_cred_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
- )
-{
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- khui_property_sheet * s;
- PROPSHEETPAGE * p;
- khm_handle cred;
-
- p = (PROPSHEETPAGE *) lParam;
- s = (khui_property_sheet *) p->lParam;
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);
-#pragma warning(pop)
-
- cred = s->cred;
-
- khui_property_wnd_set_record(
- GetDlgItem(hwnd, IDC_PP_CPROPLIST),
- cred);
- }
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-cw_pp_begin(khui_property_sheet * s)
-{
- PROPSHEETPAGE *p;
-
- if(s->identity) {
- p = PMALLOC(sizeof(*p));
- ZeroMemory(p, sizeof(*p));
-
- p->dwSize = sizeof(*p);
- p->dwFlags = 0;
- p->hInstance = khm_hInstance;
- p->pszTemplate = MAKEINTRESOURCE(IDD_PP_IDENT);
- p->pfnDlgProc = cw_pp_ident_proc;
- p->lParam = (LPARAM) s;
-
- khui_ps_add_page(s, KHUI_PPCT_IDENTITY, 129, p, NULL);
- }
-
- if(s->cred) {
- p = PMALLOC(sizeof(*p));
- ZeroMemory(p, sizeof(*p));
-
- p->dwSize = sizeof(*p);
- p->dwFlags = 0;
- p->hInstance = khm_hInstance;
- p->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED);
- p->pfnDlgProc = cw_pp_cred_proc;
- p->lParam = (LPARAM) s;
-
- khui_ps_add_page(s, KHUI_PPCT_CREDENTIAL, 128, p, NULL);
- }
-}
-
-static void
-cw_pp_precreate(khui_property_sheet * s)
-{
- khui_ps_show_sheet(khm_hwnd_main, s);
-
- khm_add_property_sheet(s);
-}
-
-static void
-cw_pp_end(khui_property_sheet * s)
-{
- khui_property_page * p = NULL;
-
- khui_ps_find_page(s, KHUI_PPCT_IDENTITY, &p);
- if(p) {
- PFREE(p->p_page);
- p->p_page = NULL;
- }
-
- p = NULL;
-
- khui_ps_find_page(s, KHUI_PPCT_CREDENTIAL, &p);
- if(p) {
- PFREE(p->p_page);
- p->p_page = NULL;
- }
-}
-
-static void
-cw_pp_destroy(khui_property_sheet *ps)
-{
- if(ps->ctx.scope == KHUI_SCOPE_CRED) {
- if(ps->header.pszCaption)
- PFREE((LPWSTR) ps->header.pszCaption);
- }
-
- khui_context_release(&ps->ctx);
-
- khui_ps_destroy_sheet(ps);
-
- /* this is pretty weird because ps gets freed when
- khui_ps_destroy_sheet() is called. However, since destroying
- ps involves sending a WM_DESTROY message to the property sheet,
- we still need to keep it on the property sheet chain (or else
- the messages will not be delivered). This is only safe because
- we are not relinquishing the thread in-between destroying ps
- and removing it from the chain. */
-
- /* TODO: fix this */
- khm_del_property_sheet(ps);
-}
-
-LRESULT
-cw_properties(HWND hwnd)
-{
- /* show a property sheet of some sort */
- khui_action_context ctx;
- khui_property_sheet * ps;
- khui_credwnd_tbl * tbl;
-
- khui_context_get(&ctx);
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- if(ctx.scope == KHUI_SCOPE_NONE) {
- khui_context_release(&ctx);
- return FALSE;
- }
-
- /* if still no context, then we can't show a property sheet */
- if(ctx.scope == KHUI_SCOPE_NONE) {
- khui_context_release(&ctx);
- return FALSE;
- }
-
- khui_ps_create_sheet(&ps);
-
- if(ctx.scope == KHUI_SCOPE_IDENT) {
- khm_handle ident;
- khm_size t;
-
- ident = ctx.identity;
-
- ps->header.hInstance = khm_hInstance;
- ps->header.pszIcon = MAKEINTRESOURCE(IDI_MAIN_APP);
-
- kcdb_identity_get_name(ident, NULL, &t);
-
- if(t > 0) {
- ps->header.pszCaption = PMALLOC(t);
- kcdb_identity_get_name(ident,
- (wchar_t *) ps->header.pszCaption, &t);
- } else {
- ps->header.pszCaption = NULL;
- }
-
- ps->ctx = ctx;
- ps->identity = ident;
- ps->credtype = KCDB_CREDTYPE_INVALID;
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_PP_BEGIN, 0, (void *) ps);
-
- } else if(ctx.scope == KHUI_SCOPE_CREDTYPE) {
- khm_size t = 0;
- khm_int32 cred_type;
-
- if (ctx.identity == NULL) {
- /* currently, we can't show a property sheet at this point
- since most credentials providers don't provide a
- property sheet that works without an identity. */
-
- khui_context_release(&ctx);
- khui_ps_destroy_sheet(ps);
- return TRUE;
- }
-
- cred_type = ctx.cred_type;
-
- ps->header.hInstance = khm_hInstance;
- ps->header.pszIcon = MAKEINTRESOURCE(IDI_MAIN_APP);
-
- ps->ctx = ctx;
- ps->credtype = cred_type;
-
- if(ctx.identity) {
- ps->identity = ctx.identity;
- /* also, if there is an associated identity, we assume that
- the properties are for the specified credentials type
- specific to the identity. Hence we change the title to
- something else */
- kcdb_identity_get_name(ctx.identity, NULL, &t);
- if (t > 0) {
- ps->header.pszCaption = PMALLOC(t);
- kcdb_identity_get_name(ctx.identity, (wchar_t *) ps->header.pszCaption, &t);
- } else {
- ps->header.pszCaption = NULL;
- }
- } else {
- /* we don't actually reach here since we handle this case
- above */
- kcdb_credtype_describe(cred_type, NULL, &t, KCDB_TS_LONG);
- if(t > 0) {
- ps->header.pszCaption = PMALLOC(t);
- kcdb_credtype_describe(cred_type, (wchar_t *) ps->header.pszCaption, &t, KCDB_TS_LONG);
- } else {
- ps->header.pszCaption = NULL;
- }
- }
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_PP_BEGIN, 0, (void *) ps);
- } else if(ctx.scope == KHUI_SCOPE_CRED) {
- khm_handle cred;
- khm_size t;
-
- cred = ctx.cred;
-
- ps->header.hInstance = khm_hInstance;
- ps->header.pszIcon = MAKEINTRESOURCE(IDI_MAIN_APP);
- ps->ctx = ctx;
-
- kcdb_cred_get_name(cred, NULL, &t);
- ps->header.pszCaption = PMALLOC(t);
- kcdb_cred_get_name(cred, (LPWSTR) ps->header.pszCaption, &t);
-
- kcdb_cred_get_identity(cred, &ps->identity);
- kcdb_cred_get_type(cred, &ps->credtype);
- ps->cred = cred;
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_PP_BEGIN, 0, (void *) ps);
- } else {
- khui_context_release(&ctx);
- khui_ps_destroy_sheet(ps);
- }
-
- /* by the way, if we are actually opening a property sheet, we
- leave ctx held (which is now copied to ps->ctx). it will be
- released when the property sheet is destroyed */
-
- return TRUE;
-}
-
-LRESULT
-cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- khui_credwnd_tbl * tbl;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- if(HIWORD(wParam) == BN_CLICKED &&
- LOWORD(wParam) == KHUI_HTWND_CTLID) {
-
- wchar_t wid[256];
- /* a hyperlink was activated */
- khui_htwnd_link * l;
- l = (khui_htwnd_link *) lParam;
- StringCchCopyN(wid, ARRAYLENGTH(wid), l->id, l->id_len);
- wid[l->id_len] = 0;
-
- if(!wcscmp(wid, L"NewCreds")) {
- PostMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(KHUI_ACTION_NEW_CRED,0), 0);
- }
- return TRUE;
- }
-
- switch(LOWORD(wParam))
- {
- case KHUI_PACTION_ENTER:
- /* enter key is a synonym for the default action, on the
- context, which is to lauch a property sheet */
- /* fallthrough */
- case KHUI_ACTION_PROPERTIES:
- {
- return cw_properties(hwnd);
- }
- break;
-
- case KHUI_ACTION_LAYOUT_RELOAD:
- {
- wchar_t cname[KCONF_MAXCCH_NAME];
- khm_size cb;
-
- cname[0] = L'\0';
-
- if (tbl->csp_view) {
- cb = sizeof(cname);
- khc_get_config_space_name(tbl->csp_view,
- cname,
- &cb);
- }
-
- cw_unload_view(tbl);
-
- cw_load_view(tbl, ((cname[0])?cname: NULL), hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
- }
- break;
-
- case KHUI_ACTION_LAYOUT_ID:
- {
- cw_save_view(tbl, NULL);
- cw_unload_view(tbl);
-
- cw_load_view(tbl, L"ByIdentity", hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- }
- break;
-
- case KHUI_ACTION_LAYOUT_LOC:
- {
- cw_save_view(tbl, NULL);
- cw_unload_view(tbl);
-
- cw_load_view(tbl, L"ByLocation", hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- }
- break;
-
- case KHUI_ACTION_LAYOUT_TYPE:
- {
- cw_save_view(tbl, NULL);
- cw_unload_view(tbl);
-
- cw_load_view(tbl, L"ByType", hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- }
- break;
-
- case KHUI_ACTION_LAYOUT_CUST:
- {
- cw_save_view(tbl, NULL);
- cw_unload_view(tbl);
-
- cw_load_view(tbl, L"Custom_0", hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- }
- break;
-
- case KHUI_ACTION_LAYOUT_MINI:
- {
- cw_save_view(tbl, NULL);
- cw_unload_view(tbl);
-
- cw_load_view(tbl, NULL, hwnd);
- cw_insert_header_cols(tbl);
-
- cw_update_creds(tbl);
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_select_row(tbl, tbl->cursor_row, 0);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
- }
- break;
-
- case KHUI_ACTION_VIEW_ALL_IDS:
- {
- khm_handle hc_cw = NULL;
-
- tbl->view_all_idents = !tbl->view_all_idents;
-
- cw_update_outline(tbl);
- cw_update_extents(tbl, TRUE);
- cw_update_selection_state(tbl);
-
- InvalidateRect(tbl->hwnd, NULL, TRUE);
-
- if(KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ | KHM_PERM_WRITE,
- &hc_cw))) {
- khc_write_int32(hc_cw, L"ViewAllIdents", tbl->view_all_idents);
- khc_close_space(hc_cw);
- }
-
- khui_check_action(KHUI_ACTION_VIEW_ALL_IDS, tbl->view_all_idents);
-
- khm_refresh_identity_menus();
- }
- break;
-
- case KHUI_PACTION_UP:
- case KHUI_PACTION_UP_EXTEND:
- case KHUI_PACTION_UP_TOGGLE:
- { /* cursor up */
- khm_int32 new_row;
- WPARAM wp = 0;
-
- new_row = tbl->cursor_row - 1;
-
- /* checking both bounds. we make no assumption about the
- value of cursor_row before this message */
- if(new_row < 0)
- new_row = 0;
- if(new_row >= (int) tbl->n_rows)
- new_row = (int) tbl->n_rows - 1;
-
- if (LOWORD(wParam) == KHUI_PACTION_UP)
- wp = 0;
- else if (LOWORD(wParam) == KHUI_PACTION_UP_EXTEND)
- wp = MK_SHIFT;
- else if (LOWORD(wParam) == KHUI_PACTION_UP_TOGGLE)
- wp = 0; //MK_CONTROL;
- else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- cw_select_row(tbl, new_row, wp);
- cw_ensure_row_visible(hwnd, tbl, new_row);
- }
- break;
-
- case KHUI_PACTION_PGUP_EXTEND:
- case KHUI_PACTION_PGUP:
- {
- khm_int32 new_row;
- WPARAM wp;
- RECT r;
-
- if (LOWORD(wParam) == KHUI_PACTION_PGUP_EXTEND)
- wp = MK_SHIFT;
- else
- wp = 0;
-
- GetClientRect(hwnd, &r);
-
- new_row = tbl->cursor_row -
- ((r.bottom - r.top) - tbl->header_height) / tbl->cell_height;
-
- if (new_row < 0)
- new_row = 0;
- if (new_row >= (int) tbl->n_rows)
- new_row = (int) tbl->n_rows - 1;
-
- cw_select_row(tbl, new_row, wp);
- cw_ensure_row_visible(hwnd, tbl, new_row);
- }
- break;
-
- case KHUI_PACTION_DOWN:
- case KHUI_PACTION_DOWN_EXTEND:
- case KHUI_PACTION_DOWN_TOGGLE:
- { /* cursor down */
- khm_int32 new_row;
- WPARAM wp = 0;
-
- new_row = tbl->cursor_row + 1;
-
- /* checking both bounds. we make no assumption about the
- value of cursor_row before this message */
- if(new_row < 0)
- new_row = 0;
- if(new_row >= (int) tbl->n_rows)
- new_row = (int) tbl->n_rows - 1;
-
- if (LOWORD(wParam) == KHUI_PACTION_DOWN)
- wp = 0;
- else if (LOWORD(wParam) == KHUI_PACTION_DOWN_EXTEND)
- wp = MK_SHIFT;
- else if (LOWORD(wParam) == KHUI_PACTION_DOWN_TOGGLE)
- wp = 0; //MK_CONTROL;
- else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- cw_select_row(tbl, new_row, wp);
- cw_ensure_row_visible(hwnd, tbl, new_row);
- }
- break;
-
- case KHUI_PACTION_PGDN_EXTEND:
- case KHUI_PACTION_PGDN:
- {
- khm_int32 new_row;
- RECT r;
- WPARAM wp;
-
- if (LOWORD(wParam) == KHUI_PACTION_PGDN_EXTEND)
- wp = MK_SHIFT;
- else
- wp = 0;
-
- GetClientRect(hwnd, &r);
-
- new_row = tbl->cursor_row +
- ((r.bottom - r.top) - tbl->header_height) / tbl->cell_height;
-
- if (new_row < 0)
- new_row = 0;
- if (new_row >= (int) tbl->n_rows)
- new_row = (int) tbl->n_rows - 1;
-
- cw_select_row(tbl, new_row, wp);
- cw_ensure_row_visible(hwnd, tbl, new_row);
- }
- break;
-
- case KHUI_PACTION_SELALL:
- {
- cw_select_all(tbl);
- }
- break;
-
- case KHUI_PACTION_LEFT:
- { /* collapse and up*/
- khui_credwnd_outline * o;
- int r;
-
- if(tbl->cursor_row < 0 || tbl->cursor_row >= (int) tbl->n_rows) {
- cw_select_row(tbl, 0, 0);
- break;
- }
-
- for(r = tbl->cursor_row;
- (r >= 0 && !(tbl->rows[r].flags & KHUI_CW_ROW_HEADER));
- r--);
-
- if(r < 0)
- break;
-
- /* If we were not on a header, we collapse the innermost
- outline. Otherwise, we collpase up to the parent
- outline level */
-
- if(r != tbl->cursor_row) {
- o = (khui_credwnd_outline *) tbl->rows[r].data;
-
- cw_toggle_outline_state(tbl, o);
- } else {
- o = (khui_credwnd_outline *) tbl->rows[r].data;
-
- if(o->flags & KHUI_CW_O_EXPAND) {
- cw_toggle_outline_state(tbl, o);
- } else {
- o = TPARENT(o);
- if(o) {
- cw_toggle_outline_state(tbl, o);
- r = o->start;
- } else if(r > 0)
- r--;
- }
- }
-
- cw_select_row(tbl, r, 0);
- }
- break;
-
- case KHUI_PACTION_RIGHT:
- { /* expand and down*/
- khui_credwnd_outline * o;
- int r;
-
- if(tbl->cursor_row < 0 ||
- tbl->cursor_row >= (int) tbl->n_rows) {
- cw_select_row(tbl, 0, 0);
- break;
- }
-
- r = tbl->cursor_row;
-
- if(tbl->rows[r].flags & KHUI_CW_ROW_HEADER) {
- o = (khui_credwnd_outline *) tbl->rows[r].data;
- if(!(o->flags & KHUI_CW_O_EXPAND)) {
- cw_toggle_outline_state(tbl, o);
- }
- }
-
- r++;
- if (r >= (int) tbl->n_rows)
- r = (int)tbl->n_rows - 1;
-
- cw_select_row(tbl, r, 0);
- }
- break;
- }
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-LRESULT
-cw_wm_contextmenu(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- RECT r;
- int x,y;
- int row;
- khui_credwnd_tbl * tbl;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return 0;
-
- GetWindowRect(hwnd, &r);
-
- x = GET_X_LPARAM(lParam);
- y = GET_Y_LPARAM(lParam);
-
- /* if the user invokes the context menu using the keyboard, we get
- x=-1 and y=-1. In this case, we use the cursor_row as the
- target row. */
- if (x == -1 && y == -1) {
-
- row = tbl->cursor_row;
-
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
- int i;
-
- y = 0;
- for (i=0; i < tbl->n_rows && i < row; i++) {
- if (tbl->rows[i].flags & KHUI_CW_ROW_EXPVIEW)
- y += tbl->cell_height * CW_EXP_ROW_MULT;
- else
- y += tbl->cell_height;
- }
- } else {
- y = row * tbl->cell_height;
- }
-
- x = r.left;
- y = y + r.top + tbl->header_height - tbl->scr_top;
-
- goto have_row;
- }
-
- x += tbl->scr_left - r.left;
- y += tbl->scr_top - tbl->header_height - r.top;
-
- if (y < 0) {
- /* context menu for header control */
- khm_menu_show_panel(KHUI_MENU_CWHEADER_CTX,
- GET_X_LPARAM(lParam),
- GET_Y_LPARAM(lParam));
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
- }
-
- if (tbl->flags & KHUI_CW_TBL_EXPIDENT) {
- int i, yt;
-
- yt = 0;
- for (i=0; i < tbl->n_rows && yt < y; i++) {
- if (tbl->rows[i].flags & KHUI_CW_ROW_EXPVIEW)
- yt += tbl->cell_height * CW_EXP_ROW_MULT;
- else
- yt += tbl->cell_height;
- if (yt > y)
- break;
- }
-
- row = i;
-
- } else {
- row = y / tbl->cell_height;
- }
-
- if(row < 0 || row >= (int) tbl->n_rows)
- return FALSE;
-
- /* now, if the user has right clicked outside the selection, we
- treat the right-click as a regular click before showing the
- context menu. */
- if (!(tbl->rows[row].flags & KHUI_CW_ROW_SELECTED)) {
- cw_select_row(tbl, row, 0);
- }
-
- x = GET_X_LPARAM(lParam);
- y = GET_Y_LPARAM(lParam);
-
- have_row:
-
- cw_set_row_context(tbl, row);
-
- khm_menu_show_panel(KHUI_MENU_IDENT_CTX, x, y);
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-/* copy and paste template */
-#if 0
-LRESULT
-cw_wm_msg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-#endif
-
-LRESULT CALLBACK
-khm_credwnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch(uMsg) {
- case WM_COMMAND:
- return cw_wm_command(hwnd, uMsg, wParam, lParam);
-
- case WM_CREATE:
- return cw_wm_create(hwnd, uMsg, wParam, lParam);
-
- case WM_DESTROY:
- return cw_wm_destroy(hwnd, uMsg, wParam, lParam);
-
- case WM_ERASEBKGND:
- /* we don't bother wasting cycles erasing the background
- because the foreground elements completely cover the
- client area */
- return FALSE;
-
- case WM_PAINT:
- return cw_wm_paint(hwnd, uMsg, wParam, lParam);
-
- case WM_PRINTCLIENT:
- return cw_wm_paint(hwnd, uMsg, wParam, lParam);
-
- case WM_SIZE:
- return cw_wm_size(hwnd, uMsg, wParam, lParam);
-
- case WM_NOTIFY:
- return cw_wm_notify(hwnd, uMsg, wParam, lParam);
-
- case WM_HSCROLL:
- return cw_wm_hscroll(hwnd, uMsg, wParam, lParam);
-
- case WM_VSCROLL:
- return cw_wm_vscroll(hwnd, uMsg, wParam, lParam);
-
- case KMQ_WM_DISPATCH:
- return cw_kmq_wm_dispatch(hwnd, uMsg, wParam, lParam);
-
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- case WM_MOUSEMOVE:
- case WM_LBUTTONUP:
- return cw_wm_mouse(hwnd, uMsg, wParam, lParam);
-
- case WM_CONTEXTMENU:
- return cw_wm_contextmenu(hwnd, uMsg, wParam, lParam);
- }
-
- return DefWindowProc(hwnd,uMsg,wParam,lParam);
-}
-
-void
-khm_measure_identity_menu_item(HWND hwnd, LPMEASUREITEMSTRUCT lpm, khui_action * act)
-{
- wchar_t * cap;
- HDC hdc;
- SIZE sz;
- size_t len;
- HFONT hf_old;
-
- sz.cx = MENU_SIZE_ICON_X;
- sz.cy = MENU_SIZE_ICON_Y;
-
- cap = act->caption;
-#ifdef DEBUG
- assert(cap);
-#endif
- hdc = GetDC(khm_hwnd_main);
-#ifdef DEBUG
- assert(hdc);
-#endif
-
- StringCchLength(cap, KHUI_MAXCCH_NAME, &len);
-
- hf_old = SelectFont(hdc, (HFONT) GetStockObject(DEFAULT_GUI_FONT));
-
- GetTextExtentPoint32(hdc, cap, (int) len, &sz);
-
- SelectFont(hdc, hf_old);
-
- ReleaseDC(khm_hwnd_main, hdc);
-
- lpm->itemWidth = sz.cx + sz.cy * 3 / 2 + GetSystemMetrics(SM_CXSMICON);
- lpm->itemHeight = sz.cy * 3 / 2;
-}
-
-void
-khm_draw_identity_menu_item(HWND hwnd, LPDRAWITEMSTRUCT lpd, khui_action * act)
-{
- khui_credwnd_tbl * tbl;
- khm_handle ident;
- size_t count = 0;
- COLORREF old_clr;
- wchar_t * cap;
- size_t len;
- int margin;
- SIZE sz;
- HBRUSH hbr;
- COLORREF text_clr;
- khm_int32 idflags;
- khm_int32 expflags;
-
- tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (tbl == NULL)
- return;
-
- ident = act->data;
- cap = act->caption;
-#ifdef DEBUG
- assert(ident != NULL);
- assert(cap != NULL);
-#endif
-
- {
- khui_credwnd_ident * cwi;
-
- cwi = cw_find_ident(tbl, ident);
- if (cwi) {
- count = cwi->id_credcount;
- } else {
- count = 0;
- }
- }
-
- expflags = cw_get_buf_exp_flags(tbl, ident);
-
- text_clr = tbl->cr_hdr_normal;
-
- if (lpd->itemState & (ODS_HOTLIGHT | ODS_SELECTED)) {
- hbr = GetSysColorBrush(COLOR_HIGHLIGHT);
- text_clr = GetSysColor(COLOR_HIGHLIGHTTEXT);
- } else if (expflags == CW_EXPSTATE_EXPIRED) {
- hbr = tbl->hb_hdr_bg_exp;
- } else if (expflags == CW_EXPSTATE_WARN) {
- hbr = tbl->hb_hdr_bg_warn;
- } else if (expflags == CW_EXPSTATE_CRITICAL) {
- hbr = tbl->hb_hdr_bg_crit;
- } else if (count > 0) {
- hbr = tbl->hb_hdr_bg_cred;
- } else {
- hbr = tbl->hb_hdr_bg;
- }
-
- FillRect(lpd->hDC, &lpd->rcItem, hbr);
-
- SetBkMode(lpd->hDC, TRANSPARENT);
-
- old_clr = SetTextColor(lpd->hDC, text_clr);
-
- StringCchLength(cap, KHUI_MAXCCH_NAME, &len);
-
- GetTextExtentPoint32(lpd->hDC, cap, (int) len, &sz);
- margin = sz.cy / 4;
-
- TextOut(lpd->hDC, lpd->rcItem.left + margin * 2 + GetSystemMetrics(SM_CXSMICON),
- lpd->rcItem.top + margin, cap, (int) len);
-
- SetTextColor(lpd->hDC, old_clr);
-
- kcdb_identity_get_flags(ident, &idflags);
-
- if (idflags & KCDB_IDENT_FLAG_DEFAULT) {
- HICON hic;
-
- hic = (HICON) LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_ENABLED),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTCOLOR);
- if (hic) {
- DrawIconEx(lpd->hDC,
- lpd->rcItem.left + margin,
- lpd->rcItem.top + margin,
- hic,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- 0,
- hbr,
- DI_NORMAL);
- DestroyIcon(hic);
- }
- }
-}
-
-void
-khm_register_credwnd_class(void) {
- WNDCLASSEX wcx;
- kcdb_attrib attrib;
- khm_int32 attr_id;
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = CS_DBLCLKS | CS_OWNDC;
- wcx.lpfnWndProc = khm_credwnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = sizeof(LONG_PTR);
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = NULL;
- wcx.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
- wcx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_CREDWND_CLASS_NAME;
- wcx.hIconSm = NULL;
-
- khui_credwnd_cls = RegisterClassEx(&wcx);
-
- /* while we are at it, register the credwnd attribute type as well, and
- obtain the type ID */
- if(KHM_FAILED(kcdb_attrib_get_id(KHUI_CREDWND_FLAG_ATTRNAME, &attr_id))) {
- ZeroMemory(&attrib, sizeof(attrib));
- attrib.id = KCDB_ATTR_INVALID;
- attrib.flags = KCDB_ATTR_FLAG_HIDDEN;
- attrib.type = KCDB_TYPE_INT32;
- attrib.name = KHUI_CREDWND_FLAG_ATTRNAME;
-
- kcdb_attrib_register(&attrib, &attr_id);
- }
-
- khui_cw_flag_id = attr_id;
-}
-
-void
-khm_unregister_credwnd_class(void) {
- UnregisterClass(MAKEINTATOM(khui_credwnd_cls), khm_hInstance);
-}
-
-HWND
-khm_create_credwnd(HWND parent) {
- RECT r;
- HWND hwnd;
-
- ZeroMemory(attr_to_action, sizeof(attr_to_action));
-
- GetClientRect(parent, &r);
-
- hwnd = CreateWindowEx
- (0,
- MAKEINTATOM(khui_credwnd_cls),
- L"",
- WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
- r.left,
- r.top,
- r.right - r.left,
- r.bottom - r.top,
- parent,
- NULL,
- khm_hInstance,
- NULL);
-
- return hwnd;
-}
diff --git a/src/windows/identity/ui/credwnd.h b/src/windows/identity/ui/credwnd.h
deleted file mode 100644
index 7f9071014..000000000
--- a/src/windows/identity/ui/credwnd.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_CREDWND_H
-#define __KHIMAIRA_CREDWND_H
-
-#define KHUI_CREDWND_CLASS_NAME L"NetIDMgrCredWnd"
-
-#define KHUI_CREDWND_FLAG_ATTRNAME L"CredWndFlags"
-
-extern khm_int32 khui_cw_flag_id;
-
-/* The expiration states */
-#define CW_EXPSTATE_NONE 0x00000000
-#define CW_EXPSTATE_WARN 0x00000400
-#define CW_EXPSTATE_CRITICAL 0x00000800
-#define CW_EXPSTATE_EXPIRED 0x00000c00
-
-#define CW_EXPSTATE_MASK 0x00000c00
-
-typedef struct khui_credwnd_outline_t {
- khm_int32 flags; /* combination of KHUI_CW_O_* */
- khm_int32 start; /* first row of outline */
- khm_int32 length; /* number of rows in outline */
- khm_int32 level; /* outline level */
- khm_int32 col; /* outline column */
- wchar_t *header; /* character string associated with header */
- khm_int32 attr_id;
- void * data; /* level specific data :
- Identity -> handle to identity
- Type -> type ID
- otherwise -> canonical data buffer
- */
- khm_size cb_data;
-
- khm_size idx_start; /* index of the first cred in the credset */
- khm_size idx_end; /* index of the last cred in the credset */
- TDCL(struct khui_credwnd_outline_t);
-} khui_credwnd_outline;
-
-#define KHUI_CW_O_EXPAND 0x00000001
-#define KHUI_CW_O_STICKY 0x00000002
-#define KHUI_CW_O_VISIBLE 0x00000004
-#define KHUI_CW_O_SHOWFLAG 0x00000008
-#define KHUI_CW_O_SELECTED 0x00000010
-#define KHUI_CW_O_DATAALLOC 0x00000020
-#define KHUI_CW_O_NOOUTLINE 0x00000040
-#define KHUI_CW_O_RELIDENT 0x00000080
-#define KHUI_CW_O_EMPTY 0x00000100
-/* NOTE: KHUI_CW_O_* shares the same bit-space as CW_EXPSTATE_* */
-
-typedef struct khui_credwnd_row_t {
- khm_int32 flags;
- khm_int32 col;
- khm_handle data;
- khm_size idx_start;
- khm_size idx_end;
- RECT r_ext; /* extents of this row */
-} khui_credwnd_row;
-
-#define KHUI_CW_ROW_CRED 0x00000002
-#define KHUI_CW_ROW_HEADER 0x00000004
-#define KHUI_CW_ROW_TIMERSET 0x00000008
-#define KHUI_CW_ROW_SELECTED 0x00000010
-#define KHUI_CW_ROW_EXPVIEW 0x00000020
-/* NOTE: KHUI_CW_ROW_* shares the same bit-space as CW_EXPSTATE_* */
-
-/* row allocation */
-/* initial number of rows to be allocated */
-#define KHUI_CW_ROW_INITIAL 512
-/* allocation increment, if we run out of space */
-#define KHUI_CW_ROW_INCREMENT 512
-
-typedef struct khui_credwnd_col_t {
- khm_int32 attr_id;
- khm_int32 width; /* width of the column (screen units) */
- khm_int32 x; /* starting x coordinate (screen units) */
- khm_int32 flags; /* combination of KHUI_CW_COL_* */
- khm_int32 sort_index;
- wchar_t * title;
-} khui_credwnd_col;
-
-/* column allocation */
-/* initial number of columns to be allocated */
-#define KHUI_CW_COL_INITIAL 16
-/* allocation increment, if we run out of space */
-#define KHUI_CW_COL_INCREMENT 16
-
-#define KHUI_CW_COL_AUTOSIZE 0x00000001
-#define KHUI_CW_COL_SORT_INC 0x00000002
-#define KHUI_CW_COL_SORT_DEC 0x00000004
-#define KHUI_CW_COL_GROUP 0x00000008
-#define KHUI_CW_COL_FIXED_WIDTH 0x00000010
-#define KHUI_CW_COL_FIXED_POS 0x00000020
-#define KHUI_CW_COL_META 0x00000040
-#define KHUI_CW_COL_FILLER 0x00000080
-
-/* Custom column attributes (are not kcdb attributes) */
-#define CW_CA_FLAGS -1
-#define CW_CANAME_FLAGS L"_CWFlags"
-
-#define CW_CA_TYPEICON -2
-#define CW_CANAME_TYPEICON L"_CWTypeIcon"
-
-#define cw_is_custom_attr(i) ((i)<0)
-
-typedef struct tag_khui_credwnd_ident {
-
- khm_handle ident;
- khm_int32 ident_flags;
- khm_int32 credtype;
- wchar_t name[KCDB_IDENT_MAXCCH_NAME];
- wchar_t credtype_name[KCDB_MAXCCH_NAME];
-
- khm_size credcount; /* count of all credentials */
- khm_size id_credcount; /* count of identity credentials
- (credentials that are of the
- identity type */
- khm_size init_credcount; /* count of initial credentials */
- FILETIME ft_expire;
-
-} khui_credwnd_ident;
-
-#define CW_IDENT_ALLOC_INCR 4
-
-#define CW_EXP_ROW_MULT 2
-
-typedef struct khui_credwnd_tbl_t {
- HWND hwnd; /* the window that this table belongs to */
-
- khm_handle csp_view; /* handle to the configuration space
- that defined the view */
-
- khm_int32 scr_top; /* screen units */
- khm_int32 scr_left; /* screen units */
- khm_int32 ext_width; /* screen units */
- khm_int32 ext_height; /* screen units */
- khm_int32 cell_height; /* screen units */
-
- HWND hwnd_header; /* header control */
- khm_int32 header_height; /* height of the header */
- HWND hwnd_notif; /* notification control */
-
- khui_credwnd_col * cols; /* n_cols elements */
- khui_credwnd_row * rows; /* n_rows elements */
- int n_cols;
- int n_total_cols; /* number of columns actually
- allocated in cols */
- int n_rows;
- int n_total_rows; /* number of rows actually allocated
- in rows */
-
- khui_credwnd_outline * outline;
-
- khm_int32 flags; /* combo of KHUI_CW_TBL_* */
-
- int cursor_row; /* cursor and selection */
- int anchor_row; /* anchor, for range selections */
-
- /* view parameters */
- khm_int32 hpad;
- khm_int32 vpad;
- khm_int32 hpad_h; /* horizontal padding correction for headers */
- khm_int32 threshold_warn; /* Warning threshold, in seconds*/
- khm_int32 threshold_critical; /* Critical threshold, in seconds */
-
- /* graphics objects we are going to need. */
- HFONT hf_normal; /* normal text */
- HFONT hf_header; /* header text */
- HFONT hf_bold; /* bold text */
- HFONT hf_bold_header; /* bold header text */
-
- HBRUSH hb_normal; /* normal background brush */
- HBRUSH hb_grey; /* normal background brush (greyed) */
- HBRUSH hb_s; /* normal background brush (selected) */
-
- HBRUSH hb_hdr_bg; /* header background brush (normal) */
- HBRUSH hb_hdr_bg_cred; /* header background brush (valid creds) */
- HBRUSH hb_hdr_bg_exp; /* header background brush (expired) */
- HBRUSH hb_hdr_bg_warn; /* header background brush (warn) */
- HBRUSH hb_hdr_bg_crit; /* header background brush (critical) */
-
- HBRUSH hb_hdr_bg_s; /* header background brush (selected) */
- HBRUSH hb_hdr_bg_cred_s;/* header background brush (valid creds) */
- HBRUSH hb_hdr_bg_exp_s; /* header background brush (expired,selected) */
- HBRUSH hb_hdr_bg_warn_s;/* header background brush (warn,selected) */
- HBRUSH hb_hdr_bg_crit_s;/* header background brush (critical,selected) */
-
- COLORREF cr_normal; /* text color (normal) */
- COLORREF cr_s; /* text color (selected) */
- COLORREF cr_hdr_normal; /* header text color (normal) */
- COLORREF cr_hdr_s; /* header text color (selected) */
- COLORREF cr_hdr_gray; /* header text color (greyed) */
- COLORREF cr_hdr_gray_s; /* header text color (greyed,selected) */
-
- COLORREF cr_hdr_outline;/* header outline color */
-
- HCURSOR hc_hand; /* the HAND cursor */
- khui_ilist * ilist; /* image list */
-
- HICON hi_lg_ident; /* large identity icon */
-
- /* mouse state */
- khm_int32 mouse_state; /* state of the mouse can be combo of CW_MOUSE_* values */
- khm_int32 mouse_row; /* row that the mouse state applies to */
- khm_int32 mouse_col; /* col that the mouse state applies to */
-
- khui_bitmap kbm_logo_shade;
-
- /* the credentials set */
- khm_handle credset;
-
- khui_credwnd_ident * idents;
- khm_size n_idents;
- khm_size nc_idents;
-
- khm_int32 view_all_idents;
-
-} khui_credwnd_tbl;
-
-#define KHUI_MAXCB_HEADING 256
-
-/* table flags */
-#define KHUI_CW_TBL_INITIALIZED 0x00000001
-#define KHUI_CW_TBL_COL_DIRTY 0x00000002
-#define KHUI_CW_TBL_ROW_DIRTY 0x00000004
-#define KHUI_CW_TBL_ACTIVE 0x00000100
-#define KHUI_CW_TBL_CUSTVIEW 0x00000200
-#define KHUI_CW_TBL_COLSKIP 0x00000400
-#define KHUI_CW_TBL_EXPIDENT 0x00000800
-#define KHUI_CW_TBL_NOHEADER 0x00001000
-
-/* mouse_state constants */
-#define CW_MOUSE_NONE 0x00000000 /* nothing interesting */
-#define CW_MOUSE_WIDGET 0x00000001 /* mouse is highlighting a
- widget */
-#define CW_MOUSE_LDOWN 0x00000002 /* left button is down */
-#define CW_MOUSE_ROW 0x00000004 /* mouse is acive over a valid
- row */
-#define CW_MOUSE_WOUTLINE 0x00000008 /* mouse is highlighting an
- outline widget */
-#define CW_MOUSE_WSTICKY 0x00000010 /* mouse is highlighting a
- sticky widget */
-#define CW_MOUSE_WICON 0x00000020 /* an icon widget. represents
- the icon next to identities
- and next to credentials. */
-
-#define CW_MOUSE_WMASK 0x00000039 /* all widget bits */
-
-void khm_unregister_credwnd_class(void);
-
-void khm_register_credwnd_class(void);
-
-HWND khm_create_credwnd(HWND parent);
-
-LRESULT CALLBACK khm_credwnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
- );
-
-void cw_load_view(khui_credwnd_tbl * tbl, wchar_t * viewname, HWND hwnd);
-
-void cw_update_creds(khui_credwnd_tbl * tbl);
-
-void cw_unload_view(khui_credwnd_tbl * tbl);
-
-void cw_hditem_from_tbl_col(khui_credwnd_col * col, HDITEM *phi);
-
-int cw_update_extents(khui_credwnd_tbl * tbl, khm_boolean update_scroll);
-
-void cw_insert_header_cols(khui_credwnd_tbl * tbl);
-
-void khm_get_cw_element_font(HDC hdc, wchar_t * name, BOOL use_default,
- LOGFONT * pfont);
-
-void khm_set_cw_element_font(wchar_t * name, LOGFONT * pfont);
-
-void khm_draw_identity_menu_item(HWND hwnd, LPDRAWITEMSTRUCT lpd, khui_action * act);
-
-void khm_measure_identity_menu_item(HWND hwnd, LPMEASUREITEMSTRUCT lpm, khui_action * act);
-
-#endif
diff --git a/src/windows/identity/ui/debugfuncs.c b/src/windows/identity/ui/debugfuncs.c
deleted file mode 100644
index ad478e5fd..000000000
--- a/src/windows/identity/ui/debugfuncs.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<tchar.h>
-
-#include<shlwapi.h>
-#include<khmapp.h>
-
-#include<stdio.h>
-
-#if DEBUG
-#include<assert.h>
-#endif
-
-#define LOGFILENAME "nidmdbg.log"
-
-CRITICAL_SECTION cs_log;
-FILE * logfile = NULL;
-BOOL log_started = FALSE;
-
-wchar_t *
-severity_string(kherr_severity severity) {
- switch(severity) {
- case KHERR_FATAL:
- return L"FATAL";
-
- case KHERR_ERROR:
- return L"ERROR";
-
- case KHERR_WARNING:
- return L"Warning";
-
- case KHERR_INFO:
- return L"Info";
-
- case KHERR_DEBUG_3:
- return L"Debug(3)";
-
- case KHERR_DEBUG_2:
- return L"Debug(2)";
-
- case KHERR_DEBUG_1:
- return L"Debug(1)";
-
- case KHERR_NONE:
- return L"(None)";
-
- default:
- return L"(Unknown severity)";
- }
-}
-
-void
-fprint_systime(FILE * f, SYSTEMTIME *psystime) {
- fprintf(logfile,
- "%d-%d-%d %02d:%02d:%02d.%03d",
-
- (int) psystime->wYear,
- (int) psystime->wMonth,
- (int) psystime->wDay,
-
- (int) psystime->wHour,
- (int) psystime->wMinute,
- (int) psystime->wSecond,
- (int) psystime->wMilliseconds);
-}
-
-void KHMAPI
-debug_event_handler(enum kherr_ctx_event e,
- kherr_context * c) {
- kherr_event * evt;
-
- EnterCriticalSection(&cs_log);
-
- if (!logfile)
- goto _done;
-
- if (e == KHERR_CTX_BEGIN) {
- SYSTEMTIME systime;
-
- GetSystemTime(&systime);
- fprintf(logfile,
- "%d\t",
- c->serial);
-
- fprint_systime(logfile, &systime);
-
- fprintf(logfile,
- "\t<< Context begin --\n");
-
- } else if (e == KHERR_CTX_DESCRIBE) {
- evt = kherr_get_desc_event(c);
- if (evt) {
- kherr_evaluate_event(evt);
- fprintf(logfile,
- "%d\t Description: %S\n",
- c->serial,
- (evt->long_desc)? evt->long_desc: evt->short_desc);
- }
- } else if (e == KHERR_CTX_END) {
- SYSTEMTIME systime;
-
- fprintf(logfile,
- "%d\t",
- c->serial);
-
- GetSystemTime(&systime);
- fprint_systime(logfile, &systime);
-
- fprintf(logfile,
- "\t>> Context end --\n");
-
- } else if (e == KHERR_CTX_EVTCOMMIT) {
- evt = kherr_get_last_event(c);
- if (evt && (evt->short_desc || evt->long_desc)) {
- SYSTEMTIME systime;
-
- kherr_evaluate_event(evt);
- FileTimeToSystemTime(&evt->time_ft, &systime);
-
- fprintf(logfile,
- "%d[%d](%S)\t",
- c->serial,
- evt->thread_id,
- (evt->facility ? evt->facility: L""));
-
- fprint_systime(logfile, &systime);
-
- fprintf(logfile,
- "\t%S: %S %S%S%S %S%S%S\n",
-
- severity_string(evt->severity),
-
- (evt->short_desc ? evt->short_desc: L""),
-
- (evt->short_desc ? L"(":L""),
- (evt->long_desc ? evt->long_desc: L""),
- (evt->short_desc ? L")":L""),
-
- (evt->suggestion ? L"[":L""),
- (evt->suggestion ? evt->suggestion: L""),
- (evt->suggestion ? L"]":L"")
- );
- }
- }
-
- _done:
-
- LeaveCriticalSection(&cs_log);
-}
-
-void khm_get_file_log_path(khm_size cb_buf, wchar_t * buf) {
-#ifdef DEBUG
- assert(cb_buf > sizeof(wchar_t));
-#endif
- *buf = L'\0';
-
- GetTempPath((DWORD) cb_buf / sizeof(wchar_t), buf);
-
- StringCbCat(buf, cb_buf, _T(LOGFILENAME));
-}
-
-void khm_start_file_log(void) {
- wchar_t temppath[MAX_PATH];
- khm_handle cs_cw = NULL;
- khm_int32 t = 0;
-
- EnterCriticalSection(&cs_log);
-
- if (log_started)
- goto _done;
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", 0, &cs_cw)))
- goto _done;
-
- if (KHM_FAILED(khc_read_int32(cs_cw, L"LogToFile", &t)) ||
- !t)
- goto _done;
-
- khm_get_file_log_path(sizeof(temppath), temppath);
-
- logfile = NULL;
-#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
- _wfopen_s(&logfile, temppath, L"w");
-#else
- logfile = _wfopen(temppath, L"w");
-#endif
- kherr_add_ctx_handler(debug_event_handler,
- KHERR_CTX_BEGIN |
- KHERR_CTX_END |
- KHERR_CTX_DESCRIBE |
- KHERR_CTX_EVTCOMMIT,
- 0);
-
- log_started = TRUE;
-
- _done:
- if (cs_cw)
- khc_close_space(cs_cw);
-
- LeaveCriticalSection(&cs_log);
-}
-
-void khm_stop_file_log(void) {
-
- EnterCriticalSection(&cs_log);
-
- if (!log_started)
- goto _done;
-
- kherr_remove_ctx_handler(debug_event_handler, 0);
-
- if (logfile)
- fclose (logfile);
- logfile = NULL;
-
- log_started = FALSE;
-
- _done:
- LeaveCriticalSection(&cs_log);
-}
-
-void khm_init_debug(void) {
- InitializeCriticalSection(&cs_log);
-
- khm_start_file_log();
-}
-
-void khm_exit_debug(void) {
- khm_stop_file_log();
-
- DeleteCriticalSection(&cs_log);
-}
diff --git a/src/windows/identity/ui/debugfuncs.h b/src/windows/identity/ui/debugfuncs.h
deleted file mode 100644
index 6467185f3..000000000
--- a/src/windows/identity/ui/debugfuncs.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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_DEBUGFUNCS_H
-#define __NETIDMGR_DEBUGFUNCS_H
-
-void khm_init_debug(void);
-void khm_exit_debug(void);
-
-void khm_start_file_log(void);
-void khm_stop_file_log(void);
-void khm_get_file_log_path(khm_size cb_buf, wchar_t * buf);
-
-#endif
diff --git a/src/windows/identity/ui/htwnd.c b/src/windows/identity/ui/htwnd.c
deleted file mode 100644
index 29c4221a7..000000000
--- a/src/windows/identity/ui/htwnd.c
+++ /dev/null
@@ -1,1311 +0,0 @@
-/*
-* Copyright (c) 2005 Massachusetts Institute of Technology
-*
-* 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<khmapp.h>
-#include<crtdbg.h>
-
-ATOM khui_htwnd_cls;
-
-#define HTW_STYLE_NORMAL 0
-
-/* There are currently 4 style "bits" and 3 sizes, which means
- there can be 2^4*3=48 possible styles max. If someone is
- feeling adventurous you can slightly improve performance of
- the parser using this little fact. For now, I don't care.
- (hint: combine size and style bits to form a single number
- and use it as an index into the styles array)
-*/
-#define HTW_STYLE_MAX 48
-
-#define HTW_FORMAT_MAX 128
-
-#define HTW_TAB_MAX 8
-
-#define HTW_DEFAULT (-1)
-
-#define HTW_NORMAL_SIZE 8
-#define HTW_LARGE_SIZE 12
-#define HTW_HUGE_SIZE 20
-
-/* font variant */
-#define FV_ABSOLUTE 0x10000000
-
-#define FV_ITALIC 0x00000002
-#define FV_UNDERLINE 0x00000004
-#define FV_STRIKEOUT 0x00000008
-#define FV_BOLD 0x00000010
-
-#define FV_NOITALIC 0x00020000
-#define FV_NOUNDERLINE 0x00040000
-#define FV_NOSTRIKEOUT 0x00080000
-#define FV_NOBOLD 0x00100000
-
-#define FV_NONE 0x00000000
-#define FV_MASK 0x0000001f
-
-#define HTW_LINK_ALLOC 8
-
-#define ALIGN_LEFT 0
-#define ALIGN_CENTER 1
-#define ALIGN_RIGHT 2
-
-struct tx_tbl_t {
- wchar_t * string;
- LONG value;
-}
-
-htw_color_table[] = {
- {L"black", RGB(0,0,0)},
- {L"white", RGB(255,255,255)},
- {L"red", RGB(255,0,0)},
- {L"green", RGB(0,255,0)},
- {L"blue", RGB(0,0,255)},
- {L"grey", RGB(128,128,128)}
-},
-
-htw_size_table[] = {
- {L"normal", HTW_NORMAL_SIZE},
- {L"large", HTW_LARGE_SIZE},
- {L"huge", HTW_HUGE_SIZE}
-},
-
-htw_align_table[] = {
- {L"left", ALIGN_LEFT},
- {L"center", ALIGN_CENTER},
- {L"right", ALIGN_RIGHT}
-};
-
-typedef struct khui_htwnd_style_t {
- LONG height;
- LONG variation; /* combination of FV_* */
-
- HFONT font;
-} khui_htwnd_style;
-
-typedef struct khui_format_t {
- int style_idx;
- COLORREF color;
-} khui_format;
-
-typedef struct format_stack_t {
- khui_format stack[HTW_FORMAT_MAX];
- int stack_top;
-} format_stack;
-
-typedef struct khui_htwnd_data_t {
- int id; /* control ID */
- int flags;
- wchar_t * text;
- int scroll_left;
- int scroll_top;
- int ext_width;
- int ext_height;
- COLORREF bk_color;
- HCURSOR hc_hand;
- int l_pixel_y;
-
- khui_htwnd_style styles[HTW_STYLE_MAX];
- int n_styles;
-
- khui_htwnd_link ** links;
- int n_links;
- int max_links;
- int active_link;
- int md_link;
-
- int tabs[HTW_TAB_MAX];
- int n_tabs;
-} khui_htwnd_data;
-
-static LONG table_lookup(struct tx_tbl_t * tbl, int n, wchar_t * v, int len)
-{
- int i;
-
- for(i=0; i<n; i++) {
- if(!_wcsnicmp(tbl[i].string, v, len))
- return tbl[i].value;
- }
-
- return -1;
-}
-
-static void clear_styles(khui_htwnd_data * d)
-{
- int i;
-
- for(i=0; i<d->n_styles; i++) {
- if(d->styles[i].font != NULL) {
- DeleteObject(d->styles[i].font);
- d->styles[i].font = NULL;
- }
- }
-
- d->n_styles = 0;
-}
-
-static void format_init(format_stack * s)
-{
- s->stack_top = -1;
- ZeroMemory(s->stack, sizeof(s->stack));
-}
-
-static khui_format * format_current(format_stack * s)
-{
- if(s->stack_top >= 0)
- return &(s->stack[s->stack_top]);
- else
- return NULL;
-}
-
-static int format_style(format_stack * s)
-{
- if(s->stack_top >= 0)
- return s->stack[s->stack_top].style_idx;
- else
- return 0;
-}
-
-static COLORREF format_color(format_stack * s)
-{
- if(s->stack_top >= 0)
- return s->stack[s->stack_top].color;
- else
- return 0;
-}
-
-static int format_level(format_stack * s)
-{
- return s->stack_top;
-}
-
-static void format_unwind(format_stack * s, int level)
-{
- s->stack_top = level;
-}
-
-static void format_push(format_stack * s, khui_htwnd_data * d, LONG height, LONG variation, COLORREF color)
-{
- int i;
- khui_format * top;
- khui_htwnd_style * style;
-
- _ASSERT(s->stack_top < (HTW_FORMAT_MAX-1));
-
- /* formatting is additive unless FV_NORMAL is set in variation */
- top = format_current(s);
- if(top) {
- style = &(d->styles[top->style_idx]);
- if(height == HTW_DEFAULT)
- height = style->height;
-
- if(variation == HTW_DEFAULT)
- variation = style->variation;
- else if(!(variation & FV_ABSOLUTE))
- variation |= style->variation;
-
- if(color == HTW_DEFAULT)
- color = top->color;
- }
-
- variation &= ~FV_ABSOLUTE;
- variation ^= variation & (variation>>16);
- variation &= FV_MASK;
-
- /* now look for an existing style that matches the requested one */
- for(i=0; i<d->n_styles; i++) {
- style = &(d->styles[i]);
-
- if(style->height == height &&
- style->variation == variation)
- break;
- }
-
- s->stack_top++;
-
- if(i<d->n_styles) {
- s->stack[s->stack_top].style_idx = i;
- } else {
- if(d->n_styles == HTW_STYLE_MAX) {
- s->stack[s->stack_top].style_idx = 0;
- } else {
- s->stack[s->stack_top].style_idx = d->n_styles;
- d->styles[d->n_styles].font = NULL;
- d->styles[d->n_styles].height = height;
- d->styles[d->n_styles].variation = variation;
- d->n_styles++;
- }
- }
- s->stack[s->stack_top].color = color;
-}
-
-static void format_pop(format_stack * s) {
- if(s->stack_top >= 0)
- s->stack_top--;
-}
-
-static wchar_t * token_end(wchar_t * s) {
- while(iswalnum(*s) || *s == L'/')
- s++;
- return s;
-}
-
-static wchar_t * skip_ws(wchar_t * s) {
- while(iswspace(*s))
- s++;
- return s;
-}
-
-/* s points to something like " = \"value\""
- start and len will point to the start and
- length of value. return value will point to the
- character following the last double quote. */
-static wchar_t * read_attr(wchar_t * s, wchar_t ** start, int * len)
-{
- wchar_t *e;
-
- *start = NULL;
- *len = 0;
-
- do {
- s = skip_ws(s);
- if(*s != L'=')
- break;
- s = skip_ws(++s);
- if(*s != L'"')
- break;
- e = wcschr(++s, L'"');
- if(!e)
- break;
-
- *start = s;
- *len = (int) (e - s);
-
- s = e + 1;
- } while(FALSE);
-
- return s;
-}
-
-/*
-We currently support the following tags:
-
-<a [id="string"] [param="paramstring"]>link text</a>
-<b>foo</b>
-<u>foo</u>
-<i>foo</i>
-
-<font [color="(color)"] [size="normal|large|huge|(point size)"]>foo</font>
- (color)=black|white|red|green|blue|grey
-<large>foo</large>
-<huge>foo</huge>
-
-<center>foo</center>
-<left>foo</left>
-<right>foo</right>
-
-<p [align="left|center|right"]>foo</p>
-<settab pos="(pos)">
-<tab>
-*/
-
-static int htw_parse_tag(
- wchar_t * start,
- wchar_t ** end,
- int * align,
- khui_htwnd_data * d,
- format_stack * s,
- PPOINT p_abs,
- PPOINT p_rel,
- int lh,
- BOOL dry_run)
-{
- wchar_t * c;
- int n = 0;
-
- /* start initially points to the starting '<' */
- c = token_end(++start);
-
- if(!_wcsnicmp(start,L"a",c-start)) {
- /* start of an 'a' tag */
- wchar_t * id_start = NULL;
- int id_len = 0;
- wchar_t * param_start = NULL;
- int param_len = 0;
-
- /* We don't need to parse the link
- if it is just a dry run */
- if(dry_run) {
- format_push(s, d, HTW_DEFAULT, HTW_DEFAULT, RGB(0,0,255));
- *end = wcschr(start, L'>');
- return FALSE;
- }
-
- while(c && *c && *c != L'>') {
- wchar_t * e;
-
- c = skip_ws(c);
- e = token_end(c);
-
- if(c==e)
- break;
-
- if(!_wcsnicmp(c,L"id",e-c)) {
- c = read_attr(e, &id_start, &id_len);
- } else if(!_wcsnicmp(c,L"param",e-c)) {
- c = read_attr(e, &param_start, &param_len);
- }
- }
-
- if(d->active_link == d->n_links)
- format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, RGB(0,0,255));
- else
- format_push(s,d, HTW_DEFAULT, FV_NONE, RGB(0,0,255));
-
- {
- khui_htwnd_link * l;
-
- if(!d->links) {
- d->links = PMALLOC(sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);
- ZeroMemory(d->links, sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);
- d->max_links = HTW_LINK_ALLOC;
- d->n_links = 0;
- }
-
- if(d->n_links >= d->max_links) {
- khui_htwnd_link ** ll;
- int n_new;
-
- n_new = UBOUNDSS(d->n_links + 1, HTW_LINK_ALLOC, HTW_LINK_ALLOC);
-
- ll = PMALLOC(sizeof(khui_htwnd_link *) * n_new);
- ZeroMemory(ll, sizeof(khui_htwnd_link *) * n_new);
- memcpy(ll, d->links, sizeof(khui_htwnd_link *) * d->max_links);
- PFREE(d->links);
- d->links = ll;
- d->max_links = n_new;
- }
-
- l = d->links[d->n_links];
- if(!l) {
- l = PMALLOC(sizeof(khui_htwnd_link));
- d->links[d->n_links] = l;
- }
-
- l->id = id_start;
- l->id_len = id_len;
- l->param = param_start;
- l->param_len = param_len;
-
- l->r.left = p_abs->x;
- l->r.top = p_abs->y;
-
- d->n_links++;
- }
-
- } else if(!_wcsnicmp(start, L"/a", c - start)) {
- khui_htwnd_link * l;
-
- c = wcschr(c,L'>');
- if(!c)
- c = c + wcslen(c);
-
- format_pop(s);
-
- if(!dry_run) {
- l = d->links[d->n_links - 1]; /* last link */
- l->r.right = p_abs->x;
- l->r.bottom = p_abs->y + lh;
- }
- } else if(!_wcsnicmp(start, L"p", c - start)) {
- wchar_t * e;
- wchar_t * align_s = NULL;
- int align_len = 0;
-
- c = skip_ws(c);
- e = token_end(c);
-
- if(c != e && !_wcsnicmp(c,L"align",e-c)) {
- c = read_attr(e, &align_s, &align_len);
- }
-
- c = wcschr(c, L'>');
- if(!c)
- c = c + wcslen(c);
-
-
- if(align_s)
- *align = table_lookup(htw_align_table, ARRAYLENGTH(htw_align_table), align_s, align_len);
- else
- *align = ALIGN_LEFT;
-
- n = 1;
- } else if(!_wcsnicmp(start, L"b", c - start)) {
- format_push(s,d, HTW_DEFAULT, FV_BOLD, (COLORREF) HTW_DEFAULT);
- } else if(!_wcsnicmp(start, L"/b", c - start)) {
- format_pop(s);
- } else if(!_wcsnicmp(start, L"u", c - start)) {
- format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, (COLORREF) HTW_DEFAULT);
- } else if(!_wcsnicmp(start, L"/u", c - start)) {
- format_pop(s);
- } else if(!_wcsnicmp(start, L"i", c - start)) {
- format_push(s,d, HTW_DEFAULT, FV_ITALIC, (COLORREF) HTW_DEFAULT);
- } else if(!_wcsnicmp(start, L"/i", c - start)) {
- format_pop(s);
- } else if(!_wcsnicmp(start, L"large", c - start)) {
- format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT);
- } else if(!_wcsnicmp(start, L"/large", c - start)) {
- format_pop(s);
- } else if(!_wcsnicmp(start, L"huge", c - start)) {
- format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT);
- } else if(!_wcsnicmp(start, L"/huge", c - start)) {
- format_pop(s);
- } else if(!_wcsnicmp(start, L"center", c - start)) {
- c = wcschr(c, L'>');
- if(!c)
- c = c + wcslen(c);
- *align = ALIGN_CENTER;
- n = 1;
- } else if(!_wcsnicmp(start, L"left", c - start) ||
- !_wcsnicmp(start, L"p", c - start))
- {
- c = wcschr(c, L'>');
- if(!c)
- c = c + wcslen(c);
- *align = ALIGN_LEFT;
- n = 1;
- } else if(!_wcsnicmp(start, L"right", c - start)) {
- c = wcschr(c, L'>');
- if(!c)
- c = c + wcslen(c);
- *align = ALIGN_RIGHT;
- n = 1;
- } else if(!_wcsnicmp(start, L"/center", c - start) ||
- !_wcsnicmp(start, L"/left", c - start) ||
- !_wcsnicmp(start, L"/right", c - start) ||
- !_wcsnicmp(start, L"/p", c - start)) {
- c = wcschr(c, L'>');
- if(!c)
- c = c + wcslen(c);
- *align = ALIGN_LEFT;
- n = 1;
- } else if(!_wcsnicmp(start, L"font", c - start)) {
- wchar_t * color_s = NULL;
- int color_len = 0;
- wchar_t * size_s = NULL;
- int size_len = 0;
- LONG color = HTW_DEFAULT;
- LONG h = HTW_DEFAULT;
-
- while(c && *c && *c != L'>') {
- wchar_t * e;
-
- c = skip_ws(c);
- e = token_end(c);
-
- if(c==e)
- break;
-
- if(!_wcsnicmp(c,L"color",e-c)) {
- c = read_attr(e, &color_s, &color_len);
- } else if(!_wcsnicmp(c,L"size",e-c)) {
- c = read_attr(e, &size_s, &size_len);
- }
- }
-
- if(color_s)
- color = table_lookup(htw_color_table, ARRAYLENGTH(htw_color_table), color_s, color_len);
- if(size_s) {
- h = table_lookup(htw_size_table, ARRAYLENGTH(htw_size_table), size_s, size_len);
- if(h)
- h = -MulDiv(h, d->l_pixel_y, 72);
- else
- h = -MulDiv(HTW_NORMAL_SIZE, d->l_pixel_y, 72);
- }
-
- format_push(s,d,h,HTW_DEFAULT,color);
- } else if(!_wcsnicmp(start, L"/font", c - start)) {
- format_pop(s);
- } else if(!_wcsnicmp(start, L"settab", c - start)) {
- wchar_t * e;
- wchar_t * pos_s = NULL;
- int pos_len;
-
- c = skip_ws(c);
- e = token_end(c);
-
- if(c != e && !_wcsnicmp(c,L"pos",e-c)) {
- c = read_attr(e, &pos_s, &pos_len);
- }
-
- c = wcschr(c, L'>');
- if(!c)
- c = c + wcslen(c);
-
- if(pos_s && d->n_tabs < HTW_TAB_MAX && !dry_run) {
- wchar_t * dummy;
- LONG bu;
- int bx;
- int dx;
-
- bu = GetDialogBaseUnits();
- bx = LOWORD(bu);
-
- dx = wcstol(pos_s, &dummy, 10);
-
- d->tabs[d->n_tabs++] = MulDiv(dx, bx, 4);
- }
- } else if(!_wcsnicmp(start, L"tab", c - start)) {
- int i;
-
- if(!dry_run) {
- for(i=0; i < d->n_tabs; i++) {
- if(d->tabs[i] > p_rel->x) {
- p_rel->x = d->tabs[i];
- break;
- }
- }
- }
- }
-
- if(*c)
- c++;
- *end = c;
-
- return n;
-}
-
-static void htw_assert_style(HDC hdc, khui_htwnd_data * d, int style)
-{
- LOGFONT lf;
-
- if(d->styles[style].font)
- return;
-
- /*TODO: we need select different fonts depending on system locale */
- lf.lfHeight = d->styles[style].height; //-MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- lf.lfWidth = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- lf.lfWeight = (d->styles[style].variation & FV_BOLD)? FW_BOLD: FW_NORMAL;
- lf.lfItalic = (BYTE) !!(d->styles[style].variation & FV_ITALIC);
- lf.lfUnderline = (BYTE) !!(d->styles[style].variation & FV_UNDERLINE);
- lf.lfStrikeOut = (BYTE) !!(d->styles[style].variation & FV_STRIKEOUT);
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = DEFAULT_QUALITY;
- lf.lfPitchAndFamily = DEFAULT_PITCH;
-
- LoadString(khm_hInstance, IDS_DEFAULT_FONT, lf.lfFaceName, ARRAYLENGTH(lf.lfFaceName));
-
- d->styles[style].font = CreateFontIndirect(&lf);
-}
-
-static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- PAINTSTRUCT ps;
- HBRUSH hbk;
- khui_htwnd_data * d;
- RECT r;
- SIZE s;
- HDC hdc;
- wchar_t * text;
- format_stack s_stack;
-
- int align;
- int y;
- wchar_t * par_start;
- int ext_width = 0;
- int ext_height = 0;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- return 0;
-
- if(!GetUpdateRect(hwnd, &r, !(d->flags & KHUI_HTWND_TRANSPARENT)))
- return 0;
-
- if(d->text == NULL)
- return 0;
-
- text = d->text;
-
- hdc = BeginPaint(hwnd, &ps);
-
- GetClientRect(hwnd, &r);
-
-#ifdef DRAW_HTWND_CLIENT_EDGE
- /* for the moment, we are skipping on the client edge. */
- if(d->flags & KHUI_HTWND_CLIENTEDGE)
- DrawEdge(hdc, &r, EDGE_SUNKEN, BF_ADJUST | BF_RECT | BF_FLAT);
-#endif
-
- hbk = GetSysColorBrush(COLOR_WINDOW);
- FillRect(hdc, &r, hbk);
- hbk = NULL; /* We don't need to destroy system
- brushes */
-
- /* push the default format */
- format_init(&s_stack);
-
- d->l_pixel_y = GetDeviceCaps(hdc, LOGPIXELSY);
- format_push(&s_stack,d, -MulDiv(HTW_NORMAL_SIZE, d->l_pixel_y, 72), FV_NONE, RGB(0,0,0));
-
- y = r.top - d->scroll_top;
-
- par_start = text;
-
- align = ALIGN_LEFT;
-
- SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
- if(d->flags & KHUI_HTWND_TRANSPARENT)
- SetBkMode(hdc, TRANSPARENT);
-
- d->n_links = 0;
- d->n_tabs = 0;
-
- while(*par_start) {
- wchar_t * p = par_start;
- wchar_t * c = NULL;
- int p_width = 0;
- int s_start;
- int l_height = 0;
- int x = 0;
- POINT pt;
- POINT pt_rel;
-
- s_start = format_level(&s_stack);
-
- /* begin dry run */
- while(*p) {
- if(*p == L'<') {
- int talign = -1;
- int n = htw_parse_tag(p,&c,&talign,d,&s_stack,NULL,NULL,0,TRUE);
-
- if(n && p_width)
- break;
-
- p = c;
-
- if(n && talign >= 0)
- align = talign;
- } else {
- HFONT hfold;
- c = wcschr(p, L'<');
- if(!c)
- c = p + wcslen(p);
-
- htw_assert_style(hdc, d, format_style(&s_stack));
- hfold = SelectFont(hdc, d->styles[format_style(&s_stack)].font);
- GetTextExtentPoint32(hdc, p, (int)(c - p), &s);
- SelectFont(hdc, hfold);
-
- p_width += s.cx;
- if(s.cy > l_height)
- l_height = s.cy;
-
- p = c;
- }
- }
-
- /* dry run ends */
-
- x = r.left - d->scroll_left;
-
- if(align == ALIGN_CENTER) {
- if (r.right - r.left > p_width)
- x += (r.right - r.left)/2 - p_width / 2;
- }
-
- else if(align == ALIGN_RIGHT) {
- if (r.right - r.left > p_width)
- x += (r.right - r.left) - p_width;
- }
-
- /* begin wet run */
- p = par_start;
- format_unwind(&s_stack, s_start); /* unwind format stack */
-
- p_width = 0;
-
- while(p && *p) {
- if(*p == L'<') {
- int talign = -1;
- int n;
-
- pt.x = x + p_width;
- pt.y = y;
- pt_rel.x = p_width;
- pt_rel.y = 0;
-
- n = htw_parse_tag(p, &c, &talign, d, &s_stack, &pt, &pt_rel, l_height, FALSE);
-
- if(n && p_width) {
- break;
- }
-
- p_width = pt_rel.x;
-
- p = c;
- if(n && talign >= 0)
- align = talign;
- } else {
- HFONT hfold;
- RECT rd;
-
- c = wcschr(p, L'<');
- if(!c)
- c = p + wcslen(p);
-
- htw_assert_style(hdc, d, format_style(&s_stack));
- hfold = SelectFont(hdc, d->styles[format_style(&s_stack)].font);
- SetTextColor(hdc, format_color(&s_stack));
-
- GetTextExtentPoint32(hdc, p, (int)(c - p), &s);
- rd.left = x + p_width;
- rd.top = y;
- rd.right = rd.left + s.cx;
- rd.bottom = rd.top + l_height;
-
- DrawText(hdc, p, (int)(c - p), &rd,
- DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
-
- p_width += s.cx;
-
- SelectFont(hdc, hfold);
- p = c;
- }
- }
-
- if (p_width > ext_width)
- ext_width = p_width;
-
- y += l_height;
- par_start = p;
- }
-
- if (y > ext_height)
- ext_height = y;
-
- EndPaint(hwnd, &ps);
-
- if (d->ext_width < ext_width ||
- d->ext_height < ext_height) {
- SCROLLINFO si;
- LONG l;
-
- /* the extents need to be adjusted. But first check if we
- have exactly the right scroll bars we need. */
- if ((ext_width > (r.right - r.left) &&
- !(d->flags & KHUI_HTWND_HSCROLL)) ||
- (ext_height > (r.bottom - r.top) &&
- !(d->flags & KHUI_HTWND_VSCROLL)) ||
-
- (ext_width <= (r.right - r.left) &&
- (d->flags & KHUI_HTWND_HSCROLL)) ||
- (ext_height <= (r.bottom - r.top) &&
- (d->flags & KHUI_HTWND_VSCROLL))) {
-
- /* need to add scroll bars */
- if (ext_width > (r.right - r.left))
- d->flags |= KHUI_HTWND_HSCROLL;
- else
- d->flags &= ~KHUI_HTWND_HSCROLL;
-
- if (ext_height > (r.bottom - r.top))
- d->flags |= KHUI_HTWND_VSCROLL;
- else
- d->flags &= ~KHUI_HTWND_VSCROLL;
-
- l = (LONG) GetWindowLongPtr(hwnd, GWL_STYLE);
- l &= ~(WS_HSCROLL | WS_VSCROLL);
-
- l |= ((d->flags & KHUI_HTWND_HSCROLL) ? WS_HSCROLL : 0) |
- ((d->flags & KHUI_HTWND_VSCROLL) ? WS_VSCROLL : 0);
-
- SetWindowLongPtr(hwnd, GWL_STYLE, l);
-
- InvalidateRect(hwnd, NULL, FALSE);
- /* since the client area changed, we do another redraw
- before updating the scroll bar positions. */
- } else {
- d->ext_width = ext_width;
- d->ext_height = ext_height;
-
- if (d->flags & KHUI_HTWND_HSCROLL) {
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
- si.nMin = 0;
- si.nMax = ext_width;
- si.nPage = r.right - r.left;
- si.nPos = d->scroll_left;
-
- SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
- }
-
- if (d->flags & KHUI_HTWND_VSCROLL) {
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
- si.nMin = 0;
- si.nMax = ext_height;
- si.nPage = r.bottom - r.top;
- si.nPos = d->scroll_top;
-
- SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
- }
- }
- }
-
- return 0;
-}
-
-LRESULT CALLBACK khui_htwnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
- )
-{
- switch(uMsg) {
- case WM_CREATE:
- {
- CREATESTRUCT * cs;
- khui_htwnd_data * d;
- size_t cbsize;
-
- cs = (CREATESTRUCT *) lParam;
-
- d = PMALLOC(sizeof(*d));
- ZeroMemory(d, sizeof(*d));
-
- if(cs->dwExStyle & WS_EX_TRANSPARENT) {
- d->flags |= KHUI_HTWND_TRANSPARENT;
- }
- if(cs->dwExStyle & WS_EX_CLIENTEDGE) {
- d->flags |= KHUI_HTWND_CLIENTEDGE;
- }
- if(cs->style & WS_HSCROLL) {
- d->flags |= KHUI_HTWND_HSCROLL;
- }
- if(cs->style & WS_VSCROLL) {
- d->flags |= KHUI_HTWND_VSCROLL;
- }
- d->id = (int)(INT_PTR) cs->hMenu;
-
- d->active_link = -1;
- d->bk_color = RGB(255,255,255);
- d->hc_hand = LoadCursor(NULL, IDC_HAND);
-
- if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {
- cbsize += sizeof(wchar_t);
- d->text = PMALLOC(cbsize);
- StringCbCopy(d->text, cbsize, cs->lpszName);
- }
-
- /* this is just a flag to the WM_PAINT handler that the
- extents haven't been set yet. */
- d->ext_width = -1;
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, 0, (LONG_PTR) d);
-#pragma warning(pop)
-
- return 0;
- }
- break;
-
- case WM_SETTEXT:
- {
- wchar_t * newtext;
- size_t cbsize;
- khui_htwnd_data * d;
- BOOL rv;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- return 0;
-
- newtext = (wchar_t *) lParam;
-
- if(d->text) {
- PFREE(d->text);
- d->text = NULL;
- }
-
- if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {
- cbsize += sizeof(wchar_t);
- d->text = PMALLOC(cbsize);
- StringCbCopy(d->text, cbsize, newtext);
- rv = TRUE;
- } else
- rv = FALSE;
-
- clear_styles(d);
-
- d->ext_width = -1;
- d->scroll_left = 0;
- d->scroll_top = 0;
-
- InvalidateRect(hwnd, NULL, TRUE);
-
- return rv;
- }
- break;
-
- case WM_DESTROY:
- {
- khui_htwnd_data * d;
- int i;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d) {
- if(d->text)
- PFREE(d->text);
- d->text = 0;
-
- if(d->links) {
- for(i=0;i<d->max_links;i++) {
- if(d->links[i])
- PFREE(d->links[i]);
- }
- PFREE(d->links);
- }
-
- clear_styles(d);
-
- PFREE(d);
- SetWindowLongPtr(hwnd, 0, 0);
- }
- }
- break;
-
- case WM_ERASEBKGND:
- {
- HDC hdc = (HDC) wParam;
- khui_htwnd_data * d;
- HBRUSH hbr;
- RECT r;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- return FALSE;
-
- GetClientRect(hwnd, &r);
- hbr = GetSysColorBrush(COLOR_WINDOW);
- FillRect(hdc, &r, hbr);
-
- /* no need to destroy the brush since it's a system
- brush. */
-
- return TRUE;
- }
-
- case WM_SIZE:
- {
- khui_htwnd_data * d;
-
- d = (khui_htwnd_data *) (LONG_PTR) GetWindowLongPtr(hwnd, 0);
-
- if (d) {
- d->ext_width = 0;
- d->ext_height = 0;
- }
- }
- return 0;
-
- case WM_PAINT:
- htw_paint(hwnd, uMsg, wParam, lParam);
- return 0;
-
- case WM_SETCURSOR:
- {
- khui_htwnd_data * d;
-
- if(hwnd != (HWND)wParam)
- break;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- if(d->active_link >= 0) {
- SetCursor(d->hc_hand);
- return TRUE;
- }
- }
- break;
-
- case WM_SETFOCUS:
- {
- khui_htwnd_data * d;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- d->flags |= KHUI_HTWND_FOCUS;
-
- InvalidateRect(hwnd, NULL, TRUE);
- }
- break;
-
- case WM_KILLFOCUS:
- {
- khui_htwnd_data * d;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- d->flags &= ~KHUI_HTWND_FOCUS;
-
- InvalidateRect(hwnd, NULL, TRUE);
- }
- break;
-
- case WM_LBUTTONDOWN:
- {
- khui_htwnd_data * d;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- d->md_link = d->active_link;
-
- SetCapture(hwnd);
- }
- break;
-
- case WM_LBUTTONUP:
- {
- khui_htwnd_data * d;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- if(d->md_link == d->active_link && d->md_link >= 0) {
- /* clicked */
- SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(d->id, BN_CLICKED), (LPARAM) d->links[d->md_link]);
- }
-
- ReleaseCapture();
- }
- break;
-
- case WM_HSCROLL:
- {
- khui_htwnd_data * d;
- int old_pos;
- int new_pos;
- int ext;
- SCROLLINFO si;
- RECT r;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- old_pos = new_pos = d->scroll_left;
- ext = d->ext_width;
-
- switch(LOWORD(wParam)) {
- case SB_THUMBPOSITION:
- case SB_ENDSCROLL:
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_POS;
- GetScrollInfo(hwnd, SB_HORZ, &si);
- new_pos = si.nPos;
- break;
-
- case SB_THUMBTRACK:
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_TRACKPOS;
- GetScrollInfo(hwnd, SB_HORZ, &si);
- new_pos = si.nTrackPos;
- break;
-
- case SB_LINELEFT:
- new_pos -= ext / 12; /* arbitrary unit */
- break;
-
- case SB_LINERIGHT:
- new_pos += ext / 12; /* arbitrary unit */
- break;
-
- case SB_PAGELEFT:
- GetClientRect(hwnd, &r);
- new_pos -= r.right - r.left;
- break;
-
- case SB_PAGERIGHT:
- GetClientRect(hwnd, &r);
- new_pos += r.right - r.left;
- break;
- }
-
- if (new_pos == old_pos)
- break;
-
- GetClientRect(hwnd, &r);
-
- if (new_pos > ext - (r.right - r.left))
- new_pos = ext - (r.right - r.left);
-
- if (new_pos < 0)
- new_pos = 0;
-
- if (new_pos == old_pos)
- break;
-
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_POS;
- si.nPos = new_pos;
- SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
- /* note that Windows sometimes adjusts the position after
- setting it with SetScrollInfo. We have to look it up
- again to see what value it ended up at. */
- GetScrollInfo(hwnd, SB_HORZ, &si);
- new_pos = si.nPos;
-
- if (new_pos == old_pos)
- break;
-
- d->scroll_left = new_pos;
-
- ScrollWindow(hwnd, old_pos - new_pos, 0, NULL, NULL);
-
- return 0;
- }
- break;
-
- case WM_MOUSEMOVE:
- {
- khui_htwnd_data * d;
- int i;
- POINT p;
- int nl;
-
- d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (d == NULL)
- break;
-
- p.x = GET_X_LPARAM(lParam) + d->scroll_left;
- p.y = GET_Y_LPARAM(lParam) + d->scroll_top;
-
- for(i=0; i<d->n_links; i++) {
- if(d->links && d->links[i] && PtInRect(&(d->links[i]->r), p))
- break;
- }
-
- if(i == d->n_links)
- nl = -1;
- else
- nl = i;
-
- if(d->active_link != nl) {
- if(d->active_link >= 0) {
- if(d->flags & KHUI_HTWND_TRANSPARENT) {
- HWND parent = GetParent(hwnd);
- if(parent) {
- RECT rdest = d->links[d->active_link]->r;
-
- MapWindowPoints(hwnd, parent, (LPPOINT) &rdest, 2);
- InvalidateRect(parent, &rdest, TRUE);
- }
- }
- /* although we are invalidating the rect before setting active_link,
- WM_PAINT will not be issued until wndproc returns */
- InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
- }
- d->active_link = nl;
- if(d->active_link >= 0) {
- /* although we are invalidating the rect before setting active_link,
- WM_PAINT will not be issued until wndproc returns */
- if(d->flags & KHUI_HTWND_TRANSPARENT) {
- HWND parent = GetParent(hwnd);
- if(parent) {
- RECT rdest = d->links[d->active_link]->r;
-
- MapWindowPoints(hwnd, parent, (LPPOINT) &rdest, 2);
- InvalidateRect(parent, &rdest, TRUE);
- }
- }
- InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
- }
- }
- }
- break;
- }
-
- return DefWindowProc(hwnd, uMsg,wParam,lParam);
-}
-
-void khm_register_htwnd_class(void)
-{
- WNDCLASSEX wcx;
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
- wcx.lpfnWndProc = khui_htwnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = sizeof(LONG_PTR);
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = NULL;
- wcx.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
- wcx.hbrBackground = CreateSolidBrush(RGB(255,255,255));
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_HTWND_CLASS;
- wcx.hIconSm = NULL;
-
- khui_htwnd_cls = RegisterClassEx(&wcx);
-}
-
-void khm_unregister_htwnd_class(void)
-{
- UnregisterClass(MAKEINTATOM(khui_htwnd_cls), khm_hInstance);
-}
-
-HWND khm_create_htwnd(HWND parent, LPWSTR text, int x, int y, int width, int height, DWORD ex_style, DWORD style)
-{
-
- return CreateWindowEx(
- ex_style,
- MAKEINTATOM(khui_htwnd_cls),
- text,
- style | WS_CHILD,
- x,y,width,height,
- parent,
- (HMENU) KHUI_HTWND_CTLID,
- khm_hInstance,
- NULL);
-}
diff --git a/src/windows/identity/ui/htwnd.h b/src/windows/identity/ui/htwnd.h
deleted file mode 100644
index f842d2d39..000000000
--- a/src/windows/identity/ui/htwnd.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_HTWND_H
-#define __KHIMAIRA_HTWND_H
-
-#include<khuidefs.h>
-
-/*
-We currently support the following tags:
-
-<a [id="string"] [param="paramstring"]>link text</a>
-<center>foo</center>
-<left>foo</left>
-<right>foo</right>
-*/
-
-#define KHUI_HTWND_TRANSPARENT 1
-#define KHUI_HTWND_CLIENTEDGE 2
-#define KHUI_HTWND_HSCROLL 4
-#define KHUI_HTWND_VSCROLL 8
-#define KHUI_HTWND_FOCUS 2048
-
-#define KHUI_HTWND_CLASS L"KhmHtWnd"
-#define KHUI_HTWND_CTLID 2040
-
-#define KHUI_HTWND_MAXCCH_TEXT 2048
-#define KHUI_HTWND_MAXCB_TEXT (sizeof(wchar_t) * KHUI_HTWND_MAXCCH_TEXT)
-
-HWND khm_create_htwnd(HWND parent, LPWSTR text, int x, int y, int width, int height, DWORD ex_style, DWORD style);
-void khm_unregister_htwnd_class(void);
-void khm_register_htwnd_class(void);
-
-#endif
diff --git a/src/windows/identity/ui/images/app_notify_error.ico b/src/windows/identity/ui/images/app_notify_error.ico
deleted file mode 100644
index 9fb30c53e..000000000
--- a/src/windows/identity/ui/images/app_notify_error.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/app_notify_info.ico b/src/windows/identity/ui/images/app_notify_info.ico
deleted file mode 100644
index 2e4d51960..000000000
--- a/src/windows/identity/ui/images/app_notify_info.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/app_notify_none.ico b/src/windows/identity/ui/images/app_notify_none.ico
deleted file mode 100644
index cf60a3e6a..000000000
--- a/src/windows/identity/ui/images/app_notify_none.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/app_notify_warn.ico b/src/windows/identity/ui/images/app_notify_warn.ico
deleted file mode 100644
index 9d43265ef..000000000
--- a/src/windows/identity/ui/images/app_notify_warn.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/app_state_exp.ico b/src/windows/identity/ui/images/app_state_exp.ico
deleted file mode 100644
index b365b6bf3..000000000
--- a/src/windows/identity/ui/images/app_state_exp.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/app_state_ok.ico b/src/windows/identity/ui/images/app_state_ok.ico
deleted file mode 100644
index 8363fb2c5..000000000
--- a/src/windows/identity/ui/images/app_state_ok.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/app_state_warn.ico b/src/windows/identity/ui/images/app_state_warn.ico
deleted file mode 100644
index 3510e5a5c..000000000
--- a/src/windows/identity/ui/images/app_state_warn.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_applied.ico b/src/windows/identity/ui/images/cfg_applied.ico
deleted file mode 100644
index 4fcdf843c..000000000
--- a/src/windows/identity/ui/images/cfg_applied.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_default.ico b/src/windows/identity/ui/images/cfg_default.ico
deleted file mode 100644
index d6e7f24e0..000000000
--- a/src/windows/identity/ui/images/cfg_default.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_deleted.ico b/src/windows/identity/ui/images/cfg_deleted.ico
deleted file mode 100644
index 2ef11c7d1..000000000
--- a/src/windows/identity/ui/images/cfg_deleted.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_mod.ico b/src/windows/identity/ui/images/cfg_mod.ico
deleted file mode 100644
index 65e3691ff..000000000
--- a/src/windows/identity/ui/images/cfg_mod.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_plugin.ico b/src/windows/identity/ui/images/cfg_plugin.ico
deleted file mode 100644
index 99ffbc411..000000000
--- a/src/windows/identity/ui/images/cfg_plugin.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_plugin_dis.ico b/src/windows/identity/ui/images/cfg_plugin_dis.ico
deleted file mode 100644
index 853ad401e..000000000
--- a/src/windows/identity/ui/images/cfg_plugin_dis.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/cfg_plugin_err.ico b/src/windows/identity/ui/images/cfg_plugin_err.ico
deleted file mode 100644
index 1b1b4ee2e..000000000
--- a/src/windows/identity/ui/images/cfg_plugin_err.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/chpw-dis-sm.bmp b/src/windows/identity/ui/images/chpw-dis-sm.bmp
deleted file mode 100644
index 230ad36a4..000000000
--- a/src/windows/identity/ui/images/chpw-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/chpw-dis.bmp b/src/windows/identity/ui/images/chpw-dis.bmp
deleted file mode 100644
index 43468cb2a..000000000
--- a/src/windows/identity/ui/images/chpw-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/chpw-sm.bmp b/src/windows/identity/ui/images/chpw-sm.bmp
deleted file mode 100644
index 4cc51e579..000000000
--- a/src/windows/identity/ui/images/chpw-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/chpw.bmp b/src/windows/identity/ui/images/chpw.bmp
deleted file mode 100644
index 43d0d5ed9..000000000
--- a/src/windows/identity/ui/images/chpw.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/disabled.ico b/src/windows/identity/ui/images/disabled.ico
deleted file mode 100644
index 6b6a9078c..000000000
--- a/src/windows/identity/ui/images/disabled.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/enabled.ico b/src/windows/identity/ui/images/enabled.ico
deleted file mode 100644
index fc83ad858..000000000
--- a/src/windows/identity/ui/images/enabled.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/flag-critical.bmp b/src/windows/identity/ui/images/flag-critical.bmp
deleted file mode 100644
index d643fb317..000000000
--- a/src/windows/identity/ui/images/flag-critical.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/flag-warning.bmp b/src/windows/identity/ui/images/flag-warning.bmp
deleted file mode 100644
index edb3fc3c8..000000000
--- a/src/windows/identity/ui/images/flag-warning.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/flag_expired.bmp b/src/windows/identity/ui/images/flag_expired.bmp
deleted file mode 100644
index a3a40feec..000000000
--- a/src/windows/identity/ui/images/flag_expired.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/flag_renewable.bmp b/src/windows/identity/ui/images/flag_renewable.bmp
deleted file mode 100644
index 3a9dc386f..000000000
--- a/src/windows/identity/ui/images/flag_renewable.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/help-sm.bmp b/src/windows/identity/ui/images/help-sm.bmp
deleted file mode 100644
index 582bbb0d8..000000000
--- a/src/windows/identity/ui/images/help-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/help.bmp b/src/windows/identity/ui/images/help.bmp
deleted file mode 100644
index c7a8a930c..000000000
--- a/src/windows/identity/ui/images/help.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-delete-dis-sm.bmp b/src/windows/identity/ui/images/id-delete-dis-sm.bmp
deleted file mode 100644
index 68850ab87..000000000
--- a/src/windows/identity/ui/images/id-delete-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-delete-dis.bmp b/src/windows/identity/ui/images/id-delete-dis.bmp
deleted file mode 100644
index 11aedd577..000000000
--- a/src/windows/identity/ui/images/id-delete-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-delete-sm.bmp b/src/windows/identity/ui/images/id-delete-sm.bmp
deleted file mode 100644
index 3447d57a1..000000000
--- a/src/windows/identity/ui/images/id-delete-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-delete.bmp b/src/windows/identity/ui/images/id-delete.bmp
deleted file mode 100644
index 5b1b68030..000000000
--- a/src/windows/identity/ui/images/id-delete.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-dis-sm.bmp b/src/windows/identity/ui/images/id-dis-sm.bmp
deleted file mode 100644
index ee55b0f20..000000000
--- a/src/windows/identity/ui/images/id-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-dis.bmp b/src/windows/identity/ui/images/id-dis.bmp
deleted file mode 100644
index 3c04aa2fa..000000000
--- a/src/windows/identity/ui/images/id-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-new-dis-sm.bmp b/src/windows/identity/ui/images/id-new-dis-sm.bmp
deleted file mode 100644
index d2a151c37..000000000
--- a/src/windows/identity/ui/images/id-new-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-new-dis.bmp b/src/windows/identity/ui/images/id-new-dis.bmp
deleted file mode 100644
index 61c2fd21a..000000000
--- a/src/windows/identity/ui/images/id-new-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-new-sm.bmp b/src/windows/identity/ui/images/id-new-sm.bmp
deleted file mode 100644
index 9fb17b98c..000000000
--- a/src/windows/identity/ui/images/id-new-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-new.bmp b/src/windows/identity/ui/images/id-new.bmp
deleted file mode 100644
index 54830c183..000000000
--- a/src/windows/identity/ui/images/id-new.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-refresh-dis.bmp b/src/windows/identity/ui/images/id-refresh-dis.bmp
deleted file mode 100644
index 7d7934369..000000000
--- a/src/windows/identity/ui/images/id-refresh-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-refresh-sm-dis.bmp b/src/windows/identity/ui/images/id-refresh-sm-dis.bmp
deleted file mode 100644
index c9d9addf1..000000000
--- a/src/windows/identity/ui/images/id-refresh-sm-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-refresh-sm.bmp b/src/windows/identity/ui/images/id-refresh-sm.bmp
deleted file mode 100644
index 11d1893b4..000000000
--- a/src/windows/identity/ui/images/id-refresh-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-refresh.bmp b/src/windows/identity/ui/images/id-refresh.bmp
deleted file mode 100644
index 6357fde4f..000000000
--- a/src/windows/identity/ui/images/id-refresh.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id-sm.bmp b/src/windows/identity/ui/images/id-sm.bmp
deleted file mode 100644
index 6edfb07d9..000000000
--- a/src/windows/identity/ui/images/id-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id.bmp b/src/windows/identity/ui/images/id.bmp
deleted file mode 100644
index 72a93c6a9..000000000
--- a/src/windows/identity/ui/images/id.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/id.ico b/src/windows/identity/ui/images/id.ico
deleted file mode 100644
index aa15f05fd..000000000
--- a/src/windows/identity/ui/images/id.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/ident.png b/src/windows/identity/ui/images/ident.png
deleted file mode 100644
index 904f0239b..000000000
--- a/src/windows/identity/ui/images/ident.png
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/import-dis.bmp b/src/windows/identity/ui/images/import-dis.bmp
deleted file mode 100644
index 4257a1ad9..000000000
--- a/src/windows/identity/ui/images/import-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/import-sm-dis.bmp b/src/windows/identity/ui/images/import-sm-dis.bmp
deleted file mode 100644
index b9398c384..000000000
--- a/src/windows/identity/ui/images/import-sm-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/import-sm.bmp b/src/windows/identity/ui/images/import-sm.bmp
deleted file mode 100644
index bc7e4f4c9..000000000
--- a/src/windows/identity/ui/images/import-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/import.bmp b/src/windows/identity/ui/images/import.bmp
deleted file mode 100644
index 6c1331dca..000000000
--- a/src/windows/identity/ui/images/import.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/khimaira-cfg.bmp b/src/windows/identity/ui/images/khimaira-cfg.bmp
deleted file mode 100644
index d20b9eb3d..000000000
--- a/src/windows/identity/ui/images/khimaira-cfg.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/logo_shade.bmp b/src/windows/identity/ui/images/logo_shade.bmp
deleted file mode 100644
index 2e36b9bf2..000000000
--- a/src/windows/identity/ui/images/logo_shade.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/main_app.ico b/src/windows/identity/ui/images/main_app.ico
deleted file mode 100644
index 8dcb29e7a..000000000
--- a/src/windows/identity/ui/images/main_app.ico
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tb-blank-small.bmp b/src/windows/identity/ui/images/tb-blank-small.bmp
deleted file mode 100644
index 0718d128b..000000000
--- a/src/windows/identity/ui/images/tb-blank-small.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tb-blank.bmp b/src/windows/identity/ui/images/tb-blank.bmp
deleted file mode 100644
index 01adca9e3..000000000
--- a/src/windows/identity/ui/images/tb-blank.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tb-space.bmp b/src/windows/identity/ui/images/tb-space.bmp
deleted file mode 100644
index d85cc5cd7..000000000
--- a/src/windows/identity/ui/images/tb-space.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-delete-dis-sm.bmp b/src/windows/identity/ui/images/tk-delete-dis-sm.bmp
deleted file mode 100644
index 00adcf443..000000000
--- a/src/windows/identity/ui/images/tk-delete-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-delete-dis.bmp b/src/windows/identity/ui/images/tk-delete-dis.bmp
deleted file mode 100644
index 844fb23a6..000000000
--- a/src/windows/identity/ui/images/tk-delete-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-delete-sm.bmp b/src/windows/identity/ui/images/tk-delete-sm.bmp
deleted file mode 100644
index b9b604f83..000000000
--- a/src/windows/identity/ui/images/tk-delete-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-delete.bmp b/src/windows/identity/ui/images/tk-delete.bmp
deleted file mode 100644
index 015159929..000000000
--- a/src/windows/identity/ui/images/tk-delete.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-dis-sm.bmp b/src/windows/identity/ui/images/tk-dis-sm.bmp
deleted file mode 100644
index 9100d9a9c..000000000
--- a/src/windows/identity/ui/images/tk-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-dis.bmp b/src/windows/identity/ui/images/tk-dis.bmp
deleted file mode 100644
index 558ba9064..000000000
--- a/src/windows/identity/ui/images/tk-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-new-dis-sm.bmp b/src/windows/identity/ui/images/tk-new-dis-sm.bmp
deleted file mode 100644
index d2e1fcdc4..000000000
--- a/src/windows/identity/ui/images/tk-new-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-new-dis.bmp b/src/windows/identity/ui/images/tk-new-dis.bmp
deleted file mode 100644
index c6abc4ec5..000000000
--- a/src/windows/identity/ui/images/tk-new-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-new-sm.bmp b/src/windows/identity/ui/images/tk-new-sm.bmp
deleted file mode 100644
index 1868eb4c9..000000000
--- a/src/windows/identity/ui/images/tk-new-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-new.bmp b/src/windows/identity/ui/images/tk-new.bmp
deleted file mode 100644
index 36f32ecca..000000000
--- a/src/windows/identity/ui/images/tk-new.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-refresh-dis-sm.bmp b/src/windows/identity/ui/images/tk-refresh-dis-sm.bmp
deleted file mode 100644
index 2745af151..000000000
--- a/src/windows/identity/ui/images/tk-refresh-dis-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-refresh-dis.bmp b/src/windows/identity/ui/images/tk-refresh-dis.bmp
deleted file mode 100644
index 45f8099b9..000000000
--- a/src/windows/identity/ui/images/tk-refresh-dis.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-refresh-sm.bmp b/src/windows/identity/ui/images/tk-refresh-sm.bmp
deleted file mode 100644
index cfee8f71b..000000000
--- a/src/windows/identity/ui/images/tk-refresh-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-refresh.bmp b/src/windows/identity/ui/images/tk-refresh.bmp
deleted file mode 100644
index 54f1a01b2..000000000
--- a/src/windows/identity/ui/images/tk-refresh.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk-sm.bmp b/src/windows/identity/ui/images/tk-sm.bmp
deleted file mode 100644
index 1e099e6f1..000000000
--- a/src/windows/identity/ui/images/tk-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/tk.bmp b/src/windows/identity/ui/images/tk.bmp
deleted file mode 100644
index e689cb830..000000000
--- a/src/windows/identity/ui/images/tk.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/vw-refresh-sm.bmp b/src/windows/identity/ui/images/vw-refresh-sm.bmp
deleted file mode 100644
index e3d321ca4..000000000
--- a/src/windows/identity/ui/images/vw-refresh-sm.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/vw-refresh.bmp b/src/windows/identity/ui/images/vw-refresh.bmp
deleted file mode 100644
index e87aa3cbc..000000000
--- a/src/windows/identity/ui/images/vw-refresh.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_collapsed.bmp b/src/windows/identity/ui/images/wdg_collapsed.bmp
deleted file mode 100644
index 4299854d3..000000000
--- a/src/windows/identity/ui/images/wdg_collapsed.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_collapsed_hi.bmp b/src/windows/identity/ui/images/wdg_collapsed_hi.bmp
deleted file mode 100644
index cb06b8acb..000000000
--- a/src/windows/identity/ui/images/wdg_collapsed_hi.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_credtype.bmp b/src/windows/identity/ui/images/wdg_credtype.bmp
deleted file mode 100644
index 3bac3fe53..000000000
--- a/src/windows/identity/ui/images/wdg_credtype.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_expanded.bmp b/src/windows/identity/ui/images/wdg_expanded.bmp
deleted file mode 100644
index 76ee5b016..000000000
--- a/src/windows/identity/ui/images/wdg_expanded.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_expanded_hi.bmp b/src/windows/identity/ui/images/wdg_expanded_hi.bmp
deleted file mode 100644
index 8180b3333..000000000
--- a/src/windows/identity/ui/images/wdg_expanded_hi.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_flag.bmp b/src/windows/identity/ui/images/wdg_flag.bmp
deleted file mode 100644
index c563c56e9..000000000
--- a/src/windows/identity/ui/images/wdg_flag.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_stick.bmp b/src/windows/identity/ui/images/wdg_stick.bmp
deleted file mode 100644
index 071a238c4..000000000
--- a/src/windows/identity/ui/images/wdg_stick.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_stick_hi.bmp b/src/windows/identity/ui/images/wdg_stick_hi.bmp
deleted file mode 100644
index 8857fec22..000000000
--- a/src/windows/identity/ui/images/wdg_stick_hi.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_stuck.bmp b/src/windows/identity/ui/images/wdg_stuck.bmp
deleted file mode 100644
index 68295181d..000000000
--- a/src/windows/identity/ui/images/wdg_stuck.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/images/wdg_stuck_hi.bmp b/src/windows/identity/ui/images/wdg_stuck_hi.bmp
deleted file mode 100644
index 3b7807129..000000000
--- a/src/windows/identity/ui/images/wdg_stuck_hi.bmp
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/khmapp.h b/src/windows/identity/ui/khmapp.h
deleted file mode 100644
index ba036c649..000000000
--- a/src/windows/identity/ui/khmapp.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_KHIMAIRA_H
-#define __KHIMAIRA_KHIMAIRA_H
-
-#include<windows.h>
-#include<windowsx.h>
-#include<strsafe.h>
-#include<commctrl.h>
-#include<htmlhelp.h>
-
-#define KHERR_HMODULE khm_hInstance
-#define KHERR_FACILITY khm_facility
-#define KHERR_FACILITY_ID 3
-
-#define NOEXPORT
-
-#include<netidmgr.h>
-
-#include<khhelp.h>
-#include<intaction.h>
-#include<intalert.h>
-
-#include<resource.h>
-#include<credfuncs.h>
-#include<appglobal.h>
-#include<mainwnd.h>
-#include<mainmenu.h>
-#include<toolbar.h>
-#include<statusbar.h>
-#include<credwnd.h>
-#include<htwnd.h>
-#include<passwnd.h>
-#include<newcredwnd.h>
-#include<propertywnd.h>
-#include<configwnd.h>
-#include<aboutwnd.h>
-#include<debugfuncs.h>
-#include<taskbar.h>
-
-#include<reqdaemon.h>
-#include<notifier.h>
-#include<timer.h>
-#include<addrchange.h>
-
-#endif
diff --git a/src/windows/identity/ui/lang/en_us/cmdline.rtf b/src/windows/identity/ui/lang/en_us/cmdline.rtf
deleted file mode 100644
index bc3356586..000000000
--- a/src/windows/identity/ui/lang/en_us/cmdline.rtf
+++ /dev/null
Binary files differ
diff --git a/src/windows/identity/ui/lang/en_us/khapp.rc b/src/windows/identity/ui/lang/en_us/khapp.rc
deleted file mode 100644
index b851ffe88..000000000
--- a/src/windows/identity/ui/lang/en_us/khapp.rc
+++ /dev/null
@@ -1,869 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "..\..\resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "..\\..\\resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_MAIN_APP ICON "..\\..\\images\\main_app.ico"
-IDI_ENABLED ICON "..\\..\\images\\enabled.ico"
-IDI_DISABLED ICON "..\\..\\images\\disabled.ico"
-IDI_NOTIFY_NONE ICON "..\\..\\images\\app_notify_none.ico"
-IDI_NOTIFY_INFO ICON "..\\..\\images\\app_notify_info.ico"
-IDI_NOTIFY_WARN ICON "..\\..\\images\\app_notify_warn.ico"
-IDI_NOTIFY_ERROR ICON "..\\..\\images\\app_notify_error.ico"
-IDI_CFG_DEFAULT ICON "..\\..\\images\\cfg_default.ico"
-IDI_CFG_MODIFIED ICON "..\\..\\images\\cfg_mod.ico"
-IDI_CFG_APPLIED ICON "..\\..\\images\\cfg_applied.ico"
-IDI_CFG_DELETED ICON "..\\..\\images\\cfg_deleted.ico"
-IDI_ID ICON "..\\..\\images\\id.ico"
-IDI_APPICON_WARN ICON "..\\..\\images\\app_state_warn.ico"
-IDI_APPICON_EXP ICON "..\\..\\images\\app_state_exp.ico"
-IDI_APPICON_OK ICON "..\\..\\images\\app_state_ok.ico"
-IDI_CFG_PLUGIN ICON "..\\..\\images\\cfg_plugin.ico"
-IDI_CFG_PLUGIN_ERR ICON "..\\..\\images\\cfg_plugin_err.ico"
-IDI_CFG_PLUGIN_DIS ICON "..\\..\\images\\cfg_plugin_dis.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDB_TK_REFRESH BITMAP "..\\..\\images\\tk-refresh.bmp"
-IDB_ID BITMAP "..\\..\\images\\id.bmp"
-IDB_ID_DELETE BITMAP "..\\..\\images\\id-delete.bmp"
-IDB_ID_NEW BITMAP "..\\..\\images\\id-new.bmp"
-IDB_ID_REFRESH BITMAP "..\\..\\images\\id-refresh.bmp"
-IDB_TK BITMAP "..\\..\\images\\tk.bmp"
-IDB_TK_DELETE BITMAP "..\\..\\images\\tk-delete.bmp"
-IDB_TK_NEW BITMAP "..\\..\\images\\tk-new.bmp"
-IDB_VW_REFRESH_SM BITMAP "..\\..\\images\\vw-refresh-sm.bmp"
-IDB_TB_BLANK BITMAP "..\\..\\images\\tb-blank.bmp"
-IDB_TB_BLANK_SM BITMAP "..\\..\\images\\tb-blank-small.bmp"
-IDB_VW_REFRESH BITMAP "..\\..\\images\\vw-refresh.bmp"
-IDB_ID_DELETE_DIS BITMAP "..\\..\\images\\id-delete-dis.bmp"
-IDB_ID_DELETE_DIS_SM BITMAP "..\\..\\images\\id-delete-dis-sm.bmp"
-IDB_ID_DELETE_SM BITMAP "..\\..\\images\\id-delete-sm.bmp"
-IDB_ID_DIS BITMAP "..\\..\\images\\id-dis.bmp"
-IDB_ID_DIS_SM BITMAP "..\\..\\images\\id-dis-sm.bmp"
-IDB_ID_NEW_DIS BITMAP "..\\..\\images\\id-new-dis.bmp"
-IDB_ID_NEW_DIS_SM BITMAP "..\\..\\images\\id-new-dis-sm.bmp"
-IDB_ID_NEW_SM BITMAP "..\\..\\images\\id-new-sm.bmp"
-IDB_ID_REFRESH_DIS BITMAP "..\\..\\images\\id-refresh-dis.bmp"
-IDB_ID_REFRESH_SM BITMAP "..\\..\\images\\id-refresh-sm.bmp"
-IDB_ID_REFRESH_DIS_SM BITMAP "..\\..\\images\\id-refresh-sm-dis.bmp"
-IDB_TK_DELETE_DIS BITMAP "..\\..\\images\\tk-delete-dis.bmp"
-IDB_TK_DELETE_DIS_SM BITMAP "..\\..\\images\\tk-delete-dis-sm.bmp"
-IDB_TK_DELETE_SM BITMAP "..\\..\\images\\tk-delete-sm.bmp"
-IDB_TK_DIS_SM BITMAP "..\\..\\images\\tk-dis-sm.bmp"
-IDB_TK_NEW_DIS BITMAP "..\\..\\images\\tk-new-dis.bmp"
-IDB_TK_NEW_DIS_SM BITMAP "..\\..\\images\\tk-new-dis-sm.bmp"
-IDB_TK_NEW_SM BITMAP "..\\..\\images\\tk-new-sm.bmp"
-IDB_TK_REFRESH_DIS BITMAP "..\\..\\images\\tk-refresh-dis.bmp"
-IDB_TK_REFRESH_DIS_SM BITMAP "..\\..\\images\\tk-refresh-dis-sm.bmp"
-IDB_TK_REFRESH_SM BITMAP "..\\..\\images\\tk-refresh-sm.bmp"
-IDB_TK_SM BITMAP "..\\..\\images\\tk-sm.bmp"
-IDB_HELP_SM BITMAP "..\\..\\images\\help-sm.bmp"
-IDB_HELP BITMAP "..\\..\\images\\help.bmp"
-IDB_LOGO_SHADE BITMAP "..\\..\\images\\logo_shade.bmp"
-IDB_WDG_EXPAND BITMAP "..\\..\\images\\wdg_expanded.bmp"
-IDB_WDG_COLLAPSE BITMAP "..\\..\\images\\wdg_collapsed.bmp"
-IDB_ID_SM BITMAP "..\\..\\images\\id-sm.bmp"
-IDB_WDG_EXPAND_HI BITMAP "..\\..\\images\\wdg_expanded_hi.bmp"
-IDB_WDG_COLLAPSE_HI BITMAP "..\\..\\images\\wdg_collapsed_hi.bmp"
-IDB_WDG_CREDTYPE BITMAP "..\\..\\images\\wdg_credtype.bmp"
-IDB_WDG_FLAG BITMAP "..\\..\\images\\wdg_flag.bmp"
-IDB_FLAG_WARN BITMAP "..\\..\\images\\flag-warning.bmp"
-IDB_FLAG_EXPIRED BITMAP "..\\..\\images\\flag_expired.bmp"
-IDB_FLAG_CRITICAL BITMAP "..\\..\\images\\flag-critical.bmp"
-IDB_LOGO_OPAQUE BITMAP "..\\..\\images\\khimaira-cfg.bmp"
-IDB_IMPORT_SM_DIS BITMAP "..\\..\\images\\import-sm-dis.bmp"
-IDB_IMPORT BITMAP "..\\..\\images\\import.bmp"
-IDB_IMPORT_DIS BITMAP "..\\..\\images\\import-dis.bmp"
-IDB_IMPORT_SM BITMAP "..\\..\\images\\import-sm.bmp"
-IDB_CHPW_SM BITMAP "..\\..\\images\\chpw-sm.bmp"
-IDB_CHPW BITMAP "..\\..\\images\\chpw.bmp"
-IDB_CHPW_DIS BITMAP "..\\..\\images\\chpw-dis.bmp"
-IDB_CHPW_DIS_SM BITMAP "..\\..\\images\\chpw-dis-sm.bmp"
-IDB_TB_SPACE BITMAP "..\\..\\images\\tb-space.bmp"
-IDB_WDG_STUCK_HI BITMAP "..\\..\\images\\wdg_stuck_hi.bmp"
-IDB_WDG_STICK BITMAP "..\\..\\images\\wdg_stick.bmp"
-IDB_WDG_STICK_HI BITMAP "..\\..\\images\\wdg_stick_hi.bmp"
-IDB_WDG_STUCK BITMAP "..\\..\\images\\wdg_stuck.bmp"
-IDB_FLAG_RENEW BITMAP "..\\..\\images\\flag_renewable.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_MENU_BAR ACCELERATORS
-BEGIN
- VK_F10, IDA_ACTIVATE_MENU, VIRTKEY, NOINVERT
- VK_UP, IDA_UP, VIRTKEY, NOINVERT
- VK_DOWN, IDA_DOWN, VIRTKEY, NOINVERT
- VK_LEFT, IDA_LEFT, VIRTKEY, NOINVERT
- VK_RIGHT, IDA_RIGHT, VIRTKEY, NOINVERT
- VK_ESCAPE, IDA_ESC, VIRTKEY, NOINVERT
- VK_EXECUTE, IDA_ENTER, VIRTKEY, NOINVERT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_NC_NEWCRED DIALOGEX 0, 0, 301, 167
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "UI Row2",IDC_NC_TPL_ROW_LG,7,31,287,18,NOT WS_VISIBLE | WS_BORDER
- LTEXT "TplPanel",IDC_NC_TPL_PANEL,7,7,287,153,NOT WS_VISIBLE | WS_BORDER
- LTEXT "UI Row",IDC_NC_TPL_ROW,7,7,287,18,NOT WS_VISIBLE | WS_BORDER
- LTEXT "TplLabel",IDC_NC_TPL_LABEL,7,8,45,10,NOT WS_VISIBLE | WS_BORDER
- LTEXT "TplInput",IDC_NC_TPL_INPUT,54,7,240,13,NOT WS_VISIBLE | WS_BORDER
- LTEXT "TplLabelLg",IDC_NC_TPL_LABEL_LG,7,33,146,10,NOT WS_VISIBLE | WS_BORDER
- LTEXT "TplInputLg",IDC_NC_TPL_INPUT_LG,155,31,139,13,NOT WS_VISIBLE | WS_BORDER
- LTEXT "&Credentials",IDC_NC_CREDTEXT_LABEL,7,66,41,10,NOT WS_VISIBLE | NOT WS_GROUP
- CONTROL "",IDC_NC_CREDTEXT,"KhmHtWnd",NOT WS_VISIBLE | WS_TABSTOP,54,65,240,95,WS_EX_CLIENTEDGE
- PUSHBUTTON "&Ok",IDOK,101,142,89,18,WS_DISABLED
- PUSHBUTTON "&Cancel",IDCANCEL,198,142,54,18
- PUSHBUTTON "&>>",IDC_NC_ADVANCED,260,142,34,18
-END
-
-IDD_NC_BBAR DIALOGEX 0, 0, 66, 190
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "&Ok",IDOK,7,7,52,41,WS_DISABLED
- PUSHBUTTON "&Cancel",IDCANCEL,7,58,52,19
- PUSHBUTTON "&<<",IDC_NC_BASIC,7,144,52,14
- PUSHBUTTON "&Help",IDC_NC_HELP,7,164,52,19
-END
-
-IDD_PP_IDENT DIALOGEX 0, 0, 235, 156
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
-EXSTYLE WS_EX_CONTROLPARENT
-CAPTION "Identity"
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- LTEXT "Name",IDC_STATIC,7,8,19,12
- LTEXT "IdentityName",IDC_PP_IDNAME,34,7,194,12,NOT WS_GROUP,WS_EX_CLIENTEDGE
- CONTROL "Default identity",IDC_PP_IDDEF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,34,22,71,12
- CONTROL "Searchable",IDC_PP_IDSEARCH,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,117,36,74,12
- CONTROL "Custom1",IDC_PP_PROPLIST,"NetIDMgrPropertyWnd",WS_TABSTOP,7,51,221,80
- CONTROL "Always visible (sticky)",IDC_PP_STICKY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,22,85,12
- PUSHBUTTON "Identity configuration ...",IDC_PP_CONFIG,117,135,111,14
-END
-
-IDD_PP_CRED DIALOGEX 0, 0, 236, 158
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
-CAPTION "Credential"
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- CONTROL "Check1",IDC_PP_DUMMY,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,0,1,39,10
- CONTROL "Custom1",IDC_PP_CPROPLIST,"NetIDMgrPropertyWnd",WS_TABSTOP,7,7,222,144
-END
-
-IDD_CFG_MAIN DIALOGEX 0, 0, 357, 222
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
-EXSTYLE WS_EX_CONTEXTHELP
-CAPTION "Network Identity Manager Configuration"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "Title",IDC_CFG_TITLE,0,0,357,20,SS_CENTERIMAGE
- CONTROL "",IDC_CFG_NODELIST,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_TRACKSELECT | WS_TABSTOP | 0x800,0,20,100,182
- LTEXT "Static",IDC_CFG_PANE,102,20,255,182,NOT WS_VISIBLE | WS_BORDER
- PUSHBUTTON "&Ok",IDOK,162,205,78,16
- PUSHBUTTON "&Cancel",IDCANCEL,246,205,51,16
- PUSHBUTTON "&Apply",IDAPPLY,303,205,51,16,WS_DISABLED
-END
-
-IDD_CFG_GENERIC DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CTEXT "Please select one of the configuration categories on the left.",IDC_STATIC,21,17,212,18,SS_CENTERIMAGE,WS_EX_TRANSPARENT
-END
-
-IDD_CFG_GENERAL DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- GROUPBOX "Startup / Shutdown",IDC_CFG_STARTUP_GROUP,7,7,241,44
- CONTROL "&Obtain new credentials at startup (if none are present)",IDC_CFG_AUTOINIT,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,20,196,10
- CONTROL "&Destroy all credentials on exit",IDC_CFG_DESTROYALL,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,36,111,10
- GROUPBOX "Other",IDC_CFG_OTHER,7,55,241,120
- CONTROL "&Run from taskbar notification area after window close",IDC_CFG_KEEPRUNNING,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,68,230,10
- LTEXT "Clicking on the &notification icon",IDC_CFG_NOTACT_STATIC,26,87,99,8
- COMBOBOX IDC_CFG_NOTACTION,133,85,110,48,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- CONTROL "&Monitor network connectivity",IDC_CFG_NETDETECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,104,106,10
- CONTROL "&Log trace events to trace log at the following location:",IDC_CFG_LOGTOFILE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,121,225,10
- EDITTEXT IDC_CFG_LOGPATH,16,135,173,14,ES_AUTOHSCROLL | ES_READONLY
- PUSHBUTTON "&Show log",IDC_CFG_SHOWLOG,193,135,50,14
- CONTROL "A&utomatically import Windows logon identity",IDC_CFG_AUTOIMPORT,
- "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,16,156,165,10
- CONTROL "&Start Network Identity Manager during Windows logon",IDC_CFG_AUTOSTART,
- "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,113,165,135,10
-END
-
-IDD_CFG_IDENTITIES DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "",IDC_CFG_TAB,"SysTabControl32",WS_TABSTOP,7,7,241,168
- LTEXT "Static",IDC_CFG_TARGET,10,21,235,151,NOT WS_VISIBLE | WS_BORDER
-END
-
-IDD_CFG_NOTIF DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "&Renew automatically at",IDC_NOTIF_RENEW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,9,100,10
- EDITTEXT IDC_NOTIF_RENEW_THR,122,7,126,14,ES_AUTOHSCROLL
- CONTROL "Renew at &half life intervals when possible",IDC_NOTIF_HALFLIFE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,48,27,148,10
- CONTROL "Initial warning at",IDC_NOTIF_WARN1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,46,100,10
- EDITTEXT IDC_NOTIF_WARN1_THR,122,44,126,14,ES_AUTOHSCROLL
- CONTROL "Final warning at",IDC_NOTIF_WARN2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,68,100,10
- EDITTEXT IDC_NOTIF_WARN2_THR,122,66,126,14,ES_AUTOHSCROLL
- CONTROL "&Monitor credential expiration",IDC_NOTIF_MONITOR,
- "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,7,103,139,10
-END
-
-IDD_CFG_PLUGINS DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "",IDC_CFG_PLUGINS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,75,168
- ICON IDI_CFG_PLUGIN,IDC_CFG_ICON,87,11,20,20
- EDITTEXT IDC_CFG_DESC,128,7,120,30,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY
- LTEXT "&Module",IDC_CFG_LBL_MOD,87,43,24,8
- EDITTEXT IDC_CFG_MODULE,128,43,120,12,ES_AUTOHSCROLL | ES_READONLY
- LTEXT "&Version",IDC_STATIC,87,59,24,8
- EDITTEXT IDC_CFG_VERSION,128,59,120,12,ES_AUTOHSCROLL | ES_READONLY
- LTEXT "Ve&ndor",IDC_CFG_LBL_VEN,87,75,24,8
- EDITTEXT IDC_CFG_VENDOR,128,75,120,12,ES_AUTOHSCROLL | ES_READONLY
- LTEXT "De&pends on",IDC_CFG_LBL_DEPS,87,93,39,8
- LISTBOX IDC_CFG_DEPS,128,93,120,34,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
- LTEXT "&Status",IDC_CFG_LBL_STATE,87,129,22,8
- EDITTEXT IDC_CFG_STATE,128,129,120,12,ES_AUTOHSCROLL | ES_READONLY
- PUSHBUTTON "&Enable ...",IDC_CFG_ENABLE,128,144,50,14,WS_DISABLED
- PUSHBUTTON "&Disable ...",IDC_CFG_DISABLE,198,144,50,14,WS_DISABLED
- PUSHBUTTON "&Unregister plug-in ...",IDC_CFG_UNREGISTER,87,161,72,14,WS_DISABLED
- PUSHBUTTON "&Register new plug-in ...",IDC_CFG_REGISTER,169,161,79,14,NOT WS_VISIBLE | WS_DISABLED
-END
-
-IDD_CFG_IDENTITY DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "",IDC_CFG_TAB,"SysTabControl32",WS_TABSTOP,7,7,241,168
- LTEXT "Static",IDC_CFG_TARGET,10,21,235,151,NOT WS_VISIBLE | WS_BORDER
-END
-
-IDD_CFG_IDS_TAB DIALOGEX 0, 0, 235, 151
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Monitor credential expiration",IDC_CFG_MONITOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,107,10
- CONTROL "Automatically renew",IDC_CFG_RENEW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,20,81,10
- CONTROL "Always show in the credentials list (Pinned)",IDC_CFG_STICKY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,34,151,10
- PUSHBUTTON "&Add new identity...",IDC_CFG_ADDIDENT,17,120,86,14
-END
-
-IDD_CFG_ID_TAB DIALOGEX 0, 0, 235, 151
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "Always show in the credentials list (Pinned)",IDC_CFG_STICKY,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,34,151,10
- CONTROL "Monitor credential expiration",IDC_CFG_MONITOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,107,10
- CONTROL "Automatically renew",IDC_CFG_RENEW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,20,81,10
- PUSHBUTTON "Remove identity ...",IDC_CFG_REMOVE,139,122,78,14
-END
-
-IDD_ABOUT DIALOGEX 0, 0, 324, 238
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "About Network Identity Manager"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,267,7,50,14
- LTEXT "Productname",IDC_PRODUCT,41,7,225,13,NOT WS_GROUP
- LTEXT "© 2005-2007 Massachusetts Institute of Technology\n© 2006-2007 Secure Endpoints Inc.",IDC_COPYRIGHT,41,23,276,23,NOT WS_GROUP
- LTEXT "BuildInfo",IDC_BUILDINFO,41,49,276,20,NOT WS_GROUP
- ICON IDI_MAIN_APP,IDC_STATIC,6,7,20,20
- CONTROL "",IDC_MODULES,"SysListView32",LVS_REPORT | LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,41,88,276,143
- LTEXT "Loaded modules",IDC_STATIC,41,76,52,8
-END
-
-IDD_CFG_APPEAR DIALOGEX 0, 0, 255, 182
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- GROUPBOX "Font for credentials display",IDC_STATIC,7,7,241,137
- LTEXT "&Font name",IDC_STATIC,17,22,35,8
- COMBOBOX IDC_CFG_FONTS,62,20,178,51,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- LTEXT "&Size",IDC_STATIC,62,43,14,8
- COMBOBOX IDC_CFG_SIZE,87,41,48,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "&Bold",IDC_CFG_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,42,29,10
- CONTROL "&Italics",IDC_CFG_ITALICS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,205,42,35,10
- EDITTEXT IDC_CFG_SAMPLE_NORMAL,62,66,178,21,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE
- EDITTEXT IDC_CFG_SAMPLE_BOLD,62,91,178,21,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE
- PUSHBUTTON "&Revert to default",IDC_CFG_REVERT,168,122,72,14
-END
-
-IDD_CFG_ADDIDENT DIALOGEX 0, 0, 279, 95
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Add new identity"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- LTEXT "&Identity name",IDC_SM_LBL,7,10,46,8,NOT WS_VISIBLE
- EDITTEXT IDC_SM_CTL,67,7,205,14,ES_AUTOHSCROLL | NOT WS_VISIBLE
- DEFPUSHBUTTON "OK",IDOK,145,74,71,14
- PUSHBUTTON "Cancel",IDCANCEL,222,74,50,14
- LTEXT "&Identity name",IDC_MED_LBL,7,27,130,8,NOT WS_VISIBLE
- EDITTEXT IDC_MED_CTL,141,24,131,14,ES_AUTOHSCROLL | NOT WS_VISIBLE
- LTEXT "&Identity name",IDC_LG_LBL,7,41,265,8,NOT WS_VISIBLE
- EDITTEXT IDC_LG_CTL,141,50,131,14,ES_AUTOHSCROLL | NOT WS_VISIBLE
-END
-
-IDD_CMDLINE DIALOGEX 0, 0, 309, 286
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_CAPTION | WS_SYSMENU
-CAPTION "Commandline options for Network Identity Manager"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,252,265,50,14
- ICON IDI_MAIN_APP,IDC_STATIC,7,7,21,20
- LTEXT "Productname",IDC_PRODUCT,40,7,262,13,NOT WS_GROUP
- CONTROL "",IDC_CONTENT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL | WS_TABSTOP,40,22,262,231
- LTEXT "© 2005-2007 Massachusetts Institute of Technology\n© 2006-2007 Secure Endpoints Inc.",IDC_COPYRIGHT,7,258,240,21,NOT WS_GROUP
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_NC_NEWCRED, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 294
- TOPMARGIN, 7
- BOTTOMMARGIN, 160
- END
-
- IDD_NC_BBAR, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 59
- TOPMARGIN, 7
- BOTTOMMARGIN, 183
- END
-
- IDD_PP_IDENT, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 228
- VERTGUIDE, 34
- VERTGUIDE, 117
- TOPMARGIN, 7
- BOTTOMMARGIN, 149
- END
-
- IDD_PP_CRED, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 229
- TOPMARGIN, 7
- BOTTOMMARGIN, 151
- END
-
- IDD_CFG_GENERIC, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- END
-
- IDD_CFG_GENERAL, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- VERTGUIDE, 16
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- END
-
- IDD_CFG_IDENTITIES, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- VERTGUIDE, 10
- VERTGUIDE, 244
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- HORZGUIDE, 22
- HORZGUIDE, 171
- END
-
- IDD_CFG_NOTIF, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- VERTGUIDE, 22
- VERTGUIDE, 122
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- END
-
- IDD_CFG_PLUGINS, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- VERTGUIDE, 87
- VERTGUIDE, 128
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- END
-
- IDD_CFG_IDENTITY, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- END
-
- IDD_CFG_IDS_TAB, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 228
- TOPMARGIN, 7
- BOTTOMMARGIN, 144
- END
-
- IDD_CFG_ID_TAB, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 228
- TOPMARGIN, 7
- BOTTOMMARGIN, 144
- END
-
- IDD_ABOUT, DIALOG
- BEGIN
- LEFTMARGIN, 6
- RIGHTMARGIN, 317
- VERTGUIDE, 41
- VERTGUIDE, 266
- TOPMARGIN, 7
- BOTTOMMARGIN, 231
- END
-
- IDD_CFG_APPEAR, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 248
- VERTGUIDE, 7
- VERTGUIDE, 62
- VERTGUIDE, 240
- VERTGUIDE, 248
- TOPMARGIN, 7
- BOTTOMMARGIN, 175
- END
-
- IDD_CFG_ADDIDENT, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 272
- TOPMARGIN, 7
- BOTTOMMARGIN, 88
- END
-
- IDD_CMDLINE, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 302
- VERTGUIDE, 40
- TOPMARGIN, 7
- BOTTOMMARGIN, 279
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// KHMRTFRESOURCE
-//
-
-IDR_CMDLINERTF KHMRTFRESOURCE "cmdline.rtf"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
- IDS_MAIN_WINDOW_TITLE "Network Identity Manager"
- IDS_MENU_FILE "&File"
- IDS_MENU_CRED "&Credential"
- IDS_MENU_VIEW "&View"
-END
-
-STRINGTABLE
-BEGIN
- IDS_MENU_OPTIONS "&Options"
- IDS_MENU_HELP "&Help"
- IDS_ACTION_PROPERTIES "&Properties"
- IDS_ACTION_EXIT "E&xit"
- IDS_CFG_ROOT_NAME "Network Identity Manager"
- IDS_ACTION_SET_DEF_ID "Set as &default"
- IDS_ACTION_SET_SRCH_ID "Allow applications to &search"
- IDS_CFG_ROOT_TITLE "Network Identity Manager Configuration"
- IDS_CFG_GENERAL_SHORT "General"
- IDS_ACTION_NEW_CRED "Obtain &new credentials ..."
- IDS_ACTION_PASSWD_ID "Change &password"
- IDS_ACTION_CHOOSE_COLS "Select columns"
- IDS_ACTION_DEBUG_WINDOW "Debug window"
- IDS_ACTION_VIEW_REFRESH "Refresh view"
- IDS_MENU_LAYOUT "Layout"
- IDS_MENU_TOOLBARS "Toolbars"
-END
-
-STRINGTABLE
-BEGIN
- IDS_ACTION_LAYOUT_ID "By identity"
- IDS_ACTION_LAYOUT_TYPE "By type"
- IDS_ACTION_LAYOUT_LOC "By location"
- IDS_ACTION_TB_STANDARD "Standard"
- IDS_ACTION_OPT_KHIM "General"
- IDS_ACTION_OPT_IDENTS "Identities"
- IDS_ACTION_OPT_NOTIF "Notifications"
- IDS_ACTION_HELP_CTX "Help Contents"
- IDS_ACTION_HELP_CONTENTS "Contents"
- IDS_ACTION_HELP_INDEX "Index"
- IDS_ACTION_HELP_ABOUT "About Network Identity Manager"
- IDS_CFG_GENERAL_LONG "General options"
- IDS_SAMPLE_STRING "Wxy"
- IDS_NO_CREDS "<large><p align=""center"">You currently have no credentials.</p><p align=""center"">Click <a id=""NewCreds"">here</a> to obtain new credentials.</p></large>"
- IDS_WT_INIT_CREDS "Obtain initial credentials"
- IDS_WT_NEW_CREDS "Obtain new credentials"
-END
-
-STRINGTABLE
-BEGIN
- IDS_NC_IDENTITY "&Identity"
- IDS_NC_IDENTS "&Identities"
- IDS_NC_CREDTEXT_ID_NONE "<p><b>(No identities specified)</b></p>"
- IDS_NC_CREDTEXT_ID_ONE "<p>Selected identity: <b>%s</b></p>"
- IDS_NC_CREDTEXT_ID_MANY "<p>Primary identity: <b>%s</b></p><p>Additional identities: <b>%s</b></p>"
- IDS_NC_CREDTEXT_ID_INVALID "<font color=""red"">%s (invalid)</font>"
- IDS_WTPOST_INIT_CREDS " - Initial credentials"
- IDS_WTPOST_NEW_CREDS " - New credentials"
- IDS_ACTION_RENEW_CRED "R&enew credentials"
- IDS_ACTION_DESTROY_CRED "De&stroy credentials"
- IDS_DEFAULT_FONT "MS Shell Dlg"
- IDS_NC_CREDTEXT_TABS "<settab pos=""15""><settab pos=""30""><settab pos=""45"">"
- IDS_NOTIFY_PREFIX "Network Identity Manager - "
- IDS_NOTIFY_READY "Ready"
- IDS_NOTIFY_ATTENTION "Attention"
- IDS_ALERT_DEFAULT "Alert"
-END
-
-STRINGTABLE
-BEGIN
- IDS_PACTION_OK "&Ok"
- IDS_PACTION_CANCEL "&Cancel"
- IDS_PACTION_CLOSE "&Close"
- IDS_ALERT_NOSEL_TITLE "No credentials selected"
- IDS_ALERT_NOSEL "Please select a credential, a credential type or an identity."
- IDS_NC_CREDTEXT_ID_VALID "<font color=""blue"">%s</font>"
- IDS_NC_CREDTEXT_ID_UNCHECKED "<font color=""grey"">%s (Unverified)</font>"
- IDS_PROP_COL_PROPERTY "Property"
- IDS_PROP_COL_VALUE "Value"
- IDS_NC_NEW_IDENT "( New identity ... )"
- IDS_NC_CREDTEXT_ID_CHECKING "<font color=""grey"">%s (Checking...)</font>"
- IDS_ACTION_OPEN_APP "Show Network Identity Manager window"
- IDS_CTX_NEW_IDENT "Obtaining new identity"
- IDS_CTX_NEW_CREDS "Obtaining new credentials"
- IDS_CTX_RENEW_CREDS "Renewing credentials"
- IDS_CTX_PROC_NEW_IDENT "Obtaining initial credentials for %1!s!"
-END
-
-STRINGTABLE
-BEGIN
- IDS_CTX_PROC_NEW_CREDS "Obtaining new credentials for %1!s!"
- IDS_CTX_PROC_RENEW_CREDS "Renewing credentials for %1!s!"
- IDS_ACTION_CLOSE_APP "Hide Network Identity Manager window"
- IDS_NC_FAILED_TITLE "Failed to acquire credentials"
- IDS_CFG_IDENTITIES_SHORT "Identities"
- IDS_CFG_IDENTITIES_LONG "Global Identity settings"
- IDS_CFG_NOTIF_SHORT "Notifications"
- IDS_CFG_NOTIF_LONG "Notifications"
- IDS_CFG_PLUGINS_SHORT "Plug-ins"
- IDS_CFG_PLUGINS_LONG "Plug-ins and Modules"
- IDS_CFG_IDENTITY_SHORT "%s"
- IDS_CFG_IDENTITY_LONG "Options for %s"
- IDS_CTX_DESTROY_CREDS "Destroying credentials"
- IDS_WARN_EXPIRE "Some of your credentials will expire in %s"
- IDS_WARN_TITLE "Credentials expiration warning"
- IDS_ALERT_MOREINFO "...\nClick here for more..."
-END
-
-STRINGTABLE
-BEGIN
- IDS_WARN_EXPIRED "Some of your credentials have expired."
- IDS_WARN_EXPIRE_ID "Credentials for %.180s will expire in %s"
- IDS_WARN_EXPIRED_ID "Credentials for %.220s have expired"
- IDS_WARN_WM_TITLE "Network Identity Manager is still running"
- IDS_WARN_WM_MSG "Click the Network Identity Manager icon below to open the application.\n\nOr right click the icon to access the Network Identity Manager menu."
- IDS_CFG_ID_TAB_SHORT "General"
- IDS_CFG_ID_TAB_LONG "General options for this identity"
- IDS_CFG_IDS_TAB_SHORT "General"
- IDS_CFG_IDS_TAB_LONG "General options for all identities"
- IDS_CFG_IDS_IDENTITY "Identity"
- IDS_ACTION_IMPORT "Import Credentials"
- IDS_CTX_IMPORT "Importing credentials from Windows"
- IDS_CFG_PI_COL_PLUGINS "Plug-ins"
- IDS_PISTATE_FAILUNK "Unknown failure"
- IDS_PISTATE_FAILMAX "Maximum failure count reached"
- IDS_PISTATE_FAILREG "Not properly registered"
-END
-
-STRINGTABLE
-BEGIN
- IDS_PISTATE_FAILDIS "Disabled"
- IDS_PISTATE_FAILLOD "Failed to initialize"
- IDS_PISTATE_PLACEHOLD "Not loaded"
- IDS_PISTATE_REG "Not initialized"
- IDS_PISTATE_HOLD "Waiting for dependencies"
- IDS_PISTATE_INIT "Initializing"
- IDS_PISTATE_RUN "Running"
- IDS_PISTATE_EXIT "Stopped"
- IDS_CTX_PASSWORD "Changing password"
- IDS_WT_PASSWORD "Changing password"
- IDS_WTPOST_PASSWORD " - Changing password"
- IDS_CTX_PROC_PASSWORD "Changing password for %1!s!"
- IDS_NC_PWD_FAILED_TITLE "Failed to change password"
- IDS_MENU_SETDEF "Set default"
- IDS_PACTION_NEXT "Next alert"
- IDS_ERR_TITLE_NO_IDENTPRO "Cannot proceed without identity provider"
-END
-
-STRINGTABLE
-BEGIN
- IDS_ERR_MSG_NO_IDENTPRO "There is no identity provider currently loaded. The identity provider is the component of Network Identity Manager that verifies and performs operations on actual identities. Without this provider, many critical operations cannot be performed."
- IDS_ERR_SUGG_NO_IDENTPRO
- "This is quite possibly caused by the identity provider module failing to load properly."
- IDS_NC_REN_FAILED_TITLE "Failed to renew credentials"
- IDS_CW_DEFAULT "(Default)"
- IDS_ACTION_OPT_PLUGINS "Plug-ins"
- IDS_NC_SETDEF "&Set as default identity"
- IDS_NC_ID_DEF "<p>This identity is the default</p>"
- IDS_NC_ID_WDEF "<p>Will be the default. (<a id=""NotDef"">Don't make default</a>)</p>"
- IDS_NC_ID_NDEF "<p>Not default identity. (<a id=""MakeDef"">make default</a>)</p>"
- IDS_PACTION_YES "&Yes"
- IDS_PACTION_NO "&No"
- IDS_PACTION_YESALL "Y&es to all"
- IDS_PACTION_NOALL "N&o to all"
- IDS_PACTION_KEEP "&Keep"
- IDS_PACTION_REMOVE "&Remove"
- IDS_PACTION_DISCARD "&Discard"
-END
-
-STRINGTABLE
-BEGIN
- IDS_CFG_IT_MOD "Changes need to be applied"
- IDS_CFG_IT_APP "Changes have been applied"
- IDS_CFG_IT_NONE "No changes"
- IDS_CFG_NODESC "(Description for plug-in %s is not available)"
- IDS_CFG_P_DELCNFT "About to disable plug-in %s"
- IDS_CFG_P_DELCNFM "Are you sure you want to disable plug-in %s ?\n\nOnce disabled, the services provided by the plug-in will no longer be available. In addition, any other plug-ins that depend on this plug-in will also become non functional.\n\nNetwork Identity Manager will need to be restarted for the plug-in to be deactivated."
- IDS_CFG_P_DELCNFS "The following plug-ins depend on this plug-in : %s"
- IDS_CFG_P_DELNDEP "No other plug-ins depend on this plug-in."
- IDS_CFG_P_ENBCNFT "About to enable plug-in %s"
- IDS_CFG_P_ENBCNFM "The plug-in %s will be marked as enabled. The plug-in will be come active the next time Network Identity Manager is started."
- IDS_PISTATE_FAILINIT "Failed to initialize"
- IDS_CFG_P_UNRCNFT "Unregistering plug-in %s"
- IDS_CFG_P_UNRCNFM "Are you sure you want to unregister plug-in %s? In addition to this plug-in, any other plug-ins that are provided by the same module will also be unregistered.\n\nThe plug-in will no longer be loaded for subsequent sessions of Network Identity Manager."
- IDS_CFG_P_UNRCNFS "Note that if the plug-in was registered by a separate installer, it should be unregistered by the same installer and not through Network Identity Manager.\n\nThe following plug-ins will be unregistered: %s"
- IDS_ACTION_LAYOUT_CUST "Custom"
- IDS_APR_HEADER_TEXT "Header text"
-END
-
-STRINGTABLE
-BEGIN
- IDS_APR_HEADER_TEXT_BOLD "Header text (selected)"
- IDS_APR_TEXT "Normal text"
- IDS_APR_TEXT_BOLD "Normal text (selected)"
- IDS_APR_SAMPLE_TEXT_NORMAL "Sample text (normal). 01234567890"
- IDS_CFG_APPEAR_SHORT "Appearance"
- IDS_CFG_APPEAR_LONG "Appearance"
- IDS_ACTION_OPT_APPEAR "Appearance"
- IDS_APR_SAMPLE_TEXT_SEL "Sample text (selected). 01234567890"
- IDS_CFG_IDNAME_INV "The identity name %s is invalid."
- IDS_CFG_IDNAME_PRB "Can't add new identity %s"
- IDS_CFG_IDNAME_EXT "The identity name %s already exists."
- IDS_CFG_IDNAME_CCR "Can't create new identity. This may be caused by lack of resources or an unknown failure. The code returned was %d."
- IDS_CFG_IDNAME_CCC "Can't create identity configuration. This may be caused by lack or resources or not having the correct permissions to create the configuration space. The code returned was %d."
- IDS_CFG_LOGF_CS "Can't show log file"
- IDS_CFG_LOGF_CSR "The log file %s does not exist."
- IDS_ACTIONT_PROPERTIES "Show properties for the current selection"
-END
-
-STRINGTABLE
-BEGIN
- IDS_ACTIONT_EXIT "Exit Network Identity Manager"
- IDS_ACTIONT_SET_DEF_ID "Set the currently selected identity as the default identity"
- IDS_ACTIONT_PASSWD_ID "Change the password the currently selected identity"
- IDS_ACTIONT_NEW_CRED "Obtain new credentials"
- IDS_ACTIONT_RENEW_CRED "Renew or re-obtain credentials for the currently selected identity"
- IDS_ACTIONT_DESTROY_CRED "Destroy the selected credentials or identities"
- IDS_ACTIONT_VIEW_REFRESH
- "Re-obtain information about credentials and refresh the credentials display"
- IDS_ACTIONT_OPT_IDENTS "Change options for identities"
- IDS_ACTIONT_OPT_KHIM "Change general application settings for Network Identity Manager"
- IDS_ACTIONT_OPT_NOTIF "Change notification options"
- IDS_ACTIONT_OPT_PLUGINS "Change options for plug-ins and modules"
- IDS_ACTIONT_OPT_APPEAR "Change appearance and display settings"
- IDS_ACTIONT_HELP_CTX "Display user documentation"
- IDS_ACTIONT_IMPORT "Import credentials from external sources such as the Windows LSA"
- IDS_NC_FAILED_TITLE_I "Failed to get credentials for %s"
- IDS_NC_PWD_FAILED_TITLE_I "Failed to change password for %s"
-END
-
-STRINGTABLE
-BEGIN
- IDS_NC_REN_FAILED_TITLE_I "Failed to renew credentials 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 "Destroy all identities"
- IDS_ACTION_RENEW_ALL "Renew all identities"
- IDS_IDACTION_RENEW "Renew %s"
- IDS_IDACTION_DESTROY "Destroy %s"
- IDS_CTX_DESTROY_ID "Destroying identity %1!s!"
- IDS_NCN_IDENT_INVALID "Identity %s is invalid."
- IDS_NCN_IDENT_CHECKING "Checking identity %s ..."
- IDS_NCN_IDENT_UNKNOWN "Validity of identity %s couldn't be determined."
- IDS_REMOTE_FAIL "The instance of Network Identity Manager that is already running is not responding to the remote request properly. Please check if you are running the latest version of Network Identity Manager software included with MIT Kerberos for Windows."
- IDS_REMOTE_FAIL_TITLE "Failed to communicate with Network Identity Manager"
- IDS_IDACTION_NEW "Obtain new credentials for %s"
- IDS_IDACTIONT_NEW "New credentials for %s"
-END
-
-STRINGTABLE
-BEGIN
- IDS_IDACTIONT_RENEW "Renew credentials for %s"
- IDS_IDACTIONT_DESTROY "Destroy credentials for %s"
- IDS_ALERTTYPE_PLUGIN "Failed to load plug-in"
- IDS_ALERTTYPE_EXPIRE "Credential expiration warning"
- IDS_ALERTTYPE_RENEWFAIL "Failed to renew credentials"
- IDS_ALERTTYPE_ACQUIREFAIL "Failed to acquire credentials"
- IDS_ALERTTYPE_CHPW "Failed to change password"
- IDS_ACTION_LAYOUT_MINI "&Advanced"
- IDS_IDEXPDISP_NOCRED "(This identity has no credentials)"
- IDS_IDEXPDISP_1CRED "(This identity has 1 credential)"
- IDS_IDEXPDISP_NCRED "(This identity has %d credentials)"
- IDS_CW_DEFAULTTF "(Default, %s)"
- IDS_CW_TYPEF "(%s)"
- IDS_CW_EXPIREF "Expires in %s"
- IDS_CW_EXPIRED "(Expired)"
- IDS_IDACTIONT_SETDEF "Set %s as default identity"
-END
-
-STRINGTABLE
-BEGIN
- IDS_IDACTION_SETDEF "%s"
- IDS_ACTION_VIEW_ALL_IDS "All identities"
-END
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
-
-
-
-
-
diff --git a/src/windows/identity/ui/main.c b/src/windows/identity/ui/main.c
deleted file mode 100644
index d1d3ecdca..000000000
--- a/src/windows/identity/ui/main.c
+++ /dev/null
@@ -1,1075 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * Copyright (2) 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<shlwapi.h>
-#include<khmapp.h>
-#include<netidmgr_intver.h>
-
-/* used for the command-line help dialog */
-#include<richedit.h>
-
-#if DEBUG
-#include<assert.h>
-
-#if defined(KH_BUILD_PRIVATE) || defined(KH_BUILD_SPECIAL)
-/* needed for writing out leaked allocation and handle report */
-#include<stdio.h>
-#endif
-
-#endif
-
-HINSTANCE khm_hInstance;
-const wchar_t * khm_facility = L"NetIDMgr";
-int khm_nCmdShow;
-khm_ui_4 khm_commctl_version = 0;
-
-khm_startup_options khm_startup;
-
-const khm_version app_version = {KH_VERSION_LIST};
-
-HRESULT hr_coinitialize = S_OK;
-
-#if defined(DEBUG) && (defined(KH_BUILD_PRIVATE) || defined(KH_BUILD_SPECIAL))
-
-KHMEXP void KHMAPI khcint_dump_handles(FILE * f);
-KHMEXP void KHMAPI perf_dump(FILE * f);
-KHMEXP void KHMAPI kmqint_dump(FILE * f);
-
-#endif
-
-void khm_init_gui(void) {
-
- hr_coinitialize = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
-
- khui_init_actions();
- khui_init_rescache();
- khui_init_menu();
- khui_init_toolbar();
- khm_init_notifier();
- khm_init_config();
- khm_init_debug();
- khm_init_taskbar_funcs();
-}
-
-void khm_exit_gui(void) {
- khm_exit_taskbar_funcs();
- khm_exit_debug();
- khm_exit_config();
- khm_exit_notifier();
- khui_exit_toolbar();
- khui_exit_menu();
- khui_exit_rescache();
- khui_exit_actions();
-
- if (hr_coinitialize == S_OK ||
- hr_coinitialize == S_FALSE) {
- CoUninitialize();
- }
-}
-
-/* This is passed into EnumResourceLanguages(). This returns the
- language ID of the first resource of the type and name that's
- passed into it. For the resources types we care about, we only
- expect there to be one resource for a given name. At the moment we
- don't support resource modules that contain resources for multiple
- languages. */
-BOOL CALLBACK
-khm_enum_res_lang_proc_first(HANDLE hModule,
- LPCTSTR lpszType,
- LPCTSTR lpszName,
- WORD wIDLanguage,
- LONG_PTR lParam)
-{
- WORD * plangid = (WORD *) lParam;
-
- *plangid = wIDLanguage;
-
- return FALSE;
-}
-
-#define KHM_RTF_RESOURCE L"KHMRTFRESOURCE"
-
-INT_PTR CALLBACK
-khm_cmdline_dlg_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- WORD langID = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
- HRSRC h_resinfo = NULL;
- HGLOBAL h_resource = NULL;
- LPVOID h_resmem = NULL;
- SETTEXTEX ste;
-
- SetDlgItemText(hwnd, IDC_PRODUCT,
- TEXT(KH_VERSTR_PRODUCT_1033));
-#ifdef OVERRIDE_COPYRIGHT
- SetDlgItemText(hwnd, IDC_COPYRIGHT,
- TEXT(KH_VERSTR_COPYRIGHT_1033));
-#endif
-
- EnumResourceLanguages(khm_hInstance,
- KHM_RTF_RESOURCE,
- MAKEINTRESOURCE(IDR_CMDLINERTF),
- khm_enum_res_lang_proc_first,
- (LONG_PTR) &langID);
-
- h_resinfo = FindResourceEx(khm_hInstance,
- KHM_RTF_RESOURCE,
- MAKEINTRESOURCE(IDR_CMDLINERTF),
- langID);
- if (h_resinfo == NULL)
- goto init_failed;
-
- h_resource = LoadResource(khm_hInstance, h_resinfo);
- if (h_resinfo == NULL)
- goto init_failed;
-
- h_resmem = LockResource(h_resource);
- if (h_resmem == NULL)
- goto init_failed;
-
- ste.flags = ST_DEFAULT;
- ste.codepage = CP_ACP;
-
- SendDlgItemMessage(hwnd, IDC_CONTENT, EM_SETTEXTEX, (WPARAM) &ste, (LPARAM) h_resmem);
- init_failed:
- /* none of the above handles need to be freed. */
-
- return TRUE;
- }
- break;
-
- case WM_COMMAND:
-
- if (wParam == MAKEWPARAM(IDOK, BN_CLICKED)) {
- EndDialog(hwnd, KHM_ERROR_EXIT);
- }
-
- return TRUE;
-
- case WM_CLOSE:
-
- EndDialog(hwnd, KHM_ERROR_EXIT);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-void khm_show_commandline_help(void) {
- HMODULE hm_richedit;
-
- hm_richedit = LoadLibrary(L"riched20.dll");
- if (hm_richedit == NULL)
- return;
-
- DialogBox(khm_hInstance, MAKEINTRESOURCE(IDD_CMDLINE),
- NULL, khm_cmdline_dlg_proc);
-
- FreeLibrary(hm_richedit);
-}
-
-void khm_parse_commandline(void) {
- LPWSTR wcmdline;
- LPWSTR * wargs;
- int wargc;
- int i;
-
- ZeroMemory(&khm_startup, sizeof(khm_startup));
-
- wcmdline = GetCommandLine();
- wargs = CommandLineToArgvW(wcmdline, &wargc);
-
- for (i=1; i<wargc; i++) {
- if (!wcscmp(wargs[i], L"-i") ||
- !wcscmp(wargs[i], L"--kinit") ||
- !wcscmp(wargs[i], L"-kinit")) {
- khm_startup.init = TRUE;
- khm_startup.exit = TRUE;
- khm_startup.no_main_window = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"-m") ||
- !wcscmp(wargs[i], L"--import") ||
- !wcscmp(wargs[i], L"-import")) {
- khm_startup.import = TRUE;
- khm_startup.exit = TRUE;
- khm_startup.no_main_window = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"-r") ||
- !wcscmp(wargs[i], L"--renew") ||
- !wcscmp(wargs[i], L"-renew")) {
- khm_startup.renew = TRUE;
- khm_startup.exit = TRUE;
- khm_startup.no_main_window = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"-d") ||
- !wcscmp(wargs[i], L"--destroy") ||
- !wcscmp(wargs[i], L"-destroy")) {
- khm_startup.destroy = TRUE;
- khm_startup.exit = TRUE;
- khm_startup.no_main_window = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"-a") ||
- !wcscmp(wargs[i], L"--autoinit") ||
- !wcscmp(wargs[i], L"-autoinit")) {
- khm_startup.autoinit = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"-x") ||
- !wcscmp(wargs[i], L"--exit") ||
- !wcscmp(wargs[i], L"-exit")) {
- khm_startup.exit = TRUE;
- khm_startup.remote_exit = TRUE;
- khm_startup.no_main_window = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"--minimized")) {
- khm_startup.no_main_window = TRUE;
- khm_startup.display |= SOPTS_DISPLAY_NODEF;
- }
- else if (!wcscmp(wargs[i], L"--show")) {
- if (khm_startup.display & SOPTS_DISPLAY_HIDE) {
- khm_show_commandline_help();
- khm_startup.error_exit = TRUE;
- break;
- }
-
- khm_startup.display |= (SOPTS_DISPLAY_SHOW | SOPTS_DISPLAY_NODEF);
- }
- else if (!wcscmp(wargs[i], L"--hide")) {
- if (khm_startup.display & SOPTS_DISPLAY_SHOW) {
- khm_show_commandline_help();
- khm_startup.error_exit = TRUE;
- break;
- }
-
- khm_startup.display |= (SOPTS_DISPLAY_HIDE | SOPTS_DISPLAY_NODEF);
- khm_startup.no_main_window = TRUE;
- }
- else {
- khm_show_commandline_help();
-
- khm_startup.error_exit = TRUE;
- break;
- }
- }
-
- /* special: always enable renew when other options aren't specified */
- if (!khm_startup.exit &&
- !khm_startup.destroy &&
- !khm_startup.init &&
- !khm_startup.remote_exit &&
- !khm_startup.display)
- khm_startup.renew = TRUE;
-}
-
-void khm_register_window_classes(void) {
- INITCOMMONCONTROLSEX ics;
-
- ZeroMemory(&ics, sizeof(ics));
- ics.dwSize = sizeof(ics);
- ics.dwICC =
- ICC_COOL_CLASSES |
- ICC_BAR_CLASSES |
- ICC_DATE_CLASSES |
- ICC_HOTKEY_CLASS |
- ICC_LISTVIEW_CLASSES |
- ICC_TAB_CLASSES |
- ICC_INTERNET_CLASSES |
-#if (_WIN32_WINNT >= 0x501)
- ((IS_COMMCTL6())?
- ICC_LINK_CLASS |
- ICC_STANDARD_CLASSES :
- 0) |
-#endif
- 0;
-
- InitCommonControlsEx(&ics);
-
- khm_register_main_wnd_class();
- khm_register_credwnd_class();
- khm_register_htwnd_class();
- khm_register_passwnd_class();
- khm_register_newcredwnd_class();
- khm_register_propertywnd_class();
-}
-
-void khm_unregister_window_classes(void) {
- khm_unregister_main_wnd_class();
- khm_unregister_credwnd_class();
- khm_unregister_htwnd_class();
- khm_unregister_passwnd_class();
- khm_unregister_newcredwnd_class();
- khm_unregister_propertywnd_class();
-}
-
-
-/* we support up to 16 simutaneous dialogs. In reality, more than two
- is pretty unlikely. Property sheets are special and are handled
- separately. */
-#define MAX_UI_DIALOGS 16
-
-typedef struct tag_khui_dialog {
- HWND hwnd;
- HWND hwnd_next;
- BOOL active;
-} khui_dialog;
-
-static khui_dialog khui_dialogs[MAX_UI_DIALOGS];
-static int n_khui_dialogs = 0;
-static HWND khui_modal_dialog = NULL;
-static BOOL khui_main_window_active;
-
-/* should only be called from the UI thread */
-void khm_add_dialog(HWND dlg) {
- if(n_khui_dialogs < MAX_UI_DIALOGS - 1) {
- khui_dialogs[n_khui_dialogs].hwnd = dlg;
- khui_dialogs[n_khui_dialogs].hwnd_next = NULL;
- khui_dialogs[n_khui_dialogs].active = TRUE;
- n_khui_dialogs++;
- } else {
-#if DEBUG
- assert(FALSE);
-#endif
- }
-}
-
-/* should only be called from the UI thread */
-void khm_enter_modal(HWND hwnd) {
- int i;
-
- if (khui_modal_dialog) {
-
- /* we are already in a modal loop. */
-
-#ifdef DEBUG
- assert(hwnd != khui_modal_dialog);
-#endif
-
- for (i=0; i < n_khui_dialogs; i++) {
- if (khui_dialogs[i].hwnd == khui_modal_dialog) {
- khui_dialogs[i].active = TRUE;
- EnableWindow(khui_modal_dialog, FALSE);
- break;
- }
- }
-
-#ifdef DEBUG
- assert(i < n_khui_dialogs);
-#endif
-
- for (i=0; i < n_khui_dialogs; i++) {
- if (khui_dialogs[i].hwnd == hwnd) {
- khui_dialogs[i].hwnd_next = khui_modal_dialog;
- break;
- }
- }
-
-#ifdef DEBUG
- assert(i < n_khui_dialogs);
-#endif
-
- khui_modal_dialog = hwnd;
-
- } else {
-
- /* we are entering a modal loop. preserve the active state of
- the overlapped dialogs and proceed with the modal
- dialog. */
-
- for (i=0; i < n_khui_dialogs; i++) {
- if(khui_dialogs[i].hwnd != hwnd) {
- khui_dialogs[i].active = IsWindowEnabled(khui_dialogs[i].hwnd);
- EnableWindow(khui_dialogs[i].hwnd, FALSE);
- }
- }
-
- khui_main_window_active = khm_is_main_window_active();
- EnableWindow(khm_hwnd_main, FALSE);
-
- khui_modal_dialog = hwnd;
-
- SetForegroundWindow(hwnd);
- }
-}
-
-/* should only be called from the UI thread */
-void khm_leave_modal(void) {
- int i;
-
- for (i=0; i < n_khui_dialogs; i++) {
- if (khui_dialogs[i].hwnd == khui_modal_dialog)
- break;
- }
-
-#ifdef DEBUG
- assert(i < n_khui_dialogs);
-#endif
-
- if (i < n_khui_dialogs && khui_dialogs[i].hwnd_next) {
-
- /* we need to proceed to the next one down the modal dialog
- chain. We are not exiting a modal loop. */
-
- khui_modal_dialog = khui_dialogs[i].hwnd_next;
- khui_dialogs[i].hwnd_next = FALSE;
-
- EnableWindow(khui_modal_dialog, TRUE);
-
- } else {
-
- HWND last_dialog = NULL;
-
- /* we are exiting a modal loop. */
-
- for (i=0; i < n_khui_dialogs; i++) {
- if(khui_dialogs[i].hwnd != khui_modal_dialog) {
- EnableWindow(khui_dialogs[i].hwnd, khui_dialogs[i].active);
- last_dialog = khui_dialogs[i].hwnd;
- }
- }
-
- EnableWindow(khm_hwnd_main, TRUE);
-
- khui_modal_dialog = NULL;
-
- if(last_dialog)
- SetActiveWindow(last_dialog);
- else
- SetActiveWindow(khm_hwnd_main);
- }
-}
-
-/* should only be called from the UI thread */
-void khm_del_dialog(HWND dlg) {
- int i;
- for(i=0;i < n_khui_dialogs; i++) {
- if(khui_dialogs[i].hwnd == dlg)
- break;
- }
-
- if(i < n_khui_dialogs)
- n_khui_dialogs--;
- else
- return;
-
- for(;i < n_khui_dialogs; i++) {
- khui_dialogs[i] = khui_dialogs[i+1];
- }
-}
-
-BOOL khm_check_dlg_message(LPMSG pmsg) {
- int i;
- BOOL found = FALSE;
- for(i=0;i<n_khui_dialogs;i++) {
- if(IsDialogMessage(khui_dialogs[i].hwnd, pmsg)) {
- found = TRUE;
- break;
- }
- }
-
- return found;
-}
-
-BOOL khm_is_dialog_active(void) {
- HWND hwnd;
- int i;
-
- hwnd = GetForegroundWindow();
-
- for (i=0; i<n_khui_dialogs; i++) {
- if (khui_dialogs[i].hwnd == hwnd)
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* We support at most 256 property sheets simultaneously. 256
- property sheets should be enough for everybody. */
-#define MAX_UI_PROPSHEETS 256
-
-khui_property_sheet *_ui_propsheets[MAX_UI_PROPSHEETS];
-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
- assert(FALSE);
-#endif
- }
-}
-
-void khm_del_property_sheet(khui_property_sheet * s) {
- int i;
-
- for(i=0;i < _n_ui_propsheets; i++) {
- if(_ui_propsheets[i] == s)
- break;
- }
-
- if(i < _n_ui_propsheets)
- _n_ui_propsheets--;
- else
- return;
-
- for(;i < _n_ui_propsheets; i++) {
- _ui_propsheets[i] = _ui_propsheets[i+1];
- }
-}
-
-BOOL khm_check_ps_message(LPMSG pmsg) {
- int i;
- khui_property_sheet * ps;
- for(i=0;i<_n_ui_propsheets;i++) {
- if(khui_ps_check_message(_ui_propsheets[i], pmsg)) {
- if(_ui_propsheets[i]->status == KHUI_PS_STATUS_DONE) {
- ps = _ui_propsheets[i];
-
- ps->status = KHUI_PS_STATUS_DESTROY;
- kmq_post_message(KMSG_CRED, KMSG_CRED_PP_END, 0, (void *) ps);
-
- return TRUE;
- }
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static HACCEL ha_menu;
-
-WPARAM khm_message_loop_int(khm_boolean * p_exit) {
- int r;
- MSG msg;
-
- while((r = GetMessage(&msg, NULL, 0,0)) &&
- (p_exit == NULL || *p_exit)) {
- if(r == -1)
- break;
- if(!khm_check_dlg_message(&msg) &&
- !khm_check_ps_message(&msg) &&
- !TranslateAccelerator(khm_hwnd_main, ha_menu, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- return msg.wParam;
-}
-
-WPARAM khm_message_loop(void) {
- WPARAM w;
- ha_menu = khui_create_global_accel_table();
- w = khm_message_loop_int(NULL);
- DestroyAcceleratorTable(ha_menu);
- return w;
-}
-
-/* Handles all context closures which have a signalled error state.
- If the context is a top level context, then the errors are
- displayed. */
-void KHMAPI
-khm_err_ctx_completion_handler(enum kherr_ctx_event evt,
- kherr_context * c) {
- kherr_event * e;
- khui_alert * a;
-
- /* we only handle top level contexts here. For others, we allow
- the child contexts to fold upward silently. */
- if (c->parent || !kherr_is_error_i(c))
- return;
-
- for(e = kherr_get_first_event(c);
- e;
- e = kherr_get_next_event(e)) {
-
- if (e->severity != KHERR_ERROR && e->severity != KHERR_WARNING)
- continue;
-
- kherr_evaluate_event(e);
-
- /* we only report errors if there is enough information to
- present a message. */
- if (e->short_desc && e->long_desc) {
-
- khui_alert_create_empty(&a);
-
- khui_alert_set_severity(a, e->severity);
- khui_alert_set_title(a, e->short_desc);
- khui_alert_set_message(a, e->long_desc);
- if (e->suggestion)
- khui_alert_set_suggestion(a, e->suggestion);
-
- khui_alert_queue(a);
-
- khui_alert_release(a);
- }
- }
-}
-
-static wchar_t helpfile[MAX_PATH] = L"";
-
-HWND khm_html_help(HWND hwnd, wchar_t * suffix,
- UINT command, DWORD_PTR data) {
-
- wchar_t gpath[MAX_PATH + MAX_PATH];
-
- if (!*helpfile) {
- DWORD dw;
- wchar_t ppath[MAX_PATH];
-
- dw = GetModuleFileName(NULL, ppath, ARRAYLENGTH(ppath));
-
- if (dw == 0) {
- StringCbCopy(helpfile, sizeof(helpfile), NIDM_HELPFILE);
- } else {
- PathRemoveFileSpec(ppath);
- PathAppend(ppath, NIDM_HELPFILE);
- StringCbCopy(helpfile, sizeof(helpfile), ppath);
- }
- }
-
- StringCbCopy(gpath, sizeof(gpath), helpfile);
-
- if (suffix)
- StringCbCat(gpath, sizeof(gpath), suffix);
-
- return HtmlHelp(hwnd, gpath, command, data);
-}
-
-void khm_load_default_modules(void) {
- kmm_load_default_modules();
-}
-
-int khm_compare_version(const khm_version * v1, const khm_version * v2) {
-
- if (v1->major != v2->major)
- return ((int)v1->major) - ((int)v2->major);
-
- if (v1->minor != v2->minor)
- return ((int)v1->minor) - ((int)v2->minor);
-
- if (v1->patch != v2->patch)
- return ((int)v1->patch) - ((int)v2->patch);
-
- return ((int)v1->aux - ((int)v2->aux));
-}
-
-int WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
-{
- int rv = 0;
- HANDLE h_appmutex;
- BOOL slave = FALSE;
- int mutex_retries = 5;
-
- khm_hInstance = hInstance;
- khm_nCmdShow = nCmdShow;
-
- khm_parse_commandline();
-
- if (khm_startup.error_exit)
- return 0;
-
- _retry_mutex:
-
- if (--mutex_retries < 0)
- return 2;
-
- h_appmutex = CreateMutex(NULL, FALSE, L"Local\\NetIDMgr_GlobalAppMutex");
- if (h_appmutex == NULL)
- return 5;
- if (GetLastError() == ERROR_ALREADY_EXISTS)
- slave = TRUE;
-
- khc_load_schema(NULL, schema_uiconfig);
-
- _start_app:
-
- if(!slave) {
-
- PDESCTHREAD(L"UI", L"App");
-
- /* set this so that we don't accidently invoke an API that
- inadvertently puts up the new creds dialog at an
- inopportune moment, like, say, during the new creds dialog
- is open. This only affects this process, and any child
- processes started by plugins. */
- SetEnvironmentVariable(L"KERBEROSLOGIN_NEVER_PROMPT", L"1");
-
- khm_version_init();
-
- khm_commctl_version = khm_get_commctl_version(NULL);
-
- /* we only open a main window if this is the only instance
- of the application that is running. */
- kmq_init();
- khm_init_gui();
- kmm_init();
-
- kmq_set_completion_handler(KMSG_CRED, kmsg_cred_completion);
-
- kherr_add_ctx_handler(khm_err_ctx_completion_handler,
- KHERR_CTX_END,
- 0);
-
- /* load the standard plugins */
- khm_load_default_modules();
-
- khm_register_window_classes();
-
- khm_init_request_daemon();
-
- khm_create_main_window();
-
- if (!khm_startup.no_main_window &&
- nCmdShow != SW_SHOWMINNOACTIVE &&
- nCmdShow != SW_MINIMIZE &&
- nCmdShow != SW_SHOWMINIMIZED) {
-
- khm_show_main_window();
- }
-
- khm_refresh_config();
-
- rv = (int) khm_message_loop();
-
- kmq_set_completion_handler(KMSG_CRED, NULL);
-
- khm_exit_request_daemon();
-
- kmm_exit();
- khm_exit_gui();
- khm_unregister_window_classes();
- kmq_exit();
-
- CloseHandle(h_appmutex);
- } else {
-
- /* There is an instance of NetIDMgr already running. */
-
- HWND hwnd = NULL;
- int retries = 5;
- HANDLE hmap;
- wchar_t mapname[256];
- DWORD tid;
- void * xfer;
- khm_query_app_version query_app_version;
- khm_version v;
- BOOL use_cmd_v1 = FALSE;
- khm_size cb = 0;
-
- CloseHandle(h_appmutex);
-
- while (hwnd == NULL && retries) {
- hwnd = FindWindowEx(NULL, NULL, KHUI_MAIN_WINDOW_CLASS, NULL);
-
- if (hwnd)
- break;
-
- retries--;
-
- /* if the app was just starting, we might have to wait
- till the main window is created. */
-
- Sleep(1000);
- }
-
- if (!hwnd) {
-
- /* if the app was just exiting, we might see the mutex but
- not the window. We go back and check if the mutex is
- still there. */
-
- goto _retry_mutex;
- }
-
- /* first check if the remote instance supports a version
- query */
-
- StringCbPrintf(mapname, sizeof(mapname),
- QUERY_APP_VER_MAP_FMT,
- (tid = GetCurrentThreadId()));
-
- hmap = CreateFileMapping(INVALID_HANDLE_VALUE,
- NULL,
- PAGE_READWRITE,
- 0,
- 4096,
- mapname);
-
- if (hmap == NULL)
- return 3;
-
- xfer = MapViewOfFile(hmap, FILE_MAP_WRITE, 0, 0,
- sizeof(query_app_version));
-
- ZeroMemory(&query_app_version, sizeof(query_app_version));
-
- if (xfer) {
- query_app_version.magic = KHM_QUERY_APP_VER_MAGIC;
- query_app_version.code = KHM_ERROR_NOT_IMPLEMENTED;
- query_app_version.ver_caller = app_version;
-
- query_app_version.request_swap = TRUE;
-
- memcpy(xfer, &query_app_version, sizeof(query_app_version));
-
- SendMessage(hwnd, WM_KHUI_QUERY_APP_VERSION,
- 0, (LPARAM) tid);
-
- memcpy(&query_app_version, xfer, sizeof(query_app_version));
-
- UnmapViewOfFile(xfer);
- xfer = NULL;
- }
-
- CloseHandle(hmap);
- hmap = NULL;
-
- if (query_app_version.magic != KHM_QUERY_APP_VER_MAGIC ||
- query_app_version.code != KHM_ERROR_SUCCESS) {
-
- /* We managed to communicate with the remote instance, but
- it didn't send us useful information. The remote
- instance is not running an actual NetIDMgr instance.
- However, it owns a top level window that was registered
- with our classname. This instance won't function
- properly if we let it proceed.
- */
-
- wchar_t error_msg[1024];
- wchar_t error_title[256];
-
- LoadString(khm_hInstance, IDS_REMOTE_FAIL_TITLE,
- error_title, ARRAYLENGTH(error_title));
- LoadString(khm_hInstance, IDS_REMOTE_FAIL,
- error_msg, ARRAYLENGTH(error_msg));
-
- MessageBox(NULL, error_msg, error_title,
- MB_OK);
-
- goto done_with_remote;
- }
-
- if (query_app_version.code == KHM_ERROR_SUCCESS &&
- query_app_version.request_swap) {
- /* the request for swap was granted. We can now
- initialize our instance as the master instance. */
-
- slave = FALSE;
- goto _start_app;
- }
-
- /* Now we can work on sending the command-line to the remote
- instance. However we need to figure out which version of
- the startup structure it supports. */
- v.major = 1;
- v.minor = 2;
- v.patch = 0;
- v.aux = 0;
-
- if (khm_compare_version(&query_app_version.ver_remote, &app_version) == 0 ||
- khm_compare_version(&query_app_version.ver_remote, &v) > 0)
- use_cmd_v1 = FALSE;
- else
- use_cmd_v1 = TRUE;
-
- StringCbPrintf(mapname, sizeof(mapname),
- COMMANDLINE_MAP_FMT,
- (tid = GetCurrentThreadId()));
-
- cb = max(sizeof(khm_startup_options_v1),
- sizeof(khm_startup_options_v2));
-
- cb = UBOUNDSS(cb, 4096, 4096);
-
-#ifdef DEBUG
- assert(cb >= 4096);
-#endif
-
- hmap = CreateFileMapping(INVALID_HANDLE_VALUE,
- NULL,
- PAGE_READWRITE,
- 0,
- (DWORD) cb,
- mapname);
-
- if (hmap == NULL)
- return 3;
-
- /* make the call */
-
- if (!use_cmd_v1) {
- /* use the v2 structure */
- khm_startup_options_v3 opt;
- khm_startup_options_v3 *xferopt;
-
- ZeroMemory(&opt, sizeof(opt));
-
- opt.v2opt.magic = STARTUP_OPTIONS_MAGIC;
-
- opt.v2opt.init = khm_startup.init;
- opt.v2opt.import = khm_startup.import;
- opt.v2opt.renew = khm_startup.renew;
- opt.v2opt.destroy = khm_startup.destroy;
- opt.v2opt.autoinit = khm_startup.autoinit;
- opt.v2opt.remote_exit = khm_startup.remote_exit;
- opt.remote_display = khm_startup.display;
-
- opt.v2opt.code = KHM_ERROR_NOT_IMPLEMENTED;
-
- /* check if we can use the v3 options structure. This
- should be possible for 1.3.1 and above. */
- v.major = 1; v.minor = 3; v.patch = 1; v.aux = 0;
- if (khm_compare_version(&query_app_version.ver_remote, &app_version) == 0 ||
- khm_compare_version(&query_app_version.ver_remote, &v) >= 0) {
-
- opt.v2opt.cb_size = sizeof(opt);
-
- } else {
-
- opt.v2opt.cb_size = sizeof(opt.v2opt);
-
- }
-
- xfer = MapViewOfFile(hmap,
- FILE_MAP_WRITE,
- 0, 0,
- opt.v2opt.cb_size);
-
- xferopt = (khm_startup_options_v3 *) xfer;
-
- if (xfer) {
- memcpy(xfer, &opt, opt.v2opt.cb_size);
-
- SendMessage(hwnd, WM_KHUI_ASSIGN_COMMANDLINE_V2,
- 0, (LPARAM) tid);
-
- /* If it looks like the request was not processed, and
- we were using a v3 request, fail-over to a v2
- request. */
- if (xferopt->v2opt.code == KHM_ERROR_NOT_IMPLEMENTED &&
- opt.v2opt.cb_size == sizeof(opt)) {
-
- opt.v2opt.cb_size = sizeof(opt.v2opt);
- memcpy(xfer, &opt, opt.v2opt.cb_size);
-
- SendMessage(hwnd, WM_KHUI_ASSIGN_COMMANDLINE_V2,
- 0, (LPARAM) tid);
- }
-
- /* if it still looks like the request was not
- processed, we failover to a v1 call */
- if (xferopt->v2opt.code == KHM_ERROR_NOT_IMPLEMENTED) {
- use_cmd_v1 = TRUE;
- } else {
- memcpy(&opt, xfer, opt.v2opt.cb_size);
- }
-
- UnmapViewOfFile(xfer);
- xfer = NULL;
- }
- }
-
- if (use_cmd_v1) {
- /* use the v1 structure */
-
- khm_startup_options_v1 v1opt;
-
- ZeroMemory(&v1opt, sizeof(v1opt));
-
- v1opt.init = khm_startup.init;
- v1opt.import = khm_startup.import;
- v1opt.renew = khm_startup.renew;
- v1opt.destroy = khm_startup.destroy;
- v1opt.autoinit = khm_startup.autoinit;
-
- xfer = MapViewOfFile(hmap,
- FILE_MAP_WRITE,
- 0, 0,
- sizeof(v1opt));
-
- if (xfer) {
- memcpy(xfer, &v1opt, sizeof(v1opt));
-
- SendMessage(hwnd, WM_KHUI_ASSIGN_COMMANDLINE_V1,
- 0, (LPARAM) tid);
-
- UnmapViewOfFile(xfer);
- xfer = NULL;
- }
- }
-
- done_with_remote:
-
- if (hmap)
- CloseHandle(hmap);
- }
-
-#if defined(DEBUG) && (defined(KH_BUILD_PRIVATE) || defined(KH_BUILD_SPECIAL))
- {
- FILE * f = NULL;
-
-#if _MSC_VER >= 1400 && __STDC_WANT_SECURE_LIB__
- if (fopen_s(&f, "memleak.txt", "w") != 0)
- goto done_with_dump;
-#else
- f = fopen("memleak.txt", "w");
- if (f == NULL)
- goto done_with_dump;
-#endif
-
- perf_dump(f);
- khcint_dump_handles(f);
- kmqint_dump(f);
-
- fclose(f);
-
- done_with_dump:
- ;
- }
-#endif
-
- return rv;
-}
diff --git a/src/windows/identity/ui/mainmenu.c b/src/windows/identity/ui/mainmenu.c
deleted file mode 100644
index d61b8d7cc..000000000
--- a/src/windows/identity/ui/mainmenu.c
+++ /dev/null
@@ -1,1233 +0,0 @@
-/*
- * 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
- * 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<khmapp.h>
-#include<assert.h>
-
-HWND khui_main_menu_toolbar;
-int mm_last_hot_item = -1;
-int mm_next_hot_item = -1;
-BOOL mm_hot_track = FALSE;
-
-#define MAX_ILIST 256
-/* not the same as MENU_SIZE_ICON_* */
-#define ILIST_ICON_X 16
-#define ILIST_ICON_Y 15
-
-khui_ilist * il_icon;
-int il_icon_id[MAX_ILIST];
-
-void khui_init_menu(void) {
- int i;
-
- il_icon = khui_create_ilist(ILIST_ICON_X,
- ILIST_ICON_Y,
- MAX_ILIST, 5, 0);
- for(i=0;i<MAX_ILIST;i++)
- il_icon_id[i] = -1;
-
- khm_refresh_identity_menus();
-}
-
-void khui_exit_menu(void) {
- khui_delete_ilist(il_icon);
-}
-
-int khui_get_icon_index(int id) {
- int i;
- HBITMAP hbm;
-
- for(i=0;i<MAX_ILIST;i++)
- if(il_icon_id[i] == id) {
- return i;
- }
-
- hbm = LoadImage(khm_hInstance,
- MAKEINTRESOURCE(id),
- IMAGE_BITMAP,
- ILIST_ICON_X, ILIST_ICON_Y,
- LR_DEFAULTCOLOR);
- i = khui_ilist_add_masked(il_icon, hbm, KHUI_TOOLBAR_BGCOLOR);
- il_icon_id[i] = id;
- DeleteObject(hbm);
-
- return i;
-}
-
-void khm_get_action_caption(khm_int32 action, wchar_t * buf, khm_size cb_buf) {
- khui_action * act;
-
- StringCbCopy(buf, cb_buf, L"");
-
- khui_action_lock();
- act = khui_find_action(action);
-
- if (act == NULL)
- goto done;
-
- if (act->caption) {
- StringCbCopy(buf, cb_buf, act->caption);
- } else if (act->is_caption) {
- LoadString(khm_hInstance, act->is_caption,
- buf, (int)(cb_buf / sizeof(wchar_t)));
- }
-
- done:
- khui_action_unlock();
-}
-
-void khm_get_action_tooltip(khm_int32 action, wchar_t * buf, khm_size cb_buf) {
- khui_action * act;
-
- StringCbCopy(buf, cb_buf, L"");
-
- khui_action_lock();
- act = khui_find_action(action);
-
- if (act == NULL)
- goto done;
-
- if (act->tooltip) {
- StringCbCopy(buf, cb_buf, act->tooltip);
- } else if (act->is_tooltip) {
- LoadString(khm_hInstance, act->is_tooltip,
- buf, (int) (cb_buf / sizeof(wchar_t)));
- }
-
- done:
- khui_action_unlock();
-}
-
-void add_action_to_menu(HMENU hm, khui_action * act,
- int idx, int flags) {
- MENUITEMINFO mii;
- wchar_t buf[MAX_RES_STRING] = L"";
- wchar_t accel[MAX_RES_STRING] = L"";
-
- assert(!act || act->cmd);
-
- mii.cbSize = sizeof(mii);
- mii.fMask = 0;
-
- if(act == NULL) {
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- } else {
- khui_menu_def * def;
-
- if (act->type == KHUI_ACTIONTYPE_IDENTITY) {
- mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_DATA;
- mii.fType = MFT_OWNERDRAW;
-
- mii.dwTypeData = 0;
- mii.dwItemData = 0;
- } else {
- khm_get_action_caption(act->cmd, buf, sizeof(buf));
-
- if(khui_get_cmd_accel_string(act->cmd, accel,
- ARRAYLENGTH(accel))) {
- StringCbCat(buf, sizeof(buf), L"\t");
- StringCbCat(buf, sizeof(buf), accel);
- }
-
- mii.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID;
- mii.fType = MFT_STRING;
-
- mii.dwTypeData = buf;
- mii.cch = (int) wcslen(buf);
- }
-
- mii.wID = act->cmd;
-
- if(act->state & KHUI_ACTIONSTATE_DISABLED) {
- mii.fMask |= MIIM_STATE;
- mii.fState = MFS_DISABLED;
- } else {
- mii.fState = 0;
- }
-
- if((act->type & KHUI_ACTIONTYPE_TOGGLE) &&
- (act->state & KHUI_ACTIONSTATE_CHECKED)) {
- mii.fMask |= MIIM_STATE;
- mii.fState |= MFS_CHECKED;
- }
-
- if(act->ib_icon) {
- mii.fMask |= MIIM_BITMAP;
- mii.hbmpItem = HBMMENU_CALLBACK;
- }
-
- if (flags & KHUI_ACTIONREF_SUBMENU) {
- def = khui_find_menu(act->cmd);
- if(def) {
- mii.fMask |= MIIM_SUBMENU;
- mii.hSubMenu = mm_create_menu_from_def(def, FALSE);
- }
- }
-
- if(flags & KHUI_ACTIONREF_DEFAULT) {
- mii.fMask |= MIIM_STATE;
- mii.fState |= MFS_DEFAULT;
- }
- }
-
- InsertMenuItem(hm,idx,TRUE,&mii);
-}
-
-static void refresh_menu(HMENU hm, khui_menu_def * def);
-
-static int refresh_menu_item(HMENU hm, khui_action * act,
- int idx, int flags) {
- MENUITEMINFO mii;
- khui_menu_def * def;
-
- mii.cbSize = sizeof(mii);
- mii.fMask = 0;
-
- if (flags & KHUI_ACTIONREF_END) {
- /* we have been asked to assert that the menu doesn't have
- more than idx items */
- mii.fMask = MIIM_FTYPE;
- while (GetMenuItemInfo(hm, idx, TRUE, &mii)) {
- RemoveMenu(hm, idx, MF_BYPOSITION);
- mii.fMask = MIIM_FTYPE;
- }
-
- return 0;
- }
-
- /* Check if the menu item is there. Otherwise we need to add
- it. */
- mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE;
- if (!GetMenuItemInfo(hm, idx, TRUE, &mii) ||
- ((flags & KHUI_ACTIONREF_SEP) && !(mii.fType & MFT_SEPARATOR)) ||
- (!(flags & KHUI_ACTIONREF_SEP) && mii.wID != (WORD) act->cmd)) {
- add_action_to_menu(hm, ((flags & KHUI_ACTIONREF_SEP)? NULL : act),
- idx, flags);
- return 0;
- }
-
- if (flags & KHUI_ACTIONREF_SEP)
- return 0;
-
-#ifdef DEBUG
- assert(act);
-#endif
- if (!act)
- return 0;
-
- if (flags & KHUI_ACTIONREF_DEFAULT) {
- if (!(mii.fState & MFS_DEFAULT)) {
- mii.fMask |= MIIM_STATE;
- mii.fState |= MFS_DEFAULT;
- }
- } else {
- if (mii.fState & MFS_DEFAULT) {
- RemoveMenu(hm, idx, MF_BYPOSITION);
- add_action_to_menu(hm, act, idx, flags);
- return 0;
- }
- }
-
- mii.fMask = 0;
-
- if(act->state & KHUI_ACTIONSTATE_DISABLED) {
- mii.fMask |= MIIM_STATE;
- mii.fState &= ~MFS_ENABLED;
- mii.fState |= MFS_DISABLED;
- } else {
- mii.fMask |= MIIM_STATE;
- mii.fState &= ~MFS_DISABLED;
- mii.fState |= MFS_ENABLED;
- }
-
- if(act->type & KHUI_ACTIONTYPE_TOGGLE) {
- mii.fMask |= MIIM_STATE;
- if (act->state & KHUI_ACTIONSTATE_CHECKED) {
- mii.fState &= ~MFS_UNCHECKED;
- mii.fState |= MFS_CHECKED;
- } else {
- mii.fState &= ~MFS_CHECKED;
- mii.fState |= MFS_UNCHECKED;
- }
- }
-
- SetMenuItemInfo(hm, act->cmd, FALSE, &mii);
-
- def = khui_find_menu(act->cmd);
-
- if(def) {
- MENUITEMINFO mii2;
-
- mii2.cbSize = sizeof(mii2);
- mii2.fMask = MIIM_SUBMENU;
-
- if (GetMenuItemInfo(hm, act->cmd, FALSE, &mii2)) {
- refresh_menu(mii2.hSubMenu, def);
- }
- }
-
- return 0;
-}
-
-
-static void refresh_menu(HMENU hm, khui_menu_def * def) {
- khui_action_ref * act;
- khm_size i, n;
-
- for(i = 0, n = khui_menu_get_size(def); i < n; i++) {
- act = khui_menu_get_action(def, i);
- refresh_menu_item(hm, khui_find_action(act->action), (int) i, act->flags);
- }
-
- refresh_menu_item(hm, NULL, (int) i, KHUI_ACTIONREF_END);
-}
-
-static HMENU mm_create_menu_from_def(khui_menu_def * def, BOOL main) {
- HMENU hm;
- khui_action_ref * act;
- khm_size i, n;
-
- if (main)
- hm = CreateMenu();
- else
- hm = CreatePopupMenu();
-
- for (i = 0, n = khui_menu_get_size(def); i < n; i++) {
- act = khui_menu_get_action(def, i);
- add_action_to_menu(hm, khui_find_action(act->action), (int) i, act->flags);
- }
-
- return hm;
-}
-
-void mm_begin_hot_track(void);
-void mm_end_hot_track(void);
-
-static void mm_show_panel_def(khui_menu_def * def, LONG x, LONG y)
-{
- HMENU hm;
-
- hm = mm_create_menu_from_def(def, FALSE);
-
- mm_hot_track = (mm_last_hot_item >= 0);
-
- if (mm_hot_track)
- mm_begin_hot_track();
-
- TrackPopupMenuEx(hm,
- TPM_LEFTALIGN | TPM_TOPALIGN |
- TPM_VERPOSANIMATION,
- x, y, khm_hwnd_main, NULL);
-
- mm_last_hot_item = -1;
-
- if (mm_hot_track)
- mm_end_hot_track();
-
- mm_hot_track = FALSE;
-
- DestroyMenu(hm);
-}
-
-void khm_menu_show_panel(int id, LONG x, LONG y) {
- khui_menu_def * def;
-
- def = khui_find_menu(id);
- if(!def)
- return;
-
- mm_show_panel_def(def, x, y);
-}
-
-LRESULT khm_menu_activate(int menu_id) {
- khui_menu_def * mmdef;
- int nmm;
-
- mmdef = khui_find_menu(KHUI_MENU_MAIN);
- nmm = (int) khui_action_list_length(mmdef->items);
-
- if(menu_id == MENU_ACTIVATE_DEFAULT) {
- if (mm_last_hot_item != -1)
- menu_id = mm_last_hot_item;
- else
- menu_id = 0;
- } else if(menu_id == MENU_ACTIVATE_LEFT) {
- menu_id = (mm_last_hot_item > 0)?
- mm_last_hot_item - 1:
- ((mm_last_hot_item == 0)? nmm - 1: 0);
- } else if(menu_id == MENU_ACTIVATE_RIGHT) {
- menu_id = (mm_last_hot_item >=0 && mm_last_hot_item < nmm - 1)?
- mm_last_hot_item + 1:
- 0;
- } else if(menu_id == MENU_ACTIVATE_NONE) {
- menu_id = -1;
- }
-
- SendMessage(khui_main_menu_toolbar,
- TB_SETHOTITEM,
- menu_id,
- 0);
-
- khm_menu_track_current();
-
- return TRUE;
-}
-
-LRESULT khm_menu_measure_item(WPARAM wParam, LPARAM lParam) {
- LPMEASUREITEMSTRUCT lpm = (LPMEASUREITEMSTRUCT) lParam;
- khui_action * act;
-
- act = khui_find_action(lpm->itemID);
- if (act && act->type == KHUI_ACTIONTYPE_IDENTITY) {
- khm_measure_identity_menu_item(khm_hwnd_main_cred, lpm, act);
- } else {
- lpm->itemWidth = MENU_SIZE_ICON_X;
- lpm->itemHeight = MENU_SIZE_ICON_Y;
- }
- return TRUE;
-}
-
-LRESULT khm_menu_draw_item(WPARAM wParam, LPARAM lParam) {
- LPDRAWITEMSTRUCT lpd;
- khui_action * act;
-
- lpd = (LPDRAWITEMSTRUCT) lParam;
- act = khui_find_action(lpd->itemID);
-
- if (act && act->type == KHUI_ACTIONTYPE_IDENTITY) {
-
- khm_draw_identity_menu_item(khm_hwnd_main_cred, lpd, act);
-
- } else {
- int resid;
- int iidx;
- UINT style;
-
- resid = 0;
- if((lpd->itemState & ODS_DISABLED) || (lpd->itemState & ODS_GRAYED)) {
- resid = act->ib_icon_dis;
- }
- if(!resid)
- resid = act->ib_icon;
-
- if(!resid) /* nothing to draw */
- return TRUE;
-
-
- iidx = khui_get_icon_index(resid);
- if(iidx == -1)
- return TRUE;
-
-
- style = ILD_TRANSPARENT;
- if(lpd->itemState & ODS_HOTLIGHT || lpd->itemState & ODS_SELECTED) {
- style |= ILD_SELECTED;
- }
-
- khui_ilist_draw(il_icon,
- iidx,
- lpd->hDC,
- lpd->rcItem.left, lpd->rcItem.top, style);
- }
-
- return TRUE;
-}
-
-void khm_track_menu(int menu) {
- TBBUTTON bi;
- RECT r;
- RECT wr;
-
- if (menu != -1)
- mm_last_hot_item = menu;
-
- if (mm_last_hot_item != -1) {
- SendMessage(khui_main_menu_toolbar,
- TB_GETBUTTON,
- mm_last_hot_item,
- (LPARAM) &bi);
-
- SendMessage(khui_main_menu_toolbar,
- TB_GETITEMRECT,
- mm_last_hot_item,
- (LPARAM) &r);
-
- GetWindowRect(khui_main_menu_toolbar, &wr);
-
- khm_menu_show_panel(bi.idCommand, wr.left + r.left, wr.top + r.bottom);
-
- r.left = 0;
-
- if (mm_next_hot_item != -1) {
- mm_last_hot_item = mm_next_hot_item;
- mm_next_hot_item = -1;
-
- PostMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(KHUI_PACTION_MENU,0),
- MAKELPARAM(mm_last_hot_item,1));
- }
- }
-}
-
-void khm_menu_track_current(void) {
- khm_track_menu(-1);
-}
-
-LRESULT khm_menu_handle_select(WPARAM wParam, LPARAM lParam) {
- if((HIWORD(wParam) == 0xffff && lParam == 0) ||
- (HIWORD(wParam) & MF_POPUP)) {
- /* the menu was closed */
- khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, NULL);
- } else {
- khui_action * act;
- int id;
- wchar_t buf[MAX_RES_STRING] = L"";
-
- id = LOWORD(wParam);
- act = khui_find_action(id);
- if(act == NULL || (act->is_tooltip == 0 && act->tooltip == NULL))
- khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, NULL);
- else {
- khm_get_action_tooltip(act->cmd, buf, sizeof(buf));
-
- khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf);
- }
- }
- return 0;
-}
-
-HHOOK mm_hevt_hook = NULL;
-HWND mm_hwnd_menu_panel = NULL;
-
-LRESULT CALLBACK mm_event_filter(int code,
- WPARAM wParam,
- LPARAM lParam) {
- MSG * m;
- RECT r;
- int x,y;
-
- if (code == MSGF_MENU) {
- /* do stuff */
- m = (MSG *) lParam;
- GetWindowRect(khui_main_menu_toolbar, &r);
-
- if (m->hwnd != khm_hwnd_main)
- mm_hwnd_menu_panel = m->hwnd;
-
- switch(m->message) {
- case WM_MOUSEMOVE:
-
- x = GET_X_LPARAM(m->lParam);
- y = GET_Y_LPARAM(m->lParam);
- x -= r.left;
- y -= r.top;
-
- SendMessage(khui_main_menu_toolbar,
- m->message,
- m->wParam,
- MAKELPARAM(x,y));
- break;
- }
- }
-
- return CallNextHookEx(mm_hevt_hook, code, wParam, lParam);
-}
-
-
-void mm_begin_hot_track(void) {
-
- if (mm_hevt_hook)
- UnhookWindowsHookEx(mm_hevt_hook);
-
- mm_hevt_hook = SetWindowsHookEx(WH_MSGFILTER,
- mm_event_filter,
- NULL,
- GetCurrentThreadId());
-}
-
-void mm_end_hot_track(void) {
- if (mm_hevt_hook)
- UnhookWindowsHookEx(mm_hevt_hook);
-
- mm_hevt_hook = NULL;
- mm_hwnd_menu_panel = NULL;
-}
-
-void mm_cancel_menu(void) {
- if (mm_hwnd_menu_panel)
- SendMessage(mm_hwnd_menu_panel, WM_CANCELMODE, 0, 0);
-}
-
-LRESULT khm_menu_notify_main(LPNMHDR notice) {
- LPNMTOOLBAR nmt;
- LRESULT ret = FALSE;
- RECT r;
- khui_menu_def * mmdef;
- khui_action_ref * mm;
- int nmm;
-
- mmdef = khui_find_menu(KHUI_MENU_MAIN);
- mm = mmdef->items;
- nmm = (int) khui_action_list_length(mm);
-
- GetWindowRect(khui_main_menu_toolbar, &r);
-
- nmt = (LPNMTOOLBAR) notice;
- switch(notice->code) {
- case TBN_DROPDOWN:
- khm_track_menu(-1);
- /*
- khm_menu_show_panel(nmt->iItem,
- r.left + nmt->rcButton.left,
- r.top + nmt->rcButton.bottom);
- */
- ret = TBDDRET_DEFAULT;
- break;
-
- case TBN_HOTITEMCHANGE:
- {
- LPNMTBHOTITEM nmhi;
- int new_item = -1;
-
- nmhi = (LPNMTBHOTITEM) notice;
-
- if(nmhi->dwFlags & HICF_LEAVING)
- new_item = -1;
- else {
- int i;
- for(i=0; i < nmm; i++) {
- if(mm[i].action == nmhi->idNew) {
- new_item = i;
- break;
- }
- }
- }
-
- if (mm_hot_track &&
- new_item != mm_last_hot_item &&
- new_item != -1 &&
- mm_last_hot_item != -1) {
-
- EndMenu();
- mm_next_hot_item = new_item;
-
- }
-
- ret = 0;
-
- if (!mm_hot_track || new_item != -1)
- mm_last_hot_item = new_item;
-
- } break;
-
- default:
- /* hmm. what to do */
- ret = FALSE;
- }
- return ret;
-}
-
-struct identity_action_map {
- khm_handle identity;
- khm_int32 renew_cmd;
- khm_int32 destroy_cmd;
- khm_int32 new_cmd;
- khm_int32 setdef_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 caption[KHUI_MAXCCH_SHORT_DESC];
- wchar_t tooltip[KHUI_MAXCCH_SHORT_DESC];
- wchar_t actionname[KHUI_MAXCCH_NAME];
- 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);
-
-#define GETFORMAT(I) do { fmt[0] = L'\0'; LoadString(khm_hInstance, I, fmt, ARRAYLENGTH(fmt)); } while(0)
-#define EXPFORMAT(d,s) do { StringCbPrintf(d, sizeof(d), fmt, s); } while(0)
- /* renew */
-
- GETFORMAT(IDS_IDACTIONT_RENEW);
- EXPFORMAT(tooltip, idname);
-
- GETFORMAT(IDS_IDACTION_RENEW);
- EXPFORMAT(caption, idname);
-
- StringCbPrintf(actionname, sizeof(actionname), L"R:%s", idname);
-
- actmap->renew_cmd =
- khui_action_create(actionname, caption, tooltip, NULL,
- KHUI_ACTIONTYPE_TRIGGER, NULL);
-
- /* destroy */
-
- GETFORMAT(IDS_IDACTIONT_DESTROY);
- EXPFORMAT(tooltip, idname);
-
- GETFORMAT(IDS_IDACTION_DESTROY);
- EXPFORMAT(caption, idname);
-
- StringCbPrintf(actionname, sizeof(actionname), L"D:%s", idname);
-
- actmap->destroy_cmd =
- khui_action_create(actionname, caption, tooltip, NULL,
- KHUI_ACTIONTYPE_TRIGGER, NULL);
-
- /* new */
-
- GETFORMAT(IDS_IDACTIONT_NEW);
- EXPFORMAT(tooltip, idname);
-
- GETFORMAT(IDS_IDACTION_NEW);
- EXPFORMAT(caption, idname);
-
- StringCbPrintf(actionname, sizeof(actionname), L"N:%s", idname);
-
- actmap->new_cmd =
- khui_action_create(actionname, caption, tooltip, NULL,
- KHUI_ACTIONTYPE_TRIGGER, NULL);
-
- /* set default */
- GETFORMAT(IDS_IDACTIONT_SETDEF);
- EXPFORMAT(tooltip, idname);
-
- GETFORMAT(IDS_IDACTION_SETDEF);
- EXPFORMAT(caption, idname);
-
- StringCbPrintf(actionname, sizeof(actionname), L"E:%s", idname);
-
- actmap->setdef_cmd =
- khui_action_create(actionname, caption, tooltip, ident,
- KHUI_ACTIONTYPE_IDENTITY, NULL);
-
- actmap->refreshcycle = idcmd_refreshcycle;
-
-#undef GETFORMAT
-#undef EXPFORMAT
-
- 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);
- khui_action_delete(id_action_map[i].new_cmd);
- khui_action_delete(id_action_map[i].setdef_cmd);
-
- id_action_map[i].renew_cmd = 0;
- id_action_map[i].destroy_cmd = 0;
- id_action_map[i].new_cmd = 0;
- id_action_map[i].setdef_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);
- }
-}
-
-khm_int32
-khm_get_identity_renew_action(khm_handle ident) {
- struct identity_action_map * map;
-
- map = get_identity_cmd_map(ident);
-
- if (map)
- return map->renew_cmd;
- else
- return 0;
-}
-
-khm_int32
-khm_get_identity_destroy_action(khm_handle ident) {
- struct identity_action_map * map;
-
- map = get_identity_cmd_map(ident);
-
- if (map)
- return map->destroy_cmd;
- else
- return 0;
-}
-
-khm_int32
-khm_get_identity_setdef_action(khm_handle ident) {
- struct identity_action_map * map;
-
- map = get_identity_cmd_map(ident);
-
- if (map)
- return map->setdef_cmd;
- else
- return 0;
-}
-
-khm_int32
-khm_get_identity_new_creds_action(khm_handle ident) {
- struct identity_action_map * map;
-
- map = get_identity_cmd_map(ident);
-
- if (map)
- return map->new_cmd;
- else
- return 0;
-}
-
-void
-khm_refresh_identity_menus(void) {
- khui_menu_def * renew_def = NULL;
- khui_menu_def * dest_def = NULL;
- khui_menu_def * setdef_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;
- khm_handle csp_cw = NULL;
- khm_int32 idflags;
- khm_int32 def_sticky = 0;
- khm_int32 all_identities = 0;
- khm_boolean sticky_done = FALSE;
- khm_boolean added_dest = FALSE;
- khm_boolean added_setdef = FALSE;
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw))) {
- khc_read_int32(csp_cw, L"DefaultSticky", &def_sticky);
- khc_read_int32(csp_cw, L"ViewAllIdents", &all_identities);
- khc_close_space(csp_cw);
- csp_cw = NULL;
- }
-
- kcdb_identity_refresh_all();
-
- khui_action_lock();
-
- idcmd_refreshcycle++;
-
- do {
- if (idlist)
- PFREE(idlist);
- idlist = NULL;
- cb = 0;
-
- rv = kcdb_identity_enum(KCDB_IDENT_FLAG_ACTIVE,
- 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_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);
- setdef_def = khui_find_menu(KHUI_MENU_SETDEF);
-#ifdef DEBUG
- assert(renew_def);
- assert(dest_def);
- assert(setdef_def);
-#endif
-
- t = khui_menu_get_size(renew_def);
- while(t) {
- khui_menu_remove_action(renew_def, 0);
- t--;
- }
-
- t = khui_menu_get_size(dest_def);
- while(t) {
- khui_menu_remove_action(dest_def, 0);
- t--;
- }
-
- t = khui_menu_get_size(setdef_def);
- while(t) {
- khui_menu_remove_action(setdef_def, 0);
- t--;
- }
-
- if (idlist != NULL && n_idents > 1) {
- khui_menu_insert_action(renew_def, 0, KHUI_ACTION_RENEW_ALL, 0);
- khui_menu_insert_action(renew_def, 1, KHUI_MENU_SEP, 0);
-
- khui_menu_insert_action(dest_def, 0, KHUI_ACTION_DESTROY_ALL, 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;
- }
-
- idflags = 0;
- kcdb_identity_get_flags(identity, &idflags);
-
- if (!(idflags & KCDB_IDENT_FLAG_STICKY) && def_sticky) {
- kcdb_identity_set_flags(identity,
- KCDB_IDENT_FLAG_STICKY,
- KCDB_IDENT_FLAG_STICKY);
- idflags |= KCDB_IDENT_FLAG_STICKY;
- sticky_done = TRUE;
- }
-
- if (!(idflags & KCDB_IDENT_FLAG_EMPTY)) {
- khui_menu_insert_action(renew_def, 1000,
- khm_get_identity_renew_action(identity),
- 0);
-
- khui_menu_insert_action(dest_def, 1000,
- khm_get_identity_destroy_action(identity),
- 0);
- added_dest = TRUE;
- }
-
- if (all_identities ||
- !(idflags & KCDB_IDENT_FLAG_EMPTY) ||
- (idflags & KCDB_IDENT_FLAG_STICKY)) {
-
- khui_menu_insert_action(setdef_def, 1000,
- khm_get_identity_setdef_action(identity),
- 0);
- added_setdef = TRUE;
- }
-
- kcdb_identity_release(identity);
- }
-
- if (idlist) {
- PFREE(idlist);
- idlist = NULL;
- }
-
- if (added_dest) {
- khui_enable_action(KHUI_MENU_RENEW_CRED, TRUE);
- khui_enable_action(KHUI_MENU_DESTROY_CRED, TRUE);
- khui_enable_action(KHUI_ACTION_RENEW_CRED, TRUE);
- khui_enable_action(KHUI_ACTION_DESTROY_CRED, TRUE);
- } else {
- khui_enable_action(KHUI_MENU_RENEW_CRED, FALSE);
- khui_enable_action(KHUI_MENU_DESTROY_CRED, FALSE);
- khui_enable_action(KHUI_ACTION_RENEW_CRED, FALSE);
- khui_enable_action(KHUI_ACTION_DESTROY_CRED, FALSE);
- }
-
- if (added_setdef) {
- khui_enable_action(KHUI_MENU_SETDEF, TRUE);
- } else {
- khui_enable_action(KHUI_MENU_SETDEF, FALSE);
- }
-
- purge_identity_cmd_map();
-
- khui_action_unlock();
-
- khui_refresh_actions();
-
- if (sticky_done) {
- InvalidateRect(khm_hwnd_main_cred, NULL, TRUE);
- }
-}
-
-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;
- }
-
- if (id_action_map[i].new_cmd == act_id) {
- khm_cred_obtain_new_creds_for_ident(id_action_map[i].identity,
- NULL);
- return TRUE;
- }
-
- if (id_action_map[i].setdef_cmd == act_id) {
- khm_cred_set_default_identity(id_action_map[i].identity);
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-
-HMENU khui_hmenu_main = NULL;
-
-void khm_menu_refresh_items(void) {
- khui_menu_def * def;
-
- if (!khui_hmenu_main)
- return;
-
- khui_action_lock();
-
- def = khui_find_menu(KHUI_MENU_MAIN);
-
- refresh_menu(khui_hmenu_main, def);
-
- khui_action_unlock();
-
- DrawMenuBar(khm_hwnd_main);
-}
-
-void khm_menu_create_main(HWND parent) {
- HMENU hmenu;
- khui_menu_def * def;
-
- def = khui_find_menu(KHUI_MENU_MAIN);
-
- hmenu = mm_create_menu_from_def(def, TRUE);
-
- SetMenu(parent, hmenu);
-
- khui_hmenu_main = hmenu;
-
- return;
-
-#ifdef USE_EXPLORER_STYLE_MENU_BAR
- HWND hwtb;
- REBARBANDINFO rbi;
- SIZE sz;
- int i;
- khui_menu_def * mmdef;
- khui_action_ref * mm;
- int nmm;
-
- mmdef = khui_find_menu(KHUI_MENU_MAIN);
- mm = mmdef->items;
- nmm = (int) khui_action_list_length(mm);
-
- hwtb = CreateWindowEx(0
-#if (_WIN32_IE >= 0x0501)
- | TBSTYLE_EX_MIXEDBUTTONS
-#endif
- ,
- TOOLBARCLASSNAME,
- (LPWSTR) NULL,
- WS_CHILD |
- CCS_ADJUSTABLE |
- TBSTYLE_FLAT |
- TBSTYLE_AUTOSIZE |
- TBSTYLE_LIST |
- CCS_NORESIZE |
- CCS_NOPARENTALIGN |
- CCS_NODIVIDER,
- 0, 0, 0, 0, rebar,
- (HMENU) NULL, khm_hInstance,
- NULL);
-
- if(!hwtb) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- khui_main_menu_toolbar = hwtb;
-
- SendMessage(hwtb,
- TB_BUTTONSTRUCTSIZE,
- (WPARAM) sizeof(TBBUTTON),
- 0);
-
- for(i=0; i<nmm; i++) {
- khui_add_action_to_toolbar(hwtb,
- khui_find_action(mm[i].action),
- KHUI_TOOLBAR_ADD_TEXT |
- KHUI_TOOLBAR_ADD_DROPDOWN |
- KHUI_TOOLBAR_VARSIZE,
- NULL);
- }
-
- SendMessage(hwtb,
- TB_AUTOSIZE,
- 0,0);
-
- SendMessage(hwtb,
- TB_GETMAXSIZE,
- 0,
- (LPARAM) &sz);
-
- ZeroMemory(&rbi, sizeof(rbi));
-
- rbi.cbSize = sizeof(rbi);
-
- rbi.fMask =
- RBBIM_ID |
- RBBIM_STYLE |
- RBBIM_CHILD |
- RBBIM_CHILDSIZE |
- RBBIM_SIZE |
- RBBIM_IDEALSIZE;
-
- rbi.fStyle =
- RBBS_USECHEVRON;
-
- rbi.hwndChild = hwtb;
- rbi.wID = KHUI_MENU_MAIN;
- rbi.cx = sz.cx;
- rbi.cxMinChild = rbi.cx;
- rbi.cxIdeal = rbi.cx;
- rbi.cyMinChild = sz.cy;
- rbi.cyChild = rbi.cyMinChild;
- rbi.cyIntegral = rbi.cyMinChild;
- rbi.cyMaxChild = rbi.cyMinChild;
-
- SendMessage(rebar,
- RB_INSERTBAND,
- 0,
- (LPARAM) &rbi);
-#endif
-}
diff --git a/src/windows/identity/ui/mainmenu.h b/src/windows/identity/ui/mainmenu.h
deleted file mode 100644
index 54504d5fb..000000000
--- a/src/windows/identity/ui/mainmenu.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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
- * 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 __KHIMAIRA_MAINMENU_H
-#define __KHIMAIRA_MAINMENU_H
-
-extern HWND khui_main_menu_toolbar;
-
-#define MENU_ACTIVATE_DEFAULT -1
-#define MENU_ACTIVATE_LEFT -2
-#define MENU_ACTIVATE_RIGHT -3
-#define MENU_ACTIVATE_NONE -4
-
-extern int mm_last_hot_item;
-extern BOOL mm_hot_track;
-
-void khm_menu_create_main(HWND rebar);
-LRESULT khm_menu_handle_select(WPARAM wParam, LPARAM lParam);
-LRESULT khm_menu_notify_main(LPNMHDR notice);
-LRESULT khm_menu_activate(int menu_id);
-void khm_menu_show_panel(int id, LONG x, LONG y);
-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);
-void khm_get_action_tooltip(khm_int32 action, wchar_t * buf, khm_size cb_buf);
-void khm_get_action_caption(khm_int32 action, wchar_t * buf, khm_size cb_buf);
-
-khm_int32 khm_get_identity_destroy_action(khm_handle ident);
-khm_int32 khm_get_identity_renew_action(khm_handle ident);
-khm_int32 khm_get_identity_new_creds_action(khm_handle ident);
-
-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);
-
-void khui_init_menu(void);
-void khui_exit_menu(void);
-
-#define MENU_SIZE_ICON_X 16
-#define MENU_SIZE_ICON_Y 16
-
-#endif
diff --git a/src/windows/identity/ui/mainwnd.c b/src/windows/identity/ui/mainwnd.c
deleted file mode 100644
index 9d1556798..000000000
--- a/src/windows/identity/ui/mainwnd.c
+++ /dev/null
@@ -1,1380 +0,0 @@
-/*
- * 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
- * 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<khmapp.h>
-#include<intaction.h>
-#include<assert.h>
-
-ATOM khm_main_window_class;
-ATOM khm_null_window_class;
-HWND khm_hwnd_null;
-HWND khm_hwnd_main;
-HWND khm_hwnd_rebar;
-HWND khm_hwnd_main_cred;
-
-int khm_main_wnd_mode = KHM_MAIN_WND_NORMAL;
-
-#define MW_RESIZE_TIMER 1
-#define MW_RESIZE_TIMEOUT 2000
-#define MW_REFRESH_TIMER 2
-#define MW_REFRESH_TIMEOUT 600
-
-void
-khm_set_dialog_result(HWND hwnd, LRESULT lr) {
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_MSGRESULT, lr);
-#pragma warning(pop)
-}
-
-static void
-mw_restart_refresh_timer(HWND hwnd) {
- khm_handle csp_cw;
- khm_int32 timeout;
-
- KillTimer(hwnd, MW_REFRESH_TIMER);
- if (KHM_SUCCEEDED(khc_open_space(NULL,
- L"CredWindow",
- KHM_PERM_READ,
- &csp_cw))) {
- if (KHM_FAILED(khc_read_int32(csp_cw,
- L"RefreshTimeout",
- &timeout)))
- timeout = MW_REFRESH_TIMEOUT;
- khc_close_space(csp_cw);
- } else {
- timeout = MW_REFRESH_TIMEOUT;
- }
-
- timeout *= 1000; /* convert to milliseconds */
-
- SetTimer(hwnd, MW_REFRESH_TIMER, timeout, NULL);
-}
-
-khm_int32 KHMAPI
-mw_select_cred(khm_handle cred, void * rock) {
- if (cred)
- kcdb_cred_set_flags(cred,
- KCDB_CRED_FLAG_SELECTED,
- KCDB_CRED_FLAG_SELECTED);
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* perform shutdown operations */
-static void
-khm_pre_shutdown(void) {
- khm_handle csp_cw = NULL;
- khm_handle credset = NULL;
- khm_int32 t;
- khm_size s;
-
- /* Check if we should destroy all credentials on exit... */
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw)))
- return;
-
- if (KHM_FAILED(khc_read_int32(csp_cw, L"DestroyCredsOnExit", &t)) ||
- !t)
- goto _cleanup;
-
- if (KHM_FAILED(kcdb_credset_create(&credset)))
- goto _cleanup;
-
- if (KHM_FAILED(kcdb_credset_extract(credset, NULL, NULL,
- KCDB_TYPE_INVALID)))
- goto _cleanup;
-
- if (KHM_FAILED(kcdb_credset_get_size(credset, &s)) ||
- s == 0)
- goto _cleanup;
-
- kcdb_credset_apply(credset, mw_select_cred, NULL);
-
- khui_context_set(KHUI_SCOPE_GROUP,
- NULL,
- KCDB_CREDTYPE_INVALID,
- NULL,
- NULL,
- 0,
- credset);
-
- khm_cred_destroy_creds(TRUE, TRUE);
-
- _cleanup:
-
- if (credset)
- kcdb_credset_delete(credset);
-
- if (csp_cw)
- khc_close_space(csp_cw);
-}
-
-void
-khm_process_query_app_ver(khm_query_app_version * papp_ver) {
-
- if (!papp_ver || papp_ver->magic != KHM_QUERY_APP_VER_MAGIC)
- return;
-
- papp_ver->ver_remote = app_version;
-
- /* the remote instance has requested swapping in. we check the
- version numbers and if the remote instance is newer than us,
- then we exit and let the remote instance take over. */
- if (papp_ver->request_swap) {
- khm_version ver_caller = papp_ver->ver_caller;
-
- if (khm_compare_version(&ver_caller, &app_version) > 0) {
-
- papp_ver->request_swap = TRUE;
-
- if (khm_hwnd_main)
- DestroyWindow(khm_hwnd_main);
-
- } else {
-
- papp_ver->request_swap = FALSE;
-
- }
- }
-
- 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);
-}
-
-
-static void
-main_wnd_save_sizepos() {
- RECT r;
- khm_handle csp_cw;
- khm_handle csp_mw;
- const wchar_t * wconfig;
-
- KillTimer(khm_hwnd_main, MW_RESIZE_TIMER);
-
- if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
- wconfig = L"Windows\\MainMini";
- else
- wconfig = L"Windows\\Main";
-
- GetWindowRect(khm_hwnd_main, &r);
-
- if (KHM_SUCCEEDED(khc_open_space(NULL,
- L"CredWindow",
- KHM_PERM_WRITE,
- &csp_cw))) {
- if (KHM_SUCCEEDED(khc_open_space(csp_cw,
- wconfig,
- KHM_PERM_WRITE,
- &csp_mw))) {
- khm_int32 t;
-
- khc_write_int32(csp_mw, L"XPos", r.left);
- khc_write_int32(csp_mw, L"YPos", r.top);
- khc_write_int32(csp_mw, L"Width", r.right - r.left);
- khc_write_int32(csp_mw, L"Height", r.bottom - r.top);
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Dock", &t)) &&
- t != KHM_DOCK_NONE) {
- khc_write_int32(csp_mw, L"Dock", KHM_DOCK_AUTO);
- }
-
- khc_close_space(csp_mw);
- }
-
- khc_close_space(csp_cw);
- }
-}
-
-LRESULT CALLBACK
-khm_main_wnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- LPNMHDR lpnm;
-
- switch(uMsg) {
- case WM_CREATE:
- khm_create_main_window_controls(hwnd);
- kmq_subscribe_hwnd(KMSG_CRED, hwnd);
- kmq_subscribe_hwnd(KMSG_ACT, hwnd);
- kmq_subscribe_hwnd(KMSG_KMM, hwnd);
- mw_restart_refresh_timer(hwnd);
-
- /* if the plug-ins finished loading before the window was
- created, we would have missed the KMSG_KMM_I_DONE message.
- So we check if the module load is complete and if so, fire
- off KMSG_ACT_BEGIN_CMDLINE. */
- if (!kmm_load_pending())
- kmq_post_message(KMSG_ACT, KMSG_ACT_BEGIN_CMDLINE, 0, 0);
- break;
-
- case WM_DESTROY:
- khm_pre_shutdown();
- kmq_unsubscribe_hwnd(KMSG_ACT, hwnd);
- kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);
- kmq_unsubscribe_hwnd(KMSG_KMM, hwnd);
- HtmlHelp(NULL, NULL, HH_CLOSE_ALL, 0);
- PostQuitMessage(0);
- break;
-
- case WM_NOTIFY:
- lpnm = (LPNMHDR) lParam;
- if(lpnm->hwndFrom == khui_main_menu_toolbar) {
- return khm_menu_notify_main(lpnm);
- } else if(lpnm->hwndFrom == khui_hwnd_standard_toolbar) {
- return khm_toolbar_notify(lpnm);
- } else if(lpnm->hwndFrom == khm_hwnd_rebar) {
- return khm_rebar_notify(lpnm);
- } else if(lpnm->hwndFrom == khm_hwnd_statusbar) {
- return khm_statusbar_notify(lpnm);
- }
- break;
-
- case WM_HELP:
- khm_html_help(khm_hwnd_main, NULL, HH_HELP_CONTEXT, IDH_WELCOME);
- break;
-
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- /* general actions */
- case KHUI_ACTION_VIEW_REFRESH:
- khm_cred_refresh();
- InvalidateRect(khm_hwnd_main_cred, NULL, FALSE);
- return 0;
-
- case KHUI_ACTION_PASSWD_ID:
- if (khm_startup.processing)
- return 0;
-
- khm_cred_change_password(NULL);
- return 0;
-
- case KHUI_ACTION_NEW_CRED:
- if (khm_startup.processing)
- return 0;
-
- khm_cred_obtain_new_creds(NULL);
- return 0;
-
- case KHUI_ACTION_RENEW_CRED:
- if (khm_startup.processing)
- return 0;
-
- khm_cred_renew_creds();
- return 0;
-
- case KHUI_ACTION_DESTROY_CRED:
- if (khm_startup.processing)
- return 0;
-
- khm_cred_destroy_creds(FALSE, FALSE);
- return 0;
-
- case KHUI_ACTION_SET_DEF_ID:
- if (khm_startup.processing)
- return 0;
-
- khm_cred_set_default();
- return 0;
-
- case KHUI_ACTION_EXIT:
- DestroyWindow(hwnd);
- return 0;
-
- case KHUI_ACTION_OPEN_APP:
- khm_show_main_window();
- return 0;
-
- case KHUI_ACTION_CLOSE_APP:
- khm_hide_main_window();
- return 0;
-
- case KHUI_ACTION_OPT_KHIM: {
- khui_config_node node = NULL;
-
- khui_cfg_open(NULL, L"KhmGeneral", &node);
- khm_show_config_pane(node);
- }
- return 0;
-
- case KHUI_ACTION_OPT_IDENTS: {
- khui_config_node node = NULL;
-
- khui_cfg_open(NULL, L"KhmIdentities", &node);
- khm_show_config_pane(node);
- }
- return 0;
-
- case KHUI_ACTION_OPT_APPEAR: {
- khui_config_node node = NULL;
-
- khui_cfg_open(NULL, L"KhmAppear", &node);
- khm_show_config_pane(node);
- }
- return 0;
-
- case KHUI_ACTION_OPT_NOTIF: {
- khui_config_node node = NULL;
-
- khui_cfg_open(NULL, L"KhmNotifications", &node);
- khm_show_config_pane(node);
- }
- return 0;
-
- case KHUI_ACTION_OPT_PLUGINS: {
- khui_config_node node = NULL;
-
- khui_cfg_open(NULL, L"KhmPlugins", &node);
- khm_show_config_pane(node);
- }
- return 0;
-
- case KHUI_ACTION_HELP_CTX:
- khm_html_help(khm_hwnd_main, NULL, HH_HELP_CONTEXT, IDH_WELCOME);
- return 0;
-
- case KHUI_ACTION_HELP_CONTENTS:
- khm_html_help(khm_hwnd_main, NULL, HH_DISPLAY_TOC, 0);
- return 0;
-
- case KHUI_ACTION_HELP_INDEX:
- khm_html_help(khm_hwnd_main, NULL, HH_DISPLAY_INDEX, (DWORD_PTR) L"");
- return 0;
-
- case KHUI_ACTION_HELP_ABOUT:
- khm_create_about_window();
- return 0;
-
- case KHUI_ACTION_IMPORT:
- khm_cred_import();
- return 0;
-
- case KHUI_ACTION_PROPERTIES:
- /* properties are not handled by the main window.
- Just bounce it to credwnd. However, use SendMessage
- instead of PostMessage so we don't lose context */
- return SendMessage(khm_hwnd_main_cred, uMsg,
- wParam, lParam);
-
- case KHUI_ACTION_UICB:
- khm_ui_cb(lParam);
- return 0;
-
- /* layout control */
-
- case KHUI_ACTION_VIEW_ALL_IDS:
- return SendMessage(khm_hwnd_main_cred, uMsg,
- wParam, lParam);
-
- case KHUI_ACTION_LAYOUT_MINI:
-
- if (khm_main_wnd_mode == KHM_MAIN_WND_MINI) {
- khm_set_main_window_mode(KHM_MAIN_WND_NORMAL);
- } else {
- khm_set_main_window_mode(KHM_MAIN_WND_MINI);
- }
- return SendMessage(khm_hwnd_main_cred, uMsg,
- wParam, lParam);
-
- case KHUI_ACTION_LAYOUT_RELOAD:
- return SendMessage(khm_hwnd_main_cred, uMsg,
- wParam, lParam);
-
- case KHUI_ACTION_LAYOUT_ID:
- case KHUI_ACTION_LAYOUT_TYPE:
- case KHUI_ACTION_LAYOUT_LOC:
- case KHUI_ACTION_LAYOUT_CUST:
- khm_set_main_window_mode(KHM_MAIN_WND_NORMAL);
- return SendMessage(khm_hwnd_main_cred, uMsg,
- wParam, lParam);
-
- /* menu commands */
- case KHUI_PACTION_MENU:
- if(HIWORD(lParam) == 1)
- mm_last_hot_item = LOWORD(lParam);
- return khm_menu_activate(MENU_ACTIVATE_DEFAULT);
-
- case KHUI_PACTION_ESC:
- /* if esc is pressed while no menu is active, we close the
- main window */
- if (mm_last_hot_item == -1) {
- khm_close_main_window();
- return 0;
- }
-
- /* generic, retargetting */
- case KHUI_PACTION_UP:
- case KHUI_PACTION_UP_TOGGLE:
- case KHUI_PACTION_UP_EXTEND:
- case KHUI_PACTION_PGUP:
- case KHUI_PACTION_PGUP_EXTEND:
- case KHUI_PACTION_DOWN:
- case KHUI_PACTION_DOWN_TOGGLE:
- case KHUI_PACTION_DOWN_EXTEND:
- case KHUI_PACTION_PGDN:
- case KHUI_PACTION_PGDN_EXTEND:
- case KHUI_PACTION_LEFT:
- case KHUI_PACTION_RIGHT:
- case KHUI_PACTION_ENTER:
- /* menu tracking */
- if(mm_last_hot_item != -1) {
- switch(LOWORD(wParam)) {
- case KHUI_PACTION_LEFT:
- khm_menu_activate(MENU_ACTIVATE_LEFT);
- break;
-
- case KHUI_PACTION_RIGHT:
- khm_menu_activate(MENU_ACTIVATE_RIGHT);
- break;
-
- case KHUI_PACTION_ESC:
- case KHUI_PACTION_ENTER:
- khm_menu_activate(MENU_ACTIVATE_NONE);
- break;
-
- case KHUI_PACTION_DOWN:
- khm_menu_track_current();
- break;
- }
- return 0;
- }
-
- /*FALLTHROUGH*/
- case KHUI_PACTION_DELETE:
-
- case KHUI_PACTION_SELALL:
- /* otherwise fallthrough and bounce to the creds window */
- return SendMessage(khm_hwnd_main_cred, uMsg,
- wParam, lParam);
-
- default:
- /* handle custom actions here */
- {
- 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);
- return 0;
- }
- }
- }
- break; /* WM_COMMAND */
-
- case WM_SYSCOMMAND:
- switch(wParam & 0xfff0) {
- case SC_MINIMIZE:
- khm_hide_main_window();
- return 0;
-
- case SC_CLOSE:
- khm_close_main_window();
- return 0;
- }
- break;
-
- case WM_MEASUREITEM:
- /* sent to measure the bitmaps associated with a menu item */
- if(!wParam) /* sent by menu */
- return khm_menu_measure_item(wParam, lParam);
- break;
-
- case WM_DRAWITEM:
- /* sent to draw a menu item */
- if(!wParam)
- return khm_menu_draw_item(wParam, lParam);
- break;
-
- case WM_ERASEBKGND:
- /* Don't erase the background. The whole client area is
- covered with children. It doesn't need to be erased */
- return TRUE;
- break;
-
- case WM_SIZE:
- if(hwnd == khm_hwnd_main &&
- (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED)) {
- int cwidth, cheight;
- RECT r_rebar, r_status;
-
- cwidth = LOWORD(lParam);
- cheight = HIWORD(lParam);
-
- /* resize the rebar control */
- SendMessage(khm_hwnd_rebar, WM_SIZE, 0, 0);
-
- khm_update_statusbar(hwnd);
-
- GetWindowRect(khm_hwnd_rebar, &r_rebar);
- GetWindowRect(khm_hwnd_statusbar, &r_status);
-
- /* the cred window fills the area between the rebar
- and the status bar */
- MoveWindow(khm_hwnd_main_cred, 0,
- r_rebar.bottom - r_rebar.top,
- r_status.right - r_status.left,
- r_status.top - r_rebar.bottom, TRUE);
-
- SetTimer(hwnd,
- MW_RESIZE_TIMER,
- MW_RESIZE_TIMEOUT,
- NULL);
- return 0;
- }
- break;
-
- case WM_MOVE:
- {
- SetTimer(hwnd,
- MW_RESIZE_TIMER,
- MW_RESIZE_TIMEOUT,
- NULL);
-
- return 0;
- }
- break;
-
- case WM_MOVING:
- {
- RECT * r;
-
- r = (RECT *) lParam;
- khm_adjust_window_dimensions_for_display(r,
- KHM_DOCK_AUTO | KHM_DOCKF_XBORDER);
- }
- return TRUE;
-
- case WM_TIMER:
- if (wParam == MW_RESIZE_TIMER) {
- main_wnd_save_sizepos();
-
- return 0;
-
- } else if (wParam == MW_REFRESH_TIMER) {
- kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);
-
- return 0;
-
- }
- break;
-
- case WM_MENUSELECT:
- return khm_menu_handle_select(wParam, lParam);
-
- case KMQ_WM_DISPATCH:
- {
- kmq_message * m;
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- kmq_wm_begin(lParam, &m);
- if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_REFRESH) {
- khm_menu_refresh_items();
- khm_update_standard_toolbar();
- } else if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_BEGIN_CMDLINE) {
- khm_cred_begin_startup_actions();
- } else if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_CONTINUE_CMDLINE) {
- khm_cred_process_startup_actions();
- } else if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_END_CMDLINE) {
- /* nothing yet */
- } else if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_SYNC_CFG) {
- khm_refresh_config();
- } else if (m->type == KMSG_ACT &&
- m->subtype == KMSG_ACT_ACTIVATE) {
- /* some custom action fired */
-
- khm_int32 action;
- khui_action * paction;
-
- action = m->uparam;
- paction = khui_find_action(action);
- if (paction && paction->data == (void *) CFGACTION_MAGIC) {
- /* a custom configuration needs to be invoked */
- khui_config_node node;
-
- if (KHM_SUCCEEDED(khui_cfg_open(NULL, paction->name, &node))) {
- khm_show_config_pane(node);
- khui_cfg_release(node);
- }
- }
- } else if (m->type == KMSG_CRED &&
- m->subtype == KMSG_CRED_REFRESH) {
- mw_restart_refresh_timer(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);
- }
-
- return kmq_wm_end(m, rv);
- }
-
- case WM_KHUI_ASSIGN_COMMANDLINE_V1:
- {
- HANDLE hmap;
- void * xfer;
- wchar_t mapname[256];
- khm_startup_options_v1 * pv1opt;
- int code = KHM_ERROR_SUCCESS;
-
- StringCbPrintf(mapname, sizeof(mapname),
- COMMANDLINE_MAP_FMT, (DWORD) lParam);
-
- hmap = OpenFileMapping(FILE_MAP_READ, FALSE, mapname);
-
- if (hmap == NULL)
- return 1;
-
- xfer = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0,
- sizeof(*pv1opt));
-
- if (xfer) {
- pv1opt = (khm_startup_options_v1 *) xfer;
-
- khm_startup.init = pv1opt->init;
- khm_startup.import = pv1opt->import;
- khm_startup.renew = pv1opt->renew;
- khm_startup.destroy = pv1opt->destroy;
-
- khm_startup.autoinit = pv1opt->autoinit;
- khm_startup.error_exit = FALSE;
-
- khm_startup.no_main_window = FALSE;
- khm_startup.remote_exit = FALSE;
- khm_startup.display = 0;
-
- UnmapViewOfFile(xfer);
- } else {
- code = KHM_ERROR_NOT_FOUND;
- }
-
- CloseHandle(hmap);
-
- if(InSendMessage())
- ReplyMessage(code);
-
- if (code == KHM_ERROR_SUCCESS) {
- khm_startup.exit = FALSE;
-
- khm_startup.seen = FALSE;
- khm_startup.remote = TRUE;
-#ifdef DEBUG
- assert(!khm_startup.processing);
-#endif
- khm_startup.processing = FALSE;
-
- khm_cred_begin_startup_actions();
- }
-
- return code;
- }
-
- case WM_KHUI_ASSIGN_COMMANDLINE_V2:
- {
- HANDLE hmap;
- void * xfer;
- wchar_t mapname[256];
- khm_startup_options_v2 *pv2opt = NULL;
- khm_startup_options_v3 *pv3opt = NULL;
- int code = KHM_ERROR_SUCCESS;
-
- StringCbPrintf(mapname, sizeof(mapname),
- COMMANDLINE_MAP_FMT, (DWORD) lParam);
-
- hmap = OpenFileMapping(FILE_MAP_WRITE, FALSE, mapname);
-
- if (hmap == NULL)
- return 1;
-
- xfer = MapViewOfFile(hmap, FILE_MAP_WRITE, 0, 0,
- sizeof(*pv2opt));
-
- if (xfer) {
- pv2opt = (khm_startup_options_v2 *) xfer;
-
- if (pv2opt->magic != STARTUP_OPTIONS_MAGIC ||
- (pv2opt->cb_size != sizeof(*pv2opt) &&
- pv2opt->cb_size != sizeof(*pv3opt))) {
- code = KHM_ERROR_INVALID_PARAM;
- goto done_with_v2_opt;
- }
-
- khm_startup.init = pv2opt->init;
- khm_startup.import = pv2opt->import;
- khm_startup.renew = pv2opt->renew;
- khm_startup.destroy = pv2opt->destroy;
-
- khm_startup.autoinit = pv2opt->autoinit;
- khm_startup.exit = pv2opt->remote_exit;
-
- pv2opt->code = KHM_ERROR_SUCCESS;
-
- if (pv2opt->cb_size == sizeof(*pv3opt)) {
- pv3opt = (khm_startup_options_v3 *) xfer;
-
- khm_startup.display = pv3opt->remote_display;
- } else {
- khm_startup.display = 0;
- }
-
- done_with_v2_opt:
- UnmapViewOfFile(xfer);
- } else {
- code = KHM_ERROR_NOT_FOUND;
- }
-
- CloseHandle(hmap);
-
- if(InSendMessage())
- ReplyMessage(code);
-
- if (code == KHM_ERROR_SUCCESS) {
- khm_startup.seen = FALSE;
- khm_startup.remote = TRUE;
-#ifdef DEBUG
- assert(!khm_startup.processing);
-#endif
- khm_startup.processing = FALSE;
-
- khm_cred_begin_startup_actions();
- }
-
- return code;
- }
-
- case WM_KHUI_QUERY_APP_VERSION:
- {
- HANDLE hmap;
- void * xfer;
- wchar_t mapname[256];
-
- StringCbPrintf(mapname, sizeof(mapname),
- QUERY_APP_VER_MAP_FMT, (DWORD) lParam);
-
- hmap = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE,
- FALSE, mapname);
-
- if (hmap == NULL)
- return 1;
-
- xfer = MapViewOfFile(hmap, FILE_MAP_WRITE, 0, 0,
- sizeof(khm_query_app_version));
-
- if (xfer) {
- khm_process_query_app_ver((khm_query_app_version *) xfer);
-
- UnmapViewOfFile(xfer);
- }
-
- CloseHandle(hmap);
- }
- return 0;
-
- }
- return DefWindowProc(hwnd,uMsg,wParam,lParam);
-}
-
-LRESULT CALLBACK
-khm_null_wnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-LRESULT
-khm_rebar_notify(LPNMHDR lpnm) {
- switch(lpnm->code) {
-#if (_WIN32_WINNT >= 0x0501)
- case RBN_AUTOBREAK:
- {
- LPNMREBARAUTOBREAK lpra = (LPNMREBARAUTOBREAK) lpnm;
- lpra->fAutoBreak = TRUE;
- }
- break;
-#endif
- case RBN_BEGINDRAG:
- {
- LPNMREBAR lprb = (LPNMREBAR) lpnm;
- if ((lprb->dwMask & RBNM_ID) &&
- lprb->wID == 0)
- return 1;
- else
- return 0;
- }
- break;
-
- case NM_CUSTOMDRAW:
- return CDRF_DODEFAULT;
- break;
- }
-
- return 1;
-}
-
-void
-khm_create_main_window_controls(HWND hwnd_main) {
- REBARINFO rbi;
- HWND hwRebar;
-
- khm_menu_create_main(hwnd_main);
-
- hwRebar =
- CreateWindowEx(WS_EX_TOOLWINDOW,
- REBARCLASSNAME,
- L"Rebar",
- WS_CHILD |
- WS_VISIBLE|
- WS_CLIPSIBLINGS |
- WS_CLIPCHILDREN |
- CCS_NODIVIDER |
- RBS_VARHEIGHT |
- RBS_FIXEDORDER,
- 0,0,0,0,
- hwnd_main,
- NULL,
- khm_hInstance,
- NULL);
-
- if(!hwRebar) {
- DWORD dwe = GetLastError();
- return;
- }
-
- khm_hwnd_rebar = hwRebar;
-
- rbi.cbSize = sizeof(rbi);
- rbi.fMask = 0;
- rbi.himl = (HIMAGELIST) NULL;
- if(!SendMessage(hwRebar, RB_SETBARINFO, 0, (LPARAM) &rbi))
- return;
-
- /* self attach */
- khm_create_standard_toolbar(hwRebar);
- khm_create_statusbar(hwnd_main);
-
- /* manual attach */
- khm_hwnd_main_cred = khm_create_credwnd(hwnd_main);
-}
-
-void
-khm_adjust_window_dimensions_for_display(RECT * pr, int dock) {
-
- HMONITOR hmon;
- RECT rm;
- long x, y, width, height;
-
- x = pr->left;
- y = pr->top;
- width = pr->right - pr->left;
- height = pr->bottom - pr->top;
-
- /* if the rect doesn't intersect with the display area of any
- monitor, we just default to the primary monitor. */
- hmon = MonitorFromRect(pr, MONITOR_DEFAULTTOPRIMARY);
-
- if (hmon == NULL) {
- /* huh? we'll just center this on the primary screen */
- goto nomonitor;
- } else {
- MONITORINFO mi;
-
- ZeroMemory(&mi, sizeof(mi));
- mi.cbSize = sizeof(mi);
-
- if (!GetMonitorInfo(hmon, &mi))
- goto nomonitor;
-
- CopyRect(&rm, &mi.rcWork);
-
- goto adjust_dims;
- }
-
- nomonitor:
- /* for some reason we couldn't get a handle on a monitor or we
- couldn't get the metrics for that monitor. We default to
- setting things up on the primary monitor. */
-
- SetRectEmpty(&rm);
- if (!SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID) &rm, 0))
- goto done_with_monitor;
-
- adjust_dims:
-
- if (width > (rm.right - rm.left))
- width = rm.right - rm.left;
- if (height > (rm.bottom - rm.top))
- height = rm.bottom - rm.top;
-
- switch (dock & KHM_DOCKF_DOCKHINT) {
- case KHM_DOCK_TOPLEFT:
- x = rm.left;
- y = rm.top;
- break;
-
- case KHM_DOCK_TOPRIGHT:
- x = rm.right - width;
- y = rm.top;
- break;
-
- case KHM_DOCK_BOTTOMRIGHT:
- x = rm.right - width;
- y = rm.bottom - height;
- break;
-
- case KHM_DOCK_BOTTOMLEFT:
- x = rm.left;
- y = rm.bottom - height;
- break;
-
- case KHM_DOCK_AUTO:
- {
- int cxt, cyt;
-
- cxt = GetSystemMetrics(SM_CXDRAG);
- cyt = GetSystemMetrics(SM_CYDRAG);
-
- if (x > rm.left && (x - rm.left) < cxt)
- x = rm.left;
- else if ((x + width) < rm.right && (rm.right - (x + width)) < cxt)
- x = rm.right - width;
-
- if (y > rm.top && (y - rm.top) < cyt)
- y = rm.top;
- else if ((y + height) < rm.bottom && (rm.bottom - (y + height)) < cyt)
- y = rm.bottom - height;
- }
- break;
- }
-
- if (!(dock & KHM_DOCKF_XBORDER)) {
- if (x < rm.left)
- x = rm.left;
- if (x + width > rm.right)
- x = rm.right - width;
- if (y < rm.top)
- y = rm.top;
- if (y + height > rm.bottom)
- y = rm.bottom - height;
- }
-
- done_with_monitor:
- pr->left = x;
- pr->top = y;
- pr->right = x + width;
- pr->bottom = y + height;
-
-}
-
-void
-khm_get_main_window_rect(RECT * pr) {
- khm_handle csp_mw = NULL;
- int x,y,width,height,dock;
- RECT r;
- const wchar_t * wconfig;
-
- x = CW_USEDEFAULT;
- y = CW_USEDEFAULT;
- width = CW_USEDEFAULT;
- height = CW_USEDEFAULT;
- dock = KHM_DOCK_NONE;
-
- if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
- wconfig = L"CredWindow\\Windows\\MainMini";
- else
- wconfig = L"CredWindow\\Windows\\Main";
-
- if (KHM_SUCCEEDED(khc_open_space(NULL,
- wconfig,
- KHM_PERM_READ,
- &csp_mw))) {
- khm_int32 t;
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"XPos", &t)))
- x = t;
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"YPos", &t)))
- y = t;
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Width", &t)))
- width = t;
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Height", &t)))
- height = t;
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Dock", &t)))
- dock = t;
-
- khc_close_space(csp_mw);
- }
-
- /* If there were no default values, we default to using 1/4 of the
- work area centered on the primary monitor. If there were any
- docking hints, then the next call to
- khm_adjust_window_dimensions_for_display() will reposition the
- window. */
- if (width == CW_USEDEFAULT || x == CW_USEDEFAULT) {
- RECT wr;
-
- SetRectEmpty(&wr);
- SystemParametersInfo(SPI_GETWORKAREA, 0, &wr, 0);
-
- if (width == CW_USEDEFAULT) {
- width = (wr.right - wr.left) / 2;
- height = (wr.bottom - wr.top) / 2;
- }
-
- if (x == CW_USEDEFAULT) {
- x = (wr.left + wr.right) / 2 - width / 2;
- y = (wr.top + wr.bottom) / 2 - height / 2;
- }
- }
-
- /* The saved dimensions might not actually be visible if the user
- has changed the resolution of the display or if it's a multiple
- monitor system where the monitor on which the Network Identity
- Manager window was on previously is no longer connected. We
- have to check for that and adjust the dimensions if needed. */
- SetRect(&r, x, y, x + width, y + height);
- khm_adjust_window_dimensions_for_display(&r, dock);
-
- *pr = r;
-}
-
-void
-khm_set_main_window_mode(int mode) {
-
- RECT r;
- khm_handle csp_cw;
-
- if (mode == khm_main_wnd_mode)
- return;
-
- khui_check_action(KHUI_ACTION_LAYOUT_MINI,
- ((mode == KHM_MAIN_WND_MINI)? FALSE : TRUE));
- khui_enable_action(KHUI_MENU_LAYOUT,
- ((mode == KHM_MAIN_WND_MINI)? FALSE : TRUE));
- khui_enable_action(KHUI_MENU_COLUMNS,
- ((mode == KHM_MAIN_WND_MINI)? FALSE : TRUE));
-
- khui_refresh_actions();
-
- /*
- * set the window position before the global khm_main_wnd_mode
- * is updated. otherwise, the windows position for the wrong
- * mode will be set. Do not set the window position if the
- * main application window has not yet been created.
- */
- if (khm_hwnd_main)
- main_wnd_save_sizepos();
-
- khm_main_wnd_mode = mode;
- if (khm_hwnd_main) {
- khm_get_main_window_rect(&r);
-
- SetWindowPos(khm_hwnd_main,
- NULL,
- r.left, r.top,
- r.right - r.left, r.bottom - r.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER);
- }
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", KHM_PERM_WRITE,
- &csp_cw))) {
-
- khc_write_int32(csp_cw, L"DefaultWindowMode", mode);
- khc_close_space(csp_cw);
-
- }
-
- khm_cred_refresh();
-}
-
-void
-khm_create_main_window(void) {
- wchar_t buf[1024];
- khm_handle csp_cw = NULL;
- RECT r;
-
- LoadString(khm_hInstance, IDS_MAIN_WINDOW_TITLE,
- buf, ARRAYLENGTH(buf));
-
- khm_hwnd_null =
- CreateWindow(MAKEINTATOM(khm_null_window_class),
- buf,
- 0, /* Style */
- 0, 0, /* x, y */
- 100, 100, /* width, height */
- NULL, /* parent */
- NULL, /* menu */
- NULL, /* HINSTANCE */
- 0); /* lparam */
-
- if (!khm_hwnd_null)
- return;
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow",
- KHM_PERM_READ,
- &csp_cw))) {
- khm_int32 t;
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultWindowMode", &t))) {
- khm_set_main_window_mode(t);
- }
-
- khc_close_space(csp_cw);
- }
-
- khm_get_main_window_rect(&r);
-
- khm_hwnd_main =
- CreateWindowEx(WS_EX_OVERLAPPEDWINDOW | WS_EX_APPWINDOW,
- MAKEINTATOM(khm_main_window_class),
- buf,
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN |
- WS_CLIPSIBLINGS,
- r.left, r.top,
- r.right - r.left,
- r.bottom - r.top,
- khm_hwnd_null,
- NULL,
- NULL,
- NULL);
-
- khui_set_main_window(khm_hwnd_main);
-}
-
-void
-khm_show_main_window(void) {
-
- if (khm_nCmdShow == SW_RESTORE) {
- HWND hw;
-
- hw = GetForegroundWindow();
- if (hw != khm_hwnd_main)
- SetForegroundWindow(khm_hwnd_main);
- }
- /*
- * We test for the values of khm_nCmdShow that
- * can be set at process startup. They will
- * only be seen the first time this function is
- * called. After the first time, the value of
- * khm_nCmdShow will always be SW_RESTORE.
- * When one of the minimized values is set,
- * khm_show_main_window() will not be called
- * unless the user initiates a request to show
- * the window.
- */
- else if (khm_nCmdShow == SW_SHOWMINIMIZED ||
- khm_nCmdShow == SW_SHOWMINNOACTIVE ||
- khm_nCmdShow == SW_MINIMIZE) {
-
- khm_nCmdShow = SW_SHOW;
- }
-
- ShowWindow(khm_hwnd_main, khm_nCmdShow);
- UpdateWindow(khm_hwnd_main);
-
- khm_cred_refresh();
-
- khm_nCmdShow = SW_RESTORE;
-}
-
-void
-khm_activate_main_window(void) {
-
- if (!SetForegroundWindow(khm_hwnd_main)) {
- FLASHWINFO finfo;
-
- SetActiveWindow(khm_hwnd_main);
-
- ZeroMemory(&finfo, sizeof(finfo));
- finfo.cbSize = sizeof(finfo);
- finfo.hwnd = khm_hwnd_main;
- finfo.dwFlags = FLASHW_ALL;
- finfo.uCount = 3;
- finfo.dwTimeout = 0;
-
- FlashWindowEx(&finfo);
- }
-}
-
-void
-khm_close_main_window(void) {
- khm_handle csp_cw;
- BOOL keep_running = FALSE;
-
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow",
- KHM_PERM_READ, &csp_cw))) {
- khm_int32 t;
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"KeepRunning",
- &t))) {
- keep_running = t;
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- khc_close_space(csp_cw);
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- if (keep_running)
- khm_hide_main_window();
- else
- DestroyWindow(khm_hwnd_main);
-}
-
-void
-khm_hide_main_window(void) {
- khm_handle csp_notices = NULL;
- khm_int32 show_warning = FALSE;
-
- if (khm_nCmdShow != SW_MINIMIZE &&
- KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow\\Notices",
- KHM_PERM_WRITE, &csp_notices)) &&
- KHM_SUCCEEDED(khc_read_int32(csp_notices, L"MinimizeWarning",
- &show_warning)) &&
- show_warning != 0) {
-
- khui_alert * alert;
- wchar_t title[KHUI_MAXCCH_TITLE];
- wchar_t msg[KHUI_MAXCCH_MESSAGE];
-
- LoadString(khm_hInstance, IDS_WARN_WM_TITLE,
- title, ARRAYLENGTH(title));
- LoadString(khm_hInstance, IDS_WARN_WM_MSG,
- msg, ARRAYLENGTH(msg));
-
- khui_alert_create_simple(title, msg, KHERR_INFO, &alert);
- khui_alert_set_flags(alert, KHUI_ALERT_FLAG_REQUEST_BALLOON,
- KHUI_ALERT_FLAG_REQUEST_BALLOON);
-
- khui_alert_show(alert);
-
- khc_write_int32(csp_notices, L"MinimizeWarning", 0);
- }
-
- if (csp_notices != NULL)
- khc_close_space(csp_notices);
-
- ShowWindow(khm_hwnd_main, SW_HIDE);
-}
-
-BOOL
-khm_is_main_window_visible(void) {
- return IsWindowVisible(khm_hwnd_main);
-}
-
-BOOL
-khm_is_main_window_active(void) {
- if (!IsWindowVisible(khm_hwnd_main))
- return FALSE;
- if (GetForegroundWindow() == khm_hwnd_main)
- return TRUE;
- return khm_is_dialog_active();
-}
-
-void
-khm_register_main_wnd_class(void) {
- WNDCLASSEX wc;
-
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = 0;
- wc.lpfnWndProc = khm_null_wnd_proc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = khm_hInstance;
- wc.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
- wc.hIconSm = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
- wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = KHUI_NULL_WINDOW_CLASS;
-
- khm_null_window_class = RegisterClassEx(&wc);
-
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = khm_main_wnd_proc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = khm_hInstance;
- wc.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
- wc.hIconSm = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
- wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = KHUI_MAIN_WINDOW_CLASS;
-
- khm_main_window_class = RegisterClassEx(&wc);
-}
-
-void
-khm_unregister_main_wnd_class(void) {
- UnregisterClass(MAKEINTATOM(khm_main_window_class),khm_hInstance);
- UnregisterClass(MAKEINTATOM(khm_null_window_class),khm_hInstance);
-}
diff --git a/src/windows/identity/ui/mainwnd.h b/src/windows/identity/ui/mainwnd.h
deleted file mode 100644
index 7916697be..000000000
--- a/src/windows/identity/ui/mainwnd.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_MAINWND_H
-#define __KHIMAIRA_MAINWND_H
-
-#define KHUI_MAIN_WINDOW_CLASS L"KhmMainWindowClass"
-#define KHUI_NULL_WINDOW_CLASS L"KhmNullWindowClass"
-
-extern ATOM khm_main_window_class;
-extern HWND khm_hwnd_main;
-extern HWND khm_hwnd_rebar;
-extern HWND khm_hwnd_main_cred;
-
-#define KHM_MAIN_WND_NORMAL 0
-#define KHM_MAIN_WND_MINI 1
-
-extern int khm_main_wnd_mode;
-
-void khm_register_main_wnd_class(void);
-void khm_unregister_main_wnd_class(void);
-void khm_create_main_window_controls(HWND);
-void khm_create_main_window(void);
-void khm_activate_main_window(void);
-void khm_show_main_window(void);
-void khm_set_main_window_mode(int mode);
-void khm_close_main_window(void);
-void khm_hide_main_window(void);
-BOOL khm_is_main_window_visible(void);
-BOOL khm_is_main_window_active(void);
-void khm_adjust_window_dimensions_for_display(RECT * pr, int dock);
-LRESULT khm_rebar_notify(LPNMHDR lpnm);
-
-void
-khm_set_dialog_result(HWND hwnd, LRESULT lr);
-
-LRESULT CALLBACK
-khm_main_wnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-#define WM_KHUI_QUERY_APP_VERSION 32809
-#define WM_KHUI_ASSIGN_COMMANDLINE_V1 32808
-#define WM_KHUI_ASSIGN_COMMANDLINE_V2 32810
-
-#define COMMANDLINE_MAP_FMT L"Local\\NetIDMgr_Cmdline_%lu"
-#define QUERY_APP_VER_MAP_FMT L"Local\\NetIDMgr_QueryVer_%lu"
-
-/* dock values for window positioning */
-#define KHM_DOCK_NONE 0
-#define KHM_DOCK_TOPLEFT 1
-#define KHM_DOCK_TOPRIGHT 2
-#define KHM_DOCK_BOTTOMRIGHT 3
-#define KHM_DOCK_BOTTOMLEFT 4
-#define KHM_DOCK_AUTO 256
-#define KHM_DOCKF_DOCKHINT 0x0000ffff
-#define KHM_DOCKF_XBORDER 0x00010000
-#endif
diff --git a/src/windows/identity/ui/makeacceldef.pl b/src/windows/identity/ui/makeacceldef.pl
deleted file mode 100644
index d1cfb2dd2..000000000
--- a/src/windows/identity/ui/makeacceldef.pl
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-
-die "Please specify input and output filenames" if($#ARGV != 1);
-
-open INF, '<', $ARGV[0] or die "Can't open input file";
-open OUF, '>', $ARGV[1] or die "Can't open output file";
-
-print OUF <<EOS;
-#include<khimaira.h>
-
- khui_accel_def khui_accel_global[] = {
-EOS
-
-# skip first line
- <INF>;
-
-while(<INF>) {
- print OUF "{".$_."},\n";
-}
-
-print OUF <<EOS;
-};
-
-int khui_n_accel_global = sizeof(khui_accel_global) / sizeof(khui_accel_def);
-
-EOS
-
-close INF;
-close OUF;
diff --git a/src/windows/identity/ui/makeactiondef.pl b/src/windows/identity/ui/makeactiondef.pl
deleted file mode 100644
index f99373588..000000000
--- a/src/windows/identity/ui/makeactiondef.pl
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-
-die "Please specify input and output filenames" if($#ARGV != 1);
-
-open INF, '<', $ARGV[0] or die "Can't open input file";
-open OUF, '>', $ARGV[1] or die "Can't open output file";
-
-print OUF <<EOS;
-#include<khimaira.h>
-
- khui_action khui_actions[] = {
-EOS
-
-# skip first line
- <INF>;
-
-while(<INF>) {
- print OUF "{".$_."},\n";
-}
-
-print OUF <<EOS;
-};
-
-int khui_n_actions = sizeof(khui_actions) / sizeof(khui_action);
-
-EOS
-
-close INF;
-close OUF;
diff --git a/src/windows/identity/ui/netidmgr.exe.manifest.i386 b/src/windows/identity/ui/netidmgr.exe.manifest.i386
deleted file mode 100644
index 3d77cce68..000000000
--- a/src/windows/identity/ui/netidmgr.exe.manifest.i386
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="X86"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.amd64.vc7 b/src/windows/identity/ui/netidmgr.manifest.amd64.vc7
deleted file mode 100644
index 0db331bb7..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.amd64.vc7
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="amd64"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="amd64"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.amd64.vc7.debug b/src/windows/identity/ui/netidmgr.manifest.amd64.vc7.debug
deleted file mode 100644
index 0db331bb7..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.amd64.vc7.debug
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="amd64"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="amd64"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.amd64.vc8 b/src/windows/identity/ui/netidmgr.manifest.amd64.vc8
deleted file mode 100644
index 6fb1e8d1e..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.amd64.vc8
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="amd64"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="amd64"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.VC80.DebugCRT"
- version="8.0.50215.4652"
- processorArchitecture="amd64"
- publicKeyToken="1fc8b3b9a1e18e3b"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.amd64.vc8.debug b/src/windows/identity/ui/netidmgr.manifest.amd64.vc8.debug
deleted file mode 100644
index 6fb1e8d1e..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.amd64.vc8.debug
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="amd64"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="amd64"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.VC80.DebugCRT"
- version="8.0.50215.4652"
- processorArchitecture="amd64"
- publicKeyToken="1fc8b3b9a1e18e3b"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.i386.vc7 b/src/windows/identity/ui/netidmgr.manifest.i386.vc7
deleted file mode 100644
index 3d77cce68..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.i386.vc7
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="X86"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.i386.vc7.debug b/src/windows/identity/ui/netidmgr.manifest.i386.vc7.debug
deleted file mode 100644
index 3d77cce68..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.i386.vc7.debug
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="X86"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.i386.vc8 b/src/windows/identity/ui/netidmgr.manifest.i386.vc8
deleted file mode 100644
index d2ced7fd2..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.i386.vc8
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="X86"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.VC80.DebugCRT"
- version="8.0.50215.4652"
- processorArchitecture="x86"
- publicKeyToken="1fc8b3b9a1e18e3b"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/netidmgr.manifest.i386.vc8.debug b/src/windows/identity/ui/netidmgr.manifest.i386.vc8.debug
deleted file mode 100644
index d2ced7fd2..000000000
--- a/src/windows/identity/ui/netidmgr.manifest.i386.vc8.debug
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="X86"
- name="MIT.NetIDMgr.UI"
- type="win32"
-/>
-<description>Khimaira Credentials Manager</description>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.VC80.DebugCRT"
- version="8.0.50215.4652"
- processorArchitecture="x86"
- publicKeyToken="1fc8b3b9a1e18e3b"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c
deleted file mode 100644
index e0c60f5c0..000000000
--- a/src/windows/identity/ui/newcredwnd.c
+++ /dev/null
@@ -1,3034 +0,0 @@
-/*
- * 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
- * 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 the OEMRESOURCE constants for locating standard icon
- resources. */
-#define OEMRESOURCE
-
-#include<khmapp.h>
-#if _WIN32_WINNT >= 0x0501
-#include<uxtheme.h>
-#endif
-#include<assert.h>
-
-ATOM khui_newcredwnd_cls;
-
-/* forward dcl */
-static void
-nc_position_credtext(khui_nc_wnd_data * d);
-
-/* Common dialog procedure used by the main credential panel
- (IDD_NC_NEWCRED) and the button bar (IDC_NC_BBAR). */
-
-static void
-nc_layout_main_panel(khui_nc_wnd_data * d);
-
-static void
-nc_layout_new_cred_window(khui_nc_wnd_data * d);
-
-static INT_PTR CALLBACK
-nc_common_dlg_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch(uMsg) {
- case WM_INITDIALOG:
- {
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *) lParam;
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, lParam);
-#pragma warning(pop)
-
- if (d->nc->subtype == KMSG_CRED_PASSWORD) {
- ShowWindow(GetDlgItem(hwnd, IDC_NC_ADVANCED),
- SW_HIDE);
- }
- }
- return TRUE;
-
- case WM_COMMAND:
- {
- int ctrl_id;
-
- ctrl_id = LOWORD(wParam);
- if (ctrl_id < KHUI_CW_ID_MIN ||
- ctrl_id > KHUI_CW_ID_MAX) {
- /* pump it to the parent */
- PostMessage(GetParent(hwnd), WM_COMMAND, wParam, lParam);
- return TRUE;
- } /* else we allow the message to fall through and get
- passed into the identity provider's message
- handler. */
- }
- break;
-
- case KHUI_WM_NC_NOTIFY:
- {
- khui_nc_wnd_data * d;
- d = (khui_nc_wnd_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
- if (d == NULL)
- break;
-
- /* message sent by parent to notify us of something */
- switch(HIWORD(wParam)) {
- case WMNC_DIALOG_EXPAND:
- /* fallthrough */
- case WMNC_UPDATE_LAYOUT:
- if(hwnd == d->dlg_main) {
-
- nc_layout_main_panel(d);
-
- return TRUE;
- }
- break; /* nop */
- }
- }
- return TRUE;
- }
-
- /* check if we have a wnd_data, and if so pass the message on to
- the identity provider callback. */
- {
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *) (LONG_PTR)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- /* TODO: filter out and forward only the messages that
- originated or pertain to the identity selection
- controls. */
- if (d && d->nc && d->nc->ident_cb) {
- return d->nc->ident_cb(d->nc, WMNC_IDENT_WMSG, hwnd, uMsg,
- wParam, lParam);
- }
- }
-
- return FALSE;
-}
-
-static void
-nc_notify_clear(khui_nc_wnd_data * d) {
-
- if (d->notif_type == NC_NOTIFY_NONE)
- /* there are no notifications anyway. */
- return;
-
- if (d->hwnd_notif_label)
- DestroyWindow(d->hwnd_notif_label);
-
- if (d->hwnd_notif_aux)
- DestroyWindow(d->hwnd_notif_aux);
-
- d->hwnd_notif_label = NULL;
- d->hwnd_notif_aux = NULL;
-
- SetRectEmpty(&d->r_notif);
-
- d->notif_type = NC_NOTIFY_NONE;
-
- /* Note that we must call nc_layout_main_panel() after calling
- this to adjust the layout of the main panel. However we aren't
- calling it here since we might want to add another set of
- notifications or make other changes to the main panel content
- before calling nc_layout_main_panel(). */
-}
-
-static void
-nc_notify_marquee(khui_nc_wnd_data * d, const wchar_t * label) {
-
-#if (_WIN32_IE >= 0x0600)
- HDC hdc;
- size_t length;
- SIZE label_size;
-#endif
-
- RECT r_label;
- RECT r_mq;
- RECT r_row;
- HFONT hfont;
- HWND hwnd;
- HDWP hdefer;
-
- /* Clear the notification area. We only support one notification
- at a time. */
- nc_notify_clear(d);
-
-#ifdef DEBUG
- assert(d->dlg_main);
-#endif
-
-#if (_WIN32_IE >= 0x0600)
-
- /* We can only show the marquee control if the comctl32 DLL is
- version 6.0 or later. Otherwise we only show the label. */
-
- if (FAILED(StringCchLength(label, KHUI_MAXCCH_SHORT_DESC, &length))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- length = KHUI_MAXCCH_SHORT_DESC;
- }
-
- /* See how big the notification control needs to be. */
-
- hdc = GetDC(d->dlg_main);
-#ifdef DEBUG
- assert(hdc != NULL);
-#endif
-
- GetTextExtentPoint32(hdc, label, (int) length, &label_size);
-
- ReleaseDC(d->dlg_main, hdc);
-
- CopyRect(&r_row, &d->r_row);
-
- if (label_size.cx > d->r_e_label.right - d->r_e_label.left) {
- /* using an entire row */
- CopyRect(&r_label, &d->r_row);
- CopyRect(&r_mq, &d->r_n_input);
- OffsetRect(&r_mq, 0, r_row.bottom - r_row.top);
- r_row.bottom += r_row.bottom - r_row.top;
- } else if (label_size.cx > d->r_n_label.right - d->r_n_label.left) {
- /* using large labels */
- CopyRect(&r_label, &d->r_e_label);
- CopyRect(&r_mq, &d->r_e_input);
- } else {
- /* normal labels */
- CopyRect(&r_label, &d->r_n_label);
- CopyRect(&r_mq, &d->r_n_input);
- }
-
- InflateRect(&r_mq, 0, - ((r_mq.bottom - r_mq.top) / 4));
-
-#else /* _WIN32_IE < 0x0600 */
-
- /* We are just showing the label */
- CopyRect(&r_row, &d->r_row);
- CopyRect(&r_label, &r_row);
- SetRectEmpty(&r_mq);
-
-#endif /* _WIN32_IE >= 0x0600 */
-
- {
- long y;
-
- if (IsRectEmpty(&d->r_custprompt)) {
- y = d->r_idspec.bottom;
- } else {
- y = d->r_custprompt.bottom;
- }
-
- OffsetRect(&r_row, d->r_area.left, y);
- OffsetRect(&r_label, r_row.left, r_row.top);
- OffsetRect(&r_mq, r_row.left, r_row.top);
- }
-
- hfont = (HFONT) SendMessage(d->dlg_main, WM_GETFONT, 0, 0);
-
- hdefer = BeginDeferWindowPos(2);
-
- /* the label */
- hwnd = CreateWindowEx(0,
- L"STATIC",
- label,
- WS_CHILD | SS_ENDELLIPSIS,
- r_label.left, r_label.top,
- r_label.right - r_label.left,
- r_label.bottom - r_label.top,
- d->dlg_main,
- NULL, NULL, NULL);
-#ifdef DEBUG
- assert(hwnd != NULL);
-#endif
- SendMessage(hwnd, WM_SETFONT, (WPARAM) hfont, (LPARAM) TRUE);
-
- DeferWindowPos(hdefer, hwnd, NULL,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOSIZE | SWP_SHOWWINDOW);
-
- d->hwnd_notif_label = hwnd;
-
- /* and the marquee */
-
-#if (_WIN32_IE >= 0x0600)
-
- /* unfortunately, the marquee is only available on comctl32
- version 6.0 or later. On previous versions, we only display
- the message label. */
-
- hwnd = CreateWindowEx(0,
- PROGRESS_CLASS,
- L"",
- WS_CHILD | PBS_MARQUEE,
- r_mq.left, r_mq.top,
- r_mq.right - r_mq.left,
- r_mq.bottom - r_mq.top,
- d->dlg_main,
- NULL, NULL, NULL);
-#ifdef DEBUG
- assert(hwnd != NULL);
-#endif
-
- SendMessage(hwnd, PBM_SETMARQUEE, TRUE, 100);
-
- DeferWindowPos(hdefer, hwnd, NULL,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOSIZE | SWP_SHOWWINDOW);
-
- d->hwnd_notif_aux = hwnd;
-
-#endif /* _WIN32_IE >= 0x0600 */
-
- EndDeferWindowPos(hdefer);
-
- CopyRect(&d->r_notif, &r_row);
-
- d->notif_type = NC_NOTIFY_MARQUEE;
-
- /* Note that we must call nc_layout_main_panel() after calling
- this to adjust the layout of the main panel. However we aren't
- calling it here since we might want to add another set of
- notifications or make other changes to the main panel content
- before calling nc_layout_main_panel(). */
-}
-
-static void
-nc_notify_message(khui_nc_wnd_data * d,
- kherr_severity severity,
- const wchar_t * message) {
-
- SIZE icon_size;
- LPCTSTR icon_res;
- HICON h_icon;
- HWND hwnd;
- HFONT hfont;
- HDWP hdefer;
-
- RECT r_row;
- RECT r_label;
- RECT r_icon;
-
- nc_notify_clear(d);
-
- icon_size.cx = GetSystemMetrics(SM_CXSMICON);
- icon_size.cy = GetSystemMetrics(SM_CYSMICON);
-
- switch(severity) {
- case KHERR_INFO:
- icon_res = MAKEINTRESOURCE(OIC_INFORMATION);
- break;
-
- case KHERR_WARNING:
- icon_res = MAKEINTRESOURCE(OIC_WARNING);
- break;
-
- case KHERR_ERROR:
- icon_res = MAKEINTRESOURCE(OIC_ERROR);
- break;
-
- default:
- icon_res = NULL;
- }
-
- if (icon_res != NULL) {
- h_icon = (HICON) LoadImage(NULL,
- icon_res,
- IMAGE_ICON,
- icon_size.cx,
- icon_size.cy,
- LR_DEFAULTCOLOR | LR_SHARED);
- } else {
- h_icon = NULL;
- }
-
- CopyRect(&r_row, &d->r_row);
-
-#define CENTERVALUE(w,v) ((w)/2 - (v)/2)
-
- SetRect(&r_icon,
- 0, CENTERVALUE(r_row.bottom - r_row.top, icon_size.cy),
- icon_size.cx,
- CENTERVALUE(r_row.bottom - r_row.top, icon_size.cy) + icon_size.cy);
-
-#undef CENTERVALUE
-
- CopyRect(&r_label, &r_row);
- OffsetRect(&r_label, -r_label.left, -r_label.top);
- r_label.left += (icon_size.cx * 3) / 2;
-
- {
- long y;
-
- if (IsRectEmpty(&d->r_custprompt)) {
- y = d->r_idspec.bottom;
- } else {
- y = d->r_custprompt.bottom;
- }
-
- OffsetRect(&r_row, d->r_area.left, y);
- OffsetRect(&r_label, r_row.left, r_row.top);
- OffsetRect(&r_icon, r_row.left, r_row.top);
- }
-
- hfont = (HFONT) SendMessage(d->dlg_main, WM_GETFONT, 0, 0);
-
- hdefer = BeginDeferWindowPos(2);
-
- hwnd = CreateWindowEx(0,
- L"STATIC",
- message,
- WS_CHILD | SS_ENDELLIPSIS | SS_CENTER,
- r_label.left, r_label.top,
- r_label.right - r_label.left,
- r_label.bottom - r_label.top,
- d->dlg_main,
- NULL, NULL, NULL);
-#ifdef DEBUG
- assert(hwnd != NULL);
-#endif
- SendMessage(hwnd, WM_SETFONT, (WPARAM) hfont, (LPARAM) TRUE);
-
- DeferWindowPos(hdefer, hwnd, NULL,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOSIZE | SWP_SHOWWINDOW);
-
- d->hwnd_notif_label = hwnd;
-
- hwnd = CreateWindowEx(0,
- L"STATIC",
- NULL,
- WS_CHILD | SS_ICON |
-#if (_WIN32_IE >= 0x0600)
- SS_REALSIZECONTROL
-#else
- 0
-#endif
- ,
- r_icon.left, r_icon.top,
- r_icon.right - r_icon.left,
- r_icon.bottom - r_icon.top,
- d->dlg_main,
- NULL, NULL, NULL);
-#ifdef DEBUG
- assert(hwnd != NULL);
-#endif
-
- if (h_icon && hwnd)
- SendMessage(hwnd, STM_SETICON, (WPARAM) h_icon, 0);
-
- DeferWindowPos(hdefer, hwnd, NULL,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOZORDER);
-
- d->hwnd_notif_aux = hwnd;
-
- EndDeferWindowPos(hdefer);
-
- CopyRect(&d->r_notif, &r_row);
-
- d->notif_type = NC_NOTIFY_MESSAGE;
-
- /* Note that we must call nc_layout_main_panel() after calling
- this to adjust the layout of the main panel. However we aren't
- calling it here since we might want to add another set of
- notifications or make other changes to the main panel content
- before calling nc_layout_main_panel(). */
-}
-
-static void
-nc_layout_main_panel(khui_nc_wnd_data * d)
-{
- RECT r_main;
- HWND hw_ct;
- HWND hw_ct_label;
- HDWP hdwp;
- RECT r_used; /* extent used by identity specifiers,
- custom prompts and notificaiton
- controls. */
-
- RECT r_wmain; /* extents of the main window in screen
- coordinates. */
-
- r_main.left = 0;
- r_main.top = 0;
- r_main.bottom = NCDLG_HEIGHT;
- r_main.right = NCDLG_WIDTH;
-
- MapDialogRect(d->dlg_main, &r_main);
-
- CopyRect(&r_used, &d->r_idspec);
-
- GetWindowRect(d->dlg_main, &r_wmain);
-
- hdwp = BeginDeferWindowPos(7);
-
- /* check if the notification area and the custom prompt area are
- overlapping. */
-
- if (d->notif_type != NC_NOTIFY_NONE) {
- long delta_y = 0;
- RECT r;
-
- CopyRect(&r, &d->r_custprompt);
-
- if (IsRectEmpty(&d->r_custprompt)) {
- /* if there are no custom prompts, then the notification
- area should be immediately below the identitify
- specifers. */
-
- delta_y = d->r_idspec.bottom - d->r_notif.top;
- } else {
- /* otherwise, the notification area should be immediately
- below the custom prompt area */
-
- delta_y = d->r_custprompt.bottom - d->r_notif.top;
- }
-
- if (delta_y != 0) {
- RECT r_lbl;
- RECT r_aux;
-
- if (d->hwnd_notif_label) {
- GetWindowRect(d->hwnd_notif_label, &r_lbl);
- OffsetRect(&r_lbl, -r_wmain.left, delta_y - r_wmain.top);
-
- DeferWindowPos(hdwp, d->hwnd_notif_label, NULL,
- r_lbl.left, r_lbl.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOSIZE);
- }
-
- if (d->hwnd_notif_aux) {
- GetWindowRect(d->hwnd_notif_aux, &r_aux);
- OffsetRect(&r_aux, -r_wmain.left, delta_y - r_wmain.top);
-
- DeferWindowPos(hdwp, d->hwnd_notif_aux, NULL,
- r_aux.left, r_aux.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOSIZE);
- }
-
- OffsetRect(&d->r_notif, 0, delta_y);
- }
- }
-
- if (!IsRectEmpty(&d->r_custprompt)) {
- r_used.bottom = max(d->r_custprompt.bottom,
- r_used.bottom);
- }
-
- if (!IsRectEmpty(&d->r_notif)) {
- r_used.bottom = max(d->r_notif.bottom,
- r_used.bottom);
- }
-
- if (d->nc->mode == KHUI_NC_MODE_MINI) {
- RECT r_ok;
- RECT r_cancel;
- RECT r_advanced;
- HWND hw;
-
- hw = GetDlgItem(d->dlg_main, IDOK);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
- GetWindowRect(hw, &r_ok);
- OffsetRect(&r_ok, -r_wmain.left, -r_ok.top + r_used.bottom);
-
- DeferWindowPos(hdwp, hw, NULL,
- r_ok.left, r_ok.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
-
- hw = GetDlgItem(d->dlg_main, IDCANCEL);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
- GetWindowRect(hw, &r_cancel);
- OffsetRect(&r_cancel, -r_wmain.left, -r_cancel.top + r_used.bottom);
-
- DeferWindowPos(hdwp, hw, NULL,
- r_cancel.left, r_cancel.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
-
- hw = GetDlgItem(d->dlg_main, IDC_NC_ADVANCED);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
- GetWindowRect(hw, &r_advanced);
- OffsetRect(&r_advanced, -r_wmain.left, -r_advanced.top + r_used.bottom);
-
- DeferWindowPos(hdwp, hw, NULL,
- r_advanced.left, r_advanced.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
-
- /* and now update the extents of the main panel */
- r_main.bottom = r_used.bottom + (r_ok.bottom - r_ok.top) + d->r_area.top;
-
- CopyRect(&d->r_main, &r_main);
-
- } else {
-
- HWND hw;
-
- hw = GetDlgItem(d->dlg_main, IDOK);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
- if (IsWindowVisible(hw))
- DeferWindowPos(hdwp, hw, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE |
- SWP_NOOWNERZORDER | SWP_NOZORDER);
-
- hw = GetDlgItem(d->dlg_main, IDCANCEL);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
- if (IsWindowVisible(hw))
- DeferWindowPos(hdwp, hw, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE |
- SWP_NOOWNERZORDER | SWP_NOZORDER);
-
- hw = GetDlgItem(d->dlg_main, IDC_NC_ADVANCED);
-#ifdef DEBUG
- assert(hw != NULL);
-#endif
- if (IsWindowVisible(hw))
- DeferWindowPos(hdwp, hw, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE |
- SWP_NOOWNERZORDER | SWP_NOZORDER);
-
- d->r_credtext.top = r_used.bottom;
-
- CopyRect(&d->r_main, &r_main);
- }
-
- /* now update the layout of the credentials text window */
-
- hw_ct = GetDlgItem(d->dlg_main, IDC_NC_CREDTEXT);
- hw_ct_label = GetDlgItem(d->dlg_main, IDC_NC_CREDTEXT_LABEL);
-#ifdef DEBUG
- assert(hw_ct != NULL);
- assert(hw_ct_label != NULL);
-#endif
-
- if (d->nc->mode == KHUI_NC_MODE_MINI ||
- d->r_credtext.bottom < d->r_credtext.top + d->r_row.bottom * 2) {
-
- /* either we aren't supposed to show the credentials text
- window, or we don't have enough room. */
- if (IsWindowVisible(hw_ct) || IsWindowVisible(hw_ct_label)) {
-
- DeferWindowPos(hdwp, hw_ct, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
-
- DeferWindowPos(hdwp, hw_ct_label, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
-
- }
-
- } else {
-
- DeferWindowPos(hdwp,
- hw_ct, NULL,
- d->r_credtext.left + d->r_n_input.left, /* x */
- d->r_credtext.top, /* y */
- d->r_n_input.right - d->r_n_input.left, /* width */
- d->r_credtext.bottom - d->r_credtext.top, /* height */
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_SHOWWINDOW);
-
- DeferWindowPos(hdwp,
- hw_ct_label, NULL,
- d->r_credtext.left + d->r_n_label.left, /* x */
- d->r_credtext.top, /* y */
- d->r_n_label.right - d->r_n_label.left, /* width */
- d->r_n_label.bottom - d->r_n_label.top, /* height */
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_SHOWWINDOW);
- }
-
- EndDeferWindowPos(hdwp);
-
- /* NOTE: although we updated d->r_main, if the new credentials
- window is in mini mode, we must call
- nc_layout_new_cred_window() to adjust the size of the new
- credentials window to fit the main panel. We don't do it here
- because we need to keep these two operations separate. */
-}
-
-/* Credential type panel comparison function. Tabs are sorted based
- on the following criteria:
-
- 1) By ordinal - Panels with ordinal -1 will be ranked after panels
- whose ordinal is not -1.
-
- 2) By name - Case insensitive comparison of the name. If the panel
- does not have a name (i.e. the ->name member is NULL, it will be
- ranked after panels which have a name.
- */
-static int __cdecl
-nc_tab_sort_func(const void * v1, const void * v2)
-{
- /* v1 and v2 and of type : khui_new_creds_by_type ** */
- khui_new_creds_by_type *t1, *t2;
-
- t1 = *((khui_new_creds_by_type **) v1);
- t2 = *((khui_new_creds_by_type **) v2);
-
- if(t1->ordinal != -1) {
- if(t2->ordinal != -1) {
- if(t1->ordinal == t2->ordinal) {
- if (t1->name && t2->name)
- return _wcsicmp(t1->name, t2->name);
- else if (t1->name)
- return -1;
- else if (t2->name)
- return 1;
- else
- return 0;
- } else {
- /* safe to convert to an int here */
- return (int) (t1->ordinal - t2->ordinal);
- }
- } else
- return -1;
- } else {
- if(t2->ordinal != -1)
- return 1;
- else if (t1->name && t2->name)
- return wcscmp(t1->name, t2->name);
- else if (t1->name)
- return -1;
- else if (t2->name)
- return 1;
- else
- return 0;
- }
-}
-
-static void
-nc_notify_types(khui_new_creds * c, UINT uMsg,
- WPARAM wParam, LPARAM lParam, BOOL sync)
-{
- khm_size i;
-
- for(i=0; i<c->n_types; i++) {
-
- if (c->types[i]->hwnd_panel == NULL)
- continue;
-
- if (sync)
- SendMessage(c->types[i]->hwnd_panel, uMsg, wParam, lParam);
- else
- PostMessage(c->types[i]->hwnd_panel, uMsg, wParam, lParam);
- }
-}
-
-static void
-nc_clear_password_fields(khui_nc_wnd_data * d)
-{
- khm_size i;
- khm_boolean need_sync = FALSE;
-
- khui_cw_lock_nc(d->nc);
-
- for (i=0; i < d->nc->n_prompts; i++) {
- if ((d->nc->prompts[i]->flags & KHUI_NCPROMPT_FLAG_HIDDEN) &&
- d->nc->prompts[i]->hwnd_edit) {
- SetWindowText(d->nc->prompts[i]->hwnd_edit,
- L"");
- need_sync = TRUE;
- }
- }
-
- khui_cw_unlock_nc(d->nc);
-
- if (need_sync) {
- khui_cw_sync_prompt_values(d->nc);
- }
-}
-
-/* used by nc_enable_controls */
-
-struct nc_enum_wnd_data {
- khui_nc_wnd_data * d;
- khm_boolean enable;
-};
-
-static
-BOOL CALLBACK
-nc_enum_wnd_proc(HWND hwnd,
- LPARAM lParam)
-{
- struct nc_enum_wnd_data * wd;
-
- wd = (struct nc_enum_wnd_data *) lParam;
-
- EnableWindow(hwnd, wd->enable);
-
- return TRUE;
-}
-
-static void
-nc_enable_controls(khui_nc_wnd_data * d, khm_boolean enable)
-{
- struct nc_enum_wnd_data wd;
-
- ZeroMemory(&wd, sizeof(wd));
-
- wd.d = d;
- wd.enable = enable;
-
- EnumChildWindows(d->dlg_main, nc_enum_wnd_proc, (LPARAM) &wd);
-}
-
-#define NC_MAXCCH_CREDTEXT 16384
-#define NC_MAXCB_CREDTEXT (NC_MAXCCH_CREDTEXT * sizeof(wchar_t))
-
-static void
-nc_update_credtext(khui_nc_wnd_data * d)
-{
- wchar_t * ctbuf = NULL;
- wchar_t * buf;
- BOOL okEnable = FALSE;
- BOOL validId = FALSE;
- HWND hw = NULL;
- size_t cch = 0;
-
- ctbuf = PMALLOC(NC_MAXCB_CREDTEXT);
-
- assert(ctbuf != NULL);
-
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_TABS, ctbuf, NC_MAXCCH_CREDTEXT);
- StringCchLength(ctbuf, NC_MAXCCH_CREDTEXT, &cch);
- buf = ctbuf + cch;
- nc_notify_types(d->nc, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_UPDATE_CREDTEXT), (LPARAM) d->nc, TRUE);
-
- /* hopefully all the types have updated their credential texts */
-
- /* if the dialog is in the mini mode, we have to display
- exceptions using a notification. */
- if (d->nc->mode == KHUI_NC_MODE_MINI) {
- BOOL need_layout = FALSE;
- if (d->nc->n_identities == 0) {
-
- /* There are no identities selected. We don't show any
- notifications here. */
- if (d->notif_type != NC_NOTIFY_NONE) {
- nc_notify_clear(d);
- need_layout = TRUE;
- }
-
- } else {
-
- wchar_t id_name[KCDB_IDENT_MAXCCH_NAME];
- wchar_t format[256];
- wchar_t msg[ARRAYLENGTH(format) + ARRAYLENGTH(id_name)];
- khm_size cbbuf;
- khm_int32 flags;
-
- kcdb_identity_get_flags(d->nc->identities[0], &flags);
-
- cbbuf = sizeof(id_name);
- kcdb_identity_get_name(d->nc->identities[0], id_name, &cbbuf);
-
- if (flags & KCDB_IDENT_FLAG_INVALID) {
-
- /* identity is invalid */
- LoadString(khm_hInstance, IDS_NCN_IDENT_INVALID,
- format, ARRAYLENGTH(format));
- StringCbPrintf(msg, sizeof(msg), format, id_name);
-
- nc_notify_message(d, KHERR_ERROR, msg);
-
- need_layout = TRUE;
-
- } else if ((flags & KCDB_IDENT_FLAG_VALID) ||
- d->nc->subtype == KMSG_CRED_PASSWORD) {
- /* special case: If we are going to change the
- password, we don't expect the identity provider to
- validate the identity in real time. As such, we
- assume that the identity is valid. */
-
- /* identity is valid */
- if (d->notif_type != NC_NOTIFY_NONE) {
- nc_notify_clear(d);
- need_layout = TRUE;
- }
-
- } else if (flags & KCDB_IDENT_FLAG_UNKNOWN) {
-
- /* unknown state */
- LoadString(khm_hInstance, IDS_NCN_IDENT_UNKNOWN,
- format, ARRAYLENGTH(format));
- StringCbPrintf(msg, sizeof(msg), format, id_name);
-
- nc_notify_message(d, KHERR_WARNING, msg);
-
- need_layout = TRUE;
-
- } else {
-
- /* still checking */
- LoadString(khm_hInstance, IDS_NCN_IDENT_CHECKING,
- format, ARRAYLENGTH(format));
- StringCbPrintf(msg, sizeof(msg), format, id_name);
-
- nc_notify_marquee(d, msg);
-
- need_layout = TRUE;
-
- }
- }
-
- if (need_layout) {
- nc_layout_main_panel(d);
- nc_layout_new_cred_window(d);
- }
- }
-
- if(d->nc->n_identities == 1) {
- wchar_t main_fmt[256];
- wchar_t id_fmt[256];
- wchar_t id_name[KCDB_IDENT_MAXCCH_NAME];
- wchar_t id_string[KCDB_IDENT_MAXCCH_NAME + 256];
- khm_size cbbuf;
- khm_int32 flags;
-
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_ONE,
- main_fmt, (int) ARRAYLENGTH(main_fmt));
-
- cbbuf = sizeof(id_name);
- kcdb_identity_get_name(d->nc->identities[0], id_name, &cbbuf);
-
- kcdb_identity_get_flags(d->nc->identities[0], &flags);
-
- if (flags & KCDB_IDENT_FLAG_INVALID) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_INVALID,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else if(flags & KCDB_IDENT_FLAG_VALID) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_VALID,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else if(flags & KCDB_IDENT_FLAG_UNKNOWN) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_UNCHECKED,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else if(d->nc->subtype == KMSG_CRED_NEW_CREDS) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_CHECKING,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_UNCHECKED,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- }
-
- StringCbPrintf(id_string, sizeof(id_string), id_fmt, id_name);
-
- StringCbPrintf(buf, NC_MAXCB_CREDTEXT - cch*sizeof(wchar_t),
- main_fmt, id_string);
-
- if (flags & KCDB_IDENT_FLAG_VALID) {
- if (flags & KCDB_IDENT_FLAG_DEFAULT)
- LoadString(khm_hInstance, IDS_NC_ID_DEF,
- id_string, ARRAYLENGTH(id_string));
- else if (d->nc->set_default)
- LoadString(khm_hInstance, IDS_NC_ID_WDEF,
- id_string, ARRAYLENGTH(id_string));
- else
- LoadString(khm_hInstance, IDS_NC_ID_NDEF,
- id_string, ARRAYLENGTH(id_string));
-
- StringCbCat(buf, NC_MAXCB_CREDTEXT - cch * sizeof(wchar_t),
- id_string);
- }
-
- } else if(d->nc->n_identities > 1) {
- wchar_t *ids_string;
- khm_size cb_ids_string;
-
- wchar_t id_name[KCDB_IDENT_MAXCCH_NAME];
- wchar_t id_fmt[256];
- wchar_t id_string[KCDB_IDENT_MAXCCH_NAME + 256];
-
- wchar_t main_fmt[256];
- khm_size cbbuf;
-
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_MANY,
- main_fmt, (int) ARRAYLENGTH(main_fmt));
-
- /* we are going to concatenate all the identity names into
- a comma separated string */
-
- /* d->nc->n_identities is at least 2 */
- ids_string = PMALLOC((KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) *
- (d->nc->n_identities - 1));
- cb_ids_string =
- (KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) *
- (d->nc->n_identities - 1);
-
- assert(ids_string != NULL);
-
- ids_string[0] = 0;
-
- {
- khm_size i;
- khm_int32 flags;
-
- for(i=1; i<d->nc->n_identities; i++) {
- if(i>1) {
- StringCbCat(ids_string, cb_ids_string, L",");
- }
-
- flags = 0;
-
- cbbuf = sizeof(id_name);
- kcdb_identity_get_name(d->nc->identities[i], id_name, &cbbuf);
- kcdb_identity_get_flags(d->nc->identities[i], &flags);
- if(flags & KCDB_IDENT_FLAG_INVALID) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_INVALID,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else if(flags & KCDB_IDENT_FLAG_VALID) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_VALID,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_UNCHECKED,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- }
-
- StringCbPrintf(id_string, sizeof(id_string), id_fmt, id_name);
- StringCbCat(ids_string, cb_ids_string, id_string);
- }
-
- cbbuf = sizeof(id_name);
- kcdb_identity_get_name(d->nc->identities[0], id_name, &cbbuf);
- kcdb_identity_get_flags(d->nc->identities[0], &flags);
- if(flags & KCDB_IDENT_FLAG_INVALID) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_INVALID,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else if(flags & KCDB_IDENT_FLAG_VALID) {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_VALID,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- } else {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_UNCHECKED,
- id_fmt, (int) ARRAYLENGTH(id_fmt));
- }
- StringCbPrintf(id_string, sizeof(id_string), id_fmt, id_name);
-
- StringCbPrintf(buf, NC_MAXCB_CREDTEXT - cch*sizeof(wchar_t),
- main_fmt, id_string, ids_string);
-
- PFREE(ids_string);
- }
- } else {
- LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_NONE,
- buf, (int)(NC_MAXCCH_CREDTEXT - cch));
- }
-
- /* now, append the credtext string from each of the cred types */
- {
- khm_size i;
- size_t cb;
- wchar_t * buf;
-
- cb = NC_MAXCB_CREDTEXT;
- buf = ctbuf;
-
- for(i=0; i<d->nc->n_types; i++) {
- if(d->nc->types[i]->credtext != NULL) {
- StringCbCatEx(buf, cb,
- d->nc->types[i]->credtext,
- &buf, &cb,
- 0);
- }
- }
- }
-
- SetDlgItemText(d->dlg_main, IDC_NC_CREDTEXT, ctbuf);
-
- PFREE(ctbuf);
-
- /* so depending on whether the primary identity was found to be
- invalid, we need to disable the Ok button and set the title to
- reflect this */
-
- if(d->nc->n_identities > 0) {
- khm_int32 flags = 0;
-
- if(KHM_SUCCEEDED(kcdb_identity_get_flags(d->nc->identities[0],
- &flags)) &&
- (flags & KCDB_IDENT_FLAG_VALID)) {
- validId = TRUE;
- }
- }
-
- if (d->nc->window_title == NULL) {
- if(validId) {
- wchar_t wpostfix[256];
- wchar_t wtitle[KCDB_IDENT_MAXCCH_NAME + 256];
- khm_size cbsize;
-
- cbsize = sizeof(wtitle);
- kcdb_identity_get_name(d->nc->identities[0], wtitle, &cbsize);
-
- if (d->nc->subtype == KMSG_CRED_PASSWORD)
- LoadString(khm_hInstance, IDS_WTPOST_PASSWORD,
- wpostfix, (int) ARRAYLENGTH(wpostfix));
- else
- LoadString(khm_hInstance, IDS_WTPOST_NEW_CREDS,
- wpostfix, (int) ARRAYLENGTH(wpostfix));
-
- StringCbCat(wtitle, sizeof(wtitle), wpostfix);
-
- SetWindowText(d->nc->hwnd, wtitle);
- } else {
- wchar_t wtitle[256];
-
- if (d->nc->subtype == KMSG_CRED_PASSWORD)
- LoadString(khm_hInstance, IDS_WT_PASSWORD,
- wtitle, (int) ARRAYLENGTH(wtitle));
- else
- LoadString(khm_hInstance, IDS_WT_NEW_CREDS,
- wtitle, (int) ARRAYLENGTH(wtitle));
-
- SetWindowText(d->nc->hwnd, wtitle);
- }
- }
-
- if (!(d->nc->response & KHUI_NC_RESPONSE_PROCESSING)) {
- if(validId ||
- d->nc->subtype == KMSG_CRED_PASSWORD) {
- /* TODO: check if all the required fields have valid values
- before enabling the Ok button */
- okEnable = TRUE;
- }
-
- hw = GetDlgItem(d->dlg_main, IDOK);
- EnableWindow(hw, okEnable);
- hw = GetDlgItem(d->dlg_bb, IDOK);
- EnableWindow(hw, okEnable);
- }
-}
-
-static void
-nc_layout_new_cred_window(khui_nc_wnd_data * ncd) {
- khui_new_creds * c;
- RECT r_main;
- RECT r_ncdialog;
- HDWP hdefer;
-
- c = ncd->nc;
-
- r_main.left = 0;
- r_main.top = 0;
- r_main.right = NCDLG_WIDTH;
- r_main.bottom = NCDLG_HEIGHT;
-
- MapDialogRect(ncd->dlg_main, &r_main);
-
- hdefer = BeginDeferWindowPos(5);
-
- if (c->mode == KHUI_NC_MODE_MINI) {
-
- if (IsWindowVisible(ncd->tab_wnd)) {
- DeferWindowPos(hdefer,
- ncd->tab_wnd, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW |
- SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOSIZE | SWP_NOZORDER);
- }
-
- if (IsWindowVisible(ncd->dlg_bb)) {
- DeferWindowPos(hdefer,
- ncd->dlg_bb, NULL,
- 0, 0, 0, 0,
- SWP_HIDEWINDOW |
- SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOSIZE | SWP_NOZORDER);
- }
-
- DeferWindowPos(hdefer, ncd->dlg_main, NULL,
- r_main.left, r_main.top,
- r_main.right - r_main.left,
- r_main.bottom - r_main.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_SHOWWINDOW);
-
- /* note that the ncd->r_main.bottom may not be the same as
- r_main.bottom because ncd->r_main.bottom is set dynamically
- depending on custom controls. ncd->r_main is valid only
- once nc_layout_main_panel() is called.*/
- CopyRect(&ncd->r_required, &ncd->r_main);
-
- } else {
- RECT r_tabctrl;
- RECT r_displayarea;
- RECT r_bbar;
- khm_size i;
-
- /* calculate the size of the tab control so that it fits
- snugly around the expanded main panel. */
- CopyRect(&r_tabctrl, &r_main);
- TabCtrl_AdjustRect(ncd->tab_wnd, TRUE, &r_tabctrl);
-
- if (r_tabctrl.left < 0 ||
- r_tabctrl.top < 0) {
-
- OffsetRect(&r_tabctrl,
- (r_tabctrl.left < 0)? -r_tabctrl.left : 0,
- (r_tabctrl.top < 0)? -r_tabctrl.top : 0);
-
- }
-
-#ifdef DEBUG
- assert(r_tabctrl.left == 0);
- assert(r_tabctrl.top == 0);
-#endif
-
- OffsetRect(&r_tabctrl, 0, ncd->r_area.top);
-
- /* and now calculate the rectangle where the main panel should
- be inside the tab control. */
- CopyRect(&r_displayarea, &r_tabctrl);
- TabCtrl_AdjustRect(ncd->tab_wnd, FALSE, &r_displayarea);
-
- DeferWindowPos(hdefer,
- ncd->tab_wnd, HWND_BOTTOM,
- r_tabctrl.left, r_tabctrl.top,
- r_tabctrl.right - r_tabctrl.left,
- r_tabctrl.bottom - r_tabctrl.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_SHOWWINDOW);
-
- /* we have to place the button bar just to the right of the
- tab panel. */
- r_bbar.left = 0;
- r_bbar.top = 0;
- r_bbar.right = NCDLG_BBAR_WIDTH;
- r_bbar.bottom = NCDLG_BBAR_HEIGHT;
-
- MapDialogRect(ncd->dlg_main, &r_bbar);
-
- OffsetRect(&r_bbar, r_tabctrl.right, 0);
-
- DeferWindowPos(hdefer,
- ncd->dlg_bb, NULL,
- r_bbar.left, r_bbar.top,
- r_bbar.right - r_bbar.left,
- r_bbar.bottom - r_bbar.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER | SWP_SHOWWINDOW);
-
- /* move the main panel inside the tab control... */
- DeferWindowPos(hdefer,
- ncd->dlg_main, NULL,
- r_displayarea.left, r_displayarea.top,
- r_displayarea.right - r_displayarea.left,
- r_displayarea.bottom - r_displayarea.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER |
- (ncd->current_panel == 0 ? SWP_SHOWWINDOW : SWP_HIDEWINDOW));
-
- /* and also move all the credential type panels (if they have
- been created) inside the tab control too. */
- khui_cw_lock_nc(c);
-
- for (i=0; i < c->n_types; i++) {
- if (c->types[i]->hwnd_panel != NULL) {
- DeferWindowPos(hdefer,
- c->types[i]->hwnd_panel, NULL,
- r_displayarea.left, r_displayarea.top,
- r_displayarea.right - r_displayarea.left,
- r_displayarea.bottom - r_displayarea.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER |
- (ncd->current_panel == c->types[i]->ordinal ?
- SWP_SHOWWINDOW : SWP_HIDEWINDOW));
- }
- }
-
- khui_cw_unlock_nc(c);
-
- /* then update the required size of the new credentials
- dialog. */
- ncd->r_required.left = 0;
- ncd->r_required.top = 0;
- ncd->r_required.right = r_bbar.right;
- ncd->r_required.bottom = max(r_tabctrl.bottom, r_bbar.bottom) + ncd->r_area.top;
- }
-
- /* commit all the window moves, resizes and hides/shows we did*/
- EndDeferWindowPos(hdefer);
-
- /* now we have to see if the client area of the new credentials
- window is the right size. */
-
- GetClientRect(c->hwnd, &r_ncdialog);
-
- if (
-
- ((r_ncdialog.right - r_ncdialog.left !=
- ncd->r_required.right - ncd->r_required.left)
-
- ||
-
- (r_ncdialog.bottom - r_ncdialog.top !=
- ncd->r_required.bottom - ncd->r_required.top))
-
- &&
-
- /* we don't bother if the new creds window is already in the
- process of changing the size. */
- !ncd->size_changing) {
-
- /* if not, notify the window that the size needs adjusting. */
- if (IsWindowVisible(c->hwnd))
- PostMessage(c->hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_UPDATE_LAYOUT), 0);
- else
- SendMessage(c->hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_UPDATE_LAYOUT), 0);
- }
-}
-
-#define CW_PARAM DWLP_USER
-
-static LRESULT
-nc_handle_wm_create(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- LPCREATESTRUCT lpc;
- khui_new_creds * c;
- khui_nc_wnd_data * ncd;
- int x, y;
- int width, height;
- RECT r;
- HFONT hf_main;
-
- lpc = (LPCREATESTRUCT) lParam;
-
- ncd = PMALLOC(sizeof(*ncd));
- ZeroMemory(ncd, sizeof(*ncd));
-
- c = (khui_new_creds *) lpc->lpCreateParams;
- ncd->nc = c;
- c->hwnd = hwnd;
-
-#ifdef DEBUG
- assert(c->subtype == KMSG_CRED_NEW_CREDS ||
- c->subtype == KMSG_CRED_PASSWORD);
-#endif
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, CW_PARAM, (LONG_PTR) ncd);
-#pragma warning(pop)
-
- /* first, create the tab control that will house the main dialog
- panel as well as the plug-in specific panels */
- ncd->tab_wnd = CreateWindowEx(0, /* extended style */
- WC_TABCONTROL,
- L"TabControloxxrz", /* window name */
- TCS_HOTTRACK | TCS_RAGGEDRIGHT |
- TCS_SINGLELINE | TCS_TABS |
- WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS,
- 0, 0, 100, 100, /* x,y,width height.
- We'll be changing
- these later
- anyway. */
- hwnd,
- (HMENU) IDC_NC_TABS,
- NULL,
- 0);
-
-#ifdef DEBUG
- assert(ncd->tab_wnd != NULL);
-#endif
-
- /* try to create the main dialog panel */
-
- ncd->dlg_main = CreateDialogParam(khm_hInstance,
- MAKEINTRESOURCE(IDD_NC_NEWCRED),
- hwnd,
- nc_common_dlg_proc,
- (LPARAM) ncd);
-#ifdef DEBUG
- assert(ncd->dlg_main != NULL);
-#endif
-
- hf_main = (HFONT) SendMessage(ncd->dlg_main, WM_GETFONT, 0, 0);
- if (hf_main)
- SendMessage(ncd->tab_wnd, WM_SETFONT, (WPARAM) hf_main, FALSE);
-
-#if _WIN32_WINNT >= 0x0501
- EnableThemeDialogTexture(ncd->dlg_main,
- ETDT_ENABLETAB);
-#endif
-
- {
- RECT r_main;
- RECT r_area;
- RECT r_row;
- HWND hw;
-
- /* During the operation of the new credentials window, we will
- need to dynamically change the layout of the controls as a
- result of custom prompting from credentials providers and
- identity selectors from identity providers. In order to
- guide the dynamic layout, we pick out a few metrics from
- the dialog template for the main panel. The metrics come
- from hidden STATIC controls in the dialog template. */
-
- GetWindowRect(ncd->dlg_main, &r_main);
-
- /* IDC_NC_TPL_PANEL spans the full extent of the dialog that
- we can populate with custom controls. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_PANEL);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r_area);
- OffsetRect(&r_area,-r_main.left, -r_main.top);
- CopyRect(&ncd->r_area, &r_area);
-
- /* IDC_NC_TPL_ROW spans the extent of a row of normal sized
- custom controls. A row of custom controls typicall consist
- of a text label and an input control. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_ROW);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r);
- CopyRect(&r_row, &r);
- OffsetRect(&r,-r.left, -r.top);
- CopyRect(&ncd->r_row, &r);
-
- /* IDC_NC_TPL_LABEL spans the extent that a normal sized
- label. The control overlaps IDC_NC_TPL_ROW so we can get
- coordinates relative to the row extents. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_LABEL);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r);
- OffsetRect(&r,-r_row.left, -r_row.top);
- CopyRect(&ncd->r_n_label, &r);
-
- /* IDC_NC_TPL_INPUT spans the extent of a normal sized input
- control in a custom control row. The control overlaps
- IDC_NC_TPL_ROW so we can get relative coordinates. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_INPUT);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r);
- OffsetRect(&r, -r_row.left, -r_row.top);
- CopyRect(&ncd->r_n_input, &r);
-
- /* IDC_NC_TPL_ROW_LG spans the extent of a row of large sized
- controls. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_ROW_LG);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r_row);
-
- /* IDC_NC_TPL_LABEL_LG is a large sized label. The control
- overlaps IDC_NC_TPL_ROW_LG. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_LABEL_LG);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r);
- OffsetRect(&r, -r_row.left, -r_row.top);
- CopyRect(&ncd->r_e_label, &r);
-
- /* IDC_NC_TPL_INPUT_LG is a large sized input control.
- Overlaps IDC_NC_TPL_ROW_LG. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_TPL_INPUT_LG);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r);
- OffsetRect(&r, -r_row.left, -r_row.top);
- CopyRect(&ncd->r_e_input, &r);
-
- CopyRect(&ncd->r_credtext, &ncd->r_area);
- CopyRect(&ncd->r_idspec, &ncd->r_area);
-
- ncd->r_idspec.bottom = ncd->r_idspec.top;
-
- /* And finally the credential text window. The only metric we
- take from here is the Y coordinate of the bottom of the
- control since the actual size and position of the
- credentials window will change depending on the custom
- controls being displayed. */
- hw = GetDlgItem(ncd->dlg_main, IDC_NC_CREDTEXT);
-#ifdef DEBUG
- assert(hw);
-#endif
- GetWindowRect(hw, &r);
- OffsetRect(&r, -r_main.left, -r_main.top);
- ncd->r_credtext.bottom = r.bottom;
- }
-
- /* if the mode is 'mini'*/
- r.left = 0;
- r.top = 0;
-
- if(c->mode == KHUI_NC_MODE_MINI) {
- r.right = NCDLG_WIDTH;
- r.bottom = NCDLG_HEIGHT;
- } else {
- r.right = NCDLG_WIDTH + NCDLG_BBAR_WIDTH;
- r.bottom = NCDLG_BBAR_HEIGHT;
- }
-
- MapDialogRect(ncd->dlg_main, &r);
-
- /* position the new credentials dialog */
- width = r.right - r.left;
- height = r.bottom - r.top;
-
- /* adjust width and height to accomodate NC area */
- {
- RECT wr,cr;
-
- GetWindowRect(hwnd, &wr);
- GetClientRect(hwnd, &cr);
-
- /* the non-client and client areas have already been calculated
- at this point. We just use the difference to adjust the width
- and height */
- width += (wr.right - wr.left) - (cr.right - cr.left);
- height += (wr.bottom - wr.top) - (cr.bottom - cr.top);
- }
-
- /* if the parent window is visible, we center the new credentials
- dialog over the parent. Otherwise, we center it on the primary
- display. */
-
- if (IsWindowVisible(lpc->hwndParent)) {
- GetWindowRect(lpc->hwndParent, &r);
- } else {
- if(!SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID) &r, 0)) {
- /* failover to the window coordinates */
- GetWindowRect(lpc->hwndParent, &r);
- }
- }
- x = (r.right + r.left)/2 - width / 2;
- y = (r.top + r.bottom)/2 - height / 2;
-
- /* we want to check if the entire rect is visible on the screen.
- If the main window is visible and in basic mode, we might end
- up with a rect that is partially outside the screen. */
- {
- RECT r;
-
- SetRect(&r, x, y, x + width, y + height);
- khm_adjust_window_dimensions_for_display(&r, 0);
-
- x = r.left;
- y = r.top;
- width = r.right - r.left;
- height = r.bottom - r.top;
- }
-
- MoveWindow(hwnd, x, y, width, height, FALSE);
-
- ncd->dlg_bb = CreateDialogParam(khm_hInstance,
- MAKEINTRESOURCE(IDD_NC_BBAR),
- hwnd,
- nc_common_dlg_proc,
- (LPARAM) ncd);
-
-#ifdef DEBUG
- assert(ncd->dlg_bb);
-#endif
-
- /* Call the identity provider callback to set the identity
- selector controls. These controls need to be there before we
- layout the main panel. */
- c->ident_cb(c, WMNC_IDENT_INIT, NULL, 0, 0, (LPARAM) ncd->dlg_main);
-
- if (c->mode == KHUI_NC_MODE_EXPANDED) {
- SendMessage(ncd->dlg_main, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_EXPAND), 0);
- } else {
- /* we don't call nc_layout_main_panel() if the dialog is
- expanded because posting WMNC_DIALOG_EXPAND to the main
- panel results in it getting called anyway. */
- nc_layout_main_panel(ncd);
- }
-
- nc_layout_new_cred_window(ncd);
-
- /* add this to the dialog chain */
- khm_add_dialog(hwnd);
-
- return TRUE;
-}
-
-/* add a control row supplied by an identity provider */
-static void
-nc_add_control_row(khui_nc_wnd_data * d,
- HWND label,
- HWND input,
- khui_control_size size)
-{
- RECT r_row;
- RECT r_label;
- RECT r_input;
- HFONT hf;
- HDWP hdefer;
-
- hf = (HFONT) SendMessage(d->dlg_main, WM_GETFONT, 0, 0);
- SendMessage(label, WM_SETFONT, (WPARAM) hf, FALSE);
- SendMessage(input, WM_SETFONT, (WPARAM) hf, FALSE);
-
- CopyRect(&r_row, &d->r_row);
- OffsetRect(&r_row, d->r_idspec.left, d->r_idspec.bottom);
-
- if (size == KHUI_CTRLSIZE_SMALL) {
- CopyRect(&r_label, &d->r_n_label);
- CopyRect(&r_input, &d->r_n_input);
- OffsetRect(&r_label, r_row.left, r_row.top);
- OffsetRect(&r_input, r_row.left, r_row.top);
- } else if (size == KHUI_CTRLSIZE_HALF) {
- CopyRect(&r_label, &d->r_e_label);
- CopyRect(&r_input, &d->r_e_input);
- OffsetRect(&r_label, r_row.left, r_row.top);
- OffsetRect(&r_input, r_row.left, r_row.top);
- } else if (size == KHUI_CTRLSIZE_FULL) {
- CopyRect(&r_label, &d->r_n_label);
- r_label.right = d->r_row.right;
- CopyRect(&r_input, &d->r_n_input);
- OffsetRect(&r_input, r_row.left, r_row.top);
- OffsetRect(&r_input, 0, r_input.bottom);
- r_row.bottom += r_input.bottom;
- OffsetRect(&r_label, r_row.left, r_row.top);
- } else {
- SetRectEmpty(&r_label);
- SetRectEmpty(&r_input);
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- hdefer = BeginDeferWindowPos(2);
-
- if (label)
- DeferWindowPos(hdefer, label,
- ((d->hwnd_last_idspec != NULL)?
- d->hwnd_last_idspec:
- HWND_TOP),
- r_label.left, r_label.top,
- r_label.right - r_label.left,
- r_label.bottom - r_label.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER);
-
- if (input)
- DeferWindowPos(hdefer, input,
- (label ? label : ((d->hwnd_last_idspec != NULL)?
- d->hwnd_last_idspec:
- HWND_TOP)),
- r_input.left, r_input.top,
- r_input.right - r_input.left,
- r_input.bottom - r_input.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER);
-
- EndDeferWindowPos(hdefer);
-
- d->hwnd_last_idspec = (input ? input : label);
-
- d->r_idspec.bottom = r_row.bottom;
-
- /* we don't update the layout of the main panel yet, since these
- control additions happen before the main panel is displayed. A
- call to nc_layout_main_panel() will be made before the main
- panel is shown anyway. */
-
-}
-
-
-static LRESULT
-nc_handle_wm_destroy(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- khui_nc_wnd_data * d;
-
- /* remove self from dialog chain */
- khm_del_dialog(hwnd);
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return TRUE;
-
- d->nc->ident_cb(d->nc, WMNC_IDENT_EXIT, NULL, 0, 0, 0);
-
- if (d->hwnd_notif_label)
- DestroyWindow(d->hwnd_notif_label);
- if (d->hwnd_notif_aux)
- DestroyWindow(d->hwnd_notif_aux);
-
- if(d->dlg_bb)
- DestroyWindow(d->dlg_bb);
- if(d->dlg_main)
- DestroyWindow(d->dlg_main);
-
- d->dlg_bb = NULL;
- d->dlg_main = NULL;
-
- PFREE(d);
- SetWindowLongPtr(hwnd, CW_PARAM, 0);
-
- return TRUE;
-}
-
-static LRESULT
-nc_handle_wm_command(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return 0;
-
- switch(HIWORD(wParam)) {
- case BN_CLICKED:
- switch(LOWORD(wParam)) {
-
- case IDOK:
- d->nc->result = KHUI_NC_RESULT_PROCESS;
-
- /* fallthrough */
-
- case IDCANCEL:
- /* the default value for d->nc->result is set to
- KHUI_NC_RESULT_CANCEL */
- d->nc->response = KHUI_NC_RESPONSE_PROCESSING;
-
- nc_enable_controls(d, FALSE);
-
- nc_notify_types(d->nc,
- KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0,WMNC_DIALOG_PREPROCESS),
- (LPARAM) d->nc,
- TRUE);
-
- khui_cw_sync_prompt_values(d->nc);
-
- khm_cred_dispatch_process_message(d->nc);
-
- /* we won't know whether to abort or not until we get
- feedback from the plugins, even if the command was
- to cancel */
- {
- HWND hw;
-
- hw = GetDlgItem(d->dlg_main, IDOK);
- EnableWindow(hw, FALSE);
- hw = GetDlgItem(d->dlg_main, IDCANCEL);
- EnableWindow(hw, FALSE);
- hw = GetDlgItem(d->dlg_main, IDC_NC_ADVANCED);
- EnableWindow(hw, FALSE);
- hw = GetDlgItem(d->dlg_bb, IDOK);
- EnableWindow(hw, FALSE);
- hw = GetDlgItem(d->dlg_bb, IDCANCEL);
- EnableWindow(hw, FALSE);
- }
- return FALSE;
-
- case IDC_NC_HELP:
- khm_html_help(hwnd, NULL, HH_HELP_CONTEXT, IDH_ACTION_NEW_ID);
- return FALSE;
-
- case IDC_NC_BASIC:
- case IDC_NC_ADVANCED:
- /* the Options button in the main window was clicked. we
- respond by expanding the dialog. */
- PostMessage(hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_EXPAND), 0);
- return FALSE;
-
- case IDC_NC_CREDTEXT: /* credtext link activated */
- {
- khui_htwnd_link * l;
- wchar_t sid[KHUI_MAXCCH_HTLINK_FIELD];
- wchar_t sparam[KHUI_MAXCCH_HTLINK_FIELD];
- wchar_t * colon;
-
- l = (khui_htwnd_link *) lParam;
-
- /* do we have a valid link? */
- if(l->id == NULL || l->id_len >= ARRAYLENGTH(sid))
- return TRUE; /* nope */
-
- StringCchCopyN(sid, ARRAYLENGTH(sid), l->id, l->id_len);
- sid[l->id_len] = L'\0'; /* just make sure */
-
- if(l->param != NULL &&
- l->param_len < ARRAYLENGTH(sparam) &&
- l->param_len > 0) {
-
- StringCchCopyN(sparam, ARRAYLENGTH(sparam),
- l->param, l->param_len);
- sparam[l->param_len] = L'\0';
-
- } else {
- sparam[0] = L'\0';
- }
-
- /* If the ID is of the form '<credtype>:<link_tag>'
- and <credtype> is a valid name of a credentials
- type that is participating in the credentials
- acquisition process, then we forward the message to
- the panel that is providing the UI for that cred
- type. We also switch to that panel first, unless
- the link is of the form '<credtype>:!<link_tag>'. */
-
- colon = wcschr(sid, L':');
- if (colon != NULL) {
- khm_int32 credtype;
- khui_new_creds_by_type * t;
-
- *colon = L'\0';
- if (KHM_SUCCEEDED(kcdb_credtype_get_id(sid, &credtype)) &&
- KHM_SUCCEEDED(khui_cw_find_type(d->nc, credtype, &t))){
- *colon = L':';
-
- if (t->ordinal != d->current_panel &&
- *(colon + 1) != L'!')
- PostMessage(hwnd,
- KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(t->ordinal,
- WMNC_DIALOG_SWITCH_PANEL),
- 0);
-
- return SendMessage(t->hwnd_panel,
- KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_CREDTEXT_LINK),
- lParam);
- } else {
- *colon = L':';
- }
- }
-
- /* if it was for us, then we need to process the message */
- if(!_wcsicmp(sid, CTLINKID_SWITCH_PANEL)) {
- khm_int32 credtype;
- khui_new_creds_by_type * t;
-
- if (KHM_SUCCEEDED(kcdb_credtype_get_id(sparam,
- &credtype)) &&
- KHM_SUCCEEDED(khui_cw_find_type(d->nc,
- credtype, &t))) {
- if (t->ordinal != d->current_panel)
- PostMessage(hwnd,
- KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(t->ordinal,
- WMNC_DIALOG_SWITCH_PANEL),
- 0);
- }
- } else if (!_wcsicmp(sid, L"NotDef")) {
- d->nc->set_default = FALSE;
- nc_update_credtext(d);
- } else if (!_wcsicmp(sid, L"MakeDef")) {
- d->nc->set_default = TRUE;
- nc_update_credtext(d);
- }
- }
- return FALSE;
-
-#if 0
- case NC_BN_SET_DEF_ID:
- {
- d->nc->set_default =
- (IsDlgButtonChecked(d->dlg_main, NC_BN_SET_DEF_ID)
- == BST_CHECKED);
- }
- return FALSE;
-#endif
- }
- break;
- }
-
- return TRUE;
-}
-
-static LRESULT nc_handle_wm_moving(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return FALSE;
-
- nc_notify_types(d->nc, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_MOVE), (LPARAM) d->nc, TRUE);
-
- return FALSE;
-}
-
-static LRESULT nc_handle_wm_nc_notify(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- khui_nc_wnd_data * d;
- int id;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return FALSE;
-
- switch(HIWORD(wParam)) {
-
- case WMNC_DIALOG_SWITCH_PANEL:
- id = LOWORD(wParam);
- if(id >= 0 && id <= (int) d->nc->n_types) {
- /* one of the tab buttons were pressed */
- if(d->current_panel == id) {
- return TRUE; /* nothing to do */
- }
-
- d->current_panel = id;
-
- TabCtrl_SetCurSel(d->tab_wnd, id);
- }
-
- if(d->nc->mode == KHUI_NC_MODE_EXPANDED) {
- nc_layout_new_cred_window(d);
- return TRUE;
- }
- /*else*/
- /* fallthrough */
-
- case WMNC_DIALOG_EXPAND:
- /* we are switching from basic to advanced or vice versa */
-
- if (d->nc->mode == KHUI_NC_MODE_EXPANDED) {
-
- if (d->current_panel != 0) {
- d->current_panel = 0;
- TabCtrl_SetCurSel(d->tab_wnd, 0);
- nc_layout_new_cred_window(d);
- }
-
- d->nc->mode = KHUI_NC_MODE_MINI;
- } else {
- d->nc->mode = KHUI_NC_MODE_EXPANDED;
- }
-
- /* if we are switching to the advanced mode, we clear any
- notifications because we now have a credential text area
- for that. */
- if (d->nc->mode == KHUI_NC_MODE_EXPANDED)
- nc_notify_clear(d);
-
- nc_layout_main_panel(d);
-
- nc_layout_new_cred_window(d);
-
- break;
-
- case WMNC_DIALOG_SETUP:
-
- if(d->nc->n_types > 0) {
- khm_size i;
- for(i=0; i < d->nc->n_types;i++) {
-
- if (d->nc->types[i]->dlg_proc == NULL) {
- d->nc->types[i]->hwnd_panel = NULL;
- } else {
- /* Create the dialog panel */
- d->nc->types[i]->hwnd_panel =
- CreateDialogParam(d->nc->types[i]->h_module,
- d->nc->types[i]->dlg_template,
- d->nc->hwnd,
- d->nc->types[i]->dlg_proc,
- (LPARAM) d->nc);
-
-#ifdef DEBUG
- assert(d->nc->types[i]->hwnd_panel);
-#endif
-#if _WIN32_WINNT >= 0x0501
- if (d->nc->types[i]->hwnd_panel) {
- EnableThemeDialogTexture(d->nc->types[i]->hwnd_panel,
- ETDT_ENABLETAB);
- }
-#endif
- }
- }
- }
-
- break;
-
- case WMNC_DIALOG_ACTIVATE:
- {
- wchar_t wname[KCDB_MAXCCH_NAME];
- TCITEM tabitem;
- khm_int32 t;
-
- /* About to activate the window. We should add all the
- panels to the tab control. */
-
-#ifdef DEBUG
- assert(d->tab_wnd != NULL);
-#endif
-
- ZeroMemory(&tabitem, sizeof(tabitem));
-
- tabitem.mask = TCIF_PARAM | TCIF_TEXT;
-
- LoadString(khm_hInstance, IDS_NC_IDENTITY,
- wname, ARRAYLENGTH(wname));
-
- tabitem.pszText = wname;
- tabitem.lParam = 0; /* ordinal */
-
- TabCtrl_InsertItem(d->tab_wnd, 0, &tabitem);
-
- khui_cw_lock_nc(d->nc);
-
- if(d->nc->n_types > 0) {
- khm_size i;
-
- /* We should sort the tabs first. See
- nc_tab_sort_func() for sort criteria. */
- qsort(d->nc->types,
- d->nc->n_types,
- sizeof(*(d->nc->types)),
- nc_tab_sort_func);
-
- for(i=0; i < d->nc->n_types;i++) {
-
- d->nc->types[i]->ordinal = i + 1;
-
- if(d->nc->types[i]->name)
- tabitem.pszText = d->nc->types[i]->name;
- else {
- khm_size cbsize;
-
- cbsize = sizeof(wname);
-
- if(KHM_FAILED
- (kcdb_credtype_describe
- (d->nc->types[i]->type,
- wname,
- &cbsize,
- KCDB_TS_SHORT))) {
-
-#ifdef DEBUG
- assert(FALSE);
-#endif
- wname[0] = L'\0';
-
- }
-
- tabitem.pszText = wname;
-
- }
-
- tabitem.lParam = d->nc->types[i]->ordinal;
-
- TabCtrl_InsertItem(d->tab_wnd, d->nc->types[i]->ordinal,
- &tabitem);
- }
- }
-
- khui_cw_unlock_nc(d->nc);
-
- nc_update_credtext(d);
-
- TabCtrl_SetCurSel(d->tab_wnd, 0); /* the first selected
- tab is the main
- panel. */
-
- /* we don't enable animations until a specific timeout
- elapses after showing the window. We don't need to
- animate any size changes if the user has barely had a
- chance to notice the original size. This prevents the
- new cred window from appearing in an animated state. */
- SetTimer(hwnd, NC_TIMER_ENABLEANIMATE, ENABLEANIMATE_TIMEOUT, NULL);
-
- ShowWindow(hwnd, SW_SHOWNORMAL);
-
- /* bring the window to the top, if necessary */
- if (KHM_SUCCEEDED(khc_read_int32(NULL,
- L"CredWindow\\Windows\\NewCred\\ForceToTop",
- &t)) &&
-
- t != 0) {
-
- BOOL sfw = FALSE;
-
- /* it used to be that the above condition also called
- !khm_is_dialog_active() to find out whether there
- was a dialog active. If there was, we wouldn't try
- to bring the new cred window to the foreground. But
- that was not the behavior we want. */
-
- /* if the main window is not visible, then the SetWindowPos()
- call is sufficient to bring the new creds window to the
- top. However, if the main window is visible but not
- active, the main window needs to be activated before a
- child window can be activated. */
-
- SetActiveWindow(hwnd);
-
- sfw = SetForegroundWindow(hwnd);
-
- if (!sfw) {
- FLASHWINFO fi;
-
- ZeroMemory(&fi, sizeof(fi));
-
- fi.cbSize = sizeof(fi);
- fi.hwnd = hwnd;
- fi.dwFlags = FLASHW_ALL;
- fi.uCount = 3;
- fi.dwTimeout = 0; /* use the default cursor blink rate */
-
- FlashWindowEx(&fi);
-
- d->flashing_enabled = TRUE;
- }
-
- } else {
- SetFocus(hwnd);
- }
-
- if (d->nc->n_identities == 0)
- break;
- /* else */
- /* fallthrough */
- }
-
- case WMNC_IDENTITY_CHANGE:
- {
- BOOL okEnable = FALSE;
-
- nc_notify_types(d->nc, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_IDENTITY_CHANGE), (LPARAM) d->nc,
- TRUE);
-
- if (d->nc->subtype == KMSG_CRED_NEW_CREDS &&
- d->nc->n_identities > 0 &&
- d->nc->identities[0]) {
- khm_int32 f = 0;
-
- kcdb_identity_get_flags(d->nc->identities[0], &f);
-
- if (!(f & KCDB_IDENT_FLAG_DEFAULT)) {
- d->nc->set_default = FALSE;
- }
- }
-
- nc_update_credtext(d);
-
- }
- break;
-
- case WMNC_TYPE_STATE:
- /* fallthrough */
- case WMNC_UPDATE_CREDTEXT:
- nc_update_credtext(d);
- break;
-
- case WMNC_CLEAR_PROMPTS:
- {
- khm_size i;
-
- khui_cw_lock_nc(d->nc);
-
- if(d->hwnd_banner != NULL) {
- DestroyWindow(d->hwnd_banner);
- d->hwnd_banner = NULL;
- }
-
- if(d->hwnd_name != NULL) {
- DestroyWindow(d->hwnd_name);
- d->hwnd_name = NULL;
- }
-
- for(i=0;i<d->nc->n_prompts;i++) {
- if(!(d->nc->prompts[i]->flags &
- KHUI_NCPROMPT_FLAG_STOCK)) {
- if(d->nc->prompts[i]->hwnd_static != NULL)
- DestroyWindow(d->nc->prompts[i]->hwnd_static);
-
- if(d->nc->prompts[i]->hwnd_edit != NULL)
- DestroyWindow(d->nc->prompts[i]->hwnd_edit);
- }
-
- d->nc->prompts[i]->hwnd_static = NULL;
- d->nc->prompts[i]->hwnd_edit = NULL;
- }
-
- khui_cw_unlock_nc(d->nc);
-
- SetRectEmpty(&d->r_custprompt);
-
- nc_layout_main_panel(d);
-
- nc_layout_new_cred_window(d);
- }
- break;
-
- case WMNC_SET_PROMPTS:
- {
- khm_size i;
- int y;
- HWND hw, hw_prev;
- HFONT hf, hfold;
- HDC hdc;
- BOOL use_large_lables = FALSE;
-
- /* we assume that WMNC_CLEAR_PROMPTS has already been
- received */
-
-#ifdef DEBUG
- assert(IsRectEmpty(&d->r_custprompt));
-#endif
-
- khui_cw_lock_nc(d->nc);
-
-#if 0
- /* special case, we have one prompt and it is a password
- prompt. very common */
- if(d->nc->n_prompts == 1 &&
- d->nc->prompts[0]->type == KHUI_NCPROMPT_TYPE_PASSWORD) {
-
- hw = GetDlgItem(d->dlg_main, IDC_NC_PASSWORD);
- EnableWindow(hw, TRUE);
-
- d->nc->prompts[0]->flags |= KHUI_NCPROMPT_FLAG_STOCK;
- d->nc->prompts[0]->hwnd_edit = hw;
- d->nc->prompts[0]->hwnd_static = NULL; /* don't care */
-
- khui_cw_unlock_nc(d->nc);
- break;
- }
-#endif
- /* for everything else */
-
- y = d->r_idspec.bottom;
-
- d->r_custprompt.left = d->r_area.left;
- d->r_custprompt.right = d->r_area.right;
- d->r_custprompt.top = y;
-
- hf = (HFONT) SendMessage(d->dlg_main, WM_GETFONT, 0, 0);
-
- if (d->nc->pname != NULL) {
- hw =
- CreateWindowEx
- (0,
- L"STATIC",
- d->nc->pname,
- SS_SUNKEN | WS_CHILD,
- d->r_area.left, y,
- d->r_row.right,
- d->r_n_label.bottom - d->r_n_label.top,
- d->dlg_main,
- NULL,
- khm_hInstance,
- NULL);
-
-#ifdef DEBUG
- assert(hw);
-#endif
- d->hwnd_name = hw;
- SendMessage(hw, WM_SETFONT, (WPARAM)hf, (LPARAM) TRUE);
- ShowWindow(hw, SW_SHOW);
-
- y += d->r_n_label.bottom - d->r_n_label.top;
- }
-
- if (d->nc->banner != NULL) {
- hw =
- CreateWindowEx
- (0,
- L"STATIC",
- d->nc->banner,
- WS_CHILD,
- d->r_area.left, y,
- d->r_row.right, d->r_row.bottom,
- d->dlg_main,
- NULL,
- khm_hInstance,
- NULL);
-#ifdef DEBUG
- assert(hw);
-#endif
- d->hwnd_banner = hw;
- SendMessage(hw, WM_SETFONT, (WPARAM)hf, (LPARAM)TRUE);
- ShowWindow(hw, SW_SHOW);
- y += d->r_row.bottom;
- }
-
- hw_prev = d->hwnd_last_idspec;
-
- hdc = GetWindowDC(d->dlg_main);
- hfold = SelectObject(hdc,hf);
-
- /* first do a trial run and see if we should use the
- larger text labels or not. This is so that all the
- labels and input controls align properly. */
- for (i=0; i < d->nc->n_prompts; i++) {
- if (d->nc->prompts[i]->prompt != NULL) {
- SIZE s;
-
- GetTextExtentPoint32(hdc,
- d->nc->prompts[i]->prompt,
- (int) wcslen(d->nc->prompts[i]->prompt),
- &s);
-
- if(s.cx >= d->r_n_label.right - d->r_n_label.left) {
- use_large_lables = TRUE;
- break;
- }
- }
- }
-
- for(i=0; i<d->nc->n_prompts; i++) {
- RECT pr, er;
- SIZE s;
- int dy;
-
- if(d->nc->prompts[i]->prompt != NULL) {
- GetTextExtentPoint32(hdc,
- d->nc->prompts[i]->prompt,
- (int) wcslen(d->nc->prompts[i]->prompt),
- &s);
- if(s.cx < d->r_n_label.right - d->r_n_label.left &&
- !use_large_lables) {
- CopyRect(&pr, &d->r_n_label);
- CopyRect(&er, &d->r_n_input);
- dy = d->r_row.bottom;
- } else if(s.cx <
- d->r_e_label.right - d->r_e_label.left) {
- CopyRect(&pr, &d->r_e_label);
- CopyRect(&er, &d->r_e_input);
- dy = d->r_row.bottom;
- } else {
- /* oops. the prompt doesn't fit in our
- controls. we need to use up two lines */
- pr.left = 0;
- pr.right = d->r_row.right;
- pr.top = 0;
- pr.bottom = d->r_n_label.bottom -
- d->r_n_label.top;
- CopyRect(&er, &d->r_n_input);
- OffsetRect(&er, 0, pr.bottom);
- dy = er.bottom + (d->r_row.bottom -
- d->r_n_input.bottom);
- }
- } else {
- SetRectEmpty(&pr);
- CopyRect(&er, &d->r_n_input);
- dy = d->r_row.bottom;
- }
-
- if(IsRectEmpty(&pr)) {
- d->nc->prompts[i]->hwnd_static = NULL;
- } else {
- OffsetRect(&pr, d->r_area.left, y);
-
- hw = CreateWindowEx
- (0,
- L"STATIC",
- d->nc->prompts[i]->prompt,
- WS_CHILD,
- pr.left, pr.top,
- pr.right - pr.left, pr.bottom - pr.top,
- d->dlg_main,
- NULL,
- khm_hInstance,
- NULL);
-#ifdef DEBUG
- assert(hw);
-#endif
-
- SendMessage(hw, WM_SETFONT,
- (WPARAM) hf, (LPARAM) TRUE);
-
- SetWindowPos(hw, hw_prev,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOOWNERZORDER | SWP_NOSIZE |
- SWP_SHOWWINDOW);
-
- d->nc->prompts[i]->hwnd_static = hw;
- hw_prev = hw;
- }
-
- OffsetRect(&er, d->r_area.left, y);
-
- hw = CreateWindowEx
- (0,
- L"EDIT",
- (d->nc->prompts[i]->def ?
- d->nc->prompts[i]->def : L""),
- WS_CHILD | WS_TABSTOP |
- WS_BORDER | ES_AUTOHSCROLL |
- ((d->nc->prompts[i]->flags &
- KHUI_NCPROMPT_FLAG_HIDDEN)? ES_PASSWORD:0),
- er.left, er.top,
- er.right - er.left, er.bottom - er.top,
- d->dlg_main,
- NULL,
- khm_hInstance,
- NULL);
-
-#ifdef DEBUG
- assert(hw);
-#endif
-
- SendMessage(hw, WM_SETFONT,
- (WPARAM) hf, (LPARAM) TRUE);
-
- SetWindowPos(hw, hw_prev,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOOWNERZORDER | SWP_NOSIZE |
- SWP_SHOWWINDOW);
-
- SendMessage(hw, EM_SETLIMITTEXT,
- KHUI_MAXCCH_PROMPT_VALUE -1,
- 0);
-
- d->nc->prompts[i]->hwnd_edit = hw;
-
- hw_prev = hw;
-
- y += dy;
- }
-
- if (d->nc->n_prompts > 0 &&
- d->nc->prompts[0]->hwnd_edit) {
-
- PostMessage(d->dlg_main, WM_NEXTDLGCTL,
- (WPARAM) d->nc->prompts[0]->hwnd_edit,
- MAKELPARAM(TRUE, 0));
-
- }
-
- SelectObject(hdc, hfold);
- ReleaseDC(d->dlg_main, hdc);
-
- khui_cw_unlock_nc(d->nc);
-
- d->r_custprompt.bottom = y;
-
- if (d->r_custprompt.bottom == d->r_custprompt.top)
- SetRectEmpty(&d->r_custprompt);
-
- nc_layout_main_panel(d);
-
- nc_layout_new_cred_window(d);
- }
- break;
-
- case WMNC_DIALOG_PROCESS_COMPLETE:
- {
- khui_new_creds * nc;
-
- nc = d->nc;
-
- nc->response &= ~KHUI_NC_RESPONSE_PROCESSING;
-
- if(nc->response & KHUI_NC_RESPONSE_NOEXIT) {
- HWND hw;
-
- nc_enable_controls(d, TRUE);
-
- /* reset state */
- nc->result = KHUI_NC_RESULT_CANCEL;
-
- hw = GetDlgItem(d->dlg_main, IDOK);
- EnableWindow(hw, TRUE);
- hw = GetDlgItem(d->dlg_main, IDCANCEL);
- EnableWindow(hw, TRUE);
- hw = GetDlgItem(d->dlg_main, IDC_NC_ADVANCED);
- EnableWindow(hw, TRUE);
- hw = GetDlgItem(d->dlg_bb, IDOK);
- EnableWindow(hw, TRUE);
- hw = GetDlgItem(d->dlg_bb, IDCANCEL);
- EnableWindow(hw, TRUE);
-
- nc_clear_password_fields(d);
-
- return TRUE;
- }
-
- DestroyWindow(hwnd);
-
- kmq_post_message(KMSG_CRED, KMSG_CRED_END, 0, (void *) nc);
- }
- break;
-
- /* MUST be called with SendMessage */
- case WMNC_ADD_CONTROL_ROW:
- {
- khui_control_row * row;
-
- row = (khui_control_row *) lParam;
-
-#ifdef DEBUG
- assert(row->label);
- assert(row->input);
-#endif
-
- nc_add_control_row(d, row->label, row->input, row->size);
- }
- break;
-
- case WMNC_UPDATE_LAYOUT:
- {
-
- RECT r_client;
- khm_int32 animate;
- khm_int32 steps;
- khm_int32 timeout;
-
- /* We are already adjusting the size of the window. The
- next time the timer fires, it will notice if the target
- size has changed. */
- if (d->size_changing)
- return TRUE;
-
- GetClientRect(hwnd, &r_client);
-
- if ((r_client.right - r_client.left ==
- d->r_required.right - d->r_required.left) &&
- (r_client.bottom - r_client.top ==
- d->r_required.bottom - d->r_required.top)) {
-
- /* the window is already at the right size */
- return TRUE;
-
- }
-
- if (!IsWindowVisible(hwnd)) {
- /* The window is not visible yet. There's no need to
- animate anything. */
-
- animate = FALSE;
-
- } else if (KHM_FAILED(khc_read_int32(NULL,
- L"CredWindow\\Windows\\NewCred\\AnimateSizeChanges",
- &animate))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- animate = TRUE;
- }
-
- /* if we aren't animating the window resize, then we just
- do it in one call. */
- if (!animate || !d->animation_enabled) {
- RECT r_window;
-
- CopyRect(&r_window, &d->r_required);
- AdjustWindowRectEx(&r_window, NC_WINDOW_STYLES, FALSE,
- NC_WINDOW_EX_STYLES);
-
- SetWindowPos(hwnd, NULL, 0, 0,
- r_window.right - r_window.left,
- r_window.bottom - r_window.top,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER |
- SWP_NOZORDER);
-
- return TRUE;
- }
-
- if (KHM_FAILED(khc_read_int32(NULL,
- L"CredWindow\\Windows\\NewCred\\AnimationSteps",
- &steps))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- steps = NC_SZ_STEPS_DEF;
- } else {
-
- if (steps < NC_SZ_STEPS_MIN)
- steps = NC_SZ_STEPS_MIN;
- else if (steps > NC_SZ_STEPS_MAX)
- steps = NC_SZ_STEPS_MAX;
-
- }
-
- if (KHM_FAILED(khc_read_int32(NULL,
- L"CredWindow\\Windows\\NewCred\\AnimationStepTimeout",
- &timeout))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- timeout = NC_SZ_TIMEOUT_DEF;
- } else {
-
- if (timeout < NC_SZ_TIMEOUT_MIN)
- timeout = NC_SZ_TIMEOUT_MIN;
- else if (timeout > NC_SZ_TIMEOUT_MAX)
- timeout = NC_SZ_TIMEOUT_MAX;
-
- }
-
- CopyRect(&d->sz_ch_source, &r_client);
- OffsetRect(&d->sz_ch_source, -d->sz_ch_source.left, -d->sz_ch_source.top);
- CopyRect(&d->sz_ch_target, &d->r_required);
- OffsetRect(&d->sz_ch_target, -d->sz_ch_target.left, -d->sz_ch_target.top);
- d->sz_ch_increment = 0;
- d->sz_ch_max = steps;
- d->sz_ch_timeout = timeout;
- d->size_changing = TRUE;
-
- SetTimer(hwnd, NC_TIMER_SIZER, timeout, NULL);
- }
- break;
- } /* switch(HIWORD(wParam)) */
-
- return TRUE;
-}
-
-static LRESULT nc_handle_wm_timer(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return FALSE;
-
- if (wParam == NC_TIMER_SIZER) {
-
- RECT r_now;
-
- /* are we done with this sizing operation? */
- if (!d->size_changing ||
- d->sz_ch_increment >= d->sz_ch_max) {
-
- d->size_changing = FALSE;
- KillTimer(hwnd, NC_TIMER_SIZER);
- return 0;
- }
-
- /* have the requirements changed while we were processing the
- sizing operation? */
- if ((d->r_required.right - d->r_required.left !=
- d->sz_ch_target.right)
-
- ||
-
- (d->r_required.bottom - d->r_required.top !=
- d->sz_ch_target.bottom)) {
-
- /* the target size has changed. we need to restart the
- sizing operation. */
-
- RECT r_client;
-
- GetClientRect(hwnd, &r_client);
-
- CopyRect(&d->sz_ch_source, &r_client);
- OffsetRect(&d->sz_ch_source, -d->sz_ch_source.left, -d->sz_ch_source.top);
- CopyRect(&d->sz_ch_target, &d->r_required);
- OffsetRect(&d->sz_ch_target, -d->sz_ch_target.left, -d->sz_ch_target.top);
- d->sz_ch_increment = 0;
-
- /* leave the other fields alone */
-
-#ifdef DEBUG
- assert(d->sz_ch_max >= NC_SZ_STEPS_MIN);
- assert(d->sz_ch_max <= NC_SZ_STEPS_MAX);
- assert(d->sz_ch_timeout >= NC_SZ_TIMEOUT_MIN);
- assert(d->sz_ch_timeout <= NC_SZ_TIMEOUT_MAX);
- assert(d->size_changing);
-#endif
- }
-
- /* we are going to do the next increment */
- d->sz_ch_increment ++;
-
- /* now, figure out the size of the client area for this
- step */
-
- r_now.left = 0;
- r_now.top = 0;
-
-#define PROPORTION(v1, v2, i, s) (((v1) * ((s) - (i)) + (v2) * (i)) / (s))
-
- r_now.right = PROPORTION(d->sz_ch_source.right, d->sz_ch_target.right,
- d->sz_ch_increment, d->sz_ch_max);
-
- r_now.bottom = PROPORTION(d->sz_ch_source.bottom, d->sz_ch_target.bottom,
- d->sz_ch_increment, d->sz_ch_max);
-
-#undef PROPORTION
-
-#ifdef DEBUG
- {
- long dx = ((r_now.right - r_now.left) - d->sz_ch_target.right) *
- (d->sz_ch_source.right - d->sz_ch_target.right);
-
- long dy = ((r_now.bottom - r_now.top) - d->sz_ch_target.bottom) *
- (d->sz_ch_source.bottom - d->sz_ch_target.bottom);
-
- if (dx < 0 || dy < 0) {
- KillTimer(hwnd, NC_TIMER_SIZER);
- assert(dx >= 0);
- assert(dy >= 0);
- SetTimer(hwnd, NC_TIMER_SIZER, d->sz_ch_timeout, NULL);
- }
- }
-#endif
-
- AdjustWindowRectEx(&r_now, NC_WINDOW_STYLES, FALSE,
- NC_WINDOW_EX_STYLES);
-
- {
- RECT r;
-
- GetWindowRect(hwnd, &r);
- OffsetRect(&r_now, r.left - r_now.left, r.top - r_now.top);
- }
-
- khm_adjust_window_dimensions_for_display(&r_now, 0);
-
- SetWindowPos(hwnd, NULL,
- r_now.left, r_now.top,
- r_now.right - r_now.left,
- r_now.bottom - r_now.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOZORDER);
-
- /* and now we wait for the next timer message */
-
- return 0;
- } else if (wParam == NC_TIMER_ENABLEANIMATE) {
-
- d->animation_enabled = TRUE;
- KillTimer(hwnd, NC_TIMER_ENABLEANIMATE);
- }
-
- return 0;
-}
-
-static LRESULT nc_handle_wm_notify(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- LPNMHDR nmhdr;
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return FALSE;
-
- nmhdr = (LPNMHDR) lParam;
-
- if (nmhdr->code == TCN_SELCHANGE) {
- /* the current tab has changed. */
- int idx;
- TCITEM tcitem;
-
- idx = TabCtrl_GetCurSel(d->tab_wnd);
- ZeroMemory(&tcitem, sizeof(tcitem));
-
- tcitem.mask = TCIF_PARAM;
- TabCtrl_GetItem(d->tab_wnd, idx, &tcitem);
-
- d->current_panel = (int) tcitem.lParam;
-
- nc_layout_new_cred_window(d);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static LRESULT nc_handle_wm_help(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- static DWORD ctxids[] = {
- NC_TS_CTRL_ID_MIN, IDH_NC_TABMAIN,
- NC_TS_CTRL_ID_MIN + 1, IDH_NC_TABBUTTON,
- NC_TS_CTRL_ID_MIN + 2, IDH_NC_TABBUTTON,
- NC_TS_CTRL_ID_MIN + 3, IDH_NC_TABBUTTON,
- NC_TS_CTRL_ID_MIN + 4, IDH_NC_TABBUTTON,
- NC_TS_CTRL_ID_MIN + 5, IDH_NC_TABBUTTON,
- NC_TS_CTRL_ID_MIN + 6, IDH_NC_TABBUTTON,
- NC_TS_CTRL_ID_MIN + 7, IDH_NC_TABBUTTON,
- IDOK, IDH_NC_OK,
- IDCANCEL, IDH_NC_CANCEL,
- IDC_NC_HELP, IDH_NC_HELP,
- IDC_NC_ADVANCED, IDH_NC_ADVANCED,
- IDC_NC_CREDTEXT, IDH_NC_CREDWND,
- 0
- };
-
- HELPINFO * hlp;
- HWND hw = NULL;
- HWND hw_ctrl;
- khui_nc_wnd_data * d;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
- if (d == NULL)
- return FALSE;
-
- hlp = (HELPINFO *) lParam;
-
- if (d->nc->subtype != KMSG_CRED_NEW_CREDS &&
- d->nc->subtype != KMSG_CRED_PASSWORD)
- return TRUE;
-
- if (hlp->iContextType != HELPINFO_WINDOW)
- return TRUE;
-
- if (hlp->hItemHandle != NULL &&
- hlp->hItemHandle != hwnd) {
- DWORD id;
- int i;
-
- hw_ctrl =hlp->hItemHandle;
-
- id = GetWindowLong(hw_ctrl, GWL_ID);
- for (i=0; ctxids[i] != 0; i += 2)
- if (ctxids[i] == id)
- break;
-
- if (ctxids[i] != 0)
- hw = khm_html_help(hw_ctrl,
- ((d->nc->subtype == KMSG_CRED_NEW_CREDS)?
- L"::popups_newcreds.txt":
- L"::popups_password.txt"),
- HH_TP_HELP_WM_HELP,
- (DWORD_PTR) ctxids);
- }
-
- if (hw == NULL) {
- khm_html_help(hwnd, NULL, HH_HELP_CONTEXT,
- ((d->nc->subtype == KMSG_CRED_NEW_CREDS)?
- IDH_ACTION_NEW_ID: IDH_ACTION_PASSWD_ID));
- }
-
- return TRUE;
-}
-
-static LRESULT nc_handle_wm_activate(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
- if (uMsg == WM_MOUSEACTIVATE ||
- wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
-
- FLASHWINFO fi;
- khui_nc_wnd_data * d;
- DWORD_PTR ex_style;
-
- d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM);
-
- if (d && d->flashing_enabled) {
- ZeroMemory(&fi, sizeof(fi));
-
- fi.cbSize = sizeof(fi);
- fi.hwnd = hwnd;
- fi.dwFlags = FLASHW_STOP;
-
- FlashWindowEx(&fi);
-
- d->flashing_enabled = FALSE;
- }
-
- ex_style = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
-
- if (ex_style & WS_EX_TOPMOST) {
- SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
- }
-
- return (uMsg == WM_MOUSEACTIVATE)? MA_ACTIVATE : 0;
-}
-
-static LRESULT CALLBACK nc_window_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch(uMsg) {
- case WM_MOUSEACTIVATE:
- case WM_ACTIVATE:
- return nc_handle_wm_activate(hwnd, uMsg, wParam, lParam);
-
- case WM_CREATE:
- return nc_handle_wm_create(hwnd, uMsg, wParam, lParam);
-
- case WM_DESTROY:
- return nc_handle_wm_destroy(hwnd, uMsg, wParam, lParam);
-
- case WM_COMMAND:
- return nc_handle_wm_command(hwnd, uMsg, wParam, lParam);
-
- case WM_NOTIFY:
- return nc_handle_wm_notify(hwnd, uMsg, wParam, lParam);
-
- case WM_MOVE:
- case WM_MOVING:
- return nc_handle_wm_moving(hwnd, uMsg, wParam, lParam);
-
- case WM_TIMER:
- return nc_handle_wm_timer(hwnd, uMsg, wParam, lParam);
-
- case WM_HELP:
- return nc_handle_wm_help(hwnd, uMsg, wParam, lParam);
-
- case KHUI_WM_NC_NOTIFY:
- return nc_handle_wm_nc_notify(hwnd, uMsg, wParam, lParam);
- }
-
- /* Note that this is technically a dialog box */
- return DefDlgProc(hwnd, uMsg, wParam, lParam);
-}
-
-void khm_register_newcredwnd_class(void)
-{
- WNDCLASSEX wcx;
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = CS_DBLCLKS | CS_OWNDC;
- wcx.lpfnWndProc = nc_window_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = DLGWINDOWEXTRA + sizeof(LONG_PTR);
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wcx.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
- wcx.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_NEWCREDWND_CLASS;
- wcx.hIconSm = NULL;
-
- khui_newcredwnd_cls = RegisterClassEx(&wcx);
-}
-
-void khm_unregister_newcredwnd_class(void)
-{
- UnregisterClass(MAKEINTATOM(khui_newcredwnd_cls), khm_hInstance);
-}
-
-HWND khm_create_newcredwnd(HWND parent, khui_new_creds * c)
-{
- wchar_t wtitle[256];
- HWND hwnd;
- khm_int32 force_topmost = 0;
-
- if (c->window_title == NULL) {
- if (c->subtype == KMSG_CRED_PASSWORD)
- LoadString(khm_hInstance,
- IDS_WT_PASSWORD,
- wtitle,
- ARRAYLENGTH(wtitle));
- else
- LoadString(khm_hInstance,
- IDS_WT_NEW_CREDS,
- wtitle,
- ARRAYLENGTH(wtitle));
- }
-
- khc_read_int32(NULL, L"CredWindow\\Windows\\NewCred\\ForceToTop", &force_topmost);
-
- hwnd = CreateWindowEx(NC_WINDOW_EX_STYLES | (force_topmost ? WS_EX_TOPMOST : 0),
- MAKEINTATOM(khui_newcredwnd_cls),
- ((c->window_title)?c->window_title: wtitle),
- NC_WINDOW_STYLES,
- 0,0,400,400, /* bogus values. the window
- is going to resize and
- reposition itself
- anyway */
- parent,
- NULL,
- khm_hInstance,
- (LPVOID) c);
-
-#ifdef DEBUG
- assert(hwnd != NULL);
-#endif
-
- /* note that the window is not visible yet. That's because, at
- this point we don't know what the panels are */
-
- return hwnd;
-}
-
-void khm_prep_newcredwnd(HWND hwnd)
-{
- SendMessage(hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_SETUP), 0);
-}
-
-void khm_show_newcredwnd(HWND hwnd)
-{
- /* add all the panels in and prep UI */
- PostMessage(hwnd, KHUI_WM_NC_NOTIFY,
- MAKEWPARAM(0, WMNC_DIALOG_ACTIVATE), 0);
-}
diff --git a/src/windows/identity/ui/newcredwnd.h b/src/windows/identity/ui/newcredwnd.h
deleted file mode 100644
index 872cad2ed..000000000
--- a/src/windows/identity/ui/newcredwnd.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_NEWCREDWND_H
-#define __KHIMAIRA_NEWCREDWND_H
-
-#include<khuidefs.h>
-
-#define KHUI_NEWCREDWND_CLASS L"KhmNewCredWnd"
-
-typedef enum tag_nc_notification_types {
- NC_NOTIFY_NONE = 0, /* no notification */
- NC_NOTIFY_MARQUEE, /* marquee type notification */
- NC_NOTIFY_PROGRESS, /* progress notification */
- NC_NOTIFY_MESSAGE, /* a message */
-} nc_notification_type;
-
-typedef struct khui_nc_wnd_data_t {
- khui_new_creds * nc;
-
- /* The tab control */
-
- HWND tab_wnd; /* tab control */
- int current_panel; /* ordinal of the current panel being
- displayed. */
-
- /* The main panel */
- HWND dlg_main; /* main dialog */
- RECT r_main; /* the extent of the main panel that
- we have used so far. The rect
- includes the size of the area used
- by the identity selector controls,
- the custom controls added by
- credentials providers and the
- buttons that may be required when
- in the mini mode. */
- RECT r_required; /* required size of the main window */
-
- /* The button bar */
-
- HWND dlg_bb; /* button bar */
-
- /* Sizing the new credentials window */
-
- BOOL animation_enabled; /* Flag indicating whether animation
- is enabled for the dialg. If this
- flag is off, we don't animate size
- changes even if the configuration
- says so. */
- BOOL size_changing; /* flag indicating that the size of
- the main window is being
- adjusted. */
- RECT sz_ch_source; /* Source size, from which we are
- going towards target size in
- sz_ch_max steps. The RECT is self
- relative (i.e. left=0 and top=0)*/
- RECT sz_ch_target; /* If we are doing an incremental size
- change, this holds the target size
- that we were going for. Note that
- the target size might change while
- we are adjusting the size. So this
- helps keep track of whether we need
- to start the size change again. The
- RECT is self relative (i.e. left=0
- and top=0). */
- int sz_ch_increment; /* Current step of the incremental
- size change operation. */
- int sz_ch_max; /* Max number of steps in the size
- change operation. */
- int sz_ch_timeout; /* Milliseconds between each increment */
-
- BOOL flashing_enabled; /* The window maybe still flashing
- from the last call to
- FlashWindowEx(). */
-
- /* Custom controls and identity specifiers */
-
- HWND hwnd_banner; /* static control for banner */
- HWND hwnd_name; /* static control for name */
-
- HWND hwnd_last_idspec; /* last identity specifier control */
-
- /* Notification windows */
-
- nc_notification_type notif_type; /* Type of notification */
- HWND hwnd_notif_label; /* Label for notifications */
- HWND hwnd_notif_aux; /* Other control for notifications */
-
- /* Areas of the main panel */
-
- RECT r_idspec; /* Area used by identity specifiers
- (relative to client) */
- RECT r_custprompt; /* Area used by custom controls (relative
- to client) */
- RECT r_notif; /* Area used for notifications. */
-
- /* Metrics for custom prompts and identity specifiers */
-
- RECT r_row; /* Metrics for a control row (left=0,
- top=0, right=width, bottom=height) */
- RECT r_area; /* Area available for controls (relative
- to client) */
- RECT r_n_label; /* coords of the static control (relative
- to row) */
- RECT r_n_input; /* coords of the edit control (relative to
- row) */
- RECT r_e_label; /* coords of the extended edit control
- (relative to row) */
- RECT r_e_input; /* coords of the extended edit control
- (relative to row) */
- RECT r_credtext; /* Area for credtext window (relative to
- row) */
-} khui_nc_wnd_data;
-
-void khm_register_newcredwnd_class(void);
-void khm_unregister_newcredwnd_class(void);
-HWND khm_create_newcredwnd(HWND parent, khui_new_creds * c);
-void khm_prep_newcredwnd(HWND hwnd);
-void khm_show_newcredwnd(HWND hwnd);
-
-/* Width of the button bar in dialog units */
-#define NCDLG_BBAR_WIDTH 66
-/* Height of the button bar in dialog units */
-#define NCDLG_BBAR_HEIGHT 190
-
-/* Control identifier for the tab control in the new credentials
- dialog. We declare this here since we will be creating the control
- manually. */
-#define IDC_NC_TABS 8001
-
-/* This is the first control ID that is created in the custom tabstrip
- control buttons. Subsequent buttons get consecutive IDs starting
- from this one. */
-#define NC_TS_CTRL_ID_MIN 8002
-
-/* Maximum number of controls */
-#define NC_TS_MAX_CTRLS 8
-
-/* Maximum control ID */
-#define NC_TS_CTRL_ID_MAX (NC_TS_CTRL_ID_MIN + NC_TS_MAX_CTRLS - 1)
-
-#define NC_BN_SET_DEF_ID 8012
-
-/* the first control ID that may be used by an identity provider */
-#define NC_IS_CTRL_ID_MIN 8016
-
-/* the maximum number of controls that may be created by an identity
- provider*/
-#define NC_IS_CTRL_MAX_CTRLS 8
-
-/* the maximum control ID that may be used by an identity provider */
-#define NC_IS_CTRL_ID_MAX (NC_IS_CTRL_ID_MIN + NC_IS_MAX_CTRLS - 1)
-
-#define NC_WINDOW_EX_STYLES (WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP | WS_EX_APPWINDOW)
-#define NC_WINDOW_STYLES (WS_DLGFRAME | WS_POPUPWINDOW | WS_CLIPCHILDREN)
-
-#define NC_SZ_STEPS_MIN 3
-#define NC_SZ_STEPS_DEF 10
-#define NC_SZ_STEPS_MAX 100
-
-#define NC_SZ_TIMEOUT_MIN 5
-#define NC_SZ_TIMEOUT_DEF 10
-#define NC_SZ_TIMEOUT_MAX 500
-
-#define NC_TIMER_SIZER 1001
-#define NC_TIMER_ENABLEANIMATE 1002
-
-#define ENABLEANIMATE_TIMEOUT 400
-
-#endif
diff --git a/src/windows/identity/ui/notifier.c b/src/windows/identity/ui/notifier.c
deleted file mode 100644
index fe057c78f..000000000
--- a/src/windows/identity/ui/notifier.c
+++ /dev/null
@@ -1,3173 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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$ */
-
-#define OEMRESOURCE
-
-#include<khmapp.h>
-#include<assert.h>
-
-#define KHUI_NOTIFIER_CLASS L"KhuiNotifierMsgWindowClass"
-#define KHUI_ALERTER_CLASS L"KhuiAlerterWindowClass"
-#define KHUI_ALERTBIN_CLASS L"KhuiAlertBinWindowClass"
-
-#define KHUI_NOTIFIER_WINDOW L"KhuiNotifierMsgWindow"
-
-
-/* The commands that are available as default actions when the user
- clicks the notification icon. */
-
-khm_int32 khm_notifier_actions[] = {
- KHUI_ACTION_OPEN_APP,
- KHUI_ACTION_NEW_CRED
-};
-
-khm_size n_khm_notifier_actions = ARRAYLENGTH(khm_notifier_actions);
-
-/* notifier message for notification icon */
-#define KHUI_WM_NOTIFIER WM_COMMAND
-
-#define DRAWTEXTOPTIONS (DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK)
-
-/* are we showing an alert? */
-#define ALERT_DISPLAYED() (balloon_alert != NULL || khui_alert_windows != NULL)
-
-/* Forward declarations */
-
-struct tag_alerter_wnd_data;
-typedef struct tag_alerter_wnd_data alerter_wnd_data;
-
-struct tag_alert_list;
-typedef struct tag_alert_list alert_list;
-
-static khm_int32
-alert_show(khui_alert * a);
-
-static khm_int32
-alert_show_minimized(khui_alert * a);
-
-static khm_int32
-alert_show_normal(khui_alert * a);
-
-static khm_int32
-alert_show_list(alert_list * alist);
-
-static khm_int32
-alert_enqueue(khui_alert * a);
-
-static khm_boolean
-alert_is_equal(khui_alert * a1, khui_alert * a2);
-
-static void
-check_for_queued_alerts(void);
-
-static void
-show_queued_alerts(void);
-
-static khm_int32
-alert_consolidate(alert_list * alist,
- khui_alert * alert,
- khm_boolean add_from_queue);
-
-/* Globals */
-
-/* window class registration atom for message only notifier window
- class */
-ATOM atom_notifier = 0;
-
-/* window class registration atom for alert windows */
-ATOM atom_alerter = 0;
-/* window class registration atom for the alert "bin", which is the
- window that holds all the alerts. */
-ATOM atom_alert_bin = 0;
-
-/* notifier message window */
-HWND hwnd_notifier = NULL;
-
-BOOL notifier_ready = FALSE;
-
-/* The list of alert windows currently active */
-alerter_wnd_data * khui_alert_windows = NULL;
-
-/* Notification icon for when there are no alerts to be displayed */
-int iid_normal = IDI_NOTIFY_NONE;
-
-/* Tooltip to use when there are no alerts to be displayed */
-wchar_t tip_normal[128] = L"";
-
-/* Current notifier severity level */
-khm_int32 notifier_severity = KHERR_NONE;
-
-/* The alert currently being displayed in a balloon */
-khui_alert * balloon_alert = NULL;
-
-/**********************************************************************
- Alert Queue
-
- The alert queue is the data structure that keeps track of all the
- alerts that are waiting to be displayed. Alerts will be placed on
- the queue if they cannot be immediately displayed for some reason
- (e.g. another alert is being displayed, or the user is working in
- another window).
-***********************************************************************/
-
-#define KHUI_ALERT_QUEUE_MAX 64
-
-khui_alert * alert_queue[KHUI_ALERT_QUEUE_MAX];
-khm_int32 alert_queue_head = 0;
-khm_int32 alert_queue_tail = 0;
-
-#define is_alert_queue_empty() (alert_queue_head == alert_queue_tail)
-#define is_alert_queue_full() (((alert_queue_tail + 1) % KHUI_ALERT_QUEUE_MAX) == alert_queue_head)
-
-/* NOTE: the alert queue functions are unsafe to call from any thread
- other than the UI thread. */
-
-static void
-alert_queue_put_alert(khui_alert * a) {
- if (is_alert_queue_full()) return;
- alert_queue[alert_queue_tail++] = a;
- khui_alert_hold(a);
- alert_queue_tail %= KHUI_ALERT_QUEUE_MAX;
-}
-
-/* the caller needs to release the alert that's returned */
-static khui_alert *
-alert_queue_get_alert(void) {
- khui_alert * a;
-
- if (is_alert_queue_empty()) return NULL;
- a = alert_queue[alert_queue_head++];
- alert_queue_head %= KHUI_ALERT_QUEUE_MAX;
-
- return a; /* held */
-}
-
-static int
-alert_queue_get_size(void) {
- if (is_alert_queue_empty())
- return 0;
-
- if (alert_queue_tail < alert_queue_head) {
- return (alert_queue_tail + KHUI_ALERT_QUEUE_MAX - alert_queue_head);
- } else {
- return alert_queue_tail - alert_queue_head;
- }
-}
-
-static khui_alert *
-alert_queue_get_alert_by_pos(int pos) {
- khui_alert * a;
-
- if (is_alert_queue_empty() ||
- pos >= alert_queue_get_size() ||
- pos < 0) {
- return NULL;
- }
-
- a = alert_queue[(alert_queue_head + pos) % KHUI_ALERT_QUEUE_MAX];
- if (a) {
- khui_alert_hold(a);
- }
- return a;
-}
-
-static int
-alert_queue_delete_alert(khui_alert * a) {
- int idx;
- int succ;
-
- idx = alert_queue_head;
- while(idx != alert_queue_tail) {
- if (alert_queue[idx] == a)
- break;
-
- idx = (idx + 1) % KHUI_ALERT_QUEUE_MAX;
- }
-
- if (idx == alert_queue_tail)
- return 0;
-
-#ifdef DEBUG
- assert(alert_queue[idx]);
-#endif
- khui_alert_release(alert_queue[idx]);
-
- succ = (idx + 1) % KHUI_ALERT_QUEUE_MAX;
- while(succ != alert_queue_tail) {
- alert_queue[idx] = alert_queue[succ];
-
- succ = (succ + 1) % KHUI_ALERT_QUEUE_MAX;
- idx = (idx + 1) % KHUI_ALERT_QUEUE_MAX;
- }
-
- alert_queue_tail = idx;
- return 1;
-}
-
-/* the caller needs to release the alert that's returned */
-static khui_alert *
-alert_queue_peek(void) {
- khui_alert * a;
-
- if (is_alert_queue_empty())
- return NULL;
-
- a = alert_queue[alert_queue_head];
- khui_alert_hold(a);
-
- return a;
-}
-
-/**********************************************************************
- Alert List
-
- A list of alerts. Currently has a fixed upper limit, but the limit
- is high enough for now.
-***********************************************************************/
-
-typedef struct tag_alert_list {
- khui_alert * alerts[KHUI_ALERT_QUEUE_MAX];
- int n_alerts;
- wchar_t title[KHUI_MAXCCH_TITLE];
-} alert_list;
-
-static void
-alert_list_init(alert_list * alist) {
- ZeroMemory(alist, sizeof(*alist));
-}
-
-static void
-alert_list_set_title(alert_list * alist, wchar_t * title) {
- StringCbCopy(alist->title, sizeof(alist->title), title);
-}
-
-static khm_int32
-alert_list_add_alert(alert_list * alist,
- khui_alert * alert) {
-
- if (alist->n_alerts == ARRAYLENGTH(alist->alerts))
- return KHM_ERROR_NO_RESOURCES;
-
- khui_alert_hold(alert);
- alist->alerts[alist->n_alerts++] = alert;
-
- return KHM_ERROR_SUCCESS;
-}
-
-static void
-alert_list_destroy(alert_list * alist) {
- int i;
-
- for (i=0; i < alist->n_alerts; i++) {
- if (alist->alerts[i] != NULL) {
- khui_alert_release(alist->alerts[i]);
- alist->alerts[i] = NULL;
- }
- }
-
- alist->n_alerts = 0;
-}
-
-
-/**********************************************************************
- Notifier Window
-
- The notifier window manages the notification icon and handles
- KMSG_ALERT messages sent from the UI library. The window will exist
- for the lifetime of the application.
-***********************************************************************/
-
-/* These are defined for APPVER >= 0x501. We are defining them here
- so that we can build with APPVER = 0x500 and use the same binaries
- with Win XP. */
-
-#ifndef NIN_BALLOONSHOW
-#define NIN_BALLOONSHOW (WM_USER + 2)
-#endif
-
-#ifndef NIN_BALLOONHIDE
-#define NIN_BALLOONHIDE (WM_USER + 3)
-#endif
-
-#ifndef NIN_BALLOONTIMEOUT
-#define NIN_BALLOONTIMEOUT (WM_USER + 4)
-#endif
-
-#ifndef NIN_BALLOONUSERCLICK
-#define NIN_BALLOONUSERCLICK (WM_USER + 5)
-#endif
-
-
-static LRESULT CALLBACK
-notifier_wnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- kmq_message * m;
- khm_int32 rv;
-
- if(uMsg == KMQ_WM_DISPATCH) {
- kmq_wm_begin(lParam, &m);
- rv = KHM_ERROR_SUCCESS;
-
- if(m->type == KMSG_ALERT) {
- /* handle notifier messages */
- switch(m->subtype) {
- case KMSG_ALERT_SHOW:
- {
- khui_alert * a;
-
- a = (khui_alert *) m->vparam;
-#ifdef DEBUG
- assert(a != NULL);
-#endif
- rv = alert_show(a);
- khui_alert_release(a);
- }
- break;
-
- case KMSG_ALERT_QUEUE:
- {
- khui_alert * a;
-
- a = (khui_alert *) m->vparam;
-#ifdef DEBUG
- assert(a != NULL);
-#endif
- rv = alert_enqueue(a);
- khui_alert_release(a);
- }
- break;
-
- case KMSG_ALERT_CHECK_QUEUE:
- check_for_queued_alerts();
- break;
-
- case KMSG_ALERT_SHOW_QUEUED:
- show_queued_alerts();
- break;
-
- case KMSG_ALERT_SHOW_MODAL:
- {
- khui_alert * a;
-
- a = (khui_alert *) m->vparam;
-#ifdef DEBUG
- assert(a != NULL);
-#endif
- khui_alert_lock(a);
- a->flags |= KHUI_ALERT_FLAG_MODAL;
- khui_alert_unlock(a);
-
- rv = alert_show(a);
-
- if (KHM_SUCCEEDED(rv)) {
- khm_message_loop_int(&a->displayed);
- }
-
- khui_alert_release(a);
- }
- break;
- }
- } else if (m->type == KMSG_CRED &&
- m->subtype == KMSG_CRED_ROOTDELTA) {
-
- KillTimer(hwnd, KHUI_REFRESH_TIMER_ID);
- SetTimer(hwnd, KHUI_REFRESH_TIMER_ID,
- KHUI_REFRESH_TIMEOUT,
- NULL);
-
- }
-
- return kmq_wm_end(m, rv);
- } else if (uMsg == KHUI_WM_NOTIFIER) {
- /* Handle events generated from the notification icon */
-
- /* wParam is the identifier of the notify icon, but we only
- have one. */
- switch(lParam) {
- case WM_CONTEXTMENU:
- {
- POINT pt;
- int menu_id;
- khui_menu_def * mdef;
- khui_action_ref * act = NULL;
- khm_size i, n;
- khm_int32 def_cmd;
-
- /* before we show the context menu, we need to make
- sure that the default action for the notification
- icon is present in the menu and that it is marked
- as the default. */
-
- def_cmd = khm_get_default_notifier_action();
-
- if (khm_is_main_window_visible()) {
- menu_id = KHUI_MENU_ICO_CTX_NORMAL;
-
- if (def_cmd == KHUI_ACTION_OPEN_APP)
- def_cmd = KHUI_ACTION_CLOSE_APP;
- } else {
- menu_id = KHUI_MENU_ICO_CTX_MIN;
- }
-
- mdef = khui_find_menu(menu_id);
-
-#ifdef DEBUG
- assert(mdef);
-#endif
- n = khui_menu_get_size(mdef);
- for (i=0; i < n; i++) {
- act = khui_menu_get_action(mdef, i);
- if (!(act->flags & KHUI_ACTIONREF_PACTION) &&
- (act->action == def_cmd))
- break;
- }
-
- if (i < n) {
- if (!(act->flags & KHUI_ACTIONREF_DEFAULT)) {
- khui_menu_remove_action(mdef, i);
- khui_menu_insert_action(mdef, i, def_cmd, KHUI_ACTIONREF_DEFAULT);
- } else {
- /* we are all set */
- }
- } else {
- /* the default action was not found on the context
- menu */
-#ifdef DEBUG
- assert(FALSE);
-#endif
- khui_menu_insert_action(mdef, 0, def_cmd, KHUI_ACTIONREF_DEFAULT);
- }
-
- SetForegroundWindow(khm_hwnd_main);
-
- GetCursorPos(&pt);
- khm_menu_show_panel(menu_id, pt.x, pt.y);
-
- PostMessage(khm_hwnd_main, WM_NULL, 0, 0);
- }
- break;
-
- case NIN_SELECT:
- /* fall through */
- case NIN_KEYSELECT:
- /* If there were any alerts waiting to be shown, we show
- them. Otherwise we perform the default action. */
- khm_notify_icon_activate();
- break;
-
- case NIN_BALLOONUSERCLICK:
- if (balloon_alert) {
- khui_alert * a;
-
- khm_notify_icon_change(KHERR_NONE);
-
- a = balloon_alert;
- balloon_alert = NULL;
-
- khui_alert_lock(a);
- a->displayed = FALSE;
-
- if ((a->flags & KHUI_ALERT_FLAG_DEFACTION) &&
- !(a->flags & KHUI_ALERT_FLAG_REQUEST_WINDOW) &&
- a->n_alert_commands > 0) {
- PostMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(a->alert_commands[0],
- 0),
- 0);
- } else if (a->flags &
- KHUI_ALERT_FLAG_REQUEST_WINDOW) {
- khm_show_main_window();
- alert_show_normal(a);
- }
-
- khui_alert_unlock(a);
- khui_alert_release(a);
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
- break;
-
- case NIN_BALLOONHIDE:
- case NIN_BALLOONTIMEOUT:
- khm_notify_icon_change(KHERR_NONE);
- if (balloon_alert) {
- khui_alert * a;
- a = balloon_alert;
- balloon_alert = NULL;
-
- khui_alert_lock(a);
- a->displayed = FALSE;
- khui_alert_unlock(a);
-
- khui_alert_release(a);
- }
- break;
- }
- } else if (uMsg == WM_TIMER) {
- if (wParam == KHUI_TRIGGER_TIMER_ID) {
- KillTimer(hwnd, KHUI_TRIGGER_TIMER_ID);
- khm_timer_fire(hwnd);
- } else if (wParam == KHUI_REFRESH_TIMER_ID) {
- KillTimer(hwnd, KHUI_REFRESH_TIMER_ID);
- kcdb_identity_refresh_all();
- khm_timer_refresh(hwnd);
- }
- }
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-ATOM
-khm_register_notifier_wnd_class(void)
-{
- WNDCLASSEX wcx;
-
- ZeroMemory(&wcx, sizeof(wcx));
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = 0;
- wcx.lpfnWndProc = notifier_wnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = 0;
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = NULL;
- wcx.hCursor = NULL;
- wcx.hbrBackground = NULL;
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_NOTIFIER_CLASS;
- wcx.hIconSm = NULL;
-
- atom_notifier = RegisterClassEx(&wcx);
-
- return atom_notifier;
-}
-
-/*********************************************************************
- Alerter
-**********************************************************************/
-
-typedef struct tag_alerter_alert_data {
- khui_alert * alert;
-
- BOOL seen; /* has the user seen this alert? */
-
- BOOL has_commands; /* we cache the value here. otherwise
- we'll have to get a lock on the
- alert each time we have to find out
- whether there are any commands for
- this alert. */
-
- RECT r_alert; /* the entire alert, relative to self. */
-
- /* the following rects are relative to the top left of r_alert. */
-
- RECT r_title; /* the title. deflate by padding to
- get the text rect. */
- RECT r_icon; /* rect for icon */
- RECT r_message; /* rect for the text. no padding
- necessary. */
- RECT r_suggestion; /* rect for the suggestion. deflate
- by padding to get the suggestion
- rect. The suggestion rect includes
- space for the small icon on the
- left and padding between the icon
- and the text. The size of the small
- icon are as per system metrics
- SM_C{X,Y}SMICON. Padding is
- s_pad.cx vertical. */
-
- int n_cmd_buttons; /* number of command buttons in this alert. */
-
- RECT r_buttons[KHUI_MAX_ALERT_COMMANDS];
- /* rects for the command buttons. */
-
- HWND hwnd_buttons[KHUI_MAX_ALERT_COMMANDS];
- /* handles for the command buttons */
-
- HWND hwnd_marker;
- /* handle to the marker window used as
- a tab-stop target when there are
- not buttons associated with the
- alert. */
-
- LDCL(struct tag_alerter_alert_data);
-} alerter_alert_data;
-
-typedef struct tag_alerter_wnd_data {
- HWND hwnd;
- HFONT hfont;
-
- wchar_t caption[KHUI_MAXCCH_TITLE]; /* the original
- caption for the
- dialog. */
-
- HWND hw_bin;
- HWND hw_scroll;
- HWND hw_close;
-
- int scroll_top;
-
- int n_cmd_buttons; /* total number of command buttons
- in all the alerts being shown in
- this dialog. */
-
- int c_alert; /* current selected alert. */
-
- /* various metrics */
- /* calculated during WM_CREATE */
- SIZE s_button; /* minimum dimensions for command button */
- SIZE s_margin;
- RECT r_text; /* only .left and .right are used. rest are 0 */
- RECT r_title; /* only .left, .right and .bottom are used. .top=0 */
- SIZE s_icon;
- SIZE s_pad;
-
- int cx_wnd;
- int cy_max_wnd;
-
- /* derived from the alert sizes */
- SIZE s_alerts;
-
- QDCL(alerter_alert_data); /* queue of alerts that are being
- shown in this window. */
-
- LDCL(struct tag_alerter_wnd_data); /* for adding to
- khui_alert_windows list. */
-
- int n_alerts;
-
-} alerter_wnd_data;
-
-#define NTF_PARAM DWLP_USER
-
-/* dialog sizes in base dialog units */
-
-#define NTF_MARGIN 5
-#define NTF_WIDTH 200
-#define NTF_MAXHEIGHT 150
-
-#define NTF_TITLE_X NTF_MARGIN
-#define NTF_TITLE_WIDTH (NTF_WIDTH - NTF_MARGIN*2)
-#define NTF_TITLE_HEIGHT 10
-
-#define NTF_TEXT_PAD 2
-
-#define NTF_BUTTON_HEIGHT 14
-
-#define NTF_TIMEOUT 20000
-
-#define ALERT_WINDOW_EX_SYLES (WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP)
-#define ALERT_WINDOW_STYLES (WS_DLGFRAME | WS_POPUPWINDOW | WS_CLIPCHILDREN | DS_NOIDLEMSG)
-
-/* Control ids */
-#define IDC_NTF_ALERTBIN 998
-#define IDC_NTF_CLOSE 999
-
-#define IDC_NTF_CMDBUTTONS 1001
-#define IDC_FROM_IDX(alert, bn) ((alert) * (KHUI_MAX_ALERT_COMMANDS + 1) + (bn) + 1 + IDC_NTF_CMDBUTTONS)
-#define ALERT_FROM_IDC(idc) (((idc) - IDC_NTF_CMDBUTTONS) / (KHUI_MAX_ALERT_COMMANDS + 1))
-#define BUTTON_FROM_IDC(idc) (((idc) - IDC_NTF_CMDBUTTONS) % (KHUI_MAX_ALERT_COMMANDS + 1) - 1)
-
-/* if the only command in an alert is "Close", we assume that the
- alert has no commands. */
-#define ALERT_HAS_CMDS(a) ((a)->n_alert_commands > 1 || ((a)->n_alert_commands == 1 && (a)->alert_commands[0] != KHUI_PACTION_CLOSE))
-
-#define SCROLL_LINE_SIZE(d) ((d)->cy_max_wnd / 12)
-
-static void
-add_alert_to_wnd_data(alerter_wnd_data * d,
- khui_alert * a) {
- alerter_alert_data * aiter;
- khm_boolean exists = 0;
-
- khui_alert_lock(a);
-
- /* check if the alert is already there */
- aiter = QTOP(d);
- while(aiter && !exists) {
- if (aiter->alert) {
- khui_alert_lock(aiter->alert);
-
- if (alert_is_equal(aiter->alert, a)) {
- exists = TRUE;
- }
-
- khui_alert_unlock(aiter->alert);
- }
-
- aiter = QNEXT(aiter);
- }
-
- a->flags |= KHUI_ALERT_FLAG_DISPLAY_WINDOW;
-
- if (!exists) {
- a->displayed = TRUE;
- }
-
- khui_alert_unlock(a);
-
- if (!exists) {
- alerter_alert_data * adata;
-
- adata = PMALLOC(sizeof(*adata));
- ZeroMemory(adata, sizeof(*adata));
-
- adata->alert = a;
- khui_alert_hold(a);
-
- QPUT(d, adata);
- d->n_alerts ++;
- }
-}
-
-static alerter_wnd_data *
-create_alerter_wnd_data(HWND hwnd, alert_list * l) {
- alerter_wnd_data * d;
- int i;
- LONG dlgb;
-
- d = PMALLOC(sizeof(*d));
- ZeroMemory(d, sizeof(*d));
-
- d->hwnd = hwnd;
-
- GetWindowText(hwnd, d->caption, ARRAYLENGTH(d->caption));
-
- for (i=0; i < l->n_alerts; i++) {
- add_alert_to_wnd_data(d, l->alerts[i]);
- }
-
- d->n_alerts = l->n_alerts;
-
- LPUSH(&khui_alert_windows, d);
-
- /* Compute a few metrics first */
-
- dlgb = GetDialogBaseUnits();
-
-#define DLG2SCNX(x) MulDiv((x), LOWORD(dlgb), 4)
-#define DLG2SCNY(y) MulDiv((y), HIWORD(dlgb), 8)
-
- d->cx_wnd = DLG2SCNX(NTF_WIDTH);
- d->cy_max_wnd = DLG2SCNY(NTF_MAXHEIGHT);
-
- d->s_margin.cx = DLG2SCNX(NTF_MARGIN);
- d->s_margin.cy = DLG2SCNY(NTF_MARGIN);
-
- d->r_title.left = DLG2SCNX(NTF_TITLE_X);
- d->r_title.right = DLG2SCNX(NTF_TITLE_X + NTF_TITLE_WIDTH);
- d->r_title.top = 0;
- d->r_title.bottom = DLG2SCNY(NTF_TITLE_HEIGHT);
-
- d->s_pad.cx = DLG2SCNX(NTF_TEXT_PAD);
- d->s_pad.cy = DLG2SCNY(NTF_TEXT_PAD);
-
- d->s_icon.cx = GetSystemMetrics(SM_CXICON);
- d->s_icon.cy = GetSystemMetrics(SM_CYICON);
-
- d->r_text.left = d->s_margin.cx * 2 + d->s_icon.cx;
- d->r_text.right = d->cx_wnd - d->s_margin.cx;
- d->r_text.top = 0;
- d->r_text.bottom = 0;
-
- d->s_button.cx = ((d->r_text.right - d->r_text.left) - (KHUI_MAX_ALERT_COMMANDS - 1) * d->s_margin.cx) / KHUI_MAX_ALERT_COMMANDS;
- d->s_button.cy = DLG2SCNY(NTF_BUTTON_HEIGHT);
-
-#undef DLG2SCNX
-#undef DLG2SCNY
-
- d->c_alert = -1;
-
- return d;
-}
-
-static void
-layout_alert(HDC hdc, alerter_wnd_data * d,
- alerter_alert_data * adata) {
- RECT r;
- size_t len;
- int y;
- int icon_y;
-
-#ifdef DEBUG
- assert(adata->alert);
-#endif
-
- khui_alert_lock(adata->alert);
-
- y = 0;
-
- /* Title */
-
- y += d->s_margin.cy;
-
- /* If there is a title and it differs from the title of the
- alerter window, then we have to show the alert title
- separately. */
- if (adata->alert->title &&
- wcscmp(adata->alert->title, d->caption)) {
-
- CopyRect(&adata->r_title, &d->r_title);
- OffsetRect(&adata->r_title, 0, y);
-
- y = adata->r_title.bottom + d->s_margin.cy;
-
- } else {
-
- SetRectEmpty(&adata->r_title);
-
- }
-
- /* Icon */
-
- SetRect(&adata->r_icon, d->s_margin.cx, y,
- d->s_margin.cx + d->s_icon.cx,
- y + d->s_icon.cy);
-
- icon_y = adata->r_icon.bottom + d->s_margin.cy; /* the bottom of the icon */
-
- /* Message */
-
- if (adata->alert->message &&
- SUCCEEDED(StringCchLength(adata->alert->message,
- KHUI_MAXCCH_MESSAGE,
- &len))) {
-
- CopyRect(&r, &d->r_text);
-
- DrawTextEx(hdc, adata->alert->message, (int) len,
- &r,
- DRAWTEXTOPTIONS,
- NULL);
-
- OffsetRect(&r, 0, y);
- CopyRect(&adata->r_message, &r);
-
- y = r.bottom + d->s_margin.cy;
-
- } else {
-
- SetRectEmpty(&adata->r_message);
-
- }
-
- /* Suggestion */
-
- if (adata->alert->suggestion &&
- SUCCEEDED(StringCchLength(adata->alert->suggestion,
- KHUI_MAXCCH_SUGGESTION,
- &len))) {
- int pad = d->s_pad.cx + GetSystemMetrics(SM_CXSMICON);
-
- CopyRect(&r, &d->r_text);
- r.left += pad;
-
- DrawTextEx(hdc, adata->alert->suggestion, (int) len,
- &r,
- DRAWTEXTOPTIONS,
- NULL);
-
- r.left -= pad;
-
- InflateRect(&r, d->s_pad.cx, d->s_pad.cy);
- OffsetRect(&r, 0, -r.top + y);
- CopyRect(&adata->r_suggestion, &r);
-
- y = r.bottom + d->s_margin.cy;
-
- } else {
-
- SetRectEmpty(&adata->r_suggestion);
-
- }
-
- y = max(y, icon_y);
-
- /* Buttons */
-
- if (ALERT_HAS_CMDS(adata->alert)) {
- khm_int32 i;
- int x, width;
- wchar_t caption[KHUI_MAXCCH_SHORT_DESC];
- size_t len;
- SIZE s;
- int skip_close;
-
- adata->has_commands = TRUE;
-
- if (d->n_alerts > 1)
- skip_close = TRUE;
- else
- skip_close = FALSE;
-
- x = d->r_text.left;
-
-#ifdef DEBUG
- assert(adata->alert->n_alert_commands <= KHUI_MAX_ALERT_COMMANDS);
-#endif
-
- for (i=0; i < adata->alert->n_alert_commands; i++) {
-
- if (adata->alert->alert_commands[i] == KHUI_PACTION_CLOSE && skip_close) {
- SetRectEmpty(&adata->r_buttons[i]);
- continue;
- }
-
- caption[0] = L'\0';
- len = 0;
- khm_get_action_caption(adata->alert->alert_commands[i],
- caption, sizeof(caption));
- StringCchLength(caption, ARRAYLENGTH(caption), &len);
-
- if (!GetTextExtentPoint32(hdc, caption, (int) len, &s)) {
- width = d->s_button.cx;
- } else {
- width = s.cx + d->s_margin.cx * 2;
- }
-
- if (width < d->s_button.cx)
- width = d->s_button.cx;
- else if (width > (d->r_text.right - d->r_text.left))
- width = d->r_text.right - d->r_text.left;
-
- if (x + width > d->r_text.right) {
- /* new line */
- x = d->r_text.left;
- y += d->s_button.cy + d->s_pad.cy;
- }
-
- SetRect(&adata->r_buttons[i], x, y, x + width, y + d->s_button.cy);
-
- x += width + d->s_margin.cx;
- }
-
- y += d->s_button.cy + d->s_margin.cy;
- }
-
- khui_alert_unlock(adata->alert);
-
- /* Now set the rect for the whole alert */
- SetRect(&adata->r_alert, 0, 0, d->cx_wnd, y);
-
-}
-
-static void
-pick_title_for_alerter_window(alerter_wnd_data * d) {
- alerter_alert_data * adata;
- wchar_t caption[KHUI_MAXCCH_TITLE];
- khm_boolean common_caption = TRUE;
- khui_alert_type ctype = KHUI_ALERTTYPE_NONE;
- khm_boolean common_type = TRUE;
-
- /* - If all the alerts have the same title, then we use the common
- title.
-
- - If all the alerts are of the same type, then we pick a title
- that is suitable for the type.
-
- - All else fails, we use a default caption for the window.
- */
-
- caption[0] = L'\0';
- adata = QTOP(d);
- while (adata && (common_caption || common_type)) {
-
- if (adata->alert) {
- khui_alert_lock(adata->alert);
-
- if (common_caption) {
- if (caption[0] == L'\0') {
- if (adata->alert->title)
- StringCbCopy(caption, sizeof(caption), adata->alert->title);
- } else if (adata->alert->title &&
- wcscmp(caption, adata->alert->title)) {
- common_caption = FALSE;
- }
- }
-
- if (common_type) {
- if (ctype == KHUI_ALERTTYPE_NONE)
- ctype = adata->alert->alert_type;
- else if (ctype != adata->alert->alert_type)
- common_type = FALSE;
- }
-
- khui_alert_unlock(adata->alert);
- }
-
- adata = QNEXT(adata);
- }
-
- /* just in case someone changes d->caption to a pointer from an
- array */
-#ifdef DEBUG
- assert(sizeof(d->caption) > sizeof(wchar_t *));
-#endif
-
- if (common_caption && caption[0] != L'\0') {
- StringCbCopy(d->caption, sizeof(d->caption), caption);
- } else if (common_type && ctype != KHUI_ALERTTYPE_NONE) {
- switch(ctype) {
- case KHUI_ALERTTYPE_PLUGIN:
- LoadString(khm_hInstance, IDS_ALERTTYPE_PLUGIN,
- d->caption, ARRAYLENGTH(d->caption));
- break;
-
- case KHUI_ALERTTYPE_EXPIRE:
- LoadString(khm_hInstance, IDS_ALERTTYPE_EXPIRE,
- d->caption, ARRAYLENGTH(d->caption));
- break;
-
- case KHUI_ALERTTYPE_RENEWFAIL:
- LoadString(khm_hInstance, IDS_ALERTTYPE_RENEWFAIL,
- d->caption, ARRAYLENGTH(d->caption));
- break;
-
- case KHUI_ALERTTYPE_ACQUIREFAIL:
- LoadString(khm_hInstance, IDS_ALERTTYPE_ACQUIREFAIL,
- d->caption, ARRAYLENGTH(d->caption));
- break;
-
- case KHUI_ALERTTYPE_CHPW:
- LoadString(khm_hInstance, IDS_ALERTTYPE_CHPW,
- d->caption, ARRAYLENGTH(d->caption));
- break;
-
- default:
- LoadString(khm_hInstance, IDS_ALERT_DEFAULT,
- d->caption, ARRAYLENGTH(d->caption));
- }
- } else {
- LoadString(khm_hInstance, IDS_ALERT_DEFAULT,
- d->caption, ARRAYLENGTH(d->caption));
- }
-
- SetWindowText(d->hwnd, d->caption);
-}
-
-static void
-estimate_alerter_wnd_sizes(alerter_wnd_data * d) {
- HDC hdc;
- HFONT hf_old;
- int height = 0;
-
- alerter_alert_data * adata;
-
- pick_title_for_alerter_window(d);
-
- hdc = GetDC(d->hwnd);
-#ifdef DEBUG
- assert(hdc);
-#endif
-
- if (d->hfont == NULL)
- d->hfont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
-
-#ifdef DEBUG
- assert(d->hfont);
-#endif
-
- hf_old = SelectFont(hdc, d->hfont);
-
- adata = QTOP(d);
- while(adata) {
- layout_alert(hdc, d, adata);
-
- height += adata->r_alert.bottom;
-
- adata = QNEXT(adata);
- }
-
- SelectFont(hdc, hf_old);
- ReleaseDC(d->hwnd, hdc);
-
- d->s_alerts.cx = d->cx_wnd;
- d->s_alerts.cy = height;
-}
-
-static void
-layout_command_buttons(alerter_wnd_data * d) {
-
- alerter_alert_data * adata;
- HDWP hdefer;
- int y;
-
- hdefer = BeginDeferWindowPos(d->n_cmd_buttons);
-
- y = 0;
- adata = QTOP(d);
- while (adata) {
- RECT r;
- int i;
-
- if (!adata->has_commands)
- goto done;
-
- for (i=0; i < adata->n_cmd_buttons; i++) {
- if (IsRectEmpty(&adata->r_buttons[i])) {
- /* the button is no longer needed */
- if (adata->hwnd_buttons[i] != NULL) {
- DestroyWindow(adata->hwnd_buttons[i]);
- adata->hwnd_buttons[i] = NULL;
- }
-
- continue;
- }
-
- if (adata->hwnd_buttons[i] == NULL) {
- continue;
- }
-
- CopyRect(&r, &adata->r_buttons[i]);
- OffsetRect(&r, 0, y - d->scroll_top);
-
- DeferWindowPos(hdefer,
- adata->hwnd_buttons[i], NULL,
- r.left, r.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER |
- SWP_NOSIZE);
- }
-
- done:
- y += adata->r_alert.bottom;
- adata = QNEXT(adata);
- }
-
- EndDeferWindowPos(hdefer);
-}
-
-static void
-setup_alerter_window_controls(alerter_wnd_data * d) {
-
- RECT r_alerts;
- RECT r_window;
- RECT r_client;
- RECT r_parent;
- HWND hw_parent;
- HWND hw_focus = NULL;
- BOOL close_button = FALSE;
- BOOL scrollbar = FALSE;
- BOOL redraw_scollbar = FALSE;
-
- /* estimate_alerter_wnd_sizes() must be called before calling
- this. */
-#ifdef DEBUG
- assert(d->s_alerts.cy > 0);
-#endif
-
- r_alerts.left = 0;
- r_alerts.top = 0;
- r_alerts.right = d->cx_wnd;
-
- if (d->s_alerts.cy > d->cy_max_wnd) {
-
- BOOL redraw = FALSE;
-
- r_alerts.right += GetSystemMetrics(SM_CXVSCROLL);
- r_alerts.bottom = d->cy_max_wnd;
-
- CopyRect(&r_client, &r_alerts);
- r_client.bottom += d->s_margin.cy + d->s_button.cy + d->s_pad.cy;
- close_button = TRUE;
-
- if (d->scroll_top > d->s_alerts.cy - d->cy_max_wnd)
- d->scroll_top = d->s_alerts.cy - d->cy_max_wnd;
-
- scrollbar = TRUE;
- } else {
- r_alerts.bottom = d->s_alerts.cy;
-
- CopyRect(&r_client, &r_alerts);
-
- if (d->n_alerts == 1) {
-
- if (!QTOP(d)->has_commands) {
- r_client.bottom += d->s_margin.cy * 2 + d->s_button.cy;
- close_button = TRUE;
- }
-
- } else {
-
- r_client.bottom += d->s_margin.cy * 2 + d->s_button.cy;
- close_button = TRUE;
- }
-
- d->scroll_top = 0;
- }
-
- if (d->hw_bin == NULL) {
- d->hw_bin = CreateWindowEx(WS_EX_CONTROLPARENT,
- MAKEINTATOM(atom_alert_bin),
- L"Alert Container",
- WS_CHILD | WS_CLIPCHILDREN |
- WS_VISIBLE |
- ((scrollbar)? WS_VSCROLL : 0),
- r_alerts.left, r_alerts.top,
- r_alerts.right - r_alerts.left,
- r_alerts.bottom - r_alerts.top,
- d->hwnd,
- (HMENU) IDC_NTF_ALERTBIN,
- khm_hInstance,
- (LPVOID) d);
- } else {
- redraw_scollbar = TRUE;
- SetWindowLongPtr(d->hw_bin, GWL_STYLE,
- WS_CHILD | WS_CLIPCHILDREN |
- WS_VISIBLE |
- ((scrollbar)? WS_VSCROLL : 0));
- SetWindowPos(d->hw_bin, NULL,
- r_alerts.left, r_alerts.top,
- r_alerts.right - r_alerts.left,
- r_alerts.bottom - r_alerts.top,
- SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE);
- }
-
- if (scrollbar) {
- SCROLLINFO si;
-
- ZeroMemory(&si, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
- si.nMin = 0;
- si.nMax = d->s_alerts.cy;
- si.nPage = d->cy_max_wnd;
- si.nPos = d->scroll_top;
-
- SetScrollInfo(d->hw_bin, SB_VERT, &si, redraw_scollbar);
- }
-
- /* create the action buttons */
- {
- alerter_alert_data * adata;
- int y;
- int idx;
- HWND last_window = HWND_TOP;
- int n_buttons = 0;
-
- idx = 0;
- y = - d->scroll_top;
- adata = QTOP(d);
- while(adata) {
- if (adata->has_commands) {
- int i;
- wchar_t caption[KHUI_MAXCCH_SHORT_DESC];
- RECT r;
-
- if (adata->hwnd_marker) {
- DestroyWindow(adata->hwnd_marker);
- adata->hwnd_marker = NULL;
- }
-
- khui_alert_lock(adata->alert);
-
- adata->n_cmd_buttons = adata->alert->n_alert_commands;
-
- for (i=0; i < adata->alert->n_alert_commands; i++) {
-
- n_buttons ++;
-
- if (IsRectEmpty(&adata->r_buttons[i])) {
- /* this button is not necessary */
- if (adata->hwnd_buttons[i]) {
- DestroyWindow(adata->hwnd_buttons[i]);
- adata->hwnd_buttons[i] = NULL;
- }
-
- continue;
- }
-
- if (adata->hwnd_buttons[i] != NULL) {
- /* already there */
- CopyRect(&r, &adata->r_buttons[i]);
- OffsetRect(&r, 0, y);
-
- SetWindowPos(adata->hwnd_buttons[i], last_window,
- r.left, r.top,
- r.right - r.left,
- r.bottom - r.top,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_SHOWWINDOW);
-
- last_window = adata->hwnd_buttons[i];
-
- if (hw_focus == NULL)
- hw_focus = adata->hwnd_buttons[i];
-
- continue;
- }
-
- khm_get_action_caption(adata->alert->alert_commands[i],
- caption, sizeof(caption));
-
- CopyRect(&r, &adata->r_buttons[i]);
- OffsetRect(&r, 0, y);
-
- adata->hwnd_buttons[i] =
- CreateWindowEx(0,
- L"BUTTON",
- caption,
- WS_CHILD | WS_TABSTOP | BS_NOTIFY,
- r.left, r.top,
- r.right - r.left,
- r.bottom - r.top,
- d->hw_bin,
- (HMENU) (INT_PTR) IDC_FROM_IDX(idx, i),
- khm_hInstance,
- NULL);
-#ifdef DEBUG
- assert(adata->hwnd_buttons[i]);
-#endif
-
- if (d->hfont) {
- SendMessage(adata->hwnd_buttons[i], WM_SETFONT,
- (WPARAM) d->hfont, FALSE);
- }
-
- SetWindowPos(adata->hwnd_buttons[i], last_window,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
-
- last_window = adata->hwnd_buttons[i];
-
- if (hw_focus == NULL)
- hw_focus = adata->hwnd_buttons[i];
- }
-
- khui_alert_unlock(adata->alert);
- } else {
- int i;
-
- /* Destroy any buttons that belong to the alert. We
- might have some left over, if there were command
- belonging to the alert that were ignored.*/
-
- for (i=0; i < adata->n_cmd_buttons; i++) {
- if (adata->hwnd_buttons[i]) {
- DestroyWindow(adata->hwnd_buttons[i]);
- adata->hwnd_buttons[i] = NULL;
- }
- }
-
- adata->n_cmd_buttons = 0;
-
- if (adata->hwnd_marker == NULL) {
- adata->hwnd_marker =
- CreateWindowEx(0,
- L"BUTTON",
- L"Marker",
- WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_NOTIFY,
- -10, 0,
- 5, 5,
- d->hw_bin,
- (HMENU) (INT_PTR) IDC_FROM_IDX(idx, -1),
- khm_hInstance,
- NULL);
-#ifdef DEBUG
- assert(adata->hwnd_marker);
-#endif
- }
-
- SetWindowPos(adata->hwnd_marker, last_window,
- 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER |
- SWP_NOMOVE | SWP_NOSIZE);
-
- last_window = adata->hwnd_marker;
-
- if (scrollbar) {
- EnableWindow(adata->hwnd_marker, TRUE);
- if (hw_focus == NULL)
- hw_focus = adata->hwnd_marker;
- } else {
- EnableWindow(adata->hwnd_marker, FALSE);
- }
- }
-
- y += adata->r_alert.bottom;
- adata = QNEXT(adata);
- idx++;
- }
-
- d->n_cmd_buttons = n_buttons;
- }
-
- if (close_button) {
- if (d->hw_close == NULL) {
- wchar_t caption[256];
-
- khm_get_action_caption(KHUI_PACTION_CLOSE, caption, sizeof(caption));
-
- d->hw_close = CreateWindowEx(0,
- L"BUTTON",
- caption,
- WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP | BS_NOTIFY,
- 0,0,100,100,
- d->hwnd,
- (HMENU) IDC_NTF_CLOSE,
- khm_hInstance,
- NULL);
-
-#ifdef DEBUG
- assert(d->hw_close);
- assert(d->hfont);
-#endif
- if (d->hfont)
- SendMessage(d->hw_close, WM_SETFONT, (WPARAM) d->hfont, FALSE);
- }
-
- {
- int x,y,width,height;
-
- x = d->r_text.left;
- y = r_client.bottom - (d->s_margin.cy + d->s_button.cy);
- width = d->s_button.cx;
- height = d->s_button.cy;
-
- SetWindowPos(d->hw_close, NULL,
- x, y, width, height,
- SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER |
- SWP_SHOWWINDOW);
- }
-
- if (hw_focus == NULL || d->n_cmd_buttons == 0)
- hw_focus = d->hw_close;
-
- } else {
- if (d->hw_close != NULL) {
- DestroyWindow(d->hw_close);
- d->hw_close = NULL;
- }
- }
-
- CopyRect(&r_window, &r_client);
- AdjustWindowRectEx(&r_window, ALERT_WINDOW_STYLES,
- FALSE, ALERT_WINDOW_EX_SYLES);
- OffsetRect(&r_window, -r_window.left, -r_window.top);
-
- /* center the window above the parent window. */
-
- hw_parent = GetWindow(d->hwnd, GW_OWNER);
- GetWindowRect(hw_parent, &r_parent);
-
- {
- int x,y;
-
- x = (r_parent.left + r_parent.right - (r_window.right - r_window.left)) / 2;
- y = (r_parent.top + r_parent.bottom - (r_window.bottom - r_window.top)) / 2;
-
- SetWindowPos(d->hwnd,
- HWND_TOP,
- x, y,
- r_window.right - r_window.left,
- r_window.bottom - r_window.top,
- SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
- }
-
- if (hw_focus != NULL)
- PostMessage(d->hwnd, WM_NEXTDLGCTL, (WPARAM) hw_focus, MAKELPARAM(TRUE, 0));
-}
-
-static void
-scroll_to_position(alerter_wnd_data * d, int new_pos, khm_boolean redraw_scrollbar) {
- int delta;
- SCROLLINFO si;
- HWND hwnd = d->hw_bin;
-
- if (new_pos < 0)
- new_pos = 0;
- else if (new_pos > d->s_alerts.cy - d->cy_max_wnd)
- new_pos = d->s_alerts.cy - d->cy_max_wnd;
-
- if (new_pos == d->scroll_top)
- return;
-
- delta = d->scroll_top - new_pos;
-
- d->scroll_top -= delta;
-
- ScrollWindowEx(hwnd, 0, delta,
- NULL, NULL, NULL, NULL,
- SW_INVALIDATE | SW_ERASE);
-
- layout_command_buttons(d);
-
- ZeroMemory(&si, sizeof(si));
-
- si.fMask = SIF_POS;
- si.nPos = d->scroll_top;
-
- SetScrollInfo(hwnd, SB_VERT, &si, redraw_scrollbar);
-}
-
-static void
-select_alert(alerter_wnd_data * d, int alert) {
-
- int y;
- RECT old_sel, new_sel;
- alerter_alert_data * adata;
- int idx;
-
- if (d->n_alerts == 1 ||
- alert < 0 ||
- alert > d->n_alerts ||
- d->c_alert == alert)
- return;
-
- SetRectEmpty(&old_sel);
- SetRectEmpty(&new_sel);
- idx = 0; y = -d->scroll_top;
- adata = QTOP(d);
- while(adata && (idx <= d->c_alert || idx <= alert)) {
-
- if (idx == d->c_alert) {
- CopyRect(&old_sel, &adata->r_alert);
- OffsetRect(&old_sel, 0, y);
- }
-
- if (idx == alert) {
- CopyRect(&new_sel, &adata->r_alert);
- OffsetRect(&new_sel, 0, y);
- }
-
- y += adata->r_alert.bottom;
- idx ++;
- adata = QNEXT(adata);
- }
-
- d->c_alert = alert;
- if (!IsRectEmpty(&old_sel))
- InvalidateRect(d->hw_bin, &old_sel, TRUE);
- if (!IsRectEmpty(&new_sel))
- InvalidateRect(d->hw_bin, &new_sel, TRUE);
-}
-
-static void
-ensure_command_is_visible(alerter_wnd_data * d, int id) {
- int alert_idx;
- int y = 0;
- alerter_alert_data * adata;
- int new_pos = 0;
-
- alert_idx = ALERT_FROM_IDC(id);
-
-#ifdef DEBUG
- assert(alert_idx >= 0 && alert_idx < d->n_alerts);
-#endif
- if (alert_idx >= d->n_alerts || alert_idx < 0)
- return;
-
- adata = QTOP(d);
- while(adata && alert_idx > 0) {
- y += adata->r_alert.bottom;
- alert_idx--;
- adata = QNEXT(adata);
- }
-
-#ifdef DEBUG
- assert(alert_idx == 0);
- assert(adata);
- assert(adata->alert);
-#endif
- if (adata == NULL || alert_idx != 0)
- return;
-
- new_pos = d->scroll_top;
- if (y < d->scroll_top) {
- new_pos = y;
- } else if (y + adata->r_alert.bottom > d->scroll_top + d->cy_max_wnd) {
- new_pos = y + adata->r_alert.bottom - d->cy_max_wnd;
- }
-
- if (new_pos != d->scroll_top)
- scroll_to_position(d, new_pos, TRUE);
-
- select_alert(d, ALERT_FROM_IDC(id));
-}
-
-static void
-handle_mouse_select(alerter_wnd_data * d, int mouse_x, int mouse_y) {
- int y;
- alerter_alert_data * adata;
-
- y = -d->scroll_top;
- adata = QTOP(d);
- while(adata) {
- if (y <= mouse_y && (y + adata->r_alert.bottom) > mouse_y) {
- HWND hw = NULL;
-
- if (adata->n_cmd_buttons > 0)
- hw = adata->hwnd_buttons[0];
- else
- hw = adata->hwnd_marker;
-
- if (hw && !IsWindowEnabled(hw))
- hw = GetNextDlgTabItem(d->hwnd, hw, FALSE);
-
- if (hw)
- PostMessage(d->hwnd, WM_NEXTDLGCTL, (WPARAM) hw, MAKELPARAM(TRUE, 0));
-
- return;
- }
-
- y += adata->r_alert.bottom;
- adata = QNEXT(adata);
- }
-}
-
-static void
-process_command_button(alerter_wnd_data * d, int id) {
- int alert_idx;
- int cmd_idx;
- khm_int32 flags = 0;
- khm_int32 cmd = 0;
- alerter_alert_data * adata;
- int i;
-
- alert_idx = ALERT_FROM_IDC(id);
- cmd_idx = BUTTON_FROM_IDC(id);
-
-#ifdef DEBUG
- assert(alert_idx >= 0 && alert_idx < d->n_alerts);
-#endif
- if (alert_idx >= d->n_alerts || alert_idx < 0)
- return;
-
- if (cmd_idx < 0) {
- /* the user selected a marker button. Nothing to do. */
- return;
- }
-
- adata = QTOP(d);
- while(adata && alert_idx > 0) {
- alert_idx--;
- adata = QNEXT(adata);
- }
-
-#ifdef DEBUG
- assert(alert_idx == 0);
- assert(adata);
- assert(adata->alert);
-#endif
- if (adata == NULL || alert_idx != 0)
- return;
-
- khui_alert_lock(adata->alert);
-#ifdef DEBUG
- assert(cmd_idx >= 0 && cmd_idx < adata->alert->n_alert_commands);
-#endif
-
- if (cmd_idx >= 0 && cmd_idx < adata->alert->n_alert_commands) {
- cmd = adata->alert->alert_commands[cmd_idx];
- }
-
- flags = adata->alert->flags;
-
- adata->alert->response = cmd;
-
- khui_alert_unlock(adata->alert);
-
- /* if we were supposed to dispatch the command, do so */
- if (cmd != 0 &&
- cmd != KHUI_PACTION_CLOSE &&
- (flags & KHUI_ALERT_FLAG_DISPATCH_CMD)) {
- PostMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(cmd, 0), 0);
- }
-
- /* if this was the only alert in the alert group and its close
- button was clicked, we close the alert window. Otherwise, the
- alert window creates its own close button that closes the
- window. */
- if (d->n_alerts == 1) {
- PostMessage(d->hwnd, WM_CLOSE, 0, 0);
- }
-
- /* While we are at it, we should disable the buttons for this
- alert since we have already dispatched the command for it. */
- if (cmd != 0) {
- HWND hw_focus = GetFocus();
- khm_boolean focus_trapped = FALSE;
-
- for (i=0; i < adata->n_cmd_buttons; i++) {
- if (adata->hwnd_buttons[i]) {
- if (hw_focus == adata->hwnd_buttons[i])
- focus_trapped = TRUE;
-
- EnableWindow(adata->hwnd_buttons[i], FALSE);
- }
- }
-
- if (focus_trapped) {
- hw_focus = GetNextDlgTabItem(d->hwnd, hw_focus, FALSE);
- if (hw_focus)
- PostMessage(d->hwnd, WM_NEXTDLGCTL, (WPARAM) hw_focus, MAKELPARAM(TRUE,0));
- }
- }
-}
-
-static void
-destroy_alerter_wnd_data(alerter_wnd_data * d) {
- alerter_alert_data * adata;
-
- LDELETE(&khui_alert_windows, d);
-
- QGET(d, &adata);
- while(adata) {
-
- if (adata->alert) {
-
- khui_alert_lock(adata->alert);
-
- adata->alert->displayed = FALSE;
-
- khui_alert_unlock(adata->alert);
-
- khui_alert_release(adata->alert);
- adata->alert = NULL;
- }
-
- PFREE(adata);
-
- QGET(d, &adata);
- }
-
- PFREE(d);
-}
-
-/* both ref and to_add must be locked and held */
-static khm_boolean
-alert_can_consolidate(khui_alert * ref,
- khui_alert * to_add,
- alert_list * alist) {
-
- /* first check if we can add anything */
- if (alist->n_alerts == ARRAYLENGTH(alist->alerts))
- return FALSE;
-
-#ifdef DEBUG
- assert(to_add != NULL);
-#endif
-
- if (ref == NULL) {
- /* we are testing whether to_add should be added to the alist
- on its own. */
- if ((to_add->flags & KHUI_ALERT_FLAG_DISPLAY_BALLOON) &&
- !(to_add->flags & KHUI_ALERT_FLAG_DISPLAY_WINDOW)) {
- /* already displayed */
- return FALSE;
- }
-
- if ((to_add->flags & (KHUI_ALERT_FLAG_REQUEST_BALLOON |
- KHUI_ALERT_FLAG_REQUEST_WINDOW)) == KHUI_ALERT_FLAG_REQUEST_BALLOON) {
- /* needs to be shown in a balloon */
- return FALSE;
- }
-
- return TRUE;
- }
-
- /* if the ref or to_add are marked for modal, then we can't
- consolidate them */
- if ((ref->flags & KHUI_ALERT_FLAG_MODAL) ||
- (to_add->flags & KHUI_ALERT_FLAG_MODAL))
- return FALSE;
-
- /* also, if either of them have requested to be exclusively shown
- in a balloon, then we can't consolidate them. */
- if (((ref->flags & (KHUI_ALERT_FLAG_REQUEST_BALLOON |
- KHUI_ALERT_FLAG_REQUEST_WINDOW)) == KHUI_ALERT_FLAG_REQUEST_BALLOON)
-
- ||
-
- ((to_add->flags & (KHUI_ALERT_FLAG_REQUEST_BALLOON |
- KHUI_ALERT_FLAG_REQUEST_WINDOW)) == KHUI_ALERT_FLAG_REQUEST_BALLOON))
- return FALSE;
-
- /* for now, all we check if whether they are of the same type. */
- if (ref->alert_type != KHUI_ALERTTYPE_NONE &&
- ref->alert_type == to_add->alert_type)
- return TRUE;
- else
- return FALSE;
-}
-
-/* both a1 and a2 must be locked */
-static khm_boolean
-alert_is_equal(khui_alert * a1, khui_alert * a2) {
- khm_int32 i;
-
- if ((a1->severity != a2->severity) ||
- (a1->n_alert_commands != a2->n_alert_commands) ||
- (a1->title && (!a2->title || wcscmp(a1->title, a2->title))) ||
- (!a1->title && a2->title) ||
- (a1->message && (!a2->message || wcscmp(a1->message, a2->message))) ||
- (!a1->message && a2->message) ||
- (a1->suggestion && (!a2->suggestion || wcscmp(a1->suggestion, a2->suggestion))) ||
- (!a1->suggestion && a2->suggestion)) {
-
- return FALSE;
-
- }
-
- for (i=0; i < a1->n_alert_commands; i++) {
- if (a1->alert_commands[i] != a2->alert_commands[i])
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* the return value is the number of alerts added to alist */
-static khm_int32
-alert_consolidate(alert_list * alist,
- khui_alert * alert,
- khm_boolean add_from_queue) {
-
- khui_alert * listtop;
- int queue_size = 0;
- int i;
- khm_int32 n_added = 0;
-
-#ifdef DEBUG
- assert(alist);
-#endif
-
- if (alist->n_alerts == ARRAYLENGTH(alist->alerts)) {
- /* can't add anything */
-
- return 0;
- }
-
- /* if the list is empty, we just add one alert */
- if (alist->n_alerts == 0) {
-
- if (alert) {
- khui_alert_lock(alert);
- if (alert_can_consolidate(NULL, alert, alist)) {
- alert_list_add_alert(alist, alert);
- n_added ++;
- alert = NULL;
- }
- khui_alert_unlock(alert);
- }
-
- if (n_added == 0 && add_from_queue) {
- khui_alert * q;
- int i;
-
- queue_size = alert_queue_get_size();
- for (i=0; i < queue_size && n_added == 0; i++) {
- q = alert_queue_get_alert_by_pos(i);
- if (q) {
- khui_alert_lock(q);
- if (alert_can_consolidate(NULL, q, alist)) {
- alert_list_add_alert(alist, q);
- n_added++;
- alert_queue_delete_alert(q);
- }
- khui_alert_unlock(q);
- khui_alert_release(q);
- }
- }
- }
-
- if (n_added == 0) {
- /* nothing to add */
- return 0;
- }
- }
-
- /* at this point, the alert list is not empty */
-#ifdef DEBUG
- assert(alist->n_alerts != 0);
- assert(alist->alerts[0]);
-#endif
-
- listtop = alist->alerts[0];
- khui_alert_hold(listtop);
- khui_alert_lock(listtop);
-
- queue_size = alert_queue_get_size();
-
- if (alert) {
- khui_alert_lock(alert);
- if (alert_can_consolidate(listtop, alert, alist)) {
- alert_list_add_alert(alist, alert);
- n_added ++;
- }
- khui_alert_unlock(alert);
- }
-
- if (add_from_queue) {
- for (i=0; i < queue_size; i++) {
- khui_alert * a;
-
- a = alert_queue_get_alert_by_pos(i);
- if (a == NULL)
- continue;
-
- khui_alert_lock(a);
- if (alert_can_consolidate(listtop, a, alist)) {
- alert_queue_delete_alert(a);
- alert_list_add_alert(alist, a);
- n_added ++;
-
- queue_size--;
- i--;
-#ifdef DEBUG
- assert(alert_queue_get_size() == queue_size);
-#endif
- }
- khui_alert_unlock(a);
- khui_alert_release(a);
- }
- }
-
- khui_alert_unlock(listtop);
- khui_alert_release(listtop);
-
- return n_added;
-}
-
-static khm_int32
-alert_check_consolidate_window(alerter_wnd_data * d, khui_alert * a) {
- alert_list alist;
- alerter_alert_data * adata;
- int n_added;
-
- alert_list_init(&alist);
-
- adata = QTOP(d);
- while(adata) {
-
-#ifdef DEBUG
- assert(adata->alert);
-#endif
- alert_list_add_alert(&alist, adata->alert);
-
- adata = QNEXT(adata);
- }
-
- n_added = alert_consolidate(&alist, a, FALSE);
-
- alert_list_destroy(&alist);
-
- return n_added;
-}
-
-static khm_int32
-alert_show_minimized(khui_alert * a) {
- wchar_t tbuf[64]; /* corresponds to NOTIFYICONDATA::szInfoTitle[] */
- wchar_t mbuf[256]; /* corresponds to NOTIFYICONDATA::szInfo[] */
-
-#ifdef DEBUG
- assert(a);
-#endif
- if (a == NULL)
- return KHM_ERROR_INVALID_PARAM;
-
- khui_alert_lock(a);
-
- if (a->message == NULL)
- goto done;
-
- if (a->title == NULL) {
- LoadString(khm_hInstance, IDS_ALERT_DEFAULT,
- tbuf, ARRAYLENGTH(tbuf));
- } else {
- StringCbCopy(tbuf, sizeof(tbuf), a->title);
- }
-
- if (FAILED(StringCbCopy(mbuf, sizeof(mbuf), a->message)) ||
- (!(a->flags & KHUI_ALERT_FLAG_DEFACTION) &&
- (a->n_alert_commands > 0 ||
- a->suggestion ||
- (a->flags & KHUI_ALERT_FLAG_VALID_ERROR)))) {
- /* if mbuf wasn't big enough, this should have copied a
- truncated version of it */
- size_t cch_m, cch_p;
- wchar_t postfix[256];
-
- cch_p = LoadString(khm_hInstance, IDS_ALERT_MOREINFO, postfix,
- ARRAYLENGTH(postfix));
- cch_p++; /* account for NULL */
-
- StringCchLength(mbuf, ARRAYLENGTH(mbuf), &cch_m);
- cch_m = min(cch_m, ARRAYLENGTH(mbuf) - cch_p);
-
- StringCchCopy(mbuf + cch_m, ARRAYLENGTH(mbuf) - cch_m,
- postfix);
-
- a->flags |= KHUI_ALERT_FLAG_REQUEST_WINDOW;
- }
-
- a->flags |= KHUI_ALERT_FLAG_DISPLAY_BALLOON;
-
-#ifdef DEBUG
- assert(balloon_alert == NULL);
-#endif
-
- if (balloon_alert) {
- khui_alert_lock(balloon_alert);
- balloon_alert->displayed = FALSE;
- khui_alert_unlock(balloon_alert);
- khui_alert_release(balloon_alert);
- balloon_alert = NULL;
- }
-
- balloon_alert = a;
- khui_alert_hold(a);
-
- a->displayed = TRUE;
-
- khm_notify_icon_balloon(a->severity,
- tbuf,
- mbuf,
- NTF_TIMEOUT);
-
- done:
- khui_alert_unlock(a);
-
- return KHM_ERROR_SUCCESS;
-}
-
-static khm_int32
-alert_show_normal(khui_alert * a) {
- wchar_t buf[256];
- wchar_t * title;
- alert_list alist;
-
- khui_alert_lock(a);
-
- if(a->title == NULL) {
- LoadString(khm_hInstance, IDS_ALERT_DEFAULT,
- buf, ARRAYLENGTH(buf));
- title = buf;
- } else
- title = a->title;
-
- khui_alert_unlock(a);
-
- alert_list_init(&alist);
- alert_list_set_title(&alist, title);
- alert_list_add_alert(&alist, a);
-
- alert_show_list(&alist);
-
- alert_list_destroy(&alist);
-
- return KHM_ERROR_SUCCESS;
-}
-
-static khm_int32
-alert_show_list(alert_list * alist) {
- HWND hwa;
-
- /* we don't need to keep track of the window handle
- because the window procedure adds it to the dialog
- list automatically */
-
- hwa =
- CreateWindowEx(ALERT_WINDOW_EX_SYLES,
- MAKEINTATOM(atom_alerter),
- alist->title,
- ALERT_WINDOW_STYLES,
- 0, 0, 300, 300, // bogus values
- khm_hwnd_main,
- (HMENU) NULL,
- khm_hInstance,
- (LPVOID) alist);
-
- ShowWindow(hwa, SW_SHOW);
-
- return (hwa != NULL);
-}
-
-static khm_int32
-alert_show(khui_alert * a) {
- khm_boolean show_normal = FALSE;
- khm_boolean show_mini = FALSE;
-
- khui_alert_lock(a);
-
- /* is there an alert already? If so, we just enqueue the message
- and let it sit. */
- if (ALERT_DISPLAYED() &&
- !(a->flags & KHUI_ALERT_FLAG_MODAL)) {
- khm_int32 rv;
- alerter_wnd_data * wdata;
-
- khui_alert_unlock(a);
-
- /* if there are any alerter windows displayed, check if this
- alert can be consolidated with any of them. If so, we
- should consolidate it. Otherwise, just enqueue it. */
- for(wdata = khui_alert_windows;
- wdata;
- wdata = LNEXT(wdata)) {
- if (alert_check_consolidate_window(wdata, a)) {
-
- add_alert_to_wnd_data(wdata, a);
- estimate_alerter_wnd_sizes(wdata);
- setup_alerter_window_controls(wdata);
-
- return KHM_ERROR_SUCCESS;
-
- }
- }
-
- rv = alert_enqueue(a);
-
- if (KHM_SUCCEEDED(rv))
- return KHM_ERROR_HELD;
- else
- return rv;
- }
-
- if((a->flags & KHUI_ALERT_FLAG_DISPLAY_WINDOW) ||
- ((a->flags & KHUI_ALERT_FLAG_DISPLAY_BALLOON) &&
- !(a->flags & KHUI_ALERT_FLAG_REQUEST_WINDOW))) {
-
- /* The alert has already been displayed. */
-
- show_normal = FALSE;
- show_mini = FALSE;
-
- } else {
-
- if(a->err_context != NULL ||
- a->err_event != NULL) {
- a->flags |= KHUI_ALERT_FLAG_VALID_ERROR;
- }
-
- /* depending on the state of the main window, we
- need to either show a window or a balloon */
- if ((a->flags & KHUI_ALERT_FLAG_MODAL) ||
- (khm_is_main_window_active() &&
- !(a->flags & KHUI_ALERT_FLAG_REQUEST_BALLOON)) ||
- (a->flags & KHUI_ALERT_FLAG_REQUEST_WINDOW)) {
-
- show_normal = TRUE;
-
- } else {
-
- show_mini = TRUE;
-
- }
- }
-
- khui_alert_unlock(a);
-
- if (show_normal)
- return alert_show_normal(a);
- else if (show_mini)
- return alert_show_minimized(a);
- else
- return KHM_ERROR_SUCCESS;
-}
-
-static void
-show_queued_alerts(void) {
-
- if (!ALERT_DISPLAYED()) {
-
- /* show next consolidated batch */
- alert_list alist;
- int n;
-
- alert_list_init(&alist);
- n = alert_consolidate(&alist, NULL, TRUE);
-
- if (n) {
- if (n == 1) {
- khui_alert_lock(alist.alerts[0]);
-
- if (alist.alerts[0]->title) {
- alert_list_set_title(&alist, alist.alerts[0]->title);
- } else {
- wchar_t title[KHUI_MAXCCH_TITLE];
- LoadString(khm_hInstance, IDS_ALERT_DEFAULT,
- title, ARRAYLENGTH(title));
- alert_list_set_title(&alist, title);
- }
-
- khui_alert_unlock(alist.alerts[0]);
- } else {
- wchar_t title[KHUI_MAXCCH_TITLE];
- LoadString(khm_hInstance, IDS_ALERT_DEFAULT,
- title, ARRAYLENGTH(title));
- alert_list_set_title(&alist, title);
- }
-
- alert_show_list(&alist);
- }
-
- alert_list_destroy(&alist);
-
- if (n == 0) {
- khui_alert * a;
-
- /* no alerts were shown above. This maybe because none of
- the alerts were consolidatable or they were requested
- to be shown in a balloon. In this case, we just take
- the first alert from the queue and show it manually. */
-
- a = alert_queue_get_alert();
- if (a) {
- alert_show(a);
- khui_alert_release(a);
- }
- }
-
- check_for_queued_alerts();
- }
-}
-
-
-static void
-check_for_queued_alerts(void) {
- if (!is_alert_queue_empty()) {
- khui_alert * a;
-
- a = alert_queue_peek();
-
- khui_alert_lock(a);
-
- if (a->title) {
- HICON hi;
- int res;
-
- if (a->severity == KHERR_ERROR)
- res = OIC_ERROR;
- else if (a->severity == KHERR_WARNING)
- res = OIC_WARNING;
- else
- res = OIC_INFORMATION;
-
- hi = LoadImage(0, MAKEINTRESOURCE(res),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
- LR_SHARED);
-
- khm_statusbar_set_part(KHUI_SBPART_NOTICE,
- hi,
- a->title);
- } else {
- khm_statusbar_set_part(KHUI_SBPART_NOTICE,
- NULL, NULL);
-#ifdef DEBUG
- DebugBreak();
-#endif
- }
-
- khui_alert_unlock(a);
- khui_alert_release(a);
-
- } else {
- khm_statusbar_set_part(KHUI_SBPART_NOTICE,
- NULL, NULL);
- }
-}
-
-static khm_int32
-alert_enqueue(khui_alert * a) {
- if (is_alert_queue_full())
- return KHM_ERROR_NO_RESOURCES;
-
- alert_queue_put_alert(a);
- check_for_queued_alerts();
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* the alerter window is actually a dialog */
-static LRESULT CALLBACK
-alerter_wnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- switch(uMsg) {
- case WM_CREATE:
- {
- LPCREATESTRUCT lpcs;
- alert_list * alist;
- alerter_wnd_data * d;
-
- lpcs = (LPCREATESTRUCT) lParam;
- alist = (alert_list *) lpcs->lpCreateParams;
-
- d = create_alerter_wnd_data(hwnd, alist);
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, NTF_PARAM, (LONG_PTR) d);
-#pragma warning(pop)
-
- khm_add_dialog(hwnd);
- khm_enter_modal(hwnd);
-
- estimate_alerter_wnd_sizes(d);
- setup_alerter_window_controls(d);
-
- if (d->hw_close) {
- SetFocus(d->hw_close);
- }
-
- return TRUE;
- }
- break; /* not reached */
-
- case WM_DESTROY:
- {
- alerter_wnd_data * d;
-
- /* khm_leave_modal() could be here, but instead it is in
- the WM_COMMAND handler. This is because the modal loop
- has to be exited before DestroyWindow() is issued. */
- //khm_leave_modal();
- khm_del_dialog(hwnd);
-
- d = (alerter_wnd_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, NTF_PARAM);
-
- if (d) {
- destroy_alerter_wnd_data(d);
- SetWindowLongPtr(hwnd, NTF_PARAM, 0);
- }
-
- return TRUE;
- }
- break;
-
- case WM_COMMAND:
- {
- alerter_wnd_data * d;
-
- d = (alerter_wnd_data *)(LONG_PTR)
- GetWindowLongPtr(hwnd, NTF_PARAM);
-
- if(HIWORD(wParam) == BN_CLICKED) {
- if (LOWORD(wParam) == IDC_NTF_CLOSE ||
- LOWORD(wParam) == KHUI_PACTION_NEXT) {
-
- khm_leave_modal();
-
- DestroyWindow(hwnd);
-
- return 0;
- }
- }
- }
- break;
-
- case WM_CLOSE:
- {
- khm_leave_modal();
-
- DestroyWindow(hwnd);
-
- return 0;
- }
- }
-
- /* Since this is a custom built dialog, we use DefDlgProc instead
- of DefWindowProc. */
- return DefDlgProc(hwnd, uMsg, wParam, lParam);
-}
-
-static LRESULT CALLBACK
-alert_bin_wnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
-{
- BOOL in_printclient = FALSE;
-
- switch(uMsg) {
- case WM_CREATE:
- {
- LPCREATESTRUCT lpcs;
- alerter_wnd_data * d;
-
- lpcs = (LPCREATESTRUCT) lParam;
- d = (alerter_wnd_data *) lpcs->lpCreateParams;
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) d);
-#pragma warning(pop)
- }
- return 0;
-
- case WM_ERASEBKGND:
- /* we erase the background when we are drawing the alerts
- anyway. */
- return 0;
-
- case WM_PRINTCLIENT:
- in_printclient = TRUE;
- /* fallthrough */
- case WM_PAINT:
- {
- HDC hdc;
- PAINTSTRUCT ps;
- RECT r;
- HFONT hf_old;
- int y;
- alerter_wnd_data * d;
- alerter_alert_data * adata;
- size_t len;
- int idx;
-
- d = (alerter_wnd_data *) (LONG_PTR) GetWindowLongPtr(hwnd, GWLP_USERDATA);
-#ifdef DEBUG
- assert(d);
-#endif
- if (d == NULL)
- break;
-
- if (in_printclient) {
- hdc = (HDC) wParam;
- ZeroMemory(&ps, sizeof(ps));
- } else {
- hdc = BeginPaint(hwnd, &ps);
- }
-
-#ifdef DEBUG
- assert(hdc);
- assert(d->hfont);
-#endif
-
-#ifdef ALERT_STATIC_BACKGROUND
- if (in_printclient || ps.fErase) {
- HBRUSH hb_background;
-
- hb_background = GetSysColorBrush(COLOR_BTNFACE);
-
- GetClientRect(hwnd, &r);
- FillRect(hdc, &r, hb_background);
- }
-#endif
-
- SetBkMode(hdc, TRANSPARENT);
-
- hf_old = SelectFont(hdc, d->hfont);
-
- y = -d->scroll_top;
- idx = 0;
- /* go through the alerts and display them */
- adata = QTOP(d);
- while(adata) {
- khui_alert * a;
-
-#ifndef ALERT_STATIC_BACKGROUND
-#define MIX_C(v1, v2, p) ((COLOR16)(((int)v1) * p + (((int) v2) * (256 - p))))
-#define ALPHA 50
- if (in_printclient || ps.fErase) {
- TRIVERTEX v[2];
- GRADIENT_RECT gr;
- COLORREF clr;
- COLORREF clr2;
-
- CopyRect(&r, &adata->r_alert);
- OffsetRect(&r, 0, y);
-
- v[0].x = r.left;
- v[0].y = r.top;
- v[0].Alpha = 0;
-
- v[1].x = r.right;
- v[1].y = r.bottom;
- v[1].Alpha = 0;
-
- if (idx == d->c_alert) {
- clr = GetSysColor(COLOR_HOTLIGHT);
-
- clr2 = GetSysColor(COLOR_BTNHIGHLIGHT);
- v[0].Red = MIX_C(GetRValue(clr), GetRValue(clr2), ALPHA);
- v[0].Green = MIX_C(GetGValue(clr), GetGValue(clr2), ALPHA);
- v[0].Blue = MIX_C(GetBValue(clr), GetBValue(clr2), ALPHA);
-
- clr2 = GetSysColor(COLOR_BTNFACE);
- v[1].Red = MIX_C(GetRValue(clr), GetRValue(clr2), ALPHA);
- v[1].Green = MIX_C(GetGValue(clr), GetGValue(clr2), ALPHA);
- v[1].Blue = MIX_C(GetBValue(clr), GetBValue(clr2), ALPHA);
- } else {
- clr = GetSysColor(COLOR_BTNHIGHLIGHT);
- v[0].Red = (COLOR16) ((int)GetRValue(clr)) << 8;
- v[0].Green = (COLOR16) ((int)GetGValue(clr)) << 8;
- v[0].Blue = (COLOR16) ((int)GetBValue(clr)) << 8;
-
- clr = GetSysColor(COLOR_BTNFACE);
- v[1].Red = (COLOR16) ((int)GetRValue(clr)) << 8;
- v[1].Green = (COLOR16) ((int)GetGValue(clr)) << 8;
- v[1].Blue = (COLOR16) ((int)GetBValue(clr)) << 8;
- }
-
- gr.UpperLeft = 0;
- gr.LowerRight = 1;
- GradientFill(hdc, v, 2, &gr, 1, GRADIENT_FILL_RECT_V);
- }
-#undef ALPHA
-#undef MIX_C
-#endif
-
- a = adata->alert;
-#ifdef DEBUG
- assert(a != NULL);
-#endif
- khui_alert_lock(a);
-
- if (!IsRectEmpty(&adata->r_title)) {
-
- CopyRect(&r, &adata->r_title);
- OffsetRect(&r, 0, y);
-
- StringCchLength(a->title, KHUI_MAXCCH_TITLE, &len);
-
- DrawEdge(hdc, &r, EDGE_RAISED, BF_RECT | BF_MIDDLE);
-
- InflateRect(&r, -d->s_pad.cx, -d->s_pad.cy);
-
- DrawText(hdc, a->title, (int) len, &r,
- DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
- }
-
- {
- HICON hicon;
- int iid;
-
- CopyRect(&r, &adata->r_icon);
- OffsetRect(&r, 0, y);
-
- if(a->severity == KHERR_ERROR)
- iid = OIC_HAND;
- else if(a->severity == KHERR_WARNING)
- iid = OIC_BANG;
- else
- iid = OIC_NOTE;
-
- hicon = (HICON) LoadImage(NULL,
- MAKEINTRESOURCE(iid),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON),
- LR_SHARED);
-
- DrawIcon(hdc, r.left, r.top, hicon);
- }
-
- if (a->message) {
-
- CopyRect(&r, &adata->r_message);
- OffsetRect(&r, 0, y);
-
- StringCchLength(a->message, KHUI_MAXCCH_MESSAGE, &len);
-
- DrawText(hdc, a->message, (int) len, &r,
- DT_WORDBREAK);
- }
-
- if (a->suggestion) {
- HICON hicon;
- SIZE sz;
-
- CopyRect(&r, &adata->r_suggestion);
- OffsetRect(&r, 0, y);
-
- DrawEdge(hdc, &r, EDGE_SUNKEN, BF_RECT | BF_MIDDLE);
-
- InflateRect(&r, -d->s_pad.cx, -d->s_pad.cy);
-
- sz.cx = GetSystemMetrics(SM_CXSMICON);
- sz.cy = GetSystemMetrics(SM_CYSMICON);
-
- hicon = (HICON) LoadImage(NULL,
- MAKEINTRESOURCE(OIC_NOTE),
- IMAGE_ICON,
- sz.cx,
- sz.cy,
- LR_SHARED);
-
- DrawIconEx(hdc, r.left, r.top, hicon, sz.cx, sz.cy, 0, NULL,
- DI_NORMAL);
-
- r.left += d->s_pad.cx + GetSystemMetrics(SM_CXSMICON);
-
- StringCchLength(a->suggestion, KHUI_MAXCCH_SUGGESTION, &len);
-
- DrawText(hdc, a->suggestion, (int) len, &r,
- DT_WORDBREAK);
- }
- khui_alert_unlock(a);
-
- y += adata->r_alert.bottom;
- idx++;
-
- adata = QNEXT(adata);
- }
-
- SelectFont(hdc, hf_old);
-
- if (!in_printclient) {
- EndPaint(hwnd, &ps);
- }
- }
- return 0;
-
- case WM_VSCROLL:
- {
- alerter_wnd_data * d;
- int new_pos = 0;
- SCROLLINFO si;
-
- d = (alerter_wnd_data *) (LONG_PTR) GetWindowLongPtr(hwnd, GWLP_USERDATA);
-#ifdef DEBUG
- assert(d);
-#endif
- if (d == NULL)
- break; /* we can't handle the message */
-
- ZeroMemory(&si, sizeof(si));
-
- switch(LOWORD(wParam)) {
- case SB_BOTTOM:
- new_pos = d->s_alerts.cy - d->cy_max_wnd;
- break;
-
- case SB_LINEDOWN:
- new_pos = d->scroll_top + SCROLL_LINE_SIZE(d);
- break;
-
- case SB_LINEUP:
- new_pos = d->scroll_top - SCROLL_LINE_SIZE(d);
- break;
-
- case SB_PAGEDOWN:
- new_pos = d->scroll_top + d->cy_max_wnd;
- break;
-
- case SB_PAGEUP:
- new_pos = d->scroll_top - d->cy_max_wnd;
- break;
-
- case SB_THUMBPOSITION:
- case SB_THUMBTRACK:
- si.fMask = SIF_TRACKPOS;
- GetScrollInfo(hwnd, SB_VERT, &si);
- new_pos = si.nTrackPos;
- break;
-
- case SB_TOP:
- new_pos = 0;
- break;
-
- case SB_ENDSCROLL:
- si.fMask = SIF_POS;
- si.nPos = d->scroll_top;
- SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
- return 0;
-
- default:
- return 0;
- }
-
- scroll_to_position(d, new_pos, FALSE);
- }
- return 0;
-
- case WM_COMMAND:
- {
- alerter_wnd_data * d;
-
- d = (alerter_wnd_data *) (LONG_PTR) GetWindowLongPtr(hwnd, GWLP_USERDATA);
-#ifdef DEBUG
- assert(d);
-#endif
- if (d == NULL)
- break;
-
- if (HIWORD(wParam) == BN_CLICKED) {
- process_command_button(d, LOWORD(wParam));
- return 0;
- } else if (HIWORD(wParam) == BN_SETFOCUS) {
- ensure_command_is_visible(d, LOWORD(wParam));
- return 0;
- }
- }
- break;
-
- case WM_LBUTTONUP:
- {
- alerter_wnd_data * d;
- int x,y;
-
- d = (alerter_wnd_data *) (LONG_PTR) GetWindowLongPtr(hwnd, GWLP_USERDATA);
-#ifdef DEBUG
- assert(d);
-#endif
- if (d == NULL)
- break;
-
- x = GET_X_LPARAM(lParam);
- y = GET_Y_LPARAM(lParam);
-
- handle_mouse_select(d, x, y);
- }
- break;
-
- case WM_SIZE:
- {
- InvalidateRect(hwnd, NULL, TRUE);
- }
- break;
-
- case WM_DESTROY:
- {
- /* nothing needs to be done here */
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- }
- return 0;
- }
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-ATOM khm_register_alerter_wnd_class(void)
-{
- WNDCLASSEX wcx;
-
- ZeroMemory(&wcx, sizeof(wcx));
-
- wcx.cbSize = sizeof(wcx);
- wcx.style =
- CS_OWNDC |
-#if(_WIN32_WINNT >= 0x0501)
- ((IS_COMMCTL6())? CS_DROPSHADOW: 0) |
-#endif
- 0;
- wcx.lpfnWndProc = alerter_wnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = DLGWINDOWEXTRA + sizeof(LONG_PTR);
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_MAIN_APP));
- wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_ALERTER_CLASS;
- wcx.hIconSm = NULL;
-
- atom_alerter = RegisterClassEx(&wcx);
-
- return atom_alerter;
-}
-
-ATOM khm_register_alert_bin_wnd_class(void)
-{
- WNDCLASSEX wcx;
-
- ZeroMemory(&wcx, sizeof(wcx));
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = CS_OWNDC;
-
- wcx.lpfnWndProc = alert_bin_wnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = sizeof(LONG_PTR);
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = NULL;
- wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_ALERTBIN_CLASS;
- wcx.hIconSm = NULL;
-
- atom_alert_bin = RegisterClassEx(&wcx);
-
- return atom_alert_bin;
-}
-
-/**********************************************************************
- Notification Icon
-***********************************************************************/
-
-#define KHUI_NOTIFY_ICON_ID 0
-
-void khm_notify_icon_add(void) {
- NOTIFYICONDATA ni;
- wchar_t buf[256];
-
- ZeroMemory(&ni, sizeof(ni));
-
- ni.cbSize = sizeof(ni);
- ni.hWnd = hwnd_notifier;
- ni.uID = KHUI_NOTIFY_ICON_ID;
- ni.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
- ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(iid_normal));
- ni.uCallbackMessage = KHUI_WM_NOTIFIER;
- LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
- StringCbCopy(tip_normal, sizeof(tip_normal), buf);
- LoadString(khm_hInstance, IDS_NOTIFY_READY, buf, ARRAYLENGTH(buf));
- StringCbCat(tip_normal, sizeof(tip_normal), buf);
-
- StringCbCopy(ni.szTip, sizeof(ni.szTip), tip_normal);
-
- Shell_NotifyIcon(NIM_ADD, &ni);
-
- DestroyIcon(ni.hIcon);
-
- ni.cbSize = sizeof(ni);
- ni.uVersion = NOTIFYICON_VERSION;
- Shell_NotifyIcon(NIM_SETVERSION, &ni);
-}
-
-void
-khm_notify_icon_balloon(khm_int32 severity,
- wchar_t * title,
- wchar_t * msg,
- khm_int32 timeout) {
- NOTIFYICONDATA ni;
- int iid;
-
- if (!msg || !title)
- return;
-
- ZeroMemory(&ni, sizeof(ni));
- ni.cbSize = sizeof(ni);
-
- if (severity == KHERR_INFO) {
- ni.dwInfoFlags = NIIF_INFO;
- iid = IDI_NOTIFY_INFO;
- } else if (severity == KHERR_WARNING) {
- ni.dwInfoFlags = NIIF_WARNING;
- iid = IDI_NOTIFY_WARN;
- } else if (severity == KHERR_ERROR) {
- ni.dwInfoFlags = NIIF_ERROR;
- iid = IDI_NOTIFY_ERROR;
- } else {
- ni.dwInfoFlags = NIIF_NONE;
- iid = iid_normal;
- }
-
- ni.hWnd = hwnd_notifier;
- ni.uID = KHUI_NOTIFY_ICON_ID;
- ni.uFlags = NIF_INFO | NIF_ICON;
- ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(iid));
-
- if (FAILED(StringCbCopy(ni.szInfo, sizeof(ni.szInfo), msg))) {
- /* too long? */
- StringCchCopyN(ni.szInfo, ARRAYLENGTH(ni.szInfo),
- msg,
- ARRAYLENGTH(ni.szInfo) - ARRAYLENGTH(ELLIPSIS));
- StringCchCat(ni.szInfo, ARRAYLENGTH(ni.szInfo),
- ELLIPSIS);
- }
-
- if (FAILED(StringCbCopy(ni.szInfoTitle, sizeof(ni.szInfoTitle),
- title))) {
- StringCchCopyN(ni.szInfoTitle, ARRAYLENGTH(ni.szInfoTitle),
- title,
- ARRAYLENGTH(ni.szInfoTitle) - ARRAYLENGTH(ELLIPSIS));
- StringCchCat(ni.szInfoTitle, ARRAYLENGTH(ni.szInfoTitle),
- ELLIPSIS);
- }
-
- ni.uTimeout = timeout;
-
- Shell_NotifyIcon(NIM_MODIFY, &ni);
-
- DestroyIcon(ni.hIcon);
-}
-
-void khm_notify_icon_expstate(enum khm_notif_expstate expseverity) {
- int new_iid;
-
- if (expseverity == KHM_NOTIF_OK)
- new_iid = IDI_APPICON_OK;
- else if (expseverity == KHM_NOTIF_WARN)
- new_iid = IDI_APPICON_WARN;
- else if (expseverity == KHM_NOTIF_EXP)
- new_iid = IDI_APPICON_EXP;
- else
- new_iid = IDI_NOTIFY_NONE;
-
- if (iid_normal == new_iid)
- return;
-
- iid_normal = new_iid;
-
- if (balloon_alert == NULL)
- khm_notify_icon_change(KHERR_NONE);
-}
-
-void khm_notify_icon_change(khm_int32 severity) {
- NOTIFYICONDATA ni;
- wchar_t buf[256];
- int iid;
-
- if (severity == KHERR_INFO)
- iid = IDI_NOTIFY_INFO;
- else if (severity == KHERR_WARNING)
- iid = IDI_NOTIFY_WARN;
- else if (severity == KHERR_ERROR)
- iid = IDI_NOTIFY_ERROR;
- else
- iid = iid_normal;
-
- ZeroMemory(&ni, sizeof(ni));
-
- ni.cbSize = sizeof(ni);
- ni.hWnd = hwnd_notifier;
- ni.uID = KHUI_NOTIFY_ICON_ID;
- ni.uFlags = NIF_ICON | NIF_TIP;
- ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(iid));
-
- if (severity == KHERR_NONE) {
- StringCbCopy(ni.szTip, sizeof(ni.szTip), tip_normal);
- } else {
- LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
- StringCbCopy(ni.szTip, sizeof(ni.szTip), buf);
- LoadString(khm_hInstance, IDS_NOTIFY_ATTENTION, buf, ARRAYLENGTH(buf));
- StringCbCat(ni.szTip, sizeof(ni.szTip), buf);
- }
-
- Shell_NotifyIcon(NIM_MODIFY, &ni);
-
- DestroyIcon(ni.hIcon);
-
- notifier_severity = severity;
-}
-
-void khm_notify_icon_tooltip(wchar_t * s) {
- wchar_t buf[256];
-
- LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
- StringCbCat(buf, sizeof(buf), s);
-
- StringCbCopy(tip_normal, sizeof(tip_normal), buf);
-
- if (notifier_severity == KHERR_NONE) {
- NOTIFYICONDATA ni;
-
- ZeroMemory(&ni, sizeof(ni));
-
- ni.cbSize = sizeof(ni);
- ni.hWnd = hwnd_notifier;
- ni.uID = KHUI_NOTIFY_ICON_ID;
- ni.uFlags = NIF_TIP;
-
- StringCbCopy(ni.szTip, sizeof(ni.szTip), tip_normal);
-
- Shell_NotifyIcon(NIM_MODIFY, &ni);
- }
-}
-
-void khm_notify_icon_remove(void) {
- NOTIFYICONDATA ni;
-
- ZeroMemory(&ni, sizeof(ni));
-
- ni.cbSize = sizeof(ni);
- ni.hWnd = hwnd_notifier;
- ni.uID = KHUI_NOTIFY_ICON_ID;
-
- Shell_NotifyIcon(NIM_DELETE, &ni);
-}
-
-khm_int32
-khm_get_default_notifier_action(void) {
- khm_int32 def_cmd = KHUI_ACTION_OPEN_APP;
- khm_handle csp_cw = NULL;
- khm_size i;
-
- if (KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ,
- &csp_cw)))
- def_cmd;
-
- khc_read_int32(csp_cw, L"NotificationAction", &def_cmd);
-
- khc_close_space(csp_cw);
-
- for (i=0; i < n_khm_notifier_actions; i++) {
- if (khm_notifier_actions[i] == def_cmd)
- break;
- }
-
- if (i < n_khm_notifier_actions)
- return def_cmd;
- else
- return KHUI_ACTION_OPEN_APP;
-}
-
-void khm_notify_icon_activate(void) {
- /* if there are any notifications waiting to be shown and there
- are no alerts already being shown, we show them. Otherwise we
- execute the default action. */
-
- khm_notify_icon_change(KHERR_NONE);
-
- if (balloon_alert != NULL && khui_alert_windows == NULL) {
-
- khui_alert * a;
- khm_boolean alert_done = FALSE;
-
- a = balloon_alert;
- balloon_alert = NULL;
-
- khui_alert_lock(a);
-
- a->displayed = FALSE;
-
- if ((a->flags & KHUI_ALERT_FLAG_DEFACTION) &&
- (a->n_alert_commands > 0)) {
-
- PostMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(a->alert_commands[0],
- 0),
- 0);
- alert_done = TRUE;
-
- } else if (a->flags & KHUI_ALERT_FLAG_REQUEST_WINDOW) {
-
- alert_show_normal(a);
- alert_done = TRUE;
-
- }
- khui_alert_unlock(a);
- khui_alert_release(a);
-
- if (alert_done)
- return;
- }
-
- if (!is_alert_queue_empty() && !ALERT_DISPLAYED()) {
-
- khm_show_main_window();
- show_queued_alerts();
-
- return;
- }
-
-
- /* if none of the above applied, then we perform the default
- action for the notification icon. */
- {
- khm_int32 cmd = 0;
-
- cmd = khm_get_default_notifier_action();
-
- if (cmd == KHUI_ACTION_OPEN_APP) {
- if (khm_is_main_window_visible()) {
- khm_hide_main_window();
- } else {
- khm_show_main_window();
- }
- } else {
- khui_action_trigger(cmd, NULL);
- }
-
- check_for_queued_alerts();
- }
-}
-
-/*********************************************************************
- Initialization
-**********************************************************************/
-
-void khm_init_notifier(void)
-{
- if(!khm_register_notifier_wnd_class())
- return;
-
- if(!khm_register_alerter_wnd_class())
- return;
-
- if(!khm_register_alert_bin_wnd_class())
- return;
-
- hwnd_notifier = CreateWindowEx(0,
- MAKEINTATOM(atom_notifier),
- KHUI_NOTIFIER_WINDOW,
- 0,
- 0,0,0,0,
- HWND_MESSAGE,
- NULL,
- khm_hInstance,
- NULL);
-
- if(hwnd_notifier != NULL) {
- kmq_subscribe_hwnd(KMSG_ALERT, hwnd_notifier);
- kmq_subscribe_hwnd(KMSG_CRED, hwnd_notifier);
- notifier_ready = TRUE;
-
- khm_notify_icon_add();
- } else {
-#ifdef DEBUG
- assert(hwnd_notifier != NULL);
-#endif
- }
- khm_timer_init();
-
- khm_addr_change_notifier_init();
-}
-
-void khm_exit_notifier(void)
-{
- khm_addr_change_notifier_exit();
-
- khm_timer_exit();
-
- if(hwnd_notifier != NULL) {
- khm_notify_icon_remove();
- kmq_unsubscribe_hwnd(KMSG_ALERT, hwnd_notifier);
- kmq_unsubscribe_hwnd(KMSG_CRED, hwnd_notifier);
- DestroyWindow(hwnd_notifier);
- hwnd_notifier = NULL;
- }
-
- if(atom_notifier != 0) {
- UnregisterClass(MAKEINTATOM(atom_notifier), khm_hInstance);
- atom_notifier = 0;
- }
-
- if(atom_alerter != 0) {
- UnregisterClass(MAKEINTATOM(atom_alerter), khm_hInstance);
- atom_alerter = 0;
- }
-
- if(atom_alert_bin != 0) {
- UnregisterClass(MAKEINTATOM(atom_alert_bin), khm_hInstance);
- atom_alert_bin = 0;
- }
-
- notifier_ready = FALSE;
-}
diff --git a/src/windows/identity/ui/notifier.h b/src/windows/identity/ui/notifier.h
deleted file mode 100644
index 4366fcb07..000000000
--- a/src/windows/identity/ui/notifier.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_NOTIFIER_H
-#define __KHIMAIRA_NOTIFIER_H
-
-extern HWND hwnd_notifier;
-
-enum khm_notif_expstate {
- KHM_NOTIF_EMPTY,
- KHM_NOTIF_OK,
- KHM_NOTIF_WARN,
- KHM_NOTIF_EXP
-};
-
-extern khm_int32 khm_notifier_actions[];
-extern khm_size n_khm_notifier_actions;
-
-void
-khm_init_notifier(void);
-
-void
-khm_exit_notifier(void);
-
-void
-khm_notify_icon_change(khm_int32 severity);
-
-void
-khm_notify_icon_tooltip(wchar_t * s);
-
-void
-khm_notify_icon_balloon(khm_int32 severity,
- wchar_t * title,
- wchar_t * msg,
- khm_int32 timeout);
-
-void
-khm_notify_icon_expstate(enum khm_notif_expstate expseverity);
-
-void
-khm_notify_icon_activate(void);
-
-khm_int32
-khm_get_default_notifier_action(void);
-
-#endif
diff --git a/src/windows/identity/ui/passwnd.c b/src/windows/identity/ui/passwnd.c
deleted file mode 100644
index e9c266051..000000000
--- a/src/windows/identity/ui/passwnd.c
+++ /dev/null
@@ -1,133 +0,0 @@
-#include<khmapp.h>
-
-static ATOM sAtom = 0;
-static HINSTANCE shInstance = 0;
-
-/* Callback for the MITPasswordControl
-This is a replacement for the normal edit control. It does not show the
-annoying password char in the edit box so that the number of chars in the
-password are not known.
-*/
-
-#define PASSWORDCHAR L'#'
-#define DLGHT(ht) (HIWORD(GetDialogBaseUnits())*(ht)/8)
-#define DLGWD(wd) (LOWORD(GetDialogBaseUnits())*(wd)/4)
-
-static
-LRESULT
-CALLBACK
-MITPasswordEditProc(
- HWND hWnd,
- UINT message,
- WPARAM wParam,
- LPARAM lParam
- )
-{
- static SIZE pwdcharsz;
- BOOL pass_the_buck = FALSE;
-
- if (message > WM_USER && message < 0x7FFF)
- pass_the_buck = TRUE;
-
- switch(message)
- {
- case WM_GETTEXT:
- case WM_GETTEXTLENGTH:
- case WM_SETTEXT:
- pass_the_buck = TRUE;
- break;
- case WM_PAINT:
- {
- HDC hdc;
- PAINTSTRUCT ps;
- RECT r;
-
- hdc = BeginPaint(hWnd, &ps);
- GetClientRect(hWnd, &r);
- Rectangle(hdc, 0, 0, r.right, r.bottom);
- EndPaint(hWnd, &ps);
- }
- break;
- case WM_SIZE:
- {
- MoveWindow(GetDlgItem(hWnd, 1), DLGWD(2), DLGHT(2),
- pwdcharsz.cx / 2, pwdcharsz.cy, TRUE);
- }
- break;
- case WM_LBUTTONDOWN:
- case WM_SETFOCUS:
- {
- SetFocus(GetDlgItem(hWnd, 1));
- }
- break;
- case WM_CREATE:
- {
- HWND heditchild;
- wchar_t pwdchar = PASSWORDCHAR;
- HDC hdc;
- /* Create a child window of this control for default processing. */
- hdc = GetDC(hWnd);
- GetTextExtentPoint32(hdc, &pwdchar, 1, &pwdcharsz);
- ReleaseDC(hWnd, hdc);
-
- heditchild =
- CreateWindow(L"edit", L"", WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL |
- ES_LEFT | ES_PASSWORD | WS_TABSTOP,
- 0, 0, 0, 0,
- hWnd,
- (HMENU)1,
- ((LPCREATESTRUCT)lParam)->hInstance,
- NULL);
- SendMessage(heditchild, EM_SETPASSWORDCHAR, PASSWORDCHAR, 0L);
- }
- break;
- }
-
- if (pass_the_buck)
- return SendMessage(GetDlgItem(hWnd, 1), message, wParam, lParam);
- return DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-khm_int32
-khm_register_passwnd_class(void)
-{
- if (!sAtom) {
- WNDCLASS wndclass;
-
- memset(&wndclass, 0, sizeof(WNDCLASS));
-
- shInstance = khm_hInstance;
-
- wndclass.style = CS_HREDRAW | CS_VREDRAW;
- wndclass.lpfnWndProc = (WNDPROC)MITPasswordEditProc;
- wndclass.cbClsExtra = sizeof(HWND);
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = shInstance;
- wndclass.hbrBackground = (void *)(COLOR_WINDOW + 1);
- wndclass.lpszClassName = MIT_PWD_DLL_CLASS;
- wndclass.hCursor = LoadCursor((HINSTANCE)NULL, IDC_IBEAM);
-
- sAtom = RegisterClass(&wndclass);
- }
-
- return (sAtom)?KHM_ERROR_SUCCESS:KHM_ERROR_UNKNOWN;
-}
-
-khm_int32
-khm_unregister_passwnd_class(void)
-{
- BOOL result = TRUE;
-
- if ((khm_hInstance != shInstance) || !sAtom) {
- return KHM_ERROR_INVALID_OPERATION;
- }
-
- result = UnregisterClass(MIT_PWD_DLL_CLASS, khm_hInstance);
- if (result) {
- sAtom = 0;
- shInstance = 0;
- return KHM_ERROR_SUCCESS;
- } else {
- return KHM_ERROR_UNKNOWN;
- }
-}
diff --git a/src/windows/identity/ui/passwnd.h b/src/windows/identity/ui/passwnd.h
deleted file mode 100644
index c3ab8ef31..000000000
--- a/src/windows/identity/ui/passwnd.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_PASSWND_H
-#define __KHIMAIRA_PASSWND_H
-
-/* Declarations for the MIT password change control. Functionally the
- same as the regular Windows password edit control but doesn't
- display the '*' password character. */
-
-#define MIT_PWD_DLL_CLASS L"MITPasswordWnd"
-
-khm_int32 khm_unregister_passwnd_class(void);
-khm_int32 khm_register_passwnd_class(void);
-
-#endif
diff --git a/src/windows/identity/ui/propertywnd.c b/src/windows/identity/ui/propertywnd.c
deleted file mode 100644
index 5f3030e59..000000000
--- a/src/windows/identity/ui/propertywnd.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-
-typedef struct tag_pw_data {
- khm_handle record;
- HWND hwnd_lv;
-} pw_data;
-
-ATOM khui_propertywnd_cls;
-
-#define ID_LISTVIEW 1
-
-#define PW_WM_SET_RECORD WM_USER
-
-void pw_update_property_data(HWND hw, pw_data * d)
-{
- HWND hwnd_lv;
- khm_int32 * attrs = NULL;
-
- hwnd_lv = d->hwnd_lv;
-
- if(hwnd_lv == NULL)
- return;
-
- ListView_DeleteAllItems(hwnd_lv);
-
- if(d->record != NULL) {
- wchar_t * buffer;
- khm_size attr_count;
- khm_size i;
- khm_size cb_buf;
- khm_size t;
- LVITEM lvi;
- int idx;
-
- if(KHM_FAILED(kcdb_attrib_get_count(
- KCDB_ATTR_FLAG_VOLATILE |
- KCDB_ATTR_FLAG_HIDDEN,
- 0,
- &attr_count)))
- return;
-
- attrs = PMALLOC(sizeof(khm_int32) * attr_count);
- assert(attrs != NULL);
-
- kcdb_attrib_get_ids(
- KCDB_ATTR_FLAG_VOLATILE |
- KCDB_ATTR_FLAG_HIDDEN,
- 0,
- attrs,
- &attr_count);
-
- cb_buf = sizeof(wchar_t) * 2048;
- buffer = PMALLOC(cb_buf);
- assert(buffer != NULL);
-
- for(i=0; i<attr_count; i++) {
- if(KHM_FAILED(kcdb_buf_get_attr(d->record, attrs[i], NULL, NULL, NULL)))
- continue;
-
- ZeroMemory(&lvi, sizeof(lvi));
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = (int) i;
- lvi.iSubItem = 0;
- lvi.pszText = buffer;
- lvi.lParam = (LPARAM) attrs[i];
-
- t = cb_buf;
- kcdb_attrib_describe(attrs[i], buffer, &t, KCDB_TS_SHORT);
-
- idx = ListView_InsertItem(hwnd_lv, &lvi);
-
- ZeroMemory(&lvi, sizeof(lvi));
- lvi.mask = LVIF_TEXT;
- lvi.iItem = idx;
- lvi.iSubItem = 1;
- lvi.pszText = buffer;
-
- t = cb_buf;
- kcdb_buf_get_attr_string(d->record, attrs[i], buffer, &t, 0);
-
- ListView_SetItem(hwnd_lv, &lvi);
- }
-
- PFREE(attrs);
- PFREE(buffer);
- }
-}
-
-LRESULT CALLBACK khui_property_wnd_proc(
- HWND hwnd,
- UINT msg,
- WPARAM wParam,
- LPARAM lParam)
-{
- BOOL child_msg = FALSE;
- pw_data * child;
-
- switch(msg) {
- case WM_CREATE:
- {
- CREATESTRUCT * cs;
- LVCOLUMN lvc;
- wchar_t sz_title[256];
-
- cs = (CREATESTRUCT *) lParam;
-
- child = PMALLOC(sizeof(*child));
- ZeroMemory(child, sizeof(*child));
-
-#pragma warning(push)
-#pragma warning(disable:4244)
- SetWindowLongPtr(hwnd, 0, (LONG_PTR) child);
-#pragma warning(pop)
-
- child->hwnd_lv = CreateWindow(
- WC_LISTVIEW,
- L"",
- WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
- LVS_REPORT | LVS_SORTASCENDING,
- 0, 0,
- cs->cx, cs->cy,
- hwnd,
- (HMENU) ID_LISTVIEW,
- khm_hInstance,
- NULL);
-
- ListView_SetExtendedListViewStyle(child->hwnd_lv,
- LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
-
- ZeroMemory(&lvc, sizeof(lvc));
- lvc.mask = LVCF_FMT | LVCF_ORDER | LVCF_TEXT | LVCF_WIDTH;
- lvc.fmt = LVCFMT_LEFT;
- lvc.cx = (cs->cx * 2)/ 5;
- lvc.pszText = sz_title;
- lvc.iSubItem = 0;
- lvc.iOrder = 0;
- LoadString(khm_hInstance, IDS_PROP_COL_PROPERTY, sz_title, ARRAYLENGTH(sz_title));
-
- ListView_InsertColumn(child->hwnd_lv, 0, &lvc);
-
- ZeroMemory(&lvc, sizeof(lvc));
- lvc.mask = LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
- lvc.fmt = LVCFMT_LEFT;
- lvc.cx = (cs->cx * 3)/ 5;
- lvc.pszText = sz_title;
- lvc.iSubItem = 1;
- lvc.iOrder = 1;
- LoadString(khm_hInstance, IDS_PROP_COL_VALUE, sz_title, ARRAYLENGTH(sz_title));
-
- ListView_InsertColumn(child->hwnd_lv, 1, &lvc);
-
- if(cs->lpCreateParams != NULL) {
- child->record = cs->lpCreateParams;
- kcdb_buf_hold(child->record);
- pw_update_property_data(hwnd, child);
- }
- }
- break;
-
- case PW_WM_SET_RECORD:
- {
- child = (pw_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (child == NULL)
- break;
-
- kcdb_buf_release(child->record);
- child->record = (khm_handle) lParam;
- kcdb_buf_hold(child->record);
- pw_update_property_data(hwnd, child);
- }
- return 0;
-
- case WM_DESTROY:
- {
- child = (pw_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- if (child) {
- kcdb_buf_release(child->record);
- PFREE(child);
- SetWindowLongPtr(hwnd, 0, 0);
- }
- }
- break;
-
- case WM_PAINT:
- break;
-
- default:
- child = (pw_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
- child_msg = TRUE;
- }
-
- /*
- if(child_msg && child && child->hwnd_lv)
- return SendMessage(child->hwnd_lv, msg, wParam, lParam);
- else
- */
- return DefWindowProc(hwnd, msg, wParam, lParam);
-}
-
-khm_int32 khm_register_propertywnd_class(void)
-{
- WNDCLASSEX wcx;
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = CS_DBLCLKS;
- wcx.lpfnWndProc = khui_property_wnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = sizeof(LONG_PTR);
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = NULL;
- wcx.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
- wcx.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_PROPERTYWND_CLASS_NAME;
- wcx.hIconSm = NULL;
-
- khui_propertywnd_cls = RegisterClassEx(&wcx);
-
- return (khui_propertywnd_cls == 0)?KHM_ERROR_UNKNOWN:KHM_ERROR_SUCCESS;
-}
-
-khm_int32 khm_unregister_propertywnd_class(void)
-{
- UnregisterClass(MAKEINTATOM(khui_propertywnd_cls), khm_hInstance);
-
- return KHM_ERROR_SUCCESS;
-}
diff --git a/src/windows/identity/ui/propertywnd.h b/src/windows/identity/ui/propertywnd.h
deleted file mode 100644
index c4a738eaf..000000000
--- a/src/windows/identity/ui/propertywnd.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_PROPERTYWND_H
-#define __KHIMAIRA_PROPERTYWND_H
-
-#define KHUI_PROPERTYWND_CLASS_NAME L"NetIDMgrPropertyWnd"
-
-khm_int32 khm_register_propertywnd_class(void);
-
-khm_int32 khm_unregister_propertywnd_class(void);
-
-#endif
diff --git a/src/windows/identity/ui/reqdaemon.c b/src/windows/identity/ui/reqdaemon.c
deleted file mode 100644
index ce3e0f9ed..000000000
--- a/src/windows/identity/ui/reqdaemon.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * 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
- * 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<khmapp.h>
-#include<assert.h>
-
-ATOM reqdaemon_atom = 0;
-HANDLE reqdaemon_thread = NULL;
-HWND reqdaemon_hwnd = NULL;
-
-LRESULT CALLBACK
-reqdaemonwnd_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- switch(uMsg) {
- case WM_CREATE:
- break;
-
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
-
- case WM_DESTROY:
- reqdaemon_hwnd = NULL;
- PostQuitMessage(0);
- break;
-
- /* Leash compatibility */
- case ID_OBTAIN_TGT_WITH_LPARAM:
- {
- wchar_t widname[KCDB_IDENT_MAXCCH_NAME];
- wchar_t wmapping[ARRAYLENGTH(KHUI_REQD_MAPPING_FORMAT) + 10];
- khm_handle identity = NULL;
- LPNETID_DLGINFO pdlginfo;
- LRESULT lr = 1;
- khm_int32 result;
- HANDLE hmap = NULL;
- HRESULT hr;
-
- hr = StringCbPrintf(wmapping, sizeof(wmapping),
- KHUI_REQD_MAPPING_FORMAT, (DWORD) lParam);
-#ifdef DEBUG
- assert(SUCCEEDED(hr));
-#endif
- hmap = CreateFileMapping(INVALID_HANDLE_VALUE,
- NULL,
- PAGE_READWRITE,
- 0, 4096,
- wmapping);
-
- if (hmap == NULL) {
- return -1;
- } else if (hmap != NULL && GetLastError() != ERROR_ALREADY_EXISTS) {
- CloseHandle(hmap);
- return -1;
- }
-
- pdlginfo = MapViewOfFile(hmap,
- FILE_MAP_WRITE,
- 0, 0,
- sizeof(*pdlginfo));
-
- if (pdlginfo == NULL) {
- CloseHandle(hmap);
- return 1;
- }
-
- if (pdlginfo->in.username[0] &&
- pdlginfo->in.realm[0] &&
- SUCCEEDED(StringCbPrintf(widname,
- sizeof(widname),
- L"%s@%s",
- pdlginfo->in.username,
- pdlginfo->in.realm))) {
-
- kcdb_identity_create(widname,
- KCDB_IDENT_FLAG_CREATE,
- &identity);
- }
-
- widname[0] = 0;
-
- do {
- if (khm_cred_is_in_dialog()) {
- khm_cred_wait_for_dialog(INFINITE, NULL, NULL, 0);
- }
-
- if (identity)
- khui_context_set_ex(KHUI_SCOPE_IDENT,
- identity,
- KCDB_CREDTYPE_INVALID,
- NULL,
- NULL,
- 0,
- NULL,
- pdlginfo,
- sizeof(*pdlginfo));
- else
- khui_context_reset();
-
- if (pdlginfo->dlgtype == NETID_DLGTYPE_TGT)
- SendMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(KHUI_ACTION_NEW_CRED, 0), 0);
- else if (pdlginfo->dlgtype == NETID_DLGTYPE_CHPASSWD)
- SendMessage(khm_hwnd_main, WM_COMMAND,
- MAKEWPARAM(KHUI_ACTION_PASSWD_ID, 0), 0);
- else
- break;
-
- if (KHM_FAILED(khm_cred_wait_for_dialog(INFINITE, &result,
- widname,
- sizeof(widname))))
- continue;
- else {
- lr = (result != KHUI_NC_RESULT_PROCESS);
- break;
- }
- } while(TRUE);
-
-#ifdef DEBUG
- assert(lr || pdlginfo->dlgtype != NETID_DLGTYPE_TGT ||
- widname[0]);
-#endif
-
- if (!lr && pdlginfo->dlgtype == NETID_DLGTYPE_TGT &&
- widname[0]) {
- khm_handle out_ident;
- wchar_t * atsign;
-
- atsign = wcsrchr(widname, L'@');
-
- if (atsign == NULL)
- goto _exit;
-
- if (KHM_SUCCEEDED(kcdb_identity_create(widname,
- 0,
- &out_ident))) {
- khm_size cb;
-
- pdlginfo->out.ccache[0] = 0;
-
- cb = sizeof(pdlginfo->out.ccache);
- kcdb_identity_get_attrib(out_ident,
- L"Krb5CCName",
- NULL,
- pdlginfo->out.ccache,
- &cb);
- kcdb_identity_release(out_ident);
- } else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
-
- *atsign++ = 0;
-
- StringCbCopy(pdlginfo->out.username,
- sizeof(pdlginfo->out.username),
- widname);
-
- StringCbCopy(pdlginfo->out.realm,
- sizeof(pdlginfo->out.realm),
- atsign);
- }
-
- _exit:
-
- if (pdlginfo)
- UnmapViewOfFile(pdlginfo);
- if (hmap)
- CloseHandle(hmap);
- if (identity)
- kcdb_identity_release(identity);
-
- return lr;
- }
-
-#ifdef DEPRECATED_REMOTE_CALL
- /* deprecated */
- case ID_OBTAIN_TGT_WITH_LPARAM:
- {
- char * param = (char *) GlobalLock((HGLOBAL) lParam);
- char * username = NULL;
- char * realm = NULL;
- char * title = NULL;
- char * ccache = NULL;
- wchar_t widname[KCDB_IDENT_MAXCCH_NAME];
- wchar_t wtitle[KHUI_MAXCCH_TITLE];
- size_t cch;
- khm_int32 rv = KHM_ERROR_SUCCESS;
- khm_handle identity = NULL;
- NETID_DLGINFO dlginfo;
-
- if (param) {
- if (*param)
- title = param;
-
- if (FAILED(StringCchLengthA(param, KHUI_MAXCCH_TITLE, &cch))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- rv = KHM_ERROR_INVALID_PARAM;
- goto _exit_tgt_with_lparam;
- }
-
- param += cch + 1;
-
- if (*param)
- username = param;
-
- if (FAILED(StringCchLengthA(param, KCDB_IDENT_MAXCCH_NAME, &cch))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- rv = KHM_ERROR_INVALID_PARAM;
- goto _exit_tgt_with_lparam;
- }
-
- param += cch + 1;
-
- if (*param)
- realm = param;
-
- if (FAILED(StringCchLengthA(param, KCDB_IDENT_MAXCCH_NAME, &cch))) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- rv = KHM_ERROR_INVALID_PARAM;
- goto _exit_tgt_with_lparam;
- }
-
- param += cch + 1;
-
- if (*param)
- ccache = param;
- }
-
- if (username && realm) {
-
- if (FAILED(StringCbPrintf(widname, sizeof(widname),
- L"%hs@%hs", username, realm))) {
- rv = KHM_ERROR_INVALID_PARAM;
- goto _exit_tgt_with_lparam;
- }
-
- rv = kcdb_identity_create(widname,
- KCDB_IDENT_FLAG_CREATE,
- &identity);
- if (KHM_FAILED(rv)) {
- goto _exit_tgt_with_lparam;
- }
- }
-
- ZeroMemory(&dlginfo, sizeof(dlginfo));
-
- dlginfo.size = NETID_DLGINFO_V1_SZ;
- dlginfo.dlgtype = NETID_DLGTYPE_TGT;
-
- if (title)
- StringCbCopy(dlginfo.in.title, sizeof(dlginfo.in.title),
- wtitle);
- if (username)
- AnsiStrToUnicode(dlginfo.in.username, sizeof(dlginfo.in.username),
- username);
- if (realm)
- AnsiStrToUnicode(dlginfo.in.realm, sizeof(dlginfo.in.realm),
- realm);
-
- if (ccache)
- AnsiStrToUnicode(dlginfo.in.ccache, sizeof(dlginfo.in.ccache),
- ccache);
-
- dlginfo.in.use_defaults = TRUE;
-
- do {
- if (khm_cred_is_in_dialog()) {
- khm_cred_wait_for_dialog(INFINITE);
- }
-
- khui_context_set_ex(KHUI_SCOPE_IDENT,
- identity,
- KCDB_CREDTYPE_INVALID,
- NULL,
- NULL,
- 0,
- NULL,
- &dlginfo,
- sizeof(dlginfo));
-
- if (title) {
- AnsiStrToUnicode(wtitle, sizeof(wtitle),
- title);
-
- khm_cred_obtain_new_creds(wtitle);
- } else {
- khm_cred_obtain_new_creds(NULL);
- }
-
- if (KHM_FAILED(khm_cred_wait_for_dialog(INFINITE)))
- continue;
- else
- break;
- } while(TRUE);
-
- _exit_tgt_with_lparam:
- if (identity)
- kcdb_identity_release(identity);
-
- GlobalUnlock((HGLOBAL) lParam);
- }
- return 0;
-#endif
-
- }
-
- return DefWindowProc(hwnd, uMsg, wParam, lParam);
-}
-
-DWORD WINAPI
-khm_reqdaemon_thread_proc(LPVOID vparam) {
- BOOL rv;
- MSG msg;
-#ifdef DEBUG
- DWORD dw;
-#endif
-
- PDESCTHREAD(L"Remote Request Daemon", L"App");
-
- khm_register_reqdaemonwnd_class();
-
-#ifdef DEBUG
- assert(reqdaemon_atom != 0);
-#endif
-
- reqdaemon_hwnd = CreateWindowEx(0,
- MAKEINTATOM(reqdaemon_atom),
- KHUI_REQDAEMONWND_NAME,
- 0,
- 0,0,0,0,
- HWND_MESSAGE,
- NULL,
- khm_hInstance,
- NULL);
-
-#ifdef DEBUG
- dw = GetLastError();
- assert(reqdaemon_hwnd != NULL);
-#endif
-
- while(rv = GetMessage(&msg, NULL, 0, 0)) {
- if (rv == -1) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- break;
- } else {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- reqdaemon_thread = NULL;
-
- khm_unregister_reqdaemonwnd_class();
-
- return 0;
-}
-
-void
-khm_register_reqdaemonwnd_class(void) {
- WNDCLASSEX wcx;
-
- ZeroMemory(&wcx, sizeof(wcx));
-
- wcx.cbSize = sizeof(wcx);
- wcx.style = 0;
- wcx.lpfnWndProc = reqdaemonwnd_proc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = 0;
- wcx.hInstance = khm_hInstance;
- wcx.hIcon = NULL;
- wcx.hCursor = NULL;
- wcx.hbrBackground = NULL;
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = KHUI_REQDAEMONWND_CLASS;
- wcx.hIconSm = NULL;
-
- reqdaemon_atom = RegisterClassEx(&wcx);
-
-#ifdef DEBUG
- assert(reqdaemon_atom != 0);
-#endif
-}
-
-void
-khm_unregister_reqdaemonwnd_class(void) {
- if (reqdaemon_atom != 0) {
- UnregisterClass(MAKEINTATOM(reqdaemon_atom), khm_hInstance);
- reqdaemon_atom = 0;
- }
-}
-
-void
-khm_init_request_daemon(void) {
-#ifdef DEBUG
- assert(reqdaemon_thread == NULL);
-#endif
-
- reqdaemon_thread = CreateThread(NULL,
- 0,
- khm_reqdaemon_thread_proc,
- NULL,
- 0,
- NULL);
-
-#ifdef DEBUG
- assert(reqdaemon_thread != NULL);
-#endif
-}
-
-void
-khm_exit_request_daemon(void) {
- if (reqdaemon_hwnd == NULL)
- return;
-
- SendMessage(reqdaemon_hwnd, WM_CLOSE, 0, 0);
-}
diff --git a/src/windows/identity/ui/reqdaemon.h b/src/windows/identity/ui/reqdaemon.h
deleted file mode 100644
index 99a50f5e0..000000000
--- a/src/windows/identity/ui/reqdaemon.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_REQDAEMON_H
-#define __KHIMAIRA_REQDAEMON_H
-
-void
-khm_register_reqdaemonwnd_class(void);
-
-void
-khm_unregister_reqdaemonwnd_class(void);
-
-void
-khm_init_request_daemon(void);
-
-void
-khm_exit_request_daemon(void);
-
-#endif
diff --git a/src/windows/identity/ui/resource.h b/src/windows/identity/ui/resource.h
deleted file mode 100644
index d14a95fde..000000000
--- a/src/windows/identity/ui/resource.h
+++ /dev/null
@@ -1,421 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by C:\work\pismere\athena\auth\krb5\src\windows\identity\ui\lang\en_us\khapp.rc
-//
-#define IDI_MAIN_APP 104
-#define IDD_PP_CRED 106
-#define IDD_PP_IDENT 107
-#define IDB_TK_REFRESH 108
-#define IDS_MAIN_WINDOW_TITLE 108
-#define IDS_MENU_FILE 109
-#define IDB_ID 110
-#define IDS_MENU_CRED 110
-#define IDB_ID_DELETE 111
-#define IDS_MENU_VIEW 111
-#define IDB_ID_NEW 112
-#define IDS_MENU_OPTIONS 112
-#define IDB_ID_REFRESH 113
-#define IDS_MENU_HELP 113
-#define IDB_TK 114
-#define IDS_ACTION_PROPERTIES 114
-#define IDB_TK_DELETE 115
-#define IDS_ACTION_EXIT 115
-#define IDB_TK_NEW 116
-#define IDS_CFG_ROOT_NAME 116
-#define IDS_ACTION_SET_DEF_ID 117
-#define IDS_ACTION_SET_SRCH_ID 118
-#define IDB_VW_REFRESH_SM 118
-#define IDR_MENU_BAR 119
-#define IDS_CFG_ROOT_TITLE 119
-#define IDS_CFG_GENERAL_SHORT 120
-#define IDB_TB_BLANK 121
-#define IDS_ACTION_NEW_CRED 121
-#define IDS_ACTION_PASSWD_ID 122
-#define IDS_ACTION_CHOOSE_COLS 123
-#define IDB_TB_BLANK_SM 123
-#define IDS_ACTION_DEBUG_WINDOW 124
-#define IDB_VW_REFRESH 124
-#define IDS_ACTION_VIEW_REFRESH 125
-#define IDB_ID_DELETE_DIS 125
-#define IDS_MENU_LAYOUT 126
-#define IDB_ID_DELETE_DIS_SM 126
-#define IDS_MENU_TOOLBARS 127
-#define IDB_ID_DELETE_SM 127
-#define IDS_ACTION_LAYOUT_ID 128
-#define IDB_ID_DIS 128
-#define IDS_ACTION_LAYOUT_TYPE 129
-#define IDB_ID_DIS_SM 129
-#define IDS_ACTION_LAYOUT_LOC 130
-#define IDB_ID_NEW_DIS 130
-#define IDS_ACTION_TB_STANDARD 131
-#define IDB_ID_NEW_DIS_SM 131
-#define IDS_ACTION_OPT_KHIM 132
-#define IDB_ID_NEW_SM 132
-#define IDB_ID_REFRESH_DIS 133
-#define IDS_ACTION_OPT_IDENTS 133
-#define IDS_ACTION_OPT_NOTIF 134
-#define IDB_ID_REFRESH_SM 134
-#define IDS_ACTION_HELP_CTX 135
-#define IDB_ID_REFRESH_DIS_SM 135
-#define IDS_ACTION_HELP_CONTENTS 136
-#define IDB_TK_DELETE_DIS 136
-#define IDS_ACTION_HELP_INDEX 137
-#define IDB_TK_DELETE_DIS_SM 137
-#define IDS_ACTION_HELP_ABOUT 138
-#define IDB_TK_DELETE_SM 138
-#define IDB_TK_DIS_SM 139
-#define IDS_CFG_GENERAL_LONG 139
-#define IDB_TK_NEW_DIS 140
-#define IDS_SAMPLE_STRING 140
-#define IDB_TK_NEW_DIS_SM 141
-#define IDS_NO_CREDS 141
-#define IDB_TK_NEW_SM 142
-#define IDS_WT_INIT_CREDS 142
-#define IDB_TK_REFRESH_DIS 143
-#define IDS_WT_NEW_CREDS 143
-#define IDB_TK_REFRESH_DIS_SM 144
-#define IDS_NC_IDENTITY 144
-#define IDB_TK_REFRESH_SM 145
-#define IDS_NC_IDENTS 145
-#define IDB_TK_SM 146
-#define IDS_NC_CREDTEXT_ID_NONE 146
-#define IDB_HELP_SM 147
-#define IDS_NC_CREDTEXT_ID_ONE 147
-#define IDB_HELP 148
-#define IDS_NC_CREDTEXT_ID_MANY 148
-#define IDB_LOGO_SHADE 149
-#define IDS_NC_CREDTEXT_ID_INVALID 149
-#define IDS_WTPOST_INIT_CREDS 150
-#define IDS_WTPOST_NEW_CREDS 151
-#define IDB_WDG_EXPAND 152
-#define IDS_ACTION_RENEW_CRED 152
-#define IDB_WDG_COLLAPSE 153
-#define IDS_ACTION_DESTROY_CRED 153
-#define IDB_ID_SM 154
-#define IDS_DEFAULT_FONT 154
-#define IDB_WDG_EXPAND_HI 155
-#define IDS_NC_CREDTEXT_TABS 155
-#define IDB_WDG_COLLAPSE_HI 156
-#define IDS_NOTIFY_PREFIX 156
-#define IDB_WDG_CREDTYPE 157
-#define IDS_NOTIFY_READY 157
-#define IDB_WDG_FLAG 158
-#define IDS_NOTIFY_ATTENTION 158
-#define IDB_FLAG_WARN 159
-#define IDS_ALERT_DEFAULT 159
-#define IDB_FLAG_EXPIRED 160
-#define IDS_PACTION_OK 160
-#define IDB_FLAG_CRITICAL 161
-#define IDS_PACTION_CANCEL 161
-#define IDS_PACTION_CLOSE 162
-#define IDD_NC_NEWCRED 162
-#define IDD_NC_BBAR 163
-#define IDS_ALERT_NOSEL_TITLE 163
-#define IDS_ALERT_NOSEL 164
-#define IDI_ENABLED 165
-#define IDS_NC_CREDTEXT_ID_VALID 165
-#define IDI_DISABLED 166
-#define IDS_NC_CREDTEXT_ID_UNCHECKED 166
-#define IDS_PROP_COL_PROPERTY 167
-#define IDS_PROP_COL_VALUE 168
-#define IDI_NOTIFY_NONE 169
-#define IDS_NC_NEW_IDENT 169
-#define IDI_NOTIFY_INFO 170
-#define IDS_NC_CREDTEXT_ID_CHECKING 170
-#define IDI_NOTIFY_WARN 171
-#define IDS_ACTION_OPEN_APP 171
-#define IDI_NOTIFY_ERROR 172
-#define IDS_CTX_NEW_IDENT 172
-#define IDS_CTX_NEW_CREDS 173
-#define IDD_CFG_MAIN 173
-#define IDS_CTX_RENEW_CREDS 174
-#define IDD_CFG_GENERIC 174
-#define IDS_CTX_PROC_NEW_IDENT 175
-#define IDB_LOGO_OPAQUE 175
-#define IDS_CTX_PROC_NEW_CREDS 176
-#define IDD_CFG_GENERAL 176
-#define IDS_CTX_PROC_RENEW_CREDS 177
-#define IDD_CFG_IDENTITIES 177
-#define IDS_ACTION_CLOSE_APP 178
-#define IDD_CFG_NOTIF 178
-#define IDS_NC_FAILED_TITLE 179
-#define IDD_CFG_PLUGINS 179
-#define IDS_CFG_IDENTITIES_SHORT 180
-#define IDD_CFG_IDENTITY 180
-#define IDS_CFG_IDENTITIES_LONG 181
-#define IDI_CFG_DEFAULT 181
-#define IDS_CFG_NOTIF_SHORT 182
-#define IDI_CFG_MODIFIED 182
-#define IDS_CFG_NOTIF_LONG 183
-#define IDI_CFG_APPLIED 183
-#define IDS_CFG_PLUGINS_SHORT 184
-#define IDD_CFG_IDS_TAB 184
-#define IDS_CFG_PLUGINS_LONG 185
-#define IDD_CFG_ID_TAB 185
-#define IDS_CFG_IDENTITY_SHORT 186
-#define IDI_CFG_DELETED 186
-#define IDS_CFG_IDENTITY_LONG 187
-#define IDI_ID 187
-#define IDS_CTX_DESTROY_CREDS 188
-#define IDB_IMPORT_SM_DIS 188
-#define IDS_WARN_EXPIRE 189
-#define IDB_IMPORT 189
-#define IDS_WARN_TITLE 190
-#define IDB_IMPORT_DIS 190
-#define IDS_ALERT_MOREINFO 191
-#define IDB_IMPORT_SM 191
-#define IDS_WARN_EXPIRED 192
-#define IDB_CHPW_SM 192
-#define IDS_WARN_EXPIRE_ID 193
-#define IDB_CHPW 193
-#define IDS_WARN_EXPIRED_ID 194
-#define IDB_CHPW_DIS 194
-#define IDS_WARN_WM_TITLE 195
-#define IDB_CHPW_DIS_SM 195
-#define IDS_WARN_WM_MSG 196
-#define IDD_ABOUT 196
-#define IDS_CFG_ID_TAB_SHORT 197
-#define IDB_TB_SPACE 197
-#define IDS_CFG_ID_TAB_LONG 198
-#define IDB_WDG_STUCK_HI 198
-#define IDS_CFG_IDS_TAB_SHORT 199
-#define IDB_WDG_STICK 199
-#define IDS_CFG_IDS_TAB_LONG 200
-#define IDB_WDG_STICK_HI 200
-#define IDS_CFG_IDS_IDENTITY 201
-#define IDB_WDG_STUCK 201
-#define IDS_ACTION_IMPORT 202
-#define IDS_CTX_IMPORT 203
-#define IDB_FLAG_RENEW 203
-#define IDS_CFG_PI_COL_PLUGINS 204
-#define IDI_APPICON_WARN 204
-#define IDS_PISTATE_FAILUNK 205
-#define IDI_APPICON_EXP 205
-#define IDS_PISTATE_FAILMAX 206
-#define IDI_APPICON_OK 206
-#define IDS_PISTATE_FAILREG 207
-#define IDI_CFG_PLUGIN 207
-#define IDS_PISTATE_FAILDIS 208
-#define IDI_CFG_PLUGIN_ERR 208
-#define IDS_PISTATE_FAILLOD 209
-#define IDI_CFG_PLUGIN_DIS 209
-#define IDS_PISTATE_PLACEHOLD 210
-#define IDD_CFG_APPEAR 210
-#define IDS_PISTATE_REG 211
-#define IDD_CFG_ADDIDENT 211
-#define IDS_PISTATE_HOLD 212
-#define IDD_CMDLINE 212
-#define IDS_PISTATE_INIT 213
-#define IDR_CMDLINERTF 213
-#define IDS_PISTATE_RUN 214
-#define IDS_PISTATE_EXIT 215
-#define IDS_CTX_PASSWORD 216
-#define IDS_WT_PASSWORD 217
-#define IDS_WTPOST_PASSWORD 218
-#define IDS_CTX_PROC_PASSWORD 219
-#define IDS_NC_PWD_FAILED_TITLE 220
-#define IDS_MENU_SETDEF 221
-#define IDS_PACTION_NEXT 222
-#define IDS_ERR_TITLE_NO_IDENTPRO 223
-#define IDS_ERR_MSG_NO_IDENTPRO 224
-#define IDS_ERR_SUGG_NO_IDENTPRO 225
-#define IDS_NC_REN_FAILED_TITLE 226
-#define IDS_CW_DEFAULT 227
-#define IDS_ACTION_OPT_PLUGINS 228
-#define IDS_NC_SETDEF 229
-#define IDS_NC_ID_DEF 230
-#define IDS_NC_ID_WDEF 231
-#define IDS_NC_ID_NDEF 232
-#define IDS_PACTION_YES 233
-#define IDS_PACTION_NO 234
-#define IDS_PACTION_YESALL 235
-#define IDS_PACTION_NOALL 236
-#define IDS_PACTION_KEEP 237
-#define IDS_PACTION_REMOVE 238
-#define IDS_PACTION_DISCARD 239
-#define IDS_CFG_IT_MOD 240
-#define IDS_CFG_IT_APP 241
-#define IDS_CFG_IT_NONE 242
-#define IDS_CFG_NODESC 243
-#define IDS_CFG_P_DELCNFT 244
-#define IDS_CFG_P_DELCNFM 245
-#define IDS_CFG_P_DELCNFS 246
-#define IDS_CFG_P_DELNDEP 247
-#define IDS_CFG_P_ENBCNFT 248
-#define IDS_CFG_P_ENBCNFM 249
-#define IDS_PISTATE_FAILINIT 250
-#define IDS_CFG_P_UNRCNFT 251
-#define IDS_CFG_P_UNRCNFM 252
-#define IDS_CFG_P_UNRCNFS 253
-#define IDS_ACTION_LAYOUT_CUST 254
-#define IDS_APR_HEADER_TEXT 255
-#define IDS_APR_HEADER_TEXT_BOLD 256
-#define IDS_APR_TEXT 257
-#define IDS_APR_TEXT_BOLD 258
-#define IDS_APR_SAMPLE_TEXT_NORMAL 259
-#define IDS_CFG_APPEAR_SHORT 260
-#define IDS_CFG_APPEAR_LONG 261
-#define IDS_ACTION_OPT_APPEAR 262
-#define IDS_APR_SAMPLE_TEXT_SEL 263
-#define IDS_CFG_IDNAME_INV 264
-#define IDS_CFG_IDNAME_PRB 265
-#define IDS_CFG_IDNAME_EXT 266
-#define IDS_CFG_IDNAME_CCR 267
-#define IDS_CFG_IDNAME_CCC 268
-#define IDS_CFG_LOGF_CS 269
-#define IDS_CFG_LOGF_CSR 270
-#define IDS_ACTIONT_PROPERTIES 271
-#define IDS_ACTIONT_EXIT 272
-#define IDS_ACTIONT_SET_DEF_ID 273
-#define IDS_ACTIONT_PASSWD_ID 274
-#define IDS_ACTIONT_NEW_CRED 275
-#define IDS_ACTIONT_RENEW_CRED 276
-#define IDS_ACTIONT_DESTROY_CRED 277
-#define IDS_ACTIONT_VIEW_REFRESH 278
-#define IDS_ACTIONT_OPT_IDENTS 279
-#define IDS_ACTIONT_OPT_KHIM 280
-#define IDS_ACTIONT_OPT_NOTIF 281
-#define IDS_ACTIONT_OPT_PLUGINS 282
-#define IDS_ACTIONT_OPT_APPEAR 283
-#define IDS_ACTIONT_HELP_CTX 284
-#define IDS_ACTIONT_IMPORT 285
-#define IDS_NC_FAILED_TITLE_I 286
-#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 IDS_NCN_IDENT_INVALID 297
-#define IDS_NCN_IDENT_CHECKING 298
-#define IDS_NCN_IDENT_UNKNOWN 299
-#define IDS_REMOTE_FAIL 300
-#define IDS_REMOTE_FAIL_TITLE 301
-#define IDS_IDACTION_NEW 302
-#define IDS_IDACTIONT_NEW 303
-#define IDS_IDACTIONT_RENEW 304
-#define IDS_IDACTIONT_DESTROY 305
-#define IDS_ALERTTYPE_PLUGIN 306
-#define IDS_ALERTTYPE_EXPIRE 307
-#define IDS_ALERTTYPE_RENEWFAIL 308
-#define IDS_ALERTTYPE_ACQUIREFAIL 309
-#define IDS_ALERTTYPE_CHPW 310
-#define IDS_ACTION_LAYOUT_MINI 311
-#define IDS_IDEXPDISP_NOCRED 312
-#define IDS_IDEXPDISP_1CRED 313
-#define IDS_IDEXPDISP_NCRED 314
-#define IDS_CW_DEFAULTTF 315
-#define IDS_CW_TYPEF 316
-#define IDS_CW_EXPIREF 317
-#define IDS_CW_EXPIRED 318
-#define IDS_IDACTIONT_SETDEF 319
-#define IDS_IDACTION_SETDEF 320
-#define IDS_ACTION_VIEW_ALL_IDS 321
-#define IDC_NC_CREDTEXT_LABEL 1009
-#define IDC_NC_CREDTEXT 1012
-#define IDC_NC_HELP 1017
-#define IDC_NC_ADVANCED 1019
-#define IDC_PP_IDNAME 1026
-#define IDC_PP_IDDEF 1027
-#define IDC_PP_IDSEARCH 1028
-#define IDC_PP_PROPLIST 1035
-#define IDC_PP_CPROPLIST 1036
-#define IDC_NC_TPL_ROW 1039
-#define IDC_NC_TPL_PANEL 1040
-#define IDC_NC_TPL_LABEL 1041
-#define IDC_NC_TPL_INPUT 1042
-#define IDC_NC_TPL_LABEL_LG 1043
-#define IDC_NC_TPL_INPUT_LG 1044
-#define IDC_NC_TPL_ROW_LG 1045
-#define IDC_CFG_NODELIST 1045
-#define IDAPPLY 1048
-#define IDC_CFG_TITLE 1050
-#define IDC_CFG_PANE 1051
-#define IDC_NOTIF_MONITOR 1053
-#define IDC_PP_DUMMY 1054
-#define IDC_NOTIF_RENEW 1055
-#define IDC_NOTIF_RENEW_THR 1056
-#define IDC_NOTIF_WARN1 1057
-#define IDC_NOTIF_WARN1_THR 1058
-#define IDC_NOTIF_WARN2 1059
-#define IDC_NOTIF_WARN2_THR 1060
-#define IDC_CFG_KEEPRUNNING 1061
-#define IDC_CFG_STARTUP_GROUP 1062
-#define IDC_CFG_AUTOSTART 1063
-#define IDC_CFG_AUTOIMPORT 1064
-#define IDC_CFG_AUTOINIT 1065
-#define IDC_CFG_OTHER 1066
-#define IDC_CFG_MONITOR 1069
-#define IDC_CFG_STICKY 1070
-#define IDC_CFG_RENEW 1075
-#define IDC_CFG_REMOVE 1076
-#define IDC_CFG_TAB 1077
-#define IDC_CFG_TARGET 1078
-#define IDC_CFG_PLUGINS 1079
-#define IDC_CFG_DESC 1084
-#define IDC_CFG_LBL_STATE 1085
-#define IDC_CFG_STATE 1086
-#define IDC_CFG_LBL_DEPS 1087
-#define IDC_CFG_DEPS 1088
-#define IDC_CFG_DISABLE 1089
-#define IDC_CFG_ENABLE 1090
-#define IDC_CFG_LBL_MOD 1092
-#define IDC_CFG_MODULE 1093
-#define IDC_CFG_LBL_VEN 1094
-#define IDC_CFG_VENDOR 1095
-#define IDC_CFG_REGISTER 1097
-#define IDC_CFG_NETDETECT 1098
-#define IDC_PP_STICKY 1099
-#define IDC_PRODUCT 1100
-#define IDC_COPYRIGHT 1101
-#define IDC_BUILDINFO 1102
-#define IDC_MODULES 1103
-#define IDC_PP_CONFIG 1104
-#define IDC_CFG_UNREGISTER 1107
-#define IDC_CFG_VERSION 1108
-#define IDC_CFG_ICON 1109
-#define IDC_CFG_LOGTOFILE 1110
-#define IDC_CFG_LOGPATH 1111
-#define IDC_NOTIF_HALFLIFE 1112
-#define IDC_CFG_DESTROYALL 1113
-#define IDC_CFG_SAMPLE_NORMAL 1123
-#define IDC_CFG_REVERT 1127
-#define IDC_CFG_FONTS 1128
-#define IDC_CFG_SAMPLE_BOLD 1129
-#define IDC_CFG_SIZE 1130
-#define IDC_CFG_BOLD 1131
-#define IDC_CFG_ITALICS 1132
-#define IDC_CFG_ADDIDENT 1133
-#define IDC_SM_CTL 1134
-#define IDC_CFG_SHOWLOG 1135
-#define IDC_MED_CTL 1135
-#define IDC_LG_CTL 1136
-#define IDC_SM_LBL 1137
-#define IDC_MED_LBL 1138
-#define IDC_LG_LBL 1139
-#define IDC_CFG_NOTACTION 1141
-#define IDC_CFG_NOTACT_STATIC 1142
-#define IDC_NC_BASIC 1143
-#define IDC_CONTENT 1144
-#define IDA_ACTIVATE_MENU 40003
-#define IDA_UP 40004
-#define IDA_DOWN 40005
-#define IDA_LEFT 40006
-#define IDA_RIGHT 40007
-#define IDA_ESC 40008
-#define IDA_ENTER 40009
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 214
-#define _APS_NEXT_COMMAND_VALUE 40010
-#define _APS_NEXT_CONTROL_VALUE 1145
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/windows/identity/ui/statusbar.c b/src/windows/identity/ui/statusbar.c
deleted file mode 100644
index 51b7ad302..000000000
--- a/src/windows/identity/ui/statusbar.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#ifdef DEBUG
-#include<assert.h>
-#endif
-
-khm_statusbar_part khm_statusbar_parts[] = {
- {KHUI_SBPART_INFO, 0, KHUI_SB_WTYPE_FILLER, NULL},
- {KHUI_SBPART_NOTICE, 40, KHUI_SB_WTYPE_RELATIVE, NULL},
-#if 0
- /* Not implemented. This was originally intended to provide
- location information. */
- {KHUI_SBPART_LOC, 40, KHUI_SB_WTYPE_ABSOLUTE, NULL}
-#endif
-};
-
-int khm_n_statusbar_parts = sizeof(khm_statusbar_parts) / sizeof(khm_statusbar_part);
-
-HWND khm_hwnd_statusbar = NULL;
-
-LRESULT
-khm_statusbar_notify(LPNMHDR nmhdr) {
- LPNMMOUSE pnmm;
-
- switch(nmhdr->code) {
- case NM_CLICK:
- case NM_DBLCLK:
- pnmm = (LPNMMOUSE) nmhdr;
-
- if (pnmm->dwItemSpec >= (DWORD) khm_n_statusbar_parts)
- return TRUE;
-
- if (khm_statusbar_parts[pnmm->dwItemSpec].id == KHUI_SBPART_NOTICE) {
- /* means, show next notification */
- kmq_post_message(KMSG_ALERT, KMSG_ALERT_SHOW_QUEUED, 0, 0);
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-void
-khui_statusbar_set_parts(HWND parent) {
- int i;
- int fillerwidth;
- int staticwidth;
- int lastx;
- int width;
- RECT r;
- INT * parts;
-
- GetClientRect(parent, &r);
- width = r.right - r.left;
-
- /* calculate fillerwidth and staticwidth */
- staticwidth = 0;
- for(i=0;i<khm_n_statusbar_parts;i++) {
- if(khm_statusbar_parts[i].wtype == KHUI_SB_WTYPE_ABSOLUTE) {
- staticwidth += khm_statusbar_parts[i].width;
- } else if(khm_statusbar_parts[i].wtype == KHUI_SB_WTYPE_RELATIVE) {
- staticwidth += (khm_statusbar_parts[i].width * width) / 100;
- }
- }
-
- fillerwidth = width - staticwidth;
-
- parts = PMALLOC(sizeof(INT) * khm_n_statusbar_parts);
-
- lastx = 0;
- for(i=0;i<khm_n_statusbar_parts;i++) {
- int w = 0;
- switch(khm_statusbar_parts[i].wtype) {
- case KHUI_SB_WTYPE_ABSOLUTE:
- w = khm_statusbar_parts[i].width;
- break;
-
- case KHUI_SB_WTYPE_RELATIVE:
- w = (khm_statusbar_parts[i].width * width) / 100;
- break;
-
- case KHUI_SB_WTYPE_FILLER:
- w = fillerwidth;
- break;
-
- default:
- w = 0;
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
- lastx += w;
-
- if(i==khm_n_statusbar_parts - 1)
- parts[i] = -1;
- else
- parts[i] = lastx;
- }
-
- SendMessage(
- khm_hwnd_statusbar,
- SB_SETPARTS,
- khm_n_statusbar_parts,
- (LPARAM) parts);
-
- PFREE(parts);
-}
-
-void khm_create_statusbar(HWND parent) {
- HWND hwsb;
-
- hwsb = CreateWindowEx(
- 0,
- STATUSCLASSNAME,
- NULL,
- SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE,
- 0,0,0,0,
- parent,
- NULL,
- khm_hInstance,
- NULL);
-
- if(!hwsb)
- return;
-
- khm_hwnd_statusbar = hwsb;
-
- khui_statusbar_set_parts(parent);
-
- kmq_post_message(KMSG_ALERT, KMSG_ALERT_CHECK_QUEUE, 0, 0);
-}
-
-void khm_update_statusbar(HWND parent) {
- MoveWindow(khm_hwnd_statusbar, 0, 0, 0, 0, TRUE);
- khui_statusbar_set_parts(parent);
-}
-
-int sb_find_index(int id) {
- int i;
-
- for(i=0;i<khm_n_statusbar_parts;i++) {
- if(khm_statusbar_parts[i].id == id)
- return i;
- }
-
- return -1;
-}
-
-void khm_statusbar_set_part(int id, HICON icon, wchar_t * text) {
- int idx;
-
- if (!khm_hwnd_statusbar)
- return;
-
- idx = sb_find_index(id);
- if(idx < 0)
- return;
-
- if (khm_statusbar_parts[idx].hIcon != NULL) {
- DestroyIcon(khm_statusbar_parts[idx].hIcon);
- khm_statusbar_parts[idx].hIcon = NULL;
- }
-
- if (icon) {
- khm_statusbar_parts[idx].hIcon = CopyImage(icon, IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_COPYFROMRESOURCE);
- }
-
- SendMessage(khm_hwnd_statusbar,
- SB_SETICON,
- idx,
- (LPARAM) (khm_statusbar_parts[idx].hIcon ? khm_statusbar_parts[idx].hIcon:icon));
-
- SendMessage(khm_hwnd_statusbar,
- SB_SETTEXT,
- idx,
- (LPARAM) text);
-}
diff --git a/src/windows/identity/ui/statusbar.h b/src/windows/identity/ui/statusbar.h
deleted file mode 100644
index 7b79f69b0..000000000
--- a/src/windows/identity/ui/statusbar.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_STATUSBAR_H
-#define __KHIMAIRA_STATUSBAR_H
-
-typedef struct khm_statusbar_part_t {
- int id;
- int width;
- int wtype; /* one of KHUI_SB_WTYPE_* */
- HICON hIcon;
-} khm_statusbar_part;
-
-#define KHUI_SB_WTYPE_RELATIVE 1
-#define KHUI_SB_WTYPE_ABSOLUTE 2
-#define KHUI_SB_WTYPE_FILLER 4
-
-/* statusbar parts */
-#define KHUI_SBPART_INFO 1
-#define KHUI_SBPART_NOTICE 2
-#define KHUI_SBPART_LOC 3
-
-extern HWND khm_hwnd_statusbar;
-extern khm_statusbar_part khm_statusbar_parts[];
-extern int khm_n_statusbar_parts;
-
-void khm_create_statusbar(HWND p);
-void khm_update_statusbar(HWND parent);
-void khm_statusbar_set_part(int id, HICON icon, wchar_t * text);
-LRESULT khm_statusbar_notify(LPNMHDR nmhdr);
-
-#endif
diff --git a/src/windows/identity/ui/taskbar.c b/src/windows/identity/ui/taskbar.c
deleted file mode 100644
index 48a575f64..000000000
--- a/src/windows/identity/ui/taskbar.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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<khmapp.h>
-
-#define COBJMACROS
-
-#include<shobjidl.h>
-
-#ifdef DEBUG
-#include<assert.h>
-#endif
-
-ITaskbarList *itbl = NULL;
-
-void
-khm_init_taskbar_funcs(void) {
- HRESULT hr = NOERROR;
-
- hr = CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,
- &IID_ITaskbarList, &itbl);
-
-#ifdef DEBUG
- assert(itbl != NULL);
-#endif
-
- if (itbl) {
- hr = ITaskbarList_HrInit(itbl);
-#ifdef DEBUG
- assert(hr == NOERROR);
-#endif
- }
-}
-
-void
-khm_exit_taskbar_funcs(void) {
- if (itbl) {
- ITaskbarList_Release(itbl);
- }
-}
-
-void
-khm_taskbar_add_window(HWND hwnd) {
- HRESULT hr = NOERROR;
-
- if (itbl) {
- hr = ITaskbarList_AddTab(itbl, hwnd);
-#ifdef DEBUG
- assert(hr == NOERROR);
-#endif
- }
-}
-
-void
-khm_taskbar_remove_window(HWND hwnd) {
- HRESULT hr = NOERROR;
-
- if (itbl) {
- hr = ITaskbarList_DeleteTab(itbl, hwnd);
-#ifdef DEBUG
- assert(hr == NOERROR);
-#endif
- }
-}
diff --git a/src/windows/identity/ui/taskbar.h b/src/windows/identity/ui/taskbar.h
deleted file mode 100644
index 32adf5c29..000000000
--- a/src/windows/identity/ui/taskbar.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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_TASKBAR_H
-#define NETIDMGR_TASKBAR_H
-
-void khm_init_taskbar_funcs(void);
-
-void khm_exit_taskbar_funcs(void);
-
-void khm_taskbar_add_window(HWND hwnd);
-
-void khm_taskbar_remove_window(HWND hwnd);
-
-#endif
diff --git a/src/windows/identity/ui/timer.c b/src/windows/identity/ui/timer.c
deleted file mode 100644
index b481ead37..000000000
--- a/src/windows/identity/ui/timer.c
+++ /dev/null
@@ -1,1015 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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<khmapp.h>
-#include<assert.h>
-
-/* The minimum half time interval is 60 seconds*/
-#define TT_MIN_HALFLIFE_INTERVAL 60
-
-/* as above, in FILETIME units of 100ns */
-#define FT_MIN_HALFLIFE_INTERVAL (TT_MIN_HALFLIFE_INTERVAL * 10000000i64)
-
-/* in seconds */
-#if 0
-khm_int32 khui_timeout_warn = KHUI_DEF_TIMEOUT_WARN;
-khm_int32 khui_timeout_crit = KHUI_DEF_TIMEOUT_CRIT;
-khm_int32 khui_timeout_renew = KHUI_DEF_TIMEOUT_RENEW;
-
-khm_boolean khui_do_renew = TRUE;
-khm_boolean khui_do_warn = TRUE;
-khm_boolean khui_do_crit = TRUE;
-#endif
-
-khui_timer_event * khui_timers = NULL;
-khm_size khui_n_timers = 0;
-khm_size khui_nc_timers = 0;
-
-CRITICAL_SECTION cs_timers;
-
-/*********************************************************************
- Timers
- *********************************************************************/
-
-
-#define KHUI_TIMER_ALLOC_INCR 16
-
-void
-khm_timer_init(void) {
-#ifdef DEBUG
- assert(khui_timers == NULL);
-#endif
-
- khui_nc_timers = KHUI_TIMER_ALLOC_INCR;
- khui_n_timers = 0;
- khui_timers = PMALLOC(sizeof(*khui_timers) * khui_nc_timers);
-
-#ifdef DEBUG
- assert(khui_timers != NULL);
-#endif
-
- InitializeCriticalSection(&cs_timers);
-}
-
-void
-khm_timer_exit(void) {
- EnterCriticalSection(&cs_timers);
-
- if (khui_timers)
- PFREE(khui_timers);
- khui_timers = NULL;
- khui_n_timers = 0;
- khui_nc_timers = 0;
-
- LeaveCriticalSection(&cs_timers);
- DeleteCriticalSection(&cs_timers);
-}
-
-/* called with cs_timers held */
-static void
-tmr_fire_timer(void) {
- int i;
- khm_int64 curtime;
- khm_int64 err;
- khm_int64 next_event;
- int tmr_count[KHUI_N_TTYPES];
- khm_int64 tmr_offset[KHUI_N_TTYPES];
- int t;
- khm_handle eff_ident = NULL;
- khui_timer_type eff_type = 0; /* meaningless */
- int fire_count = 0;
- FILETIME ft;
-
- _begin_task(0);
- _report_cs0(KHERR_DEBUG_1, L"Checking for expired timers");
- _describe();
-
- TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR_SMALL, &ft);
- err = FtToInt(&ft);
- GetSystemTimeAsFileTime(&ft);
- curtime = FtToInt(&ft);
-
- next_event = 0;
-
- ZeroMemory(tmr_count, sizeof(tmr_count));
- ZeroMemory(tmr_offset, sizeof(tmr_offset));
-
- for (i=0; i < (int) khui_n_timers; i++) {
- if (!(khui_timers[i].flags &
- (KHUI_TE_FLAG_STALE | KHUI_TE_FLAG_EXPIRED)) &&
- khui_timers[i].type != KHUI_TTYPE_ID_MARK &&
- khui_timers[i].expire < curtime + err) {
-
- _report_cs3(KHERR_DEBUG_1, L"Expiring timer index=%1!d!, type=%2!d!, key=%3!p!",
- _int32(i), _int32(khui_timers[i].type),
- _cptr(khui_timers[i].key));
-
- t = khui_timers[i].type;
-
- switch(t) {
- case KHUI_TTYPE_ID_RENEW:
- _report_cs1(KHERR_DEBUG_1, L"Renewing identity %1!p!",
- _cptr(khui_timers[i].key));
- khm_cred_renew_identity(khui_timers[i].key);
- khui_timers[i].flags |= KHUI_TE_FLAG_EXPIRED;
- break;
-
- case KHUI_TTYPE_CRED_RENEW:
- /* the equivalence threshold for setting the timer is
- a lot larger than what we are testing for here
- (KHUI_TIMEEQ_ERROR vs KHUI_TIMEEQ_ERROR_SMALL) so
- we assume that it is safe to trigger a renew_cred
- call here without checking if there's an imminent
- renew_identity call. */
- _report_cs1(KHERR_DEBUG_1, L"Renewing credential %1!p!",
- _cptr(khui_timers[i].key));
- khm_cred_renew_cred(khui_timers[i].key);
- khui_timers[i].flags |= KHUI_TE_FLAG_EXPIRED;
- break;
-
- default:
- if (t < KHUI_N_TTYPES) {
- tmr_count[t]++;
- if (tmr_offset[t] == 0 ||
- tmr_offset[t] > khui_timers[i].offset)
- tmr_offset[t] = khui_timers[i].offset;
- if (next_event == 0 ||
- next_event >
- khui_timers[i].expire + khui_timers[i].offset)
- next_event = khui_timers[i].expire +
- khui_timers[i].offset;
-
- if (eff_ident == NULL &&
- (t == KHUI_TTYPE_ID_EXP ||
- t == KHUI_TTYPE_ID_CRIT ||
- t == KHUI_TTYPE_ID_WARN)) {
- /* we don't need a hold since we will be done
- with the handle before the marker is
- expired (the marker is the timer with the
- KHUI_TTYPE_ID_MARK which contains a held
- handle and is not really a timer.) */
- eff_ident = khui_timers[i].key;
- eff_type = t;
- }
-
- fire_count++;
-
- khui_timers[i].flags |= KHUI_TE_FLAG_EXPIRED;
- }
- else {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- }
- }
- }
- }
-
- /* See if we have anything to do */
- if (next_event == 0)
- return;
- else {
- wchar_t fmt[128];
- wchar_t wtime[128];
- wchar_t wmsg[256];
- wchar_t wtitle[64];
- khm_int64 second;
- khui_alert * alert = NULL;
-
- khm_size cb;
-
- next_event -= curtime;
-
- /* Due to measurement errors we may be slightly off on our
- next_event calculation which shows up as '4 mins 59
- seconds' instead of '5 mins' and so on when converting to a
- string. So we add half a second to make the message
- neater. */
- TimetToFileTimeInterval(1, &ft);
- second = FtToInt(&ft);
- next_event += second / 2;
-
- cb = sizeof(wtime);
- ft = IntToFt(next_event);
- FtIntervalToString(&ft,
- wtime,
- &cb);
-
- if (fire_count == 1 &&
- eff_ident != NULL &&
- (eff_type == KHUI_TTYPE_ID_EXP ||
- eff_type == KHUI_TTYPE_ID_CRIT ||
- eff_type == KHUI_TTYPE_ID_WARN)) {
-
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
-
- cb = sizeof(idname);
- kcdb_identity_get_name(eff_ident, idname, &cb);
-
- if (next_event < second) {
- LoadString(khm_hInstance, IDS_WARN_EXPIRED_ID,
- fmt, ARRAYLENGTH(fmt));
-
- StringCbPrintf(wmsg, sizeof(wmsg), fmt, idname);
- } else {
- LoadString(khm_hInstance, IDS_WARN_EXPIRE_ID,
- fmt, ARRAYLENGTH(fmt));
-
- StringCbPrintf(wmsg, sizeof(wmsg), fmt, idname, wtime);
- }
- } else {
- if (next_event < second) {
- LoadString(khm_hInstance, IDS_WARN_EXPIRED,
- wmsg, ARRAYLENGTH(wmsg));
- } else {
- LoadString(khm_hInstance, IDS_WARN_EXPIRE,
- fmt, ARRAYLENGTH(fmt));
-
- StringCbPrintf(wmsg, sizeof(wmsg), fmt, wtime);
- }
- }
-
- LoadString(khm_hInstance, IDS_WARN_TITLE,
- wtitle, ARRAYLENGTH(wtitle));
-
- khui_alert_create_simple(wtitle, wmsg, KHERR_WARNING, &alert);
- khui_alert_set_flags(alert,
- KHUI_ALERT_FLAG_REQUEST_BALLOON | KHUI_ALERT_FLAG_DISPATCH_CMD,
- KHUI_ALERT_FLAG_REQUEST_BALLOON | KHUI_ALERT_FLAG_DISPATCH_CMD);
-
- if (eff_ident != NULL) {
- khm_int32 cmd;
-
- cmd = khm_get_identity_new_creds_action(eff_ident);
-
- if (cmd) {
- khui_alert_add_command(alert, cmd);
- khui_alert_add_command(alert, KHUI_PACTION_CLOSE);
- }
- }
-
- khui_alert_show(alert);
- khui_alert_release(alert);
- }
-
- _end_task();
-
-}
-
-void
-khm_timer_fire(HWND hwnd) {
- EnterCriticalSection(&cs_timers);
- tmr_fire_timer();
- LeaveCriticalSection(&cs_timers);
-
- khm_timer_refresh(hwnd);
-}
-
-static int
-tmr_update(khm_handle key, khui_timer_type type, __int64 expire,
- __int64 offset, void * data, khm_boolean reinstate) {
- int i;
- wchar_t name[KCDB_MAXCCH_NAME];
- wchar_t tstamp[128];
- wchar_t *type_str = NULL;
- SYSTEMTIME st;
- FILETIME ft;
- FILETIME ftl;
- khm_size cb;
-
- switch(type) {
- case KHUI_TTYPE_ID_MARK:
- type_str = L"marker";
- break;
-
- case KHUI_TTYPE_CRED_WARN:
- case KHUI_TTYPE_ID_WARN:
- type_str = L"warning";
- break;
-
- case KHUI_TTYPE_CRED_CRIT:
- case KHUI_TTYPE_ID_CRIT:
- type_str = L"critical";
- break;
-
- case KHUI_TTYPE_CRED_EXP:
- case KHUI_TTYPE_ID_EXP:
- type_str = L"expiry";
- break;
-
- case KHUI_TTYPE_CRED_RENEW:
- case KHUI_TTYPE_ID_RENEW:
- type_str = L"renew";
- break;
- }
-
- ft = IntToFt(expire);
- FileTimeToLocalFileTime(&ft, &ftl);
- FileTimeToSystemTime(&ftl, &st);
- StringCbPrintf(tstamp, sizeof(tstamp),
- L"%d-%d-%d %d:%d:%d",
- st.wYear, st.wMonth, st.wDay,
- st.wHour, st.wMinute, st.wSecond);
-
- cb = sizeof(name); name[0] = L'\0';
- if (type_str == NULL) {
-
- _report_cs2(KHERR_DEBUG_1,
- L"Updating uknown timer of type %1!d! exp(%2!s!)",
- _int32(type),
- _cstr(tstamp));
- _resolve();
-
- } else if (type == KHUI_TTYPE_ID_MARK ||
- type == KHUI_TTYPE_ID_WARN ||
- type == KHUI_TTYPE_ID_CRIT ||
- type == KHUI_TTYPE_ID_EXP ||
- type == KHUI_TTYPE_ID_RENEW) {
-
- kcdb_identity_get_name(key, name, &cb);
- _report_cs3(KHERR_DEBUG_1,
- L"Updating identity %1!s! timer for %2!s! exp(%3!s!)",
- _cstr(type_str),
- _cstr(name),
- _cstr(tstamp));
- _resolve();
-
- } else if (type == KHUI_TTYPE_CRED_RENEW ||
- type == KHUI_TTYPE_CRED_WARN ||
- type == KHUI_TTYPE_CRED_CRIT ||
- type == KHUI_TTYPE_CRED_EXP) {
-
- kcdb_cred_get_name(key, name, &cb);
- _report_cs3(KHERR_DEBUG_1,
- L"Updating credential %1!s! timer for %2!s! exp(%3!s!)",
- _cstr(type_str),
- _cstr(name),
- _cstr(tstamp));
- _resolve();
-
- }
-
- for (i=0; i < (int) khui_n_timers; i++) {
- if (khui_timers[i].key == key &&
- khui_timers[i].type == type)
- break;
- }
-
- if (i >= (int) khui_n_timers) {
- i = (int) khui_n_timers;
-
- if (i >= (int) khui_nc_timers) {
- khui_timer_event * nt;
-#ifdef DEBUG
- assert(khui_timers);
-#endif
- khui_nc_timers = UBOUNDSS(i+1, KHUI_TIMER_ALLOC_INCR,
- KHUI_TIMER_ALLOC_INCR);
- nt = PMALLOC(sizeof(*nt) * khui_nc_timers);
-#ifdef DEBUG
- assert(nt);
-#endif
- memcpy(nt, khui_timers, sizeof(*nt) * khui_n_timers);
-
- PFREE(khui_timers);
- khui_timers = nt;
- }
-
- khui_timers[i].key = key;
- khui_timers[i].type = type;
- khui_timers[i].flags = 0;
- khui_n_timers++;
- }
-
- khui_timers[i].expire = expire;
- khui_timers[i].offset = offset;
- khui_timers[i].data = data;
-
- khui_timers[i].flags &= ~KHUI_TE_FLAG_STALE;
- if (reinstate)
- khui_timers[i].flags &= ~KHUI_TE_FLAG_EXPIRED;
-
- return i;
-}
-
-/* called with cs_timers held */
-static int
-tmr_find(khm_handle key, khui_timer_type type,
- khm_int32 and_flags, khm_int32 eq_flags) {
- int i;
-
- eq_flags &= and_flags;
-
- for (i=0; i < (int) khui_n_timers; i++) {
- if (khui_timers[i].key == key &&
- khui_timers[i].type == type &&
- (khui_timers[i].flags & and_flags) == eq_flags)
- break;
- }
-
- if (i < (int) khui_n_timers)
- return i;
- else
- return -1;
-}
-
-/* called with cs_timers held. */
-static FILETIME
-tmr_next_halflife_timeout(int idx, FILETIME * issue, FILETIME * expire) {
- FILETIME lifetime;
- FILETIME current;
- FILETIME ret;
-
- khm_int64 ilife;
- khm_int64 icurrent;
- khm_int64 iexpire;
-
- khm_int64 iret;
-
- GetSystemTimeAsFileTime(&current);
-
- /* wha?? */
- if (CompareFileTime(issue, expire) >= 0)
- return current;
-
- lifetime = FtSub(expire, issue);
- icurrent = FtToInt(&current);
- iexpire = FtToInt(expire);
-
- ilife = FtToInt(&lifetime);
-
- while(ilife / 2 > FT_MIN_HALFLIFE_INTERVAL) {
- ilife /= 2;
-
- /* is this the next renewal time? */
- if (iexpire - ilife > icurrent) {
- if (idx >= 0 &&
- khui_timers[idx].expire == iexpire - ilife &&
- (khui_timers[idx].flags & KHUI_TE_FLAG_EXPIRED)) {
-
- /* if this renewal time has already been triggered
- (note that when the timer fires, it also fires all
- events that are within a few seconds of the current
- time) then we need to set the alarm for the next
- slot down the line. */
-
- continue;
-
- } else {
- break;
- }
- }
- }
-
- iret = iexpire - ilife;
-
- ret = IntToFt(iret);
-
- /* if the previous renew timer had fired, we need to mark it as
- not expired. However, we leave it to the caller to update the
- actual timer and mark it as not stale. */
- if (idx >= 0 &&
- khui_timers[idx].expire < iret) {
-
- khui_timers[idx].flags &= ~KHUI_TE_FLAG_EXPIRED;
- khui_timers[idx].expire = iret;
- }
-
- return ret;
-}
-
-/* called with cs_timers held. Called once for each credential in the
- root credentials set. */
-static khm_int32 KHMAPI
-tmr_cred_apply_proc(khm_handle cred, void * rock) {
- khm_handle ident = NULL;
- int mark_idx;
- int idx;
- FILETIME ft_expiry;
- FILETIME ft_current;
- FILETIME ft_creinst;
- FILETIME ft_cred_expiry;
- FILETIME ft_cred_issue;
- FILETIME ft_issue;
- FILETIME ft;
- FILETIME fte;
- FILETIME ft_reinst;
- khm_size cb;
- wchar_t wname[KCDB_MAXCCH_NAME];
-
- cb = sizeof(wname);
- wname[0] = L'\0';
- kcdb_cred_get_name(cred, wname, &cb);
-
- _report_cs1(KHERR_DEBUG_1, L"Looking at cred [%1!s!]",
- _cstr(wname));
- _resolve();
-
- kcdb_cred_get_identity(cred, &ident);
-#ifdef DEBUG
- assert(ident);
-#endif
-
- /* now get the expiry for the identity*/
- cb = sizeof(ft_expiry);
- if (KHM_FAILED(kcdb_identity_get_attr(ident, KCDB_ATTR_EXPIRE,
- NULL,
- &ft_expiry, &cb))) {
-
- /* failing which, we get the expiry for this credential */
- cb = sizeof(ft_expiry);
- if (KHM_FAILED(kcdb_cred_get_attr(cred, KCDB_ATTR_EXPIRE,
- NULL,
- &ft_expiry, &cb))) {
- /* we don't have an expiry time to work with */
- _report_cs1(KHERR_DEBUG_1, L"Skipping cred [%1!s!]. No expiry time",
- _cstr(wname));
- _resolve();
-
- kcdb_identity_release(ident);
- return KHM_ERROR_SUCCESS;
- } else {
- /* and the time of issue */
- cb = sizeof(ft_issue);
- if (KHM_FAILED(kcdb_cred_get_attr(cred, KCDB_ATTR_ISSUE,
- NULL, &ft_issue, &cb)))
- ZeroMemory(&ft_issue, sizeof(ft_issue));
- }
-
- } else {
- /* also try to get the time of issue. */
- cb = sizeof(ft_issue);
- if (KHM_FAILED(kcdb_identity_get_attr(ident, KCDB_ATTR_ISSUE,
- NULL, &ft_issue, &cb)))
- /* if we fail, we just zero out the time of issue and
- failover to using the threshold value to set the expiry
- timer instead of the half life algorithm. */
- ZeroMemory(&ft_issue, sizeof(ft_issue));
- }
-
- /* and the current time */
- GetSystemTimeAsFileTime(&ft_current);
-
- TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, &ft_reinst);
-
- ft_creinst = FtAdd(&ft_current, &ft_reinst);
-
- mark_idx = tmr_find(ident, KHUI_TTYPE_ID_MARK, 0, 0);
-
- if (mark_idx < 0) {
- mark_idx = tmr_update(ident, KHUI_TTYPE_ID_MARK, 0, 0, 0, FALSE);
- kcdb_identity_hold(ident);
-#ifdef DEBUG
- assert(mark_idx >= 0);
-#endif
- khui_timers[mark_idx].flags |= KHUI_TE_FLAG_STALE;
- }
-
- if (khui_timers[mark_idx].flags & KHUI_TE_FLAG_STALE) {
- /* first time we are touching this */
- khm_handle csp_cw = NULL;
- khm_handle csp_id = NULL;
- khm_int32 rv;
- khm_int32 t;
- khm_boolean do_warn = TRUE;
- khm_boolean do_crit = TRUE;
- khm_boolean do_renew = TRUE;
- khm_boolean do_halflife = TRUE;
- khm_boolean renew_done = FALSE;
- khm_boolean monitor = TRUE;
- khm_int32 to_warn = KHUI_DEF_TIMEOUT_WARN;
- khm_int32 to_crit = KHUI_DEF_TIMEOUT_CRIT;
- khm_int32 to_renew = KHUI_DEF_TIMEOUT_RENEW;
-
- if (CompareFileTime(&ft_expiry, &ft_current) < 0)
- /* already expired */
- goto _done_with_ident;
-
- rv = khc_open_space(NULL, L"CredWindow", KHM_PERM_READ,
- &csp_cw);
-
- assert(KHM_SUCCEEDED(rv));
-
- rv = kcdb_identity_get_config(ident, KHM_PERM_READ, &csp_id);
- if (KHM_SUCCEEDED(rv)) {
- khc_shadow_space(csp_id, csp_cw);
- khc_close_space(csp_cw);
- } else {
- csp_id = csp_cw;
- }
- csp_cw = NULL;
-
- rv = khc_read_int32(csp_id, L"Monitor", &t);
- if (KHM_SUCCEEDED(rv))
- monitor = t;
-
- rv = khc_read_int32(csp_id, L"AllowWarn", &t);
- if (KHM_SUCCEEDED(rv))
- do_warn = t;
-
- rv = khc_read_int32(csp_id, L"AllowCritical", &t);
- if (KHM_SUCCEEDED(rv))
- do_crit = t;
-
- rv = khc_read_int32(csp_id, L"AllowAutoRenew", &t);
- if (KHM_SUCCEEDED(rv))
- do_renew = t;
-
- rv = khc_read_int32(csp_id, L"RenewAtHalfLife", &t);
- if (KHM_SUCCEEDED(rv))
- do_halflife = t;
-
- rv = khc_read_int32(csp_id, L"WarnThreshold", &t);
- if (KHM_SUCCEEDED(rv))
- to_warn = t;
-
- rv = khc_read_int32(csp_id, L"CriticalThreshold", &t);
- if (KHM_SUCCEEDED(rv))
- to_crit = t;
-
- rv = khc_read_int32(csp_id, L"AutoRenewThreshold", &t);
- if (KHM_SUCCEEDED(rv))
- to_renew = t;
-
- khc_close_space(csp_id);
-
- if (monitor && do_renew) {
- int prev;
-
- TimetToFileTimeInterval(to_renew, &ft);
-
- prev =
- tmr_find(ident, KHUI_TTYPE_ID_RENEW, 0, 0);
-
- if (do_halflife && (ft_issue.dwLowDateTime != 0 ||
- ft_issue.dwHighDateTime != 0))
- fte = tmr_next_halflife_timeout(prev, &ft_issue, &ft_expiry);
- else
- fte = FtSub(&ft_expiry, &ft);
-
- /* we set off a renew notification immediately if the
- renew threshold has passed but a renew was never sent.
- This maybe because that NetIDMgr was started at the
- last minute, or because for some reason the renew timer
- could not be triggered earlier. */
-
- if (CompareFileTime(&fte, &ft_current) > 0 ||
- prev == -1 ||
- !(khui_timers[prev].flags & KHUI_TE_FLAG_EXPIRED)) {
-
- if (CompareFileTime(&fte, &ft_current) < 0)
- fte = ft_current;
-
- tmr_update(ident, KHUI_TTYPE_ID_RENEW,
- FtToInt(&fte), FtToInt(&ft), 0,
- CompareFileTime(&fte,&ft_creinst) > 0);
- renew_done = TRUE;
-
- } else {
-
- /* special case. If the renew timer was in the past
- and it was expired, then we retain the record as
- long as the credentials are around. If the renewal
- failed we don't want to automatically retry
- everytime we check the timers. */
-
- tmr_update(ident, KHUI_TTYPE_ID_RENEW,
- FtToInt(&fte), FtToInt(&ft), 0, FALSE);
-
- }
- }
-
- if (monitor && do_warn && !renew_done) {
-
- TimetToFileTimeInterval(to_warn, &ft);
- fte = FtSub(&ft_expiry, &ft);
-
- if (CompareFileTime(&fte, &ft_current) > 0)
- tmr_update(ident, KHUI_TTYPE_ID_WARN,
- FtToInt(&fte), FtToInt(&ft), 0,
- CompareFileTime(&fte, &ft_creinst) > 0);
- }
-
- if (monitor && do_crit && !renew_done) {
- TimetToFileTimeInterval(to_crit, &ft);
- fte = FtSub(&ft_expiry, &ft);
-
- if (CompareFileTime(&fte, &ft_current) > 0)
- tmr_update(ident, KHUI_TTYPE_ID_CRIT,
- FtToInt(&fte), FtToInt(&ft), 0,
- CompareFileTime(&fte, &ft_creinst) > 0);
- }
-
- if (monitor && !renew_done) {
- if (CompareFileTime(&ft_expiry, &ft_current) > 0)
- tmr_update(ident, KHUI_TTYPE_ID_EXP,
- FtToInt(&ft_expiry), 0, 0,
- CompareFileTime(&fte, &ft_creinst) > 0);
- }
-
- _done_with_ident:
- khui_timers[mark_idx].flags &= ~KHUI_TE_FLAG_STALE;
- }
-
- cb = sizeof(ft_cred_expiry);
- if (KHM_FAILED(kcdb_cred_get_attr(cred, KCDB_ATTR_EXPIRE,
- NULL,
- &ft_cred_expiry,
- &cb))) {
- _report_cs1(KHERR_DEBUG_1, L"Skipping cred [%1!s!]. Can't lookup cred expiry",
- _cstr(wname));
- _resolve();
- goto _cleanup;
- }
-
- cb = sizeof(ft_cred_issue);
- if (KHM_FAILED(kcdb_cred_get_attr(cred, KCDB_ATTR_ISSUE,
- NULL,
- &ft_cred_issue,
- &cb))) {
-
- ZeroMemory(&ft_cred_issue, sizeof(ft_cred_issue));
-
- }
-
- TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, &ft);
-
- {
- /* if the credential has a longer lifetime than the identity,
- or it expires within KHUI_TIMEEQ_ERROR seconds of the
- identity, then we don't need to set any alerts for this
- credential. */
-
- FILETIME ft_delta;
-
- ft_delta = FtSub(&ft_expiry, &ft_cred_expiry);
-
- if (CompareFileTime(&ft_cred_expiry, &ft_expiry) >= 0 ||
- CompareFileTime(&ft_delta, &ft) < 0) {
-
- _report_cs1(KHERR_DEBUG_1,
- L"Skipping credential [%1!s!]. The expiry time is too close to the identity expiry.",
- _cstr(wname));
- _resolve();
- goto _cleanup;
- }
- }
-
- if ((idx = tmr_find(ident, KHUI_TTYPE_ID_WARN, 0, 0)) >= 0 &&
- !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {
-
- fte = IntToFt(FtToInt(&ft_cred_expiry) - khui_timers[idx].offset);
- if (CompareFileTime(&fte, &ft_current) > 0) {
- tmr_update(cred, KHUI_TTYPE_CRED_WARN,
- FtToInt(&fte),
- khui_timers[idx].offset, 0,
- CompareFileTime(&fte, &ft_creinst) > 0);
- kcdb_cred_hold(cred);
- }
- }
-
- if ((idx = tmr_find(ident, KHUI_TTYPE_ID_CRIT, 0, 0)) >= 0 &&
- !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {
-
- fte = IntToFt(FtToInt(&ft_cred_expiry) - khui_timers[idx].offset);
- if (CompareFileTime(&fte, &ft_current) > 0) {
- tmr_update(cred, KHUI_TTYPE_CRED_CRIT,
- FtToInt(&fte),
- khui_timers[idx].offset, 0,
- CompareFileTime(&fte, &ft_creinst) > 0);
- kcdb_cred_hold(cred);
- }
- }
-
- if ((idx = tmr_find(ident, KHUI_TTYPE_ID_RENEW, 0, 0)) >= 0 &&
- !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {
-
- int cidx = tmr_find(cred, KHUI_TTYPE_CRED_RENEW, 0, 0);
-
- if (ft_cred_issue.dwLowDateTime == 0 &&
- ft_cred_issue.dwHighDateTime == 0) {
- fte = IntToFt(FtToInt(&ft_cred_expiry) - khui_timers[idx].offset);
- /* a special case, for a credential whose remaining
- lifetime is less than the offset, we try half life on
- the current time and the expiry. */
- if (CompareFileTime(&fte, &ft_current) <= 0 &&
- CompareFileTime(&ft_current, &ft_expiry) < 0) {
- fte = tmr_next_halflife_timeout(cidx, &ft_current, &ft_cred_expiry);
-#if 0
- /* now, if we already have a renew timer for this
- credential that hasn't expired yet and that is set
- for earlier than fte, we let it be. */
- if (cidx >= 0 &&
- khui_timers[cidx].expire < FtToInt(&fte) &&
- khui_timers[cidx].expire > FtToInt(&ft_current) &&
- !(khui_timers[cidx].flags & KHUI_TE_FLAG_EXPIRED)) {
-
- fte = IntToFt(khui_timers[cidx].expire);
-
- }
-#endif
- }
- } else {
- fte = tmr_next_halflife_timeout(cidx, &ft_cred_issue, &ft_cred_expiry);
- }
-
- if (CompareFileTime(&fte, &ft_current) > 0) {
- tmr_update(cred, KHUI_TTYPE_CRED_RENEW,
- FtToInt(&fte),
- khui_timers[idx].offset, 0,
- CompareFileTime(&fte, &ft_creinst) > 0);
- kcdb_cred_hold(cred);
- }
- }
-
- if ((idx = tmr_find(ident, KHUI_TTYPE_ID_EXP, 0, 0)) >= 0 &&
- !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {
-
- if (CompareFileTime(&ft_cred_expiry, &ft_current) > 0) {
- tmr_update(cred, KHUI_TTYPE_CRED_EXP,
- FtToInt(&ft_cred_expiry),
- 0, 0,
- CompareFileTime(&ft_cred_expiry, &ft_creinst) > 0);
- }
- }
-
- _cleanup:
-
- if (ident)
- kcdb_identity_release(ident);
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* called with cs_timers held */
-static void
-tmr_purge(void) {
- int i, j;
-
- for (i=0,j=0; i < (int) khui_n_timers; i++) {
- if (khui_timers[i].flags & KHUI_TE_FLAG_STALE) {
- if (khui_timers[i].type == KHUI_TTYPE_ID_MARK) {
- kcdb_identity_release(khui_timers[i].key);
-#ifdef DEBUG
- {
- int idx;
-
- idx = tmr_find(khui_timers[i].key,
- KHUI_TTYPE_ID_CRIT, 0, 0);
- assert(idx < 0 ||
- (khui_timers[idx].flags &
- KHUI_TE_FLAG_STALE));
-
- idx = tmr_find(khui_timers[i].key,
- KHUI_TTYPE_ID_RENEW, 0, 0);
- assert(idx < 0 ||
- (khui_timers[idx].flags &
- KHUI_TE_FLAG_STALE));
-
- idx = tmr_find(khui_timers[i].key,
- KHUI_TTYPE_ID_WARN, 0, 0);
- assert(idx < 0 ||
- (khui_timers[idx].flags &
- KHUI_TE_FLAG_STALE));
-
- idx = tmr_find(khui_timers[i].key,
- KHUI_TTYPE_ID_EXP, 0, 0);
- assert(idx < 0 ||
- (khui_timers[idx].flags &
- KHUI_TE_FLAG_STALE));
- }
-#endif
- } else if (khui_timers[i].type == KHUI_TTYPE_CRED_WARN ||
- khui_timers[i].type == KHUI_TTYPE_CRED_CRIT ||
- khui_timers[i].type == KHUI_TTYPE_CRED_RENEW ||
- khui_timers[i].type == KHUI_TTYPE_CRED_EXP) {
- kcdb_cred_release(khui_timers[i].key);
- }
- } else {
- if (i != j)
- khui_timers[j] = khui_timers[i];
- j++;
- }
- }
-
- khui_n_timers = j;
-}
-
-/* go through all the credentials and set timers as appropriate. hwnd
- is the window that will receive the timer events.*/
-void
-khm_timer_refresh(HWND hwnd) {
- int i;
- khm_int64 next_event = 0;
- khm_int64 curtime;
- khm_int64 diff;
-
- _begin_task(0);
- _report_cs0(KHERR_DEBUG_1, L"Refreshing timers");
- _describe();
-
- EnterCriticalSection(&cs_timers);
-
- KillTimer(hwnd, KHUI_TRIGGER_TIMER_ID);
-
- /* When refreshing timers, we go through all of them and mark them
- as stale. Then we go through the credentials in the root
- credential set and add or refresh the timers associated with
- each identity and credential. Once this is done, we remove the
- timers that are still stale, since they are no longer in
- use. */
-
- for (i=0; i < (int) khui_n_timers; i++) {
-#ifdef NOT_IMPLEMENTED_YET
- if (khui_timers[i].type == KHUI_TTYPE_BMSG ||
- khui_timers[i].type == KHUI_TTYPE_SMSG) {
- khui_timers[i].flags &= ~KHUI_TE_FLAG_STALE;
- } else {
-#endif
-
- khui_timers[i].flags |= KHUI_TE_FLAG_STALE;
-
-#ifdef NOT_IMPLEMENTED_YET
- }
-#endif
- }
-
- _report_cs1(KHERR_DEBUG_1, L"Starting with %1!d! timers",
- _int32(khui_n_timers));
-
- kcdb_credset_apply(NULL,
- tmr_cred_apply_proc,
- NULL);
-
- tmr_purge();
-
- _report_cs1(KHERR_DEBUG_1, L"Leaving with %1!d! timers",
- _int32(khui_n_timers));
-
- _check_next_event:
-
- /* Before we return, we should check if any timers are set to
- expire right now. If there are, we should fire the timer
- before returning. */
-
- next_event = 0;
- for (i=0; i < (int) khui_n_timers; i++) {
- if (!(khui_timers[i].flags & KHUI_TE_FLAG_EXPIRED) &&
- khui_timers[i].type != KHUI_TTYPE_ID_MARK &&
- (next_event == 0 ||
- next_event > khui_timers[i].expire)) {
-
- next_event = khui_timers[i].expire;
-
- }
- }
-
- if (next_event != 0) {
- FILETIME ft;
-
- GetSystemTimeAsFileTime(&ft);
- curtime = FtToInt(&ft);
-
- TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR_SMALL, &ft);
- diff = FtToInt(&ft);
-
- if (curtime + diff > next_event) {
- tmr_fire_timer();
- goto _check_next_event;
- } else {
- diff = next_event - curtime;
- ft = IntToFt(diff);
- SetTimer(hwnd,
- KHUI_TRIGGER_TIMER_ID,
- FtIntervalToMilliseconds(&ft),
- NULL);
- }
- }
-
- LeaveCriticalSection(&cs_timers);
-
- _end_task();
-}
diff --git a/src/windows/identity/ui/timer.h b/src/windows/identity/ui/timer.h
deleted file mode 100644
index 91ca52032..000000000
--- a/src/windows/identity/ui/timer.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_TIMER_H
-#define __KHIMAIRA_TIMER_H
-
-/* note that the ordering of the first few enum constants are
- significant. The values of the constants up to KHUI_N_TTYPES are
- used as indices. */
-typedef enum tag_khui_timer_type {
- KHUI_TTYPE_ID_EXP = 0, /* Identity expiration */
- KHUI_TTYPE_ID_CRIT, /* Identity critical */
- KHUI_TTYPE_ID_WARN, /* Identity warning */
- KHUI_TTYPE_CRED_EXP, /* Credential expiration */
- KHUI_TTYPE_CRED_CRIT, /* Credential critical */
- KHUI_TTYPE_CRED_WARN, /* Credential warning */
-
- KHUI_N_TTYPES, /* Count of the timers that we
- aggregate for notifications */
-
- KHUI_TTYPE_ID_MARK, /* Identity marker */
-
- KHUI_TTYPE_ID_RENEW, /* Identity auto renewal */
- KHUI_TTYPE_CRED_RENEW, /* Credential renewal */
-
-#if 0
- KHUI_TTYPE_BMSG, /* Custom. Sends broadcast message
- when triggered.*/
- KHUI_TTYPE_SMSG, /* Custom. Sends subscription message
- when triggered. */
-#endif
-} khui_timer_type;
-
-typedef struct tag_khui_timer_event {
- khm_handle key;
- khui_timer_type type;
-
- khm_int64 expire; /* time at which the timer expires */
- khm_int64 offset; /* time offset at which the event that the
- timer warns of happens */
- void * data;
- khm_int32 flags;
-} khui_timer_event;
-
-#define KHUI_TRIGGER_TIMER_ID 48
-#define KHUI_REFRESH_TIMER_ID 49
-
-#define KHUI_REFRESH_TIMEOUT 5000
-
-#define KHUI_TE_FLAG_EXPIRED 0x00000001
-#define KHUI_TE_FLAG_STALE 0x00000002
-
-#define KHUI_DEF_TIMEOUT_WARN 900
-#define KHUI_DEF_TIMEOUT_CRIT 300
-#define KHUI_DEF_TIMEOUT_RENEW 60
-
-/* the max absolute difference between two timers (in seconds) that
- can exist where we consider both timers to be in the same
- timeslot. */
-#define KHUI_TIMEEQ_ERROR 20
-
-/* the small error. */
-#define KHUI_TIMEEQ_ERROR_SMALL 1
-
-void
-khm_timer_refresh(HWND hwnd);
-
-void
-khm_timer_fire(HWND hwnd);
-
-void
-khm_timer_init(void);
-
-void
-khm_timer_exit(void);
-
-#endif
diff --git a/src/windows/identity/ui/toolbar.c b/src/windows/identity/ui/toolbar.c
deleted file mode 100644
index 4a3c61f7f..000000000
--- a/src/windows/identity/ui/toolbar.c
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * 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
- * 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<khmapp.h>
-#include<assert.h>
-
-HWND khui_hwnd_standard_toolbar;
-int khui_tb_blank;
-
-khui_ilist * ilist_toolbar;
-
-void khui_init_toolbar(void) {
- ilist_toolbar = khui_create_ilist(KHUI_TOOLBAR_IMAGE_WIDTH, KHUI_TOOLBAR_IMAGE_HEIGHT, KHUI_TOOLBAR_MAX_BTNS, 5, 0);
-}
-
-void khui_exit_toolbar(void) {
- khui_delete_ilist(ilist_toolbar);
-}
-
-LRESULT khm_toolbar_notify(LPNMHDR notice) {
- switch(notice->code) {
- case TBN_GETINFOTIP:
- {
- LPNMTBGETINFOTIP git = (LPNMTBGETINFOTIP) notice;
- int cmd;
- khui_action * a;
-
- cmd = git->iItem;
- a = khui_find_action(cmd);
-
- if (a) {
- if (a->caption) {
- StringCchCopy(git->pszText, git->cchTextMax, a->caption);
- } else if (a->tooltip) {
- StringCchCopy(git->pszText, git->cchTextMax, a->tooltip);
- } else if (a->is_caption) {
- wchar_t buf[INFOTIPSIZE];
-
- buf[0] = L'\0';
- LoadString(khm_hInstance, a->is_caption,
- buf, ARRAYLENGTH(buf));
-
- StringCchCopy(git->pszText, git->cchTextMax, buf);
- } else {
- StringCchCopy(git->pszText, git->cchTextMax, L"");
- }
- } else {
- StringCchCopy(git->pszText,
- git->cchTextMax,
- L"");
- }
- }
- break;
-
- case TBN_HOTITEMCHANGE:
- {
- LPNMTBHOTITEM hi = (LPNMTBHOTITEM) notice;
-
- if (hi->dwFlags & HICF_LEAVING) {
- khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, L"");
- } else {
- khui_action * a;
- int cmd;
- wchar_t buf[256];
-
- cmd = hi->idNew;
- a = khui_find_action(cmd);
-
- buf[0] = L'\0';
-
- if (a) {
- if (a->tooltip)
- StringCbCopy(buf, sizeof(buf), a->tooltip);
- else if (a->is_tooltip) {
- LoadString(khm_hInstance, a->is_tooltip,
- buf, ARRAYLENGTH(buf));
- }
- }
-
- khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf);
- }
- }
- break;
-
- case TBN_DROPDOWN:
- {
- LPNMTOOLBAR nmtb = (LPNMTOOLBAR) notice;
- RECT r;
-
- GetWindowRect(khui_hwnd_standard_toolbar, &r);
- if (nmtb->iItem == KHUI_ACTION_DESTROY_CRED) {
- khm_menu_show_panel(KHUI_MENU_DESTROY_CRED,
- r.left + nmtb->rcButton.left,
- r.top + nmtb->rcButton.bottom);
- } else if (nmtb->iItem == KHUI_ACTION_RENEW_CRED) {
- khm_menu_show_panel(KHUI_MENU_RENEW_CRED,
- r.left + nmtb->rcButton.left,
- r.top + nmtb->rcButton.bottom);
- } else {
- return TBDDRET_NODEFAULT;
- }
-
- return TBDDRET_DEFAULT;
- }
- break;
-
- case NM_CUSTOMDRAW:
- {
- LPNMTBCUSTOMDRAW nmcd = (LPNMTBCUSTOMDRAW) notice;
- if(nmcd->nmcd.dwDrawStage == CDDS_PREPAINT) {
- return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE;
- } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) {
- return CDRF_NOTIFYPOSTPAINT;
- } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) {
- /* draw the actual icon */
- int iidx;
- int ibmp;
- HBITMAP hbmp;
- RECT r;
-
- khui_action * act =
- khui_find_action((int) nmcd->nmcd.dwItemSpec);
-
- if(!act || !act->ib_normal)
- return CDRF_DODEFAULT;
-
- if((act->state & KHUI_ACTIONSTATE_DISABLED) &&
- act->ib_disabled) {
- ibmp = act->ib_disabled;
- } else if(act->ib_hot &&
- ((nmcd->nmcd.uItemState & CDIS_HOT) ||
- (nmcd->nmcd.uItemState & CDIS_SELECTED))){
- ibmp = act->ib_hot;
- } else {
- ibmp = act->ib_normal;
- }
-
- iidx = khui_ilist_lookup_id(ilist_toolbar, ibmp);
- if(iidx < 0) {
- hbmp = LoadImage(khm_hInstance,
- MAKEINTRESOURCE(ibmp),
- IMAGE_BITMAP,
- KHUI_TOOLBAR_IMAGE_WIDTH,
- KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
- iidx =
- khui_ilist_add_masked_id(ilist_toolbar,
- hbmp,
- KHUI_TOOLBAR_BGCOLOR,
- ibmp);
- DeleteObject(hbmp);
- }
-
- if(iidx < 0)
- return CDRF_DODEFAULT;
-
- CopyRect(&r, &(nmcd->nmcd.rc));
- r.left += ((r.bottom - r.top) -
- KHUI_TOOLBAR_IMAGE_HEIGHT) / 2;
- r.top += ((r.bottom - r.top) -
- KHUI_TOOLBAR_IMAGE_HEIGHT) / 2;
-#if 0
- r.left += ((r.right - r.left) -
- KHUI_TOOLBAR_IMAGE_WIDTH) / 2;
-#endif
- khui_ilist_draw(ilist_toolbar,
- iidx,
- nmcd->nmcd.hdc,
- r.left,
- r.top,
- 0);
-
- return CDRF_DODEFAULT;
- }
- }
- break;
- }
- return 0;
-}
-
-void khui_add_action_to_toolbar(HWND tb, khui_action *a, int opt, HIMAGELIST hiList) {
- wchar_t buf[MAX_RES_STRING] = L"";
- int idx_caption = 0;
- TBBUTTON bn;
- LRESULT lr;
-
- ZeroMemory(&bn,sizeof(bn));
-
- if(opt & KHUI_TOOLBAR_ADD_SEP) {
- bn.fsStyle = BTNS_SEP;
- bn.iBitmap = 3;
-
- lr = SendMessage(tb,
- TB_ADDBUTTONS,
- 1,
- (LPARAM) &bn);
-#ifdef DEBUG
- assert(lr);
-#endif
- return;
- }
-
- bn.fsStyle = BTNS_BUTTON;
-
- if(opt & KHUI_TOOLBAR_VARSIZE) {
- bn.fsStyle |= BTNS_AUTOSIZE;
- }
-
- if(opt & KHUI_TOOLBAR_ADD_TEXT) {
- int sid = 0;
- if((opt & KHUI_TOOLBAR_ADD_LONGTEXT) ==
- KHUI_TOOLBAR_ADD_LONGTEXT) {
- sid = a->is_tooltip;
- }
- if(!sid)
- sid = a->is_caption;
- if(sid) {
- LoadString(khm_hInstance,
- sid,
- buf, ARRAYLENGTH(buf));
- buf[wcslen(buf) + 1] = L'\0';
- idx_caption = (int) SendMessage(tb,
- TB_ADDSTRING,
- (WPARAM) NULL,
- (LPARAM) buf);
-#if (_WIN32_IE >= 0x0501)
- bn.fsStyle |= BTNS_SHOWTEXT;
-#endif
- bn.iString = idx_caption;
- }
- }
-
- if(opt & KHUI_TOOLBAR_ADD_DROPDOWN) {
- bn.fsStyle |= BTNS_DROPDOWN;
- }
-
- if((opt & KHUI_TOOLBAR_ADD_BITMAP) && a->ib_normal) {
- bn.fsStyle |= TBSTYLE_CUSTOMERASE;
- bn.iBitmap = khui_tb_blank;
- } else {
-#if (_WIN32_IE >= 0x0501)
- bn.iBitmap = I_IMAGENONE;
-#endif
- }
-
- bn.idCommand = a->cmd;
-
- if(a->state & KHUI_ACTIONSTATE_DISABLED) {
- bn.fsState = 0;
- } else {
- bn.fsState = TBSTATE_ENABLED;
- }
-
- if(a->state & KHUI_ACTIONSTATE_CHECKED) {
- bn.fsState |= TBSTATE_CHECKED;
- }
-
- bn.dwData = 0;
-
- lr = SendMessage(
- tb,
- TB_ADDBUTTONS,
- 1,
- (LPARAM) &bn);
-
-#ifdef DEBUG
- assert(lr);
-#endif
-}
-
-void khm_update_standard_toolbar(void)
-{
- khui_menu_def * def;
- khui_action_ref * aref;
- khui_action * act;
-
- def = khui_find_menu(KHUI_TOOLBAR_STANDARD);
-
- aref = def->items;
-
- while(aref && aref->action != KHUI_MENU_END) {
- if(aref->action == KHUI_MENU_SEP) {
- aref++;
- continue;
- }
-
- act = khui_find_action(aref->action);
- if(act) {
- BOOL enable;
-
- enable = !(act->state & KHUI_ACTIONSTATE_DISABLED);
- SendMessage(khui_hwnd_standard_toolbar,
- TB_ENABLEBUTTON,
- (WPARAM) act->cmd,
- MAKELPARAM(enable, 0));
- }
-
- aref++;
- }
-}
-
-void khm_create_standard_toolbar(HWND rebar) {
- HWND hwtb;
- SIZE sz;
- HBITMAP hbm_blank;
- HIMAGELIST hiList;
- REBARBANDINFO rbi;
- khui_menu_def * def;
- khui_action * act;
- khui_action_ref * aref;
- int idx_blank;
-
- def = khui_find_menu(KHUI_TOOLBAR_STANDARD);
-
- if (!def) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
- hwtb = CreateWindowEx(0 ,
- TOOLBARCLASSNAME,
- (LPWSTR) NULL,
- WS_CHILD |
- TBSTYLE_FLAT |
- TBSTYLE_AUTOSIZE |
- TBSTYLE_TOOLTIPS |
- CCS_NORESIZE |
- CCS_NOPARENTALIGN |
- CCS_ADJUSTABLE |
- CCS_NODIVIDER,
- 0, 0, 0, 0, rebar,
- (HMENU) NULL, khm_hInstance,
- NULL);
-
- if(!hwtb) {
-#ifdef DEBUG
- assert(FALSE);
-#endif
- return;
- }
-
-#if (_WIN32_IE >= 0x0501)
- SendMessage(hwtb, TB_SETEXTENDEDSTYLE, 0,
- TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS);
-#endif
-
- hiList = ImageList_Create(
- KHUI_TOOLBAR_IMAGE_WIDTH,
- KHUI_TOOLBAR_IMAGE_HEIGHT,
- ILC_MASK,
- (int) khui_action_list_length(def->items),
- 3);
-
- hbm_blank = LoadImage(khm_hInstance,
- MAKEINTRESOURCE(IDB_TB_BLANK),
- IMAGE_BITMAP,
- KHUI_TOOLBAR_IMAGE_WIDTH,
- KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
- idx_blank = ImageList_AddMasked(hiList, hbm_blank, RGB(0,0,0));
-
- khui_hwnd_standard_toolbar = hwtb;
- khui_tb_blank = idx_blank;
-
- def = khui_find_menu(KHUI_TOOLBAR_STANDARD);
-
- aref = def->items;
-
- SendMessage(hwtb,
- TB_BUTTONSTRUCTSIZE,
- sizeof(TBBUTTON),
- 0);
-
- SendMessage(hwtb,
- TB_SETBITMAPSIZE,
- 0,
- MAKELONG(KHUI_TOOLBAR_IMAGE_WIDTH,KHUI_TOOLBAR_IMAGE_HEIGHT));
-
- SendMessage(hwtb,
- TB_SETIMAGELIST,
- 0,
- (LPARAM) hiList);
-
- SendMessage(hwtb,
- TB_SETBUTTONSIZE,
- 0,
- MAKELONG(KHUI_TOOLBAR_IMAGE_WIDTH,KHUI_TOOLBAR_IMAGE_HEIGHT));
-
- while(aref && aref->action != KHUI_MENU_END) {
- if(aref->action == KHUI_MENU_SEP) {
- khui_add_action_to_toolbar(hwtb,
- NULL,
- KHUI_TOOLBAR_ADD_SEP,
- hiList);
- } else {
- act = khui_find_action(aref->action);
- khui_add_action_to_toolbar(hwtb,
- act,
- KHUI_TOOLBAR_ADD_BITMAP |
- ((aref->flags & KHUI_ACTIONREF_SUBMENU)?
- KHUI_TOOLBAR_ADD_DROPDOWN: 0),
- hiList);
- }
- aref ++;
- }
-
- SendMessage(hwtb,
- TB_AUTOSIZE,
- 0,0);
-
- SendMessage(hwtb,
- TB_GETMAXSIZE,
- 0,
- (LPARAM) &sz);
-
- sz.cy += 5;
-
- ZeroMemory(&rbi, sizeof(rbi));
-
- rbi.cbSize = sizeof(rbi);
- rbi.fMask =
- RBBIM_ID |
- RBBIM_CHILD |
- RBBIM_CHILDSIZE |
- RBBIM_IDEALSIZE |
- RBBIM_SIZE |
- RBBIM_STYLE;
- rbi.fStyle =
- RBBS_USECHEVRON |
- RBBS_BREAK;
- rbi.hwndChild = hwtb;
-
- rbi.wID = KHUI_TOOLBAR_STANDARD;
- rbi.cx = sz.cx;
- rbi.cxMinChild = sz.cx;
- rbi.cyMinChild = sz.cy;
- rbi.cyChild = rbi.cyMinChild;
- rbi.cyMaxChild = rbi.cyMinChild;
- rbi.cyIntegral = rbi.cyMinChild;
-
- rbi.cxIdeal = rbi.cx;
-
- SendMessage(rebar,
- RB_INSERTBAND,
- 0,
- (LPARAM) &rbi);
-}
diff --git a/src/windows/identity/ui/toolbar.h b/src/windows/identity/ui/toolbar.h
deleted file mode 100644
index ac09c6619..000000000
--- a/src/windows/identity/ui/toolbar.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2005 Massachusetts Institute of Technology
- *
- * 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 __KHIMAIRA_TOOLBAR_H
-#define __KHIMAIRA_TOOLBAR_H
-
-extern HWND khui_hwnd_standard_toolbar;
-
-void khui_init_toolbar(void);
-void khui_exit_toolbar(void);
-LRESULT khm_toolbar_notify(LPNMHDR notice);
-void khm_create_standard_toolbar(HWND rebar);
-void khui_add_action_to_toolbar(HWND toolbar, khui_action * act, int opt, HIMAGELIST hiList);
-void khm_update_standard_toolbar(void);
-
-/* options for khui_add_action_to_toolbar */
-#define KHUI_TOOLBAR_ADD_TEXT 0x00000001
-#define KHUI_TOOLBAR_ADD_BITMAP 0x00000002
-#define KHUI_TOOLBAR_ADD_LONGTEXT 0x00000005
-#define KHUI_TOOLBAR_ADD_DROPDOWN 0x00000008
-#define KHUI_TOOLBAR_ADD_SEP 0x00000010
-#define KHUI_TOOLBAR_VARSIZE 0x00000020
-
-#define KHUI_TOOLBAR_IMAGE_WIDTH 29
-#define KHUI_TOOLBAR_IMAGE_HEIGHT 27
-#define KHUI_TOOLBAR_BGCOLOR RGB(0xd7,0xd7,0xd7)
-#define KHUI_TOOLBAR_MAX_BTNS 64
-
-#endif
diff --git a/src/windows/identity/ui/uiconfig.csv b/src/windows/identity/ui/uiconfig.csv
deleted file mode 100644
index 3a8006f55..000000000
--- a/src/windows/identity/ui/uiconfig.csv
+++ /dev/null
@@ -1,273 +0,0 @@
-#@#include<windows.h>
-#@#define RGBA(r,g,b,a) ((((DWORD) ((a) & 0xff)) << 24) | RGB(r,g,b))
-Name,Type,Value,Description
-CredWindow,KC_SPACE,0,"Options for the credentials window as well as the Network Identity Manager application."
- AutoInit,KC_INT32,0,"Boolean. Prompt for new credentials if no credentials are present during startup."
- AutoStart,KC_INT32,0,"[PRIVATE] Boolean. Start Network Identity Manager automatically when the current user logs in."
- AutoImport,KC_INT32,1,"Boolean. Import credentials from the LSA cache when Network Identity Manager starts."
- AutoDetectNet,KC_INT32,1,"Boolean. Automatically detect network connectivity changes."
- HideWatermark,KC_INT32,0,"Boolean. Suppress watermark in Credentials display. NOTE: there is no guarantee that this value will exist in future versions."
- KeepRunning,KC_INT32,1,"Boolean. Run from the system notification area after the main window is closed."
- DefaultView,KC_STRING,ByIdentity,"[PRIVATE] Name of the default view in Advanced mode."
- DefaultViewMini,KC_STRING,CompactIdentity,"[PRIVATE] Name of the default view in Basic mode."
- PaddingHorizontal,KC_INT32,4,"[PRIVATE]"
- PaddingVertical,KC_INT32,2,"[PRIVATE]"
- PaddingHeader,KC_INT32,16,"[PRIVATE]"
- Monitor,KC_INT32,1,"Boolean. Monitor credentials for expiration and renewal."
- DefaultMonitor,KC_INT32,1,"Boolean. This is the default Monitor value that is assigned for new identities."
- RefreshTimeout,KC_INT32,60,"Number of seconds between credentials window refreshes. The credentials window automatically triggers a refresh operation. This value specifies the number of seconds that must elapse between two refreshes. During the refresh, all the credentials provider plug-ins will need to re-enumerate their respective credentials."
- WarnThreshold,KC_INT32,900,In seconds
- AllowWarn,KC_INT32,1,"Boolean. Enables warning."
- CriticalThreshold,KC_INT32,300,In seconds
- AllowCritical,KC_INT32,1,Boolean. Enables critical.
- AutoRenewThreshold,KC_INT32,600,In seconds
- AllowAutoRenew,KC_INT32,1,Boolean.
- RenewAtHalfLife,KC_INT32,1,Boolean. Use half-life algorithm for renewals.
- DefaultAllowAutoRenew,KC_INT32,1,Default AllowAutoRenew value for new identities
- DefaultSticky,KC_INT32,0,Default Sticky value for new identities
- MaxThreshold,KC_INT32,86400,Max value for a threshold (1 day)
- MinThreshold,KC_INT32,10,Min value for a threshold (0)
- LogToFile,KC_INT32,0,Boolean. If true logs trace events to a nidmdbg.log in the temp folder
- DestroyCredsOnExit,KC_INT32,0,Boolean. If true; all credentials will be destroyed when NetIDMgr exits.
- NotificationAction,KC_INT32,50025,Action to perform when the user clicks on the notification icon.
- DefaultWindowMode,KC_INT32,1,(0-normal; 1-mini)
- DefaultTheme,KC_STRING,Default,Default theme. The name should correspond to a subspace in Themes
- ViewAllIdents,KC_INT32,0,"Boolean. Try to display all known identities if non-zero."
- Windows,KC_SPACE,0,Window parameters
- _Schema,KC_SPACE,0,Schema
- Width,KC_INT32,0,
- Height,KC_INT32,0,
- XPos,KC_INT32,0,
- YPos,KC_INT32,0,
- Dock,KC_INT32,0,Dock on window corner (0-none; 1-top left; 2-top right; 3-bottom right; 4-bottom left)
- _Schema,KC_ENDSPACE,0,
- Main,KC_SPACE,0,Main window
- Main,KC_ENDSPACE,0,
- MainMini,KC_SPACE,0,Main window (mini mode)
- Width,KC_INT32,470,
- Height,KC_INT32,500,
- Dock,KC_INT32,3,
- MainMini,KC_ENDSPACE,0,
- NewCred,KC_SPACE,0,New credentials window
- ForceToTop,KC_INT32,1,Force new creds window to the top
- AnimateSizeChanges,KC_INT32,1,Animate the new creds window when the size needs changing.
- AnimationSteps,KC_INT32,7,Number of steps in size-change animation
- AnimationStepTimeout,KC_INT32,40,Number of milliseconds to wait between each step of the size-change animation
- NewCred,KC_ENDSPACE,0,
- Windows,KC_ENDSPACE,0,
- Views,KC_SPACE,0,Preconfigured views for credentials
- _Schema,KC_SPACE,0,Schema for view definitions
- Description,KC_STRING,"",Description of the view
- ColumnList,KC_STRING,"","List of columns for the view, in order"
- _AppVersion,KC_BINARY,0,Binary version stamp
- Columns,KC_SPACE,0,"Column definitions. Each column name should have a corresponding subspace here. The name of the column should be a property or field name, unless it is a pseudo column like _CWFlags."
- _Schema,KC_SPACE,0,Column definition schema
- Width,KC_INT32,0,Width of the column
- SortIndex,KC_INT32,0,Sort index
- Flags,KC_INT32,0,Flags (See KHUI_CW_COL_* values)
- _Schema,KC_ENDSPACE,0
- Columns,KC_ENDSPACE,0
- _Schema,KC_ENDSPACE,0,
- Custom_0,KC_SPACE,0,First custom view. Additional views have names of the form Custom_N
- Description,KC_STRING,Custom view,
- ColumnList,KC_STRING,"_CWFlags,IdentityName,TypeName,Name,TimeLeft",
- Columns,KC_SPACE,0,Columns
- _CWFlags,KC_SPACE,0,
- Width,KC_INT32,20,
- Flags,KC_INT32,112,
- _CWFlags,KC_ENDSPACE,0,
- IdentityName,KC_SPACE,0,
- Width,KC_INT32,100,
- SortIndex,KC_INT32,0,
- Flags,KC_INT32,11,
- IdentityName,KC_ENDSPACE,0
- TypeName,KC_SPACE,0
- Width,KC_INT32,100
- SortIndex,KC_INT32,1
- Flags,KC_INT32,11
- TypeName,KC_ENDSPACE,0
- Name,KC_SPACE,0
- Width,KC_INT32,200
- SortIndex,KC_INT32,2
- Flags,KC_INT32,3
- Name,KC_ENDSPACE,0
- TimeLeft,KC_SPACE,0
- Width,KC_INT32,200
- Flags,KC_INT32,1
- TimeLeft,KC_ENDSPACE,0
- Columns,KC_ENDSPACE,0
- Custom_0,KC_ENDSPACE,0,
- ByIdentity,KC_SPACE,0,The default view
- Description,KC_STRING,View grouped by identity and credential type,
- ColumnList,KC_STRING,"_CWFlags,IdentityName,TypeName,Location,Name,TimeLeft",
- Columns,KC_SPACE,0,Columns
- _CWFlags,KC_SPACE,0,
- Width,KC_INT32,20,
- Flags,KC_INT32,112,
- _CWFlags,KC_ENDSPACE,0,
- IdentityName,KC_SPACE,0,
- Width,KC_INT32,100,
- SortIndex,KC_INT32,0,
- Flags,KC_INT32,11,
- IdentityName,KC_ENDSPACE,0
- TypeName,KC_SPACE,0
- Width,KC_INT32,100
- SortIndex,KC_INT32,1
- Flags,KC_INT32,11
- TypeName,KC_ENDSPACE,0
- Location,KC_SPACE,0,
- Width,KC_INT32,50
- SortIndex,KC_INT32,2
- Flags,KC_INT32,11
- Location,KC_ENDSPACE,0,
- Name,KC_SPACE,0
- Width,KC_INT32,200
- SortIndex,KC_INT32,3
- Flags,KC_INT32,3
- Name,KC_ENDSPACE,0
- TimeLeft,KC_SPACE,0
- Width,KC_INT32,200
- Flags,KC_INT32,1
- TimeLeft,KC_ENDSPACE,0
- Columns,KC_ENDSPACE,0
- ByIdentity,KC_ENDSPACE,0
- ByType,KC_SPACE,0,The default view
- Description,KC_STRING,View grouped by type and identity,
- ColumnList,KC_STRING,"_CWFlags,TypeName,IdentityName,Name,TimeLeft",
- Columns,KC_SPACE,0,Columns
- _CWFlags,KC_SPACE,0,
- Width,KC_INT32,20,
- Flags,KC_INT32,112,
- _CWFlags,KC_ENDSPACE,0,
- TypeName,KC_SPACE,0
- Width,KC_INT32,100
- SortIndex,KC_INT32,0
- Flags,KC_INT32,11
- TypeName,KC_ENDSPACE,0
- IdentityName,KC_SPACE,0,
- Width,KC_INT32,100,
- SortIndex,KC_INT32,1,
- Flags,KC_INT32,11,
- IdentityName,KC_ENDSPACE,0
- Name,KC_SPACE,0
- Width,KC_INT32,200
- SortIndex,KC_INT32,2
- Flags,KC_INT32,3
- Name,KC_ENDSPACE,0
- TimeLeft,KC_SPACE,0
- Width,KC_INT32,200
- Flags,KC_INT32,1
- TimeLeft,KC_ENDSPACE,0
- Columns,KC_ENDSPACE,0
- ByType,KC_ENDSPACE,0
- ByLocation,KC_SPACE,0,View by location
- Description,KC_STRING,View grouped by location,
- ColumnList,KC_STRING,"_CWFlags,Location,IdentityName,TypeName,Name,TimeLeft",
- Columns,KC_SPACE,0,Columns
- _CWFlags,KC_SPACE,0,
- Width,KC_INT32,20,
- Flags,KC_INT32,112,
- _CWFlags,KC_ENDSPACE,0,
- Location,KC_SPACE,0,
- Width,KC_INT32,100,
- SortIndex,KC_INT32,0,
- Flags,KC_INT32,11,
- Location,KC_ENDSPACE,0,
- IdentityName,KC_SPACE,0,
- Width,KC_INT32,100,
- SortIndex,KC_INT32,1,
- Flags,KC_INT32,11,
- IdentityName,KC_ENDSPACE,0
- TypeName,KC_SPACE,0
- Width,KC_INT32,100
- SortIndex,KC_INT32,2
- Flags,KC_INT32,11
- TypeName,KC_ENDSPACE,0
- Name,KC_SPACE,0
- Width,KC_INT32,200
- SortIndex,KC_INT32,3
- Flags,KC_INT32,3
- Name,KC_ENDSPACE,0
- TimeLeft,KC_SPACE,0
- Width,KC_INT32,200
- Flags,KC_INT32,1
- TimeLeft,KC_ENDSPACE,0
- Columns,KC_ENDSPACE,0
- ByLocation,KC_ENDSPACE,0
- CompactIdentity,KC_SPACE,0,Default Compact View by Identity
- Description,KC_STRING,Compact view of identities
- ColumnList,KC_STRING,"IdentityName",
- ExpandedIdentity,KC_INT32,1,Use expanded display of identity headers
- NoHeader,KC_INT32,1,Suppress the column header
- Columns,KC_SPACE,0,
- IdentityName,KC_SPACE,0,
- Width,KC_INT32,415,
- SortIndex,KC_INT32,0,
- Flags,KC_INT32,171
- IdentityName,KC_ENDSPACE,0,
- Columns,KC_ENDSPACE,0,
- CompactIdentity,KC_ENDSPACE,0
- Custom_1,KC_SPACE,0,Default Compact View by Identity
- Description,KC_STRING,Compact view of identities
- ColumnList,KC_STRING,"IdentityName",
- ExpandedIdentity,KC_INT32,1,Use expanded display of identity headers
- NoHeader,KC_INT32,1,Suppress the column header
- Columns,KC_SPACE,0,
- IdentityName,KC_SPACE,0,
- Width,KC_INT32,415,
- SortIndex,KC_INT32,0,
- Flags,KC_INT32,171
- IdentityName,KC_ENDSPACE,0,
- Columns,KC_ENDSPACE,0,
- Custom_1,KC_ENDSPACE,0
- Views,KC_ENDSPACE,0
- Notices,KC_SPACE,0,Notices and alerts
- MinimizeWarning,KC_INT32,1,Show the minimize warning?
- Notices,KC_ENDSPACE,0
- Themes,KC_SPACE,0,Color schemes for the credentials display
- _Schema,KC_SPACE,0,Schema for color schemes
- ClrSelection,KC_INT32,0,"Background (Selection)"
- ClrBackground,KC_INT32,0,"Background (Normal)"
- ClrGray,KC_INT32,0,"Background (Gray)"
- ClrHeader,KC_INT32,0,"Header (Normal)"
- ClrHeaderCred,KC_INT32,0,"Header (with credentials)"
- ClrHeaderWarn,KC_INT32,0,"Header (Warning)"
- ClrHeaderCrit,KC_INT32,0,"Header (Critical)"
- ClrHeaderExp,KC_INT32,0,"Header (Expired)"
- ClrHeaderSel,KC_INT32,0,"Header (Normal, Selected)"
- ClrHeaderCredSel,KC_INT32,0,"Header (with credentials, Selected)"
- ClrHeaderWarnSel,KC_INT32,0,"Header (Warning, Selected)"
- ClrHeaderCritSel,KC_INT32,0,"Header (Critical, Selected)"
- ClrHeaderExpSel,KC_INT32,0,"Header (Expired, Selected)"
- ClrHeaderOutline,KC_INT32,0,"Header (Outline color)"
- ClrText,KC_INT32,0,"Text (Normal)"
- ClrTextSel,KC_INT32,0,"Text (Selected)"
- ClrTextHeader,KC_INT32,0,"Text (Header)"
- ClrTextHeaderSel,KC_INT32,0,"Text (Header, Selected)"
- ClrTextHeaderGray,KC_INT32,0,"Text (Header, Gray)"
- ClrTextHeaderGraySel,KC_INT32,0,"Text (Header, Gray, Selected)"
- _Schema,KC_ENDSPACE,0,
- Default,KC_SPACE,0,Default color scheme
- ClrSelection,KC_INT32,"RGB(192,192,192)",
- ClrBackground,KC_INT32,"RGB(255,255,255)",
- ClrGray,KC_INT32,"RGB(240,240,240)",
- ClrHeader,KC_INT32,"RGB(240,240,240)",
- ClrHeaderCred,KC_INT32,"RGB(184,235,134)",
- ClrHeaderWarn,KC_INT32,"RGB(235,235,134)",
- ClrHeaderCrit,KC_INT32,"RGB(235,184,134)",
- ClrHeaderExp,KC_INT32,"RGB(235,134,134)",
- ClrHeaderSel,KC_INT32,"RGB(200,200,200)",
- ClrHeaderCredSel,KC_INT32,"RGB(144,195, 94)",
- ClrHeaderWarnSel,KC_INT32,"RGB(195,195, 94)",
- ClrHeaderCritSel,KC_INT32,"RGB(195,144, 94)",
- ClrHeaderExpSel,KC_INT32,"RGB(195, 94, 94)",
- ClrHeaderOutline,KC_INT32,"RGB(15,15,15)",
- ClrText,KC_INT32,"RGB(15,15,15)",
- ClrTextSel,KC_INT32,"RGB(0,0,0)",
- ClrTextHeader,KC_INT32,"RGB(15,15,15)",
- ClrTextHeaderSel,KC_INT32,"RGB(0,0,0)",
- ClrTextHeaderGray,KC_INT32,"RGB(192,192,192)",
- ClrTextHeaderGraySel,KC_INT32,"RGB(240,240,240)",
- Default,KC_ENDSPACE,0
- Themes,KC_ENDSPACE,0
-CredWindow,KC_ENDSPACE,0