windows-netidmgr-extension-sample-20080217
[openafs.git] / src / WINNT / netidmgr_plugin / extensions / sample / config_main.c
1 /*
2  * Copyright (c) 2006 Secure Endpoints Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24
25 /* $Id$ */
26
27 #include "credprov.h"
28 #include <assert.h>
29
30 /* Dialog procedures and support functions for handling configuration
31    dialogs for general plug-in configuration. */
32
33 /* Structure for holding dialog data for the configuration window. */
34 typedef struct tag_config_main_dlg_data {
35     khui_config_node cnode;
36
37     /* TODO: add fields as needed */
38 } config_main_dlg_data;
39
40 INT_PTR CALLBACK
41 config_dlgproc(HWND hwnd,
42                UINT uMsg,
43                WPARAM wParam,
44                LPARAM lParam) {
45
46     config_main_dlg_data * d;
47
48     switch (uMsg) {
49     case WM_INITDIALOG:
50         d = malloc(sizeof(*d));
51         assert(d);
52         ZeroMemory(d, sizeof(*d));
53
54         /* for configuration panels that are not subpanels, lParam is
55            a held handle to the configuration node.  The handle will
56            be held for the lifetime of the window. */
57
58         d->cnode = (khui_config_node) lParam;
59
60         /* TODO: perform any other required initialization stuff
61            here */
62
63 #pragma warning(push)
64 #pragma warning(disable: 4244)
65         SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
66 #pragma warning(pop)
67
68         break;
69
70     case KHUI_WM_CFG_NOTIFY:
71         {
72             d = (config_main_dlg_data *)
73                 GetWindowLongPtr(hwnd, DWLP_USER);
74             if (d == NULL)
75                 break;
76
77             /* WMCFG_APPLY is the only notification we care about */
78
79             if (HIWORD(wParam) == WMCFG_APPLY) {
80                 /* TODO: Apply changes and update the state */
81
82                 return TRUE;
83             }
84         }
85         break;
86
87     case WM_DESTROY:
88         d = (config_main_dlg_data *)
89             GetWindowLongPtr(hwnd, DWLP_USER);
90
91         /* TODO: perform any other required uninitialization here */
92
93         if (d) {
94             free(d);
95             SetWindowLongPtr(hwnd, DWLP_USER, 0);
96         }
97
98         break;
99     }
100
101     return FALSE;
102
103 }