diff options
| author | Ken Raeburn <raeburn@mit.edu> | 2007-06-20 01:19:59 +0000 |
|---|---|---|
| committer | Ken Raeburn <raeburn@mit.edu> | 2007-06-20 01:19:59 +0000 |
| commit | 78ec90d925e1f672639762e6c9fa674bf7ff0a64 (patch) | |
| tree | 3aad3df3133e6e0f2922f575b9da94630543f433 /src/windows/identity/sample | |
| parent | d275e06d0cb0f248aa54a6f134a59f84aa563e14 (diff) | |
set svn:eol-style to native for *.[ch]
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19596 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/identity/sample')
10 files changed, 1592 insertions, 1592 deletions
diff --git a/src/windows/identity/sample/templates/credprov/config_id.c b/src/windows/identity/sample/templates/credprov/config_id.c index ed5b3e4c3..850016266 100644 --- a/src/windows/identity/sample/templates/credprov/config_id.c +++ b/src/windows/identity/sample/templates/credprov/config_id.c @@ -1,118 +1,118 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-#include <assert.h>
-
-/* Dialog procedures and support functions for handling configuration
- dialogs for per-identity configuration. When the configuration
- dialog is activated, an instance of this dialog will be created for
- each identity that the user touches. */
-
-/* The structure that we use to hold state information for the
- dialog. */
-typedef struct tag_config_id_dlg_data {
- khui_config_init_data cfg; /* instance information for this
- dialog */
-
- khm_handle ident; /* handle to the identity for this
- dialog */
-
- /* TODO: Add any fields for holding state here */
-} config_id_dlg_data;
-
-INT_PTR CALLBACK
-config_id_dlgproc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- config_id_dlg_data * d;
-
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
- khm_size cb;
- khm_int32 rv;
-
- d = malloc(sizeof(*d));
- assert(d);
- ZeroMemory(d, sizeof(*d));
-
- /* for subpanels, lParam is a pointer to a
- khui_config_init_data strucutre that provides the
- instance and context information. It's not a
- persistent strucutre, so we have to make a copy. */
- d->cfg = *((khui_config_init_data *) lParam);
-
- cb = sizeof(idname);
- rv = khui_cfg_get_name(d->cfg.ctx_node, idname, &cb);
- assert(KHM_SUCCEEDED(rv));
-
- rv = kcdb_identity_create(idname, 0, &d->ident);
- assert(KHM_SUCCEEDED(rv));
-
- /* TODO: perform any other required initialization */
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
- }
- break;
-
- case KHUI_WM_CFG_NOTIFY:
- d = (config_id_dlg_data *)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
- /* TODO: apply changes */
-
- return TRUE;
- }
- break;
-
- case WM_DESTROY:
- {
- d = (config_id_dlg_data *)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (d) {
- if (d->ident)
- kcdb_identity_release(d->ident);
-
- /* TODO: perform any other required uninitialization */
-
- free(d);
- }
- }
- break;
- }
-
- return FALSE;
-
-}
+/* + * Copyright (c) 2006 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 "credprov.h" +#include <assert.h> + +/* Dialog procedures and support functions for handling configuration + dialogs for per-identity configuration. When the configuration + dialog is activated, an instance of this dialog will be created for + each identity that the user touches. */ + +/* The structure that we use to hold state information for the + dialog. */ +typedef struct tag_config_id_dlg_data { + khui_config_init_data cfg; /* instance information for this + dialog */ + + khm_handle ident; /* handle to the identity for this + dialog */ + + /* TODO: Add any fields for holding state here */ +} config_id_dlg_data; + +INT_PTR CALLBACK +config_id_dlgproc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + + config_id_dlg_data * d; + + switch (uMsg) { + case WM_INITDIALOG: + { + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + khm_size cb; + khm_int32 rv; + + d = malloc(sizeof(*d)); + assert(d); + ZeroMemory(d, sizeof(*d)); + + /* for subpanels, lParam is a pointer to a + khui_config_init_data strucutre that provides the + instance and context information. It's not a + persistent strucutre, so we have to make a copy. */ + d->cfg = *((khui_config_init_data *) lParam); + + cb = sizeof(idname); + rv = khui_cfg_get_name(d->cfg.ctx_node, idname, &cb); + assert(KHM_SUCCEEDED(rv)); + + rv = kcdb_identity_create(idname, 0, &d->ident); + assert(KHM_SUCCEEDED(rv)); + + /* TODO: perform any other required initialization */ + +#pragma warning(push) +#pragma warning(disable: 4244) + SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d); +#pragma warning(pop) + } + break; + + case KHUI_WM_CFG_NOTIFY: + d = (config_id_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (HIWORD(wParam) == WMCFG_APPLY) { + /* TODO: apply changes */ + + return TRUE; + } + break; + + case WM_DESTROY: + { + d = (config_id_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (d) { + if (d->ident) + kcdb_identity_release(d->ident); + + /* TODO: perform any other required uninitialization */ + + free(d); + } + } + break; + } + + return FALSE; + +} diff --git a/src/windows/identity/sample/templates/credprov/config_ids.c b/src/windows/identity/sample/templates/credprov/config_ids.c index 413951207..8d6f0081a 100644 --- a/src/windows/identity/sample/templates/credprov/config_ids.c +++ b/src/windows/identity/sample/templates/credprov/config_ids.c @@ -1,96 +1,96 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-#include<assert.h>
-
-/* Dialog procedures and support functions for handling configuration
- dialogs for all identities. */
-
-/* The structure that we use to hold state information for the
- dialog. */
-typedef struct tag_config_ids_dlg_data {
- khui_config_init_data cfg; /* instance information for this
- dialog */
-
- /* TODO: Add any fields for holding state here */
-} config_ids_dlg_data;
-
-INT_PTR CALLBACK
-config_ids_dlgproc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- config_ids_dlg_data * d;
-
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- d = malloc(sizeof(*d));
- assert(d);
- ZeroMemory(d, sizeof(*d));
-
- /* for subpanels, lParam is a pointer to a
- khui_config_init_data strucutre that provides the
- instance and context information. It's not a
- persistent strucutre, so we have to make a copy. */
- d->cfg = *((khui_config_init_data *) lParam);
-
- /* TODO: perform any additional initialization */
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
- }
- break;
-
- case KHUI_WM_CFG_NOTIFY:
- d = (config_ids_dlg_data *)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
- /* TODO: apply changes */
-
- return TRUE;
- }
- break;
-
- case WM_DESTROY:
- d = (config_ids_dlg_data *)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (d) {
- /* TODO: Perform any additional uninitialization */
-
- free (d);
- }
- break;
- }
-
- return FALSE;
-}
+/* + * Copyright (c) 2006 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 "credprov.h" +#include<assert.h> + +/* Dialog procedures and support functions for handling configuration + dialogs for all identities. */ + +/* The structure that we use to hold state information for the + dialog. */ +typedef struct tag_config_ids_dlg_data { + khui_config_init_data cfg; /* instance information for this + dialog */ + + /* TODO: Add any fields for holding state here */ +} config_ids_dlg_data; + +INT_PTR CALLBACK +config_ids_dlgproc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + + config_ids_dlg_data * d; + + switch (uMsg) { + case WM_INITDIALOG: + { + d = malloc(sizeof(*d)); + assert(d); + ZeroMemory(d, sizeof(*d)); + + /* for subpanels, lParam is a pointer to a + khui_config_init_data strucutre that provides the + instance and context information. It's not a + persistent strucutre, so we have to make a copy. */ + d->cfg = *((khui_config_init_data *) lParam); + + /* TODO: perform any additional initialization */ + +#pragma warning(push) +#pragma warning(disable: 4244) + SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d); +#pragma warning(pop) + } + break; + + case KHUI_WM_CFG_NOTIFY: + d = (config_ids_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (HIWORD(wParam) == WMCFG_APPLY) { + /* TODO: apply changes */ + + return TRUE; + } + break; + + case WM_DESTROY: + d = (config_ids_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (d) { + /* TODO: Perform any additional uninitialization */ + + free (d); + } + break; + } + + return FALSE; +} diff --git a/src/windows/identity/sample/templates/credprov/config_main.c b/src/windows/identity/sample/templates/credprov/config_main.c index 3461ac0cc..87a2a15fc 100644 --- a/src/windows/identity/sample/templates/credprov/config_main.c +++ b/src/windows/identity/sample/templates/credprov/config_main.c @@ -1,99 +1,99 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-#include <assert.h>
-
-/* Dialog procedures and support functions for handling configuration
- dialogs for general plug-in configuration. */
-
-/* Structure for holding dialog data for the configuration window. */
-typedef struct tag_config_main_dlg_data {
- khui_config_node cnode;
-
- /* TODO: add fields as needed */
-} config_main_dlg_data;
-
-INT_PTR CALLBACK
-config_dlgproc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- config_main_dlg_data * d;
-
- switch (uMsg) {
- case WM_INITDIALOG:
- d = malloc(sizeof(*d));
- assert(d);
- ZeroMemory(d, sizeof(*d));
-
- /* for configuration panels that are not subpanels, lParam is
- a held handle to the configuration node. The handle will
- be held for the lifetime of the window. */
-
- d->cnode = (khui_config_node) lParam;
-
- /* TODO: perform any other required initialization stuff
- here */
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);
-#pragma warning(pop)
-
- break;
-
- case KHUI_WM_CFG_NOTIFY:
- {
- d = (config_main_dlg_data *)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- /* WMCFG_APPLY is the only notification we care about */
-
- if (HIWORD(wParam) == WMCFG_APPLY) {
- /* TODO: Apply changes and update the state */
-
- return TRUE;
- }
- }
- break;
-
- case WM_DESTROY:
- d = (config_main_dlg_data *)
- GetWindowLongPtr(hwnd, DWLP_USER);
-
- /* TODO: perform any other required uninitialization here */
-
- if (d)
- free(d);
-
- break;
- }
-
- return FALSE;
-
-}
+/* + * Copyright (c) 2006 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 "credprov.h" +#include <assert.h> + +/* Dialog procedures and support functions for handling configuration + dialogs for general plug-in configuration. */ + +/* Structure for holding dialog data for the configuration window. */ +typedef struct tag_config_main_dlg_data { + khui_config_node cnode; + + /* TODO: add fields as needed */ +} config_main_dlg_data; + +INT_PTR CALLBACK +config_dlgproc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + + config_main_dlg_data * d; + + switch (uMsg) { + case WM_INITDIALOG: + d = malloc(sizeof(*d)); + assert(d); + ZeroMemory(d, sizeof(*d)); + + /* for configuration panels that are not subpanels, lParam is + a held handle to the configuration node. The handle will + be held for the lifetime of the window. */ + + d->cnode = (khui_config_node) lParam; + + /* TODO: perform any other required initialization stuff + here */ + +#pragma warning(push) +#pragma warning(disable: 4244) + SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d); +#pragma warning(pop) + + break; + + case KHUI_WM_CFG_NOTIFY: + { + d = (config_main_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + /* WMCFG_APPLY is the only notification we care about */ + + if (HIWORD(wParam) == WMCFG_APPLY) { + /* TODO: Apply changes and update the state */ + + return TRUE; + } + } + break; + + case WM_DESTROY: + d = (config_main_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + /* TODO: perform any other required uninitialization here */ + + if (d) + free(d); + + break; + } + + return FALSE; + +} diff --git a/src/windows/identity/sample/templates/credprov/credacq.c b/src/windows/identity/sample/templates/credprov/credacq.c index da07756da..cd8db44ee 100644 --- a/src/windows/identity/sample/templates/credprov/credacq.c +++ b/src/windows/identity/sample/templates/credprov/credacq.c @@ -1,405 +1,405 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-#include<assert.h>
-
-/* This file provides handlers for the credentials acquisition
- messages including handling the user interface for the new
- credentials dialogs. */
-
-/*********************************************************************
-
-These are stubs for the Window message for the dialog panel. This
-dialog panel is the one that is added to the new credentials window
-for obtaining new credentials.
-
-Note that all the UI callbacks run under the UI thread.
-
- *********************************************************************/
-
-/* This structure will hold all the state information we will need to
- access from the new credentials panel for our credentials type. */
-struct nc_dialog_data {
- khui_new_creds * nc;
- khui_new_creds_by_type * nct;
-
- /* TODO: add any other state information here */
-};
-
-/* Note: This callback runs under the UI thread */
-INT_PTR
-handle_wm_initdialog(HWND hwnd, WPARAM wParam, LPARAM lParam) {
- khui_new_creds * nc = NULL;
- khui_new_creds_by_type * nct = NULL;
- struct nc_dialog_data * d = NULL;
-
- nc = (khui_new_creds *) lParam;
- khui_cw_find_type(nc, credtype_id, &nct);
-
- assert(nct);
-
- d = malloc(sizeof(*d));
- ZeroMemory(d, sizeof(*d));
-
- d->nc = nc;
- d->nct = nct;
-
-#pragma warning(push)
-#pragma warning(disable: 4244)
- SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) d);
-#pragma warning(pop)
-
- nct->aux = (LPARAM) d; /* we can use the auxiliary field to
- hold a pointer to d */
-
- /* TODO: Perform any additional initialization here */
-
- return FALSE;
-}
-
-/* Note: This callback runs under the UI thread */
-INT_PTR
-handle_khui_wm_nc_notify(HWND hwnd, WPARAM wParam, LPARAM lParam) {
-
- struct nc_dialog_data * d;
-
- /* Refer to the khui_wm_nc_notifications enumeration in the
- NetIDMgr SDK for the full list of notification messages that
- can be sent. */
-
- d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (!d)
- return TRUE;
-
- /* these should be set by now */
- assert(d->nc);
- assert(d->nct);
-
- switch (HIWORD(wParam)) {
- case WMNC_UPDATE_CREDTEXT:
- {
- wchar_t fmt[KHUI_MAXCCH_LONG_DESC];
- wchar_t tbuf[256];
-
- /* we are being requested to update the credentials
- text. We already allocated a buffer when we created the
- nct structure. So we can just set the text here.*/
-
- /* TODO: The credtext should reflect the credentials that
- will be obtained when the new credentials operation
- completes. */
-
- LoadString(hResModule, IDS_NC_CT_TEMPLATE,
- fmt, ARRAYLENGTH(fmt));
-
- LoadString(hResModule, IDS_GEN_NONE,
- tbuf, ARRAYLENGTH(tbuf));
-
- assert(d->nct->credtext);
-
- StringCbPrintf(d->nct->credtext, KHUI_MAXCB_LONG_DESC,
- fmt, tbuf);
- }
- break;
-
- case WMNC_CREDTEXT_LINK:
- break;
-
- case WMNC_IDENTITY_CHANGE:
- break;
-
- case WMNC_DIALOG_PREPROCESS:
- break;
- }
-
- return TRUE;
-}
-
-/* Note: This callback runs under the UI thread */
-INT_PTR
-handle_wm_command(HWND hwnd, WPARAM wParam, LPARAM lParam) {
-
- struct nc_dialog_data * d;
-
- d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER);
-
- /* TODO: handle WM_COMMAND */
- return FALSE;
-}
-
-/* Note: This callback runs under the UI thread */
-INT_PTR
-handle_wm_destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) {
-
- struct nc_dialog_data * d;
-
- d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER);
-
- if (d) {
- d->nc = NULL;
- d->nct = NULL;
-
- free(d);
- }
-
- /* TODO: Perform any additional uninitialization */
-
- return FALSE;
-}
-
-/* Dialog procedure for the new credentials panel for our credentials
- type. We just dispatch messages here to other functions here.
-
- Note that this procedure runs under the UI thread.
- */
-INT_PTR CALLBACK
-nc_dlg_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- switch (uMsg) {
- case WM_INITDIALOG:
- return handle_wm_initdialog(hwnd, wParam, lParam);
-
- case WM_COMMAND:
- return handle_wm_command(hwnd, wParam, lParam);
-
- case KHUI_WM_NC_NOTIFY:
- return handle_khui_wm_nc_notify(hwnd, wParam, lParam);
-
- case WM_DESTROY:
- return handle_wm_destroy(hwnd, wParam, lParam);
-
- /* TODO: add code for handling other windows messages here. */
- }
-
- return FALSE;
-}
-
-/*******************************************************************
-
-The following section contains function stubs for each of the
-credentials messages that a credentials provider is likely to want to
-handle. It doesn't include a few messages, but they should be easy to
-add. Please see the documentation for each of the KMSG_CRED_*
-messages for documentation on how to handle each of the messages.
-
-********************************************************************/
-
-
-/* Handler for KMSG_CRED_NEW_CREDS */
-khm_int32
-handle_kmsg_cred_new_creds(khui_new_creds * nc) {
-
- wchar_t wshortdesc[KHUI_MAXCCH_SHORT_DESC];
- size_t cb = 0;
- khui_new_creds_by_type * nct = NULL;
-
- /* This is a minimal handler that just adds a dialog pane to the
- new credentials window to handle new credentials acquisition
- for this credentials type. */
-
- /* TODO: add additional initialization etc. as needed */
-
- nct = malloc(sizeof(*nct));
- ZeroMemory(nct, sizeof(*nct));
-
- nct->type = credtype_id;
- nct->ordinal = -1;
-
- LoadString(hResModule, IDS_CT_SHORT_DESC,
- wshortdesc, ARRAYLENGTH(wshortdesc));
- StringCbLength(wshortdesc, sizeof(wshortdesc), &cb);
-#ifdef DEBUG
- assert(cb > 0);
-#endif
- cb += sizeof(wchar_t);
-
- nct->name = malloc(cb);
- StringCbCopy(nct->name, cb, wshortdesc);
-
- /* while we are at it, we should also allocate space for the
- credential text. */
- nct->credtext = malloc(KHUI_MAXCB_LONG_DESC);
- ZeroMemory(nct->credtext, KHUI_MAXCB_LONG_DESC);
-
- nct->h_module = hResModule;
- nct->dlg_proc = nc_dlg_proc;
- nct->dlg_template = MAKEINTRESOURCE(IDD_NEW_CREDS);
-
- khui_cw_add_type(nc, nct);
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_RENEW_CREDS */
-khm_int32
-handle_kmsg_cred_renew_creds(khui_new_creds * nc) {
-
- khui_new_creds_by_type * nct;
-
- /* This is a minimal handler that just adds this credential type
- to the list of credential types that are participating in this
- renewal operation. */
-
- /* TODO: add additional initialization etc. as needed */
-
- nct = malloc(sizeof(*nct));
- ZeroMemory(nct, sizeof(*nct));
-
- nct->type = credtype_id;
-
- khui_cw_add_type(nc, nct);
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_DIALOG_PRESTART */
-khm_int32
-handle_kmsg_cred_dialog_prestart(khui_new_creds * nc) {
- /* TODO: Handle this message */
-
- /* The message is sent after the dialog has been created. The
- window handle for the created dialog can be accessed through
- the hwnd_panel member of the khui_new_creds_by_type structure
- that was added for this credentials type. */
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_DIALOG_NEW_IDENTITY */
-/* Not a message sent out by NetIDMgr. See documentation of
- KMSG_CRED_DIALOG_NEW_IDENTITY */
-khm_int32
-handle_kmsg_cred_dialog_new_identity(khm_ui_4 uparam,
- void * vparam) {
- /* TODO: Handle this message */
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_DIALOG_NEW_OPTIONS */
-/* Not a message sent out by NetIDMgr. See documentation of
- KMSG_CRED_DIALOG_NEW_OPTIONS */
-khm_int32
-handle_kmsg_cred_dialog_new_options(khm_ui_4 uparam,
- void * vparam) {
- /* TODO: Handle this message */
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_PROCESS */
-khm_int32
-handle_kmsg_cred_process(khui_new_creds * nc) {
- /* TODO: Handle this message */
-
- /* This is where the credentials acquisition should be performed
- as determined by the UI. Note that this message is sent even
- when the user clicks 'cancel'. The value of nc->result should
- be checked before performing any credentials acquisition. If
- the value is KHUI_NC_RESULT_CANCEL, then no credentials should
- be acquired. Otherwise, the value would be
- KHUI_NC_RESULT_PROCESS. */
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_END */
-khm_int32
-handle_kmsg_cred_end(khui_new_creds * nc) {
-
- khui_new_creds_by_type * nct = NULL;
-
- /* TODO: Perform any additional uninitialization as needed. */
-
- khui_cw_find_type(nc, credtype_id, &nct);
-
- if (nct) {
-
- khui_cw_del_type(nc, credtype_id);
-
- if (nct->name)
- free(nct->name);
- if (nct->credtext)
- free(nct->credtext);
-
- free(nct);
-
- }
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for KMSG_CRED_IMPORT */
-khm_int32
-handle_kmsg_cred_import(void) {
-
- /* TODO: Handle this message */
-
- return KHM_ERROR_SUCCESS;
-}
-
-
-/******************************************************
- Dispatch each message to individual handlers above.
- */
-khm_int32 KHMAPI
-handle_cred_acq_msg(khm_int32 msg_type,
- khm_int32 msg_subtype,
- khm_ui_4 uparam,
- void * vparam) {
-
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- switch(msg_subtype) {
- case KMSG_CRED_NEW_CREDS:
- return handle_kmsg_cred_new_creds((khui_new_creds *) vparam);
-
- case KMSG_CRED_RENEW_CREDS:
- return handle_kmsg_cred_renew_creds((khui_new_creds *) vparam);
-
- case KMSG_CRED_DIALOG_PRESTART:
- return handle_kmsg_cred_dialog_prestart((khui_new_creds *) vparam);
-
- case KMSG_CRED_PROCESS:
- return handle_kmsg_cred_process((khui_new_creds *) vparam);
-
- case KMSG_CRED_DIALOG_NEW_IDENTITY:
- return handle_kmsg_cred_dialog_new_identity(uparam, vparam);
-
- case KMSG_CRED_DIALOG_NEW_OPTIONS:
- return handle_kmsg_cred_dialog_new_options(uparam, vparam);
-
- case KMSG_CRED_END:
- return handle_kmsg_cred_end((khui_new_creds *) vparam);
-
- case KMSG_CRED_IMPORT:
- return handle_kmsg_cred_import();
- }
-
- return rv;
-}
+/* + * Copyright (c) 2006 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 "credprov.h" +#include<assert.h> + +/* This file provides handlers for the credentials acquisition + messages including handling the user interface for the new + credentials dialogs. */ + +/********************************************************************* + +These are stubs for the Window message for the dialog panel. This +dialog panel is the one that is added to the new credentials window +for obtaining new credentials. + +Note that all the UI callbacks run under the UI thread. + + *********************************************************************/ + +/* This structure will hold all the state information we will need to + access from the new credentials panel for our credentials type. */ +struct nc_dialog_data { + khui_new_creds * nc; + khui_new_creds_by_type * nct; + + /* TODO: add any other state information here */ +}; + +/* Note: This callback runs under the UI thread */ +INT_PTR +handle_wm_initdialog(HWND hwnd, WPARAM wParam, LPARAM lParam) { + khui_new_creds * nc = NULL; + khui_new_creds_by_type * nct = NULL; + struct nc_dialog_data * d = NULL; + + nc = (khui_new_creds *) lParam; + khui_cw_find_type(nc, credtype_id, &nct); + + assert(nct); + + d = malloc(sizeof(*d)); + ZeroMemory(d, sizeof(*d)); + + d->nc = nc; + d->nct = nct; + +#pragma warning(push) +#pragma warning(disable: 4244) + SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) d); +#pragma warning(pop) + + nct->aux = (LPARAM) d; /* we can use the auxiliary field to + hold a pointer to d */ + + /* TODO: Perform any additional initialization here */ + + return FALSE; +} + +/* Note: This callback runs under the UI thread */ +INT_PTR +handle_khui_wm_nc_notify(HWND hwnd, WPARAM wParam, LPARAM lParam) { + + struct nc_dialog_data * d; + + /* Refer to the khui_wm_nc_notifications enumeration in the + NetIDMgr SDK for the full list of notification messages that + can be sent. */ + + d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER); + + if (!d) + return TRUE; + + /* these should be set by now */ + assert(d->nc); + assert(d->nct); + + switch (HIWORD(wParam)) { + case WMNC_UPDATE_CREDTEXT: + { + wchar_t fmt[KHUI_MAXCCH_LONG_DESC]; + wchar_t tbuf[256]; + + /* we are being requested to update the credentials + text. We already allocated a buffer when we created the + nct structure. So we can just set the text here.*/ + + /* TODO: The credtext should reflect the credentials that + will be obtained when the new credentials operation + completes. */ + + LoadString(hResModule, IDS_NC_CT_TEMPLATE, + fmt, ARRAYLENGTH(fmt)); + + LoadString(hResModule, IDS_GEN_NONE, + tbuf, ARRAYLENGTH(tbuf)); + + assert(d->nct->credtext); + + StringCbPrintf(d->nct->credtext, KHUI_MAXCB_LONG_DESC, + fmt, tbuf); + } + break; + + case WMNC_CREDTEXT_LINK: + break; + + case WMNC_IDENTITY_CHANGE: + break; + + case WMNC_DIALOG_PREPROCESS: + break; + } + + return TRUE; +} + +/* Note: This callback runs under the UI thread */ +INT_PTR +handle_wm_command(HWND hwnd, WPARAM wParam, LPARAM lParam) { + + struct nc_dialog_data * d; + + d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER); + + /* TODO: handle WM_COMMAND */ + return FALSE; +} + +/* Note: This callback runs under the UI thread */ +INT_PTR +handle_wm_destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) { + + struct nc_dialog_data * d; + + d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER); + + if (d) { + d->nc = NULL; + d->nct = NULL; + + free(d); + } + + /* TODO: Perform any additional uninitialization */ + + return FALSE; +} + +/* Dialog procedure for the new credentials panel for our credentials + type. We just dispatch messages here to other functions here. + + Note that this procedure runs under the UI thread. + */ +INT_PTR CALLBACK +nc_dlg_proc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + + switch (uMsg) { + case WM_INITDIALOG: + return handle_wm_initdialog(hwnd, wParam, lParam); + + case WM_COMMAND: + return handle_wm_command(hwnd, wParam, lParam); + + case KHUI_WM_NC_NOTIFY: + return handle_khui_wm_nc_notify(hwnd, wParam, lParam); + + case WM_DESTROY: + return handle_wm_destroy(hwnd, wParam, lParam); + + /* TODO: add code for handling other windows messages here. */ + } + + return FALSE; +} + +/******************************************************************* + +The following section contains function stubs for each of the +credentials messages that a credentials provider is likely to want to +handle. It doesn't include a few messages, but they should be easy to +add. Please see the documentation for each of the KMSG_CRED_* +messages for documentation on how to handle each of the messages. + +********************************************************************/ + + +/* Handler for KMSG_CRED_NEW_CREDS */ +khm_int32 +handle_kmsg_cred_new_creds(khui_new_creds * nc) { + + wchar_t wshortdesc[KHUI_MAXCCH_SHORT_DESC]; + size_t cb = 0; + khui_new_creds_by_type * nct = NULL; + + /* This is a minimal handler that just adds a dialog pane to the + new credentials window to handle new credentials acquisition + for this credentials type. */ + + /* TODO: add additional initialization etc. as needed */ + + nct = malloc(sizeof(*nct)); + ZeroMemory(nct, sizeof(*nct)); + + nct->type = credtype_id; + nct->ordinal = -1; + + LoadString(hResModule, IDS_CT_SHORT_DESC, + wshortdesc, ARRAYLENGTH(wshortdesc)); + StringCbLength(wshortdesc, sizeof(wshortdesc), &cb); +#ifdef DEBUG + assert(cb > 0); +#endif + cb += sizeof(wchar_t); + + nct->name = malloc(cb); + StringCbCopy(nct->name, cb, wshortdesc); + + /* while we are at it, we should also allocate space for the + credential text. */ + nct->credtext = malloc(KHUI_MAXCB_LONG_DESC); + ZeroMemory(nct->credtext, KHUI_MAXCB_LONG_DESC); + + nct->h_module = hResModule; + nct->dlg_proc = nc_dlg_proc; + nct->dlg_template = MAKEINTRESOURCE(IDD_NEW_CREDS); + + khui_cw_add_type(nc, nct); + + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_RENEW_CREDS */ +khm_int32 +handle_kmsg_cred_renew_creds(khui_new_creds * nc) { + + khui_new_creds_by_type * nct; + + /* This is a minimal handler that just adds this credential type + to the list of credential types that are participating in this + renewal operation. */ + + /* TODO: add additional initialization etc. as needed */ + + nct = malloc(sizeof(*nct)); + ZeroMemory(nct, sizeof(*nct)); + + nct->type = credtype_id; + + khui_cw_add_type(nc, nct); + + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_DIALOG_PRESTART */ +khm_int32 +handle_kmsg_cred_dialog_prestart(khui_new_creds * nc) { + /* TODO: Handle this message */ + + /* The message is sent after the dialog has been created. The + window handle for the created dialog can be accessed through + the hwnd_panel member of the khui_new_creds_by_type structure + that was added for this credentials type. */ + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_DIALOG_NEW_IDENTITY */ +/* Not a message sent out by NetIDMgr. See documentation of + KMSG_CRED_DIALOG_NEW_IDENTITY */ +khm_int32 +handle_kmsg_cred_dialog_new_identity(khm_ui_4 uparam, + void * vparam) { + /* TODO: Handle this message */ + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_DIALOG_NEW_OPTIONS */ +/* Not a message sent out by NetIDMgr. See documentation of + KMSG_CRED_DIALOG_NEW_OPTIONS */ +khm_int32 +handle_kmsg_cred_dialog_new_options(khm_ui_4 uparam, + void * vparam) { + /* TODO: Handle this message */ + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_PROCESS */ +khm_int32 +handle_kmsg_cred_process(khui_new_creds * nc) { + /* TODO: Handle this message */ + + /* This is where the credentials acquisition should be performed + as determined by the UI. Note that this message is sent even + when the user clicks 'cancel'. The value of nc->result should + be checked before performing any credentials acquisition. If + the value is KHUI_NC_RESULT_CANCEL, then no credentials should + be acquired. Otherwise, the value would be + KHUI_NC_RESULT_PROCESS. */ + + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_END */ +khm_int32 +handle_kmsg_cred_end(khui_new_creds * nc) { + + khui_new_creds_by_type * nct = NULL; + + /* TODO: Perform any additional uninitialization as needed. */ + + khui_cw_find_type(nc, credtype_id, &nct); + + if (nct) { + + khui_cw_del_type(nc, credtype_id); + + if (nct->name) + free(nct->name); + if (nct->credtext) + free(nct->credtext); + + free(nct); + + } + + return KHM_ERROR_SUCCESS; +} + +/* Handler for KMSG_CRED_IMPORT */ +khm_int32 +handle_kmsg_cred_import(void) { + + /* TODO: Handle this message */ + + return KHM_ERROR_SUCCESS; +} + + +/****************************************************** + Dispatch each message to individual handlers above. + */ +khm_int32 KHMAPI +handle_cred_acq_msg(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + + khm_int32 rv = KHM_ERROR_SUCCESS; + + switch(msg_subtype) { + case KMSG_CRED_NEW_CREDS: + return handle_kmsg_cred_new_creds((khui_new_creds *) vparam); + + case KMSG_CRED_RENEW_CREDS: + return handle_kmsg_cred_renew_creds((khui_new_creds *) vparam); + + case KMSG_CRED_DIALOG_PRESTART: + return handle_kmsg_cred_dialog_prestart((khui_new_creds *) vparam); + + case KMSG_CRED_PROCESS: + return handle_kmsg_cred_process((khui_new_creds *) vparam); + + case KMSG_CRED_DIALOG_NEW_IDENTITY: + return handle_kmsg_cred_dialog_new_identity(uparam, vparam); + + case KMSG_CRED_DIALOG_NEW_OPTIONS: + return handle_kmsg_cred_dialog_new_options(uparam, vparam); + + case KMSG_CRED_END: + return handle_kmsg_cred_end((khui_new_creds *) vparam); + + case KMSG_CRED_IMPORT: + return handle_kmsg_cred_import(); + } + + return rv; +} diff --git a/src/windows/identity/sample/templates/credprov/credprov.h b/src/windows/identity/sample/templates/credprov/credprov.h index 1851eaa4b..14670934d 100644 --- a/src/windows/identity/sample/templates/credprov/credprov.h +++ b/src/windows/identity/sample/templates/credprov/credprov.h @@ -1,176 +1,176 @@ -/*
- * Copyright (c) 2006 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$ */
-
-/* only include this header file once */
-#pragma once
-
-#ifndef _UNICODE
-#ifndef RC_INVOKED
-/* This template relies on _UNICODE being defined to call the correct
- APIs. */
-#error This template needs to be compiled with _UNICODE
-#endif
-#endif
-
-/* Pull in configuration macros from the Makefile */
-#include "credacq_config.h"
-
-/* declare a few macros about our plugin */
-
-/* The following macro will be used throughout the template to refer
- to the name of the plugin. The macro is actually defined the
- Makefile generated configuration header file. Modify the
- PLUGINNAME Makefile macro.*/
-#ifndef MYPLUGIN_NAME
-#error MYPLUGIN_NAME not defined
-#endif
-
-/* Also define the unicde equivalent of the name. In general strings
- in NetIDMgr are unicode. */
-#define MYPLUGIN_NAMEW _T(MYPLUGIN_NAME)
-
-/* The name of the module. This is distinct from the name of the
- plugin for several reasons. One of which is that a single module
- can provide multiple plugins. Also, having a module name distinct
- from a plugin name allows multiple vendors to provide the same
- plugin. For example, the module name for the MIT Kerberos 5 plugin
- is MITKrb5 while the plugin name is Krb5Cred. The macro is
- actually defined in the Makefile generated configuration header
- file. Modify the MODULENAME Makefile macro.*/
-#ifndef MYMODULE_NAME
-#error MYMODULE_NAME not defined
-#endif
-
-#define MYMODULE_NAMEW _T(MYMODULE_NAME)
-
-/* When logging events from our plugin, the event logging API can
- optionally take a facility name to provide a friendly label to
- identify where each event came from. We will default to the plugin
- name, although it can be anything. */
-#define MYPLUGIN_FACILITYW MYPLUGIN_NAMEW
-
-/* Base name of the DLL that will be providing the plugin. We use it
- to construct names of the DLLs that will contain localized
- resources. This is defined in the Makefile and fed in to the build
- through there. The macro to change in the Makefile is
- DLLBASENAME. */
-#ifndef MYPLUGIN_DLLBASE
-#error MYPLUGIN_DLLBASE Not defined!
-#endif
-
-#define MYPLUGIN_DLLBASEW _T(MYPLUGIN_DLLBASE)
-
-/* Name of the credentials type that will be registered by the plugin.
- This macro is actually defined in the Makefile generated
- configuration header file. Change the CREDTYPENAME macro in the
- Makefile. */
-#ifndef MYCREDTYPE_NAME
-#error MYCREDTYPE_NAME not defined
-#endif
-
-#define MYCREDTYPE_NAMEW _T(MYCREDTYPE_NAME)
-
-/* Configuration node names. We just concatenate a few strings
- together, although you should feel free to completely define your
- own. */
-
-#define CONFIGNODE_MAIN MYCREDTYPE_NAMEW L"Config"
-#define CONFIGNODE_ALL_ID MYCREDTYPE_NAMEW L"AllIdents"
-#define CONFIGNODE_PER_ID MYCREDTYPE_NAMEW L"PerIdent"
-
-#include<windows.h>
-/* include the standard NetIDMgr header files */
-#include<netidmgr.h>
-#include<tchar.h>
-
-/* declarations for language resources */
-#include "langres.h"
-
-#ifndef NOSTRSAFE
-#include<strsafe.h>
-#endif
-
-/***************************************************
- Externals
-***************************************************/
-
-extern kmm_module h_khModule;
-extern HINSTANCE hInstance;
-extern HMODULE hResModule;
-
-extern const wchar_t * my_facility;
-
-extern khm_int32 credtype_id;
-
-/* Function declarations */
-
-/* in plugin.c */
-khm_int32 KHMAPI
-plugin_msg_proc(khm_int32 msg_type,
- khm_int32 msg_subtype,
- khm_ui_4 uparam,
- void * vparam);
-
-/* in credtype.c */
-khm_int32 KHMAPI
-cred_is_equal(khm_handle cred1,
- khm_handle cred2,
- void * rock);
-
-/* in credacq.c */
-khm_int32 KHMAPI
-handle_cred_acq_msg(khm_int32 msg_type,
- khm_int32 msg_subtype,
- khm_ui_4 uparam,
- void * vparam);
-
-/* in proppage.c */
-INT_PTR CALLBACK
-pp_cred_dlg_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-/* in config_id.c */
-INT_PTR CALLBACK
-config_id_dlgproc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-/* in config_ids.c */
-INT_PTR CALLBACK
-config_ids_dlgproc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
-
-/* in config_main.c */
-INT_PTR CALLBACK
-config_dlgproc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam);
+/* + * Copyright (c) 2006 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$ */ + +/* only include this header file once */ +#pragma once + +#ifndef _UNICODE +#ifndef RC_INVOKED +/* This template relies on _UNICODE being defined to call the correct + APIs. */ +#error This template needs to be compiled with _UNICODE +#endif +#endif + +/* Pull in configuration macros from the Makefile */ +#include "credacq_config.h" + +/* declare a few macros about our plugin */ + +/* The following macro will be used throughout the template to refer + to the name of the plugin. The macro is actually defined the + Makefile generated configuration header file. Modify the + PLUGINNAME Makefile macro.*/ +#ifndef MYPLUGIN_NAME +#error MYPLUGIN_NAME not defined +#endif + +/* Also define the unicde equivalent of the name. In general strings + in NetIDMgr are unicode. */ +#define MYPLUGIN_NAMEW _T(MYPLUGIN_NAME) + +/* The name of the module. This is distinct from the name of the + plugin for several reasons. One of which is that a single module + can provide multiple plugins. Also, having a module name distinct + from a plugin name allows multiple vendors to provide the same + plugin. For example, the module name for the MIT Kerberos 5 plugin + is MITKrb5 while the plugin name is Krb5Cred. The macro is + actually defined in the Makefile generated configuration header + file. Modify the MODULENAME Makefile macro.*/ +#ifndef MYMODULE_NAME +#error MYMODULE_NAME not defined +#endif + +#define MYMODULE_NAMEW _T(MYMODULE_NAME) + +/* When logging events from our plugin, the event logging API can + optionally take a facility name to provide a friendly label to + identify where each event came from. We will default to the plugin + name, although it can be anything. */ +#define MYPLUGIN_FACILITYW MYPLUGIN_NAMEW + +/* Base name of the DLL that will be providing the plugin. We use it + to construct names of the DLLs that will contain localized + resources. This is defined in the Makefile and fed in to the build + through there. The macro to change in the Makefile is + DLLBASENAME. */ +#ifndef MYPLUGIN_DLLBASE +#error MYPLUGIN_DLLBASE Not defined! +#endif + +#define MYPLUGIN_DLLBASEW _T(MYPLUGIN_DLLBASE) + +/* Name of the credentials type that will be registered by the plugin. + This macro is actually defined in the Makefile generated + configuration header file. Change the CREDTYPENAME macro in the + Makefile. */ +#ifndef MYCREDTYPE_NAME +#error MYCREDTYPE_NAME not defined +#endif + +#define MYCREDTYPE_NAMEW _T(MYCREDTYPE_NAME) + +/* Configuration node names. We just concatenate a few strings + together, although you should feel free to completely define your + own. */ + +#define CONFIGNODE_MAIN MYCREDTYPE_NAMEW L"Config" +#define CONFIGNODE_ALL_ID MYCREDTYPE_NAMEW L"AllIdents" +#define CONFIGNODE_PER_ID MYCREDTYPE_NAMEW L"PerIdent" + +#include<windows.h> +/* include the standard NetIDMgr header files */ +#include<netidmgr.h> +#include<tchar.h> + +/* declarations for language resources */ +#include "langres.h" + +#ifndef NOSTRSAFE +#include<strsafe.h> +#endif + +/*************************************************** + Externals +***************************************************/ + +extern kmm_module h_khModule; +extern HINSTANCE hInstance; +extern HMODULE hResModule; + +extern const wchar_t * my_facility; + +extern khm_int32 credtype_id; + +/* Function declarations */ + +/* in plugin.c */ +khm_int32 KHMAPI +plugin_msg_proc(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam); + +/* in credtype.c */ +khm_int32 KHMAPI +cred_is_equal(khm_handle cred1, + khm_handle cred2, + void * rock); + +/* in credacq.c */ +khm_int32 KHMAPI +handle_cred_acq_msg(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam); + +/* in proppage.c */ +INT_PTR CALLBACK +pp_cred_dlg_proc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam); + +/* in config_id.c */ +INT_PTR CALLBACK +config_id_dlgproc(HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam); + +/* in config_ids.c */ +INT_PTR CALLBACK +config_ids_dlgproc(HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam); + +/* in config_main.c */ +INT_PTR CALLBACK +config_dlgproc(HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam); diff --git a/src/windows/identity/sample/templates/credprov/credtype.c b/src/windows/identity/sample/templates/credprov/credtype.c index 039c64454..cee7df19a 100644 --- a/src/windows/identity/sample/templates/credprov/credtype.c +++ b/src/windows/identity/sample/templates/credprov/credtype.c @@ -1,52 +1,52 @@ -/*
- * Copyright (c) 2006 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 AND
- * 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 "credprov.h"
-
-/* Functions for handling our credentials type.
-*/
-
-khm_int32 KHMAPI
-cred_is_equal(khm_handle cred1,
- khm_handle cred2,
- void * rock) {
-
- khm_int32 result;
-
- /* TODO: Check any additional fields to determine if the two
- credentials are equal or not. */
-
- /* Note that this is actually a comparison function. It should
- return 0 if the credentials are found to be equal, and non-zero
- if they are not. We just set this to 0 if we don't need to
- check any additional fields and accept the two credentials as
- being equal. By the time this function is called, the
- identity, name and type of the credentials have already been
- found to be equal. */
- result = 0;
-
- return result;
-}
+/* + * Copyright (c) 2006 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 AND + * 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 "credprov.h" + +/* Functions for handling our credentials type. +*/ + +khm_int32 KHMAPI +cred_is_equal(khm_handle cred1, + khm_handle cred2, + void * rock) { + + khm_int32 result; + + /* TODO: Check any additional fields to determine if the two + credentials are equal or not. */ + + /* Note that this is actually a comparison function. It should + return 0 if the credentials are found to be equal, and non-zero + if they are not. We just set this to 0 if we don't need to + check any additional fields and accept the two credentials as + being equal. By the time this function is called, the + identity, name and type of the credentials have already been + found to be equal. */ + result = 0; + + return result; +} diff --git a/src/windows/identity/sample/templates/credprov/langres.h b/src/windows/identity/sample/templates/credprov/langres.h index 2b81c554d..962c4cb22 100644 --- a/src/windows/identity/sample/templates/credprov/langres.h +++ b/src/windows/identity/sample/templates/credprov/langres.h @@ -1,34 +1,34 @@ -//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by C:\work\pismere\athena\auth\krb5\src\windows\identity\sample\templates\credprov\lang\en_us\langres.rc
-//
-#define IDD_PP_CRED 106
-#define IDD_PP_IDENT 107
-#define IDS_PLUGIN_DESC 109
-#define IDS_CT_SHORT_DESC 110
-#define IDI_PLUGIN 110
-#define IDS_CT_LONG_DESC 111
-#define IDD_NEW_CREDS 112
-#define IDS_NC_CT_TEMPLATE 112
-#define IDS_NC_CT_TEMPLATE_NL 113
-#define IDD_CONFIG 113
-#define IDS_GEN_NONE 114
-#define IDD_CONFIG_ID 114
-#define IDS_CFG_SHORT_DESC 115
-#define IDD_CONFIG_IDS 115
-#define IDS_CFG_LONG_DESC 116
-#define IDS_CFG_IDS_SHORT_DESC 117
-#define IDS_CFG_IDS_LONG_DESC 118
-#define IDS_CFG_ID_SHORT_DESC 119
-#define IDS_CFG_ID_LONG_DESC 120
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 116
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1039
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by C:\work\pismere\athena\auth\krb5\src\windows\identity\sample\templates\credprov\lang\en_us\langres.rc +// +#define IDD_PP_CRED 106 +#define IDD_PP_IDENT 107 +#define IDS_PLUGIN_DESC 109 +#define IDS_CT_SHORT_DESC 110 +#define IDI_PLUGIN 110 +#define IDS_CT_LONG_DESC 111 +#define IDD_NEW_CREDS 112 +#define IDS_NC_CT_TEMPLATE 112 +#define IDS_NC_CT_TEMPLATE_NL 113 +#define IDD_CONFIG 113 +#define IDS_GEN_NONE 114 +#define IDD_CONFIG_ID 114 +#define IDS_CFG_SHORT_DESC 115 +#define IDD_CONFIG_IDS 115 +#define IDS_CFG_LONG_DESC 116 +#define IDS_CFG_IDS_SHORT_DESC 117 +#define IDS_CFG_IDS_LONG_DESC 118 +#define IDS_CFG_ID_SHORT_DESC 119 +#define IDS_CFG_ID_LONG_DESC 120 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 116 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1039 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/windows/identity/sample/templates/credprov/main.c b/src/windows/identity/sample/templates/credprov/main.c index 7a5020573..07da40d57 100644 --- a/src/windows/identity/sample/templates/credprov/main.c +++ b/src/windows/identity/sample/templates/credprov/main.c @@ -1,171 +1,171 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-
-/* This file provides the entry points for the module. The purpose of
- each entry point is explained below.
-*/
-
-kmm_module h_khModule; /* KMM's handle to this module */
-HINSTANCE hInstance; /* handle to our DLL */
-HMODULE hResModule; /* handle to DLL containing language specific resources */
-
-const wchar_t * my_facility = MYPLUGIN_FACILITYW;
-
-/* locales and n_locales are used to provide information to NetIDMgr
- about the locales that we support. Each locale that is supported
- is represented by a single line below. NetIDMgr will pick a
- suitable locale from this list as described in the documentation
- for kmm_set_locale_info(). */
-kmm_module_locale locales[] = {
-
- /* there needs to be at least one language that is supported.
- Here we declare that to be US English, and make it the
- default. */
- LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
- MYPLUGIN_DLLBASEW L"_en_us.dll", /* this is the name of
- the DLL. We paste a
- trailer to basename
- of the DLL. This
- DLL should reside in
- the same directory
- as the plugin
- DLL. */
- KMM_MLOC_FLAG_DEFAULT)
-};
-int n_locales = ARRAYLENGTH(locales);
-
-/*******************************************************************
- init_module
- *****************************************************************
-
- This is the entry point for the module. Each module can provide
- multiple plugins and each plugin will need a separate entry point.
- Generally, the module entry point will set up localized resources
- and register the plugins.
-
-*/
-KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {
-
- khm_int32 rv = KHM_ERROR_SUCCESS;
- kmm_plugin_reg pi;
- wchar_t description[KMM_MAXCCH_DESC];
- int t;
-
- h_khModule = h_module;
-
- rv = kmm_set_locale_info(h_module, locales, n_locales);
- if(KHM_SUCCEEDED(rv)) {
- /* if the call succeeded, then NetIDMgr has picked a localized
- resource DLL for us to use. */
- hResModule = kmm_get_resource_hmodule(h_module);
- } else
- goto _exit;
-
- /* TODO: Perform any other required initialization operations. */
-
- /* register our plugin */
- ZeroMemory(&pi, sizeof(pi));
-
- pi.name = MYPLUGIN_NAMEW; /* name of the plugin */
- pi.type = KHM_PITYPE_CRED; /* type. This is a credentials
- provider. Setting this type has
- the effect of having the plugin
- entrypoint being automatically
- subscribed to credentials provider
- messages. */
-
- /* An icon is optional, but we provide one anyway. */
- pi.icon = LoadImage(hResModule, MAKEINTRESOURCE(IDI_PLUGIN),
- IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
- pi.flags = 0;
- pi.msg_proc = plugin_msg_proc;
- pi.description = description;
- pi.dependencies = NULL;
- t = LoadString(hResModule, IDS_PLUGIN_DESC,
- description, ARRAYLENGTH(description));
- if (!t)
- description[0] = L'\0';
- else
- description[ARRAYLENGTH(description) - 1] = L'\0';
-
- rv = kmm_provide_plugin(h_module, &pi);
-
- /* TODO: register any additional plugins */
-
- /* Returning a successful code (KHM_ERROR_SUCCESS) will cause the
- plugins to be initialized. If no plugin is successfully
- registered while processing init_module or if a code other than
- KHM_ERROR_SUCCESS is returned, the module will be immediately
- unloaded. */
-
- _exit:
- return rv;
-}
-
-/**********************************************************
- Exit module
- ********************************************************
-
- Called by the NetIDMgr module manager when unloading the module.
- This will get called even if the module is being unloaded due to an
- error code returned by init_module(). This callback is required. */
-KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) {
-
- /* Unregistering the plugin is not required at this point. */
-
- /* TODO: Perform any other required cleanup here. */
-
- return KHM_ERROR_SUCCESS; /* the return code is ignored */
-}
-
-/* General DLL initialization. It is advisable to not do anything
- here and also keep in mind that the plugin will be loaded at a time
- where some threads have already started. So DLL_THREAD_ATTACH will
- not fire for every thread. In addition, the plugin will be
- unloaded before the application and all the threads terminate. */
-BOOL WINAPI DllMain(HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
-{
- switch(fdwReason) {
- case DLL_PROCESS_ATTACH:
- hInstance = hinstDLL;
- break;
-
- case DLL_PROCESS_DETACH:
- break;
-
- case DLL_THREAD_ATTACH:
- break;
-
- case DLL_THREAD_DETACH:
- break;
- }
-
- return TRUE;
-}
+/* + * Copyright (c) 2006 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 "credprov.h" + +/* This file provides the entry points for the module. The purpose of + each entry point is explained below. +*/ + +kmm_module h_khModule; /* KMM's handle to this module */ +HINSTANCE hInstance; /* handle to our DLL */ +HMODULE hResModule; /* handle to DLL containing language specific resources */ + +const wchar_t * my_facility = MYPLUGIN_FACILITYW; + +/* locales and n_locales are used to provide information to NetIDMgr + about the locales that we support. Each locale that is supported + is represented by a single line below. NetIDMgr will pick a + suitable locale from this list as described in the documentation + for kmm_set_locale_info(). */ +kmm_module_locale locales[] = { + + /* there needs to be at least one language that is supported. + Here we declare that to be US English, and make it the + default. */ + LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US), + MYPLUGIN_DLLBASEW L"_en_us.dll", /* this is the name of + the DLL. We paste a + trailer to basename + of the DLL. This + DLL should reside in + the same directory + as the plugin + DLL. */ + KMM_MLOC_FLAG_DEFAULT) +}; +int n_locales = ARRAYLENGTH(locales); + +/******************************************************************* + init_module + ***************************************************************** + + This is the entry point for the module. Each module can provide + multiple plugins and each plugin will need a separate entry point. + Generally, the module entry point will set up localized resources + and register the plugins. + +*/ +KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) { + + khm_int32 rv = KHM_ERROR_SUCCESS; + kmm_plugin_reg pi; + wchar_t description[KMM_MAXCCH_DESC]; + int t; + + h_khModule = h_module; + + rv = kmm_set_locale_info(h_module, locales, n_locales); + if(KHM_SUCCEEDED(rv)) { + /* if the call succeeded, then NetIDMgr has picked a localized + resource DLL for us to use. */ + hResModule = kmm_get_resource_hmodule(h_module); + } else + goto _exit; + + /* TODO: Perform any other required initialization operations. */ + + /* register our plugin */ + ZeroMemory(&pi, sizeof(pi)); + + pi.name = MYPLUGIN_NAMEW; /* name of the plugin */ + pi.type = KHM_PITYPE_CRED; /* type. This is a credentials + provider. Setting this type has + the effect of having the plugin + entrypoint being automatically + subscribed to credentials provider + messages. */ + + /* An icon is optional, but we provide one anyway. */ + pi.icon = LoadImage(hResModule, MAKEINTRESOURCE(IDI_PLUGIN), + IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE); + pi.flags = 0; + pi.msg_proc = plugin_msg_proc; + pi.description = description; + pi.dependencies = NULL; + t = LoadString(hResModule, IDS_PLUGIN_DESC, + description, ARRAYLENGTH(description)); + if (!t) + description[0] = L'\0'; + else + description[ARRAYLENGTH(description) - 1] = L'\0'; + + rv = kmm_provide_plugin(h_module, &pi); + + /* TODO: register any additional plugins */ + + /* Returning a successful code (KHM_ERROR_SUCCESS) will cause the + plugins to be initialized. If no plugin is successfully + registered while processing init_module or if a code other than + KHM_ERROR_SUCCESS is returned, the module will be immediately + unloaded. */ + + _exit: + return rv; +} + +/********************************************************** + Exit module + ******************************************************** + + Called by the NetIDMgr module manager when unloading the module. + This will get called even if the module is being unloaded due to an + error code returned by init_module(). This callback is required. */ +KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) { + + /* Unregistering the plugin is not required at this point. */ + + /* TODO: Perform any other required cleanup here. */ + + return KHM_ERROR_SUCCESS; /* the return code is ignored */ +} + +/* General DLL initialization. It is advisable to not do anything + here and also keep in mind that the plugin will be loaded at a time + where some threads have already started. So DLL_THREAD_ATTACH will + not fire for every thread. In addition, the plugin will be + unloaded before the application and all the threads terminate. */ +BOOL WINAPI DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch(fdwReason) { + case DLL_PROCESS_ATTACH: + hInstance = hinstDLL; + break; + + case DLL_PROCESS_DETACH: + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} diff --git a/src/windows/identity/sample/templates/credprov/plugin.c b/src/windows/identity/sample/templates/credprov/plugin.c index 31c9626a5..9b1b0ce94 100644 --- a/src/windows/identity/sample/templates/credprov/plugin.c +++ b/src/windows/identity/sample/templates/credprov/plugin.c @@ -1,382 +1,382 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-#include<assert.h>
-
-/* This file provides the message processing function and the support
- routines for implementing our plugin. Note that some of the
- message processing routines have been moved to other source files
- based on their use.
-*/
-
-khm_int32 credtype_id = KCDB_CREDTYPE_INVALID;
-khm_handle g_credset = NULL;
-
-/* Handler for system messages. The only two we handle are
- KMSG_SYSTEM_INIT and KMSG_SYSTEM_EXIT. */
-khm_int32 KHMAPI
-handle_kmsg_system(khm_int32 msg_type,
- khm_int32 msg_subtype,
- khm_ui_4 uparam,
- void * vparam) {
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- switch (msg_subtype) {
-
- /* This is the first message that will be received by a
- plugin. We use it to perform initialization operations
- such as registering any credential types, data types and
- attributes. */
- case KMSG_SYSTEM_INIT:
- {
- kcdb_credtype ct;
- wchar_t short_desc[KCDB_MAXCCH_SHORT_DESC];
- wchar_t long_desc[KCDB_MAXCCH_LONG_DESC];
- khui_config_node cnode;
- khui_config_node_reg creg;
-
- /* First and foremost, we need to register a credential
- type. */
- ZeroMemory(&ct, sizeof(ct));
- ct.id = KCDB_CREDTYPE_AUTO;
- ct.name = MYCREDTYPE_NAMEW;
-
- short_desc[0] = L'\0';
- LoadString(hResModule, IDS_CT_SHORT_DESC,
- short_desc, ARRAYLENGTH(short_desc));
-
- long_desc[0] = L'\0';
- LoadString(hResModule, IDS_CT_LONG_DESC,
- long_desc, ARRAYLENGTH(long_desc));
-
- ct.icon = NULL; /* We skip the icon for now, but you
- can assign a handle to an icon
- here. The icon will be used to
- represent the credentials type.*/
-
- kmq_create_subscription(plugin_msg_proc, &ct.sub);
-
- ct.is_equal = cred_is_equal;
-
- rv = kcdb_credtype_register(&ct, &credtype_id);
-
- /* We create a global credential set that we use in the
- plug-in thread. This alleviates the need to create one
- everytime we need one. Keep in mind that this should
- only be used in the plug-in thread and should not be
- touched from the UI thread or any other thread. */
- kcdb_credset_create(&g_credset);
-
- /* TODO: Perform additional initialization operations. */
-
- /* TODO: Also list out the credentials of this type that
- already exist. */
-
- /* Now we register our configuration panels. */
-
-
- /* This configuration panel is the one that controls
- general options. We leave the identity specific and
- identity defaults for other configuration panels. */
-
- ZeroMemory(&creg, sizeof(creg));
-
- short_desc[0] = L'\0';
-
- LoadString(hResModule, IDS_CFG_SHORT_DESC,
- short_desc, ARRAYLENGTH(short_desc));
-
- long_desc[0] = L'\0';
-
- LoadString(hResModule, IDS_CFG_LONG_DESC,
- long_desc, ARRAYLENGTH(long_desc));
-
- creg.name = CONFIGNODE_MAIN;
- creg.short_desc = short_desc;
- creg.long_desc = long_desc;
- creg.h_module = hResModule;
- creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG);
- creg.dlg_proc = config_dlgproc;
- creg.flags = 0;
-
- khui_cfg_register(NULL, &creg);
-
- /* Now we do the identity specific and identity default
- configuration panels. "KhmIdentities" is a predefined
- configuration node under which all the identity spcific
- configuration is managed. */
-
- if (KHM_FAILED(khui_cfg_open(NULL, L"KhmIdentities", &cnode))) {
- /* this should always work */
- assert(FALSE);
- rv = KHM_ERROR_NOT_FOUND;
- break;
- }
-
- /* First the tab panel for defaults for all identities */
-
- ZeroMemory(&creg, sizeof(creg));
-
- short_desc[0] = L'\0';
- LoadString(hResModule, IDS_CFG_IDS_SHORT_DESC,
- short_desc, ARRAYLENGTH(short_desc));
- long_desc[0] = L'\0';
- LoadString(hResModule, IDS_CFG_IDS_LONG_DESC,
- long_desc, ARRAYLENGTH(long_desc));
-
- creg.name = CONFIGNODE_ALL_ID;
- creg.short_desc = short_desc;
- creg.long_desc = long_desc;
- creg.h_module = hResModule;
- creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG_IDS);
- creg.dlg_proc = config_ids_dlgproc;
- creg.flags = KHUI_CNFLAG_SUBPANEL;
-
- khui_cfg_register(cnode, &creg);
-
- /* Now the panel for per identity configuration */
-
- ZeroMemory(&creg, sizeof(creg));
-
- short_desc[0] = L'\0';
- LoadString(hResModule, IDS_CFG_ID_SHORT_DESC,
- short_desc, ARRAYLENGTH(short_desc));
- long_desc[0] = L'\0';
- LoadString(hResModule, IDS_CFG_ID_LONG_DESC,
- long_desc, ARRAYLENGTH(long_desc));
-
- creg.name = CONFIGNODE_PER_ID;
- creg.short_desc = short_desc;
- creg.long_desc = long_desc;
- creg.h_module = hResModule;
- creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG_ID);
- creg.dlg_proc = config_id_dlgproc;
- creg.flags = KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_PLURAL;
-
- khui_cfg_register(cnode, &creg);
-
- khui_cfg_release(cnode);
- }
- break;
-
- /* This is the last message that will be received by the
- plugin. */
- case KMSG_SYSTEM_EXIT:
- {
- khui_config_node cnode;
- khui_config_node cn_idents;
-
- /* It should not be assumed that initialization of the
- plugin went well at this point since we receive a
- KMSG_SYSTEM_EXIT even if the initialization failed. */
-
- if (credtype_id != KCDB_CREDTYPE_INVALID) {
- kcdb_credtype_unregister(credtype_id);
- credtype_id = KCDB_CREDTYPE_INVALID;
- }
-
- if (g_credset) {
- kcdb_credset_delete(g_credset);
- g_credset = NULL;
- }
-
- /* Now unregister any configuration nodes we registered. */
-
- if (KHM_SUCCEEDED(khui_cfg_open(NULL, CONFIGNODE_MAIN, &cnode))) {
- khui_cfg_remove(cnode);
- khui_cfg_release(cnode);
- }
-
- if (KHM_SUCCEEDED(khui_cfg_open(NULL, L"KhmIdentities", &cn_idents))) {
- if (KHM_SUCCEEDED(khui_cfg_open(cn_idents,
- CONFIGNODE_ALL_ID,
- &cnode))) {
- khui_cfg_remove(cnode);
- khui_cfg_release(cnode);
- }
-
- if (KHM_SUCCEEDED(khui_cfg_open(cn_idents,
- CONFIGNODE_PER_ID,
- &cnode))) {
- khui_cfg_remove(cnode);
- khui_cfg_release(cnode);
- }
-
- khui_cfg_release(cn_idents);
- }
-
- /* TODO: Perform additional uninitialization
- operations. */
- }
- break;
- }
-
- return rv;
-}
-
-/* Handler for credentials the refresh message. */
-khm_int32
-handle_kmsg_cred_refresh(void) {
- /* TODO: Re-enumerate the credentials of our credentials type */
-
- /*
- Re-enumerating credentials would look something like this:
-
- - flush all credentials from g_credset (kcdb_credset_flush())
-
- - list out the credentials and add them to g_credset
-
- - collect the credentials from g_credset to the root credentials
- set. (kcdb_credset_collect())
-
- Note that when listing credentials, each credential must be
- populated with enough information to locate the actual
- credential at a later time.
- */
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Handler for destroying credentials */
-khm_int32
-handle_kmsg_cred_destroy_creds(khui_action_context * ctx) {
- /* TODO: Destroy credentials of our type as specified by the
- action context passed in through vparam. */
-
- /* The credential set in ctx->credset contains the credentials
- that are to be destroyed. */
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Begin a property sheet */
-khm_int32
-handle_kmsg_cred_pp_begin(khui_property_sheet * ps) {
-
- /* TODO: Provide the information necessary to show a property
- page for a credentials belonging to our credential type. */
-
- PROPSHEETPAGE *p;
-
- if (ps->credtype == credtype_id &&
- ps->cred) {
- /* We have been requested to show a property sheet for one of
- our credentials. */
- p = malloc(sizeof(*p));
- ZeroMemory(p, sizeof(*p));
-
- p->dwSize = sizeof(*p);
- p->dwFlags = 0;
- p->hInstance = hResModule;
- p->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED);
- p->pfnDlgProc = pp_cred_dlg_proc;
- p->lParam = (LPARAM) ps;
- khui_ps_add_page(ps, credtype_id, 0, p, NULL);
- }
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* End a property sheet */
-khm_int32
-handle_kmsg_cred_pp_end(khui_property_sheet * ps) {
- /* TODO: Handle the end of a property sheet. */
-
- khui_property_page * p = NULL;
-
- khui_ps_find_page(ps, credtype_id, &p);
- if (p) {
- if (p->p_page)
- free(p->p_page);
- p->p_page = NULL;
- }
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* IP address change notification */
-khm_int32
-handle_kmsg_cred_addr_change(void) {
- /* TODO: Handle this message. */
-
- return KHM_ERROR_SUCCESS;
-}
-
-/* Message dispatcher for credentials messages. */
-khm_int32 KHMAPI
-handle_kmsg_cred(khm_int32 msg_type,
- khm_int32 msg_subtype,
- khm_ui_4 uparam,
- void * vparam) {
- khm_int32 rv = KHM_ERROR_SUCCESS;
-
- switch(msg_subtype) {
- case KMSG_CRED_REFRESH:
- return handle_kmsg_cred_refresh();
-
- case KMSG_CRED_DESTROY_CREDS:
- return handle_kmsg_cred_destroy_creds((khui_action_context *) vparam);
-
- case KMSG_CRED_PP_BEGIN:
- return handle_kmsg_cred_pp_begin((khui_property_sheet *) vparam);
-
- case KMSG_CRED_PP_END:
- return handle_kmsg_cred_pp_end((khui_property_sheet *) vparam);
-
- case KMSG_CRED_ADDR_CHANGE:
- return handle_kmsg_cred_addr_change();
-
- default:
- /* Credentials acquisition messages are all handled in a
- different source file. */
- if (IS_CRED_ACQ_MSG(msg_subtype))
- return handle_cred_acq_msg(msg_type, msg_subtype,
- uparam, vparam);
- }
-
- return rv;
-}
-
-
-/* This is the main message handler for our plugin. All the plugin
- messages end up here where we either handle it directly or dispatch
- it to other handlers. */
-khm_int32 KHMAPI plugin_msg_proc(khm_int32 msg_type,
- khm_int32 msg_subtype,
- khm_ui_4 uparam,
- void * vparam) {
-
- switch(msg_type) {
- case KMSG_SYSTEM:
- return handle_kmsg_system(msg_type, msg_subtype, uparam, vparam);
-
- case KMSG_CRED:
- return handle_kmsg_cred(msg_type, msg_subtype, uparam, vparam);
- }
-
- return KHM_ERROR_SUCCESS;
-}
+/* + * Copyright (c) 2006 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 "credprov.h" +#include<assert.h> + +/* This file provides the message processing function and the support + routines for implementing our plugin. Note that some of the + message processing routines have been moved to other source files + based on their use. +*/ + +khm_int32 credtype_id = KCDB_CREDTYPE_INVALID; +khm_handle g_credset = NULL; + +/* Handler for system messages. The only two we handle are + KMSG_SYSTEM_INIT and KMSG_SYSTEM_EXIT. */ +khm_int32 KHMAPI +handle_kmsg_system(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + khm_int32 rv = KHM_ERROR_SUCCESS; + + switch (msg_subtype) { + + /* This is the first message that will be received by a + plugin. We use it to perform initialization operations + such as registering any credential types, data types and + attributes. */ + case KMSG_SYSTEM_INIT: + { + kcdb_credtype ct; + wchar_t short_desc[KCDB_MAXCCH_SHORT_DESC]; + wchar_t long_desc[KCDB_MAXCCH_LONG_DESC]; + khui_config_node cnode; + khui_config_node_reg creg; + + /* First and foremost, we need to register a credential + type. */ + ZeroMemory(&ct, sizeof(ct)); + ct.id = KCDB_CREDTYPE_AUTO; + ct.name = MYCREDTYPE_NAMEW; + + short_desc[0] = L'\0'; + LoadString(hResModule, IDS_CT_SHORT_DESC, + short_desc, ARRAYLENGTH(short_desc)); + + long_desc[0] = L'\0'; + LoadString(hResModule, IDS_CT_LONG_DESC, + long_desc, ARRAYLENGTH(long_desc)); + + ct.icon = NULL; /* We skip the icon for now, but you + can assign a handle to an icon + here. The icon will be used to + represent the credentials type.*/ + + kmq_create_subscription(plugin_msg_proc, &ct.sub); + + ct.is_equal = cred_is_equal; + + rv = kcdb_credtype_register(&ct, &credtype_id); + + /* We create a global credential set that we use in the + plug-in thread. This alleviates the need to create one + everytime we need one. Keep in mind that this should + only be used in the plug-in thread and should not be + touched from the UI thread or any other thread. */ + kcdb_credset_create(&g_credset); + + /* TODO: Perform additional initialization operations. */ + + /* TODO: Also list out the credentials of this type that + already exist. */ + + /* Now we register our configuration panels. */ + + + /* This configuration panel is the one that controls + general options. We leave the identity specific and + identity defaults for other configuration panels. */ + + ZeroMemory(&creg, sizeof(creg)); + + short_desc[0] = L'\0'; + + LoadString(hResModule, IDS_CFG_SHORT_DESC, + short_desc, ARRAYLENGTH(short_desc)); + + long_desc[0] = L'\0'; + + LoadString(hResModule, IDS_CFG_LONG_DESC, + long_desc, ARRAYLENGTH(long_desc)); + + creg.name = CONFIGNODE_MAIN; + creg.short_desc = short_desc; + creg.long_desc = long_desc; + creg.h_module = hResModule; + creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG); + creg.dlg_proc = config_dlgproc; + creg.flags = 0; + + khui_cfg_register(NULL, &creg); + + /* Now we do the identity specific and identity default + configuration panels. "KhmIdentities" is a predefined + configuration node under which all the identity spcific + configuration is managed. */ + + if (KHM_FAILED(khui_cfg_open(NULL, L"KhmIdentities", &cnode))) { + /* this should always work */ + assert(FALSE); + rv = KHM_ERROR_NOT_FOUND; + break; + } + + /* First the tab panel for defaults for all identities */ + + ZeroMemory(&creg, sizeof(creg)); + + short_desc[0] = L'\0'; + LoadString(hResModule, IDS_CFG_IDS_SHORT_DESC, + short_desc, ARRAYLENGTH(short_desc)); + long_desc[0] = L'\0'; + LoadString(hResModule, IDS_CFG_IDS_LONG_DESC, + long_desc, ARRAYLENGTH(long_desc)); + + creg.name = CONFIGNODE_ALL_ID; + creg.short_desc = short_desc; + creg.long_desc = long_desc; + creg.h_module = hResModule; + creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG_IDS); + creg.dlg_proc = config_ids_dlgproc; + creg.flags = KHUI_CNFLAG_SUBPANEL; + + khui_cfg_register(cnode, &creg); + + /* Now the panel for per identity configuration */ + + ZeroMemory(&creg, sizeof(creg)); + + short_desc[0] = L'\0'; + LoadString(hResModule, IDS_CFG_ID_SHORT_DESC, + short_desc, ARRAYLENGTH(short_desc)); + long_desc[0] = L'\0'; + LoadString(hResModule, IDS_CFG_ID_LONG_DESC, + long_desc, ARRAYLENGTH(long_desc)); + + creg.name = CONFIGNODE_PER_ID; + creg.short_desc = short_desc; + creg.long_desc = long_desc; + creg.h_module = hResModule; + creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG_ID); + creg.dlg_proc = config_id_dlgproc; + creg.flags = KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_PLURAL; + + khui_cfg_register(cnode, &creg); + + khui_cfg_release(cnode); + } + break; + + /* This is the last message that will be received by the + plugin. */ + case KMSG_SYSTEM_EXIT: + { + khui_config_node cnode; + khui_config_node cn_idents; + + /* It should not be assumed that initialization of the + plugin went well at this point since we receive a + KMSG_SYSTEM_EXIT even if the initialization failed. */ + + if (credtype_id != KCDB_CREDTYPE_INVALID) { + kcdb_credtype_unregister(credtype_id); + credtype_id = KCDB_CREDTYPE_INVALID; + } + + if (g_credset) { + kcdb_credset_delete(g_credset); + g_credset = NULL; + } + + /* Now unregister any configuration nodes we registered. */ + + if (KHM_SUCCEEDED(khui_cfg_open(NULL, CONFIGNODE_MAIN, &cnode))) { + khui_cfg_remove(cnode); + khui_cfg_release(cnode); + } + + if (KHM_SUCCEEDED(khui_cfg_open(NULL, L"KhmIdentities", &cn_idents))) { + if (KHM_SUCCEEDED(khui_cfg_open(cn_idents, + CONFIGNODE_ALL_ID, + &cnode))) { + khui_cfg_remove(cnode); + khui_cfg_release(cnode); + } + + if (KHM_SUCCEEDED(khui_cfg_open(cn_idents, + CONFIGNODE_PER_ID, + &cnode))) { + khui_cfg_remove(cnode); + khui_cfg_release(cnode); + } + + khui_cfg_release(cn_idents); + } + + /* TODO: Perform additional uninitialization + operations. */ + } + break; + } + + return rv; +} + +/* Handler for credentials the refresh message. */ +khm_int32 +handle_kmsg_cred_refresh(void) { + /* TODO: Re-enumerate the credentials of our credentials type */ + + /* + Re-enumerating credentials would look something like this: + + - flush all credentials from g_credset (kcdb_credset_flush()) + + - list out the credentials and add them to g_credset + + - collect the credentials from g_credset to the root credentials + set. (kcdb_credset_collect()) + + Note that when listing credentials, each credential must be + populated with enough information to locate the actual + credential at a later time. + */ + + return KHM_ERROR_SUCCESS; +} + +/* Handler for destroying credentials */ +khm_int32 +handle_kmsg_cred_destroy_creds(khui_action_context * ctx) { + /* TODO: Destroy credentials of our type as specified by the + action context passed in through vparam. */ + + /* The credential set in ctx->credset contains the credentials + that are to be destroyed. */ + + return KHM_ERROR_SUCCESS; +} + +/* Begin a property sheet */ +khm_int32 +handle_kmsg_cred_pp_begin(khui_property_sheet * ps) { + + /* TODO: Provide the information necessary to show a property + page for a credentials belonging to our credential type. */ + + PROPSHEETPAGE *p; + + if (ps->credtype == credtype_id && + ps->cred) { + /* We have been requested to show a property sheet for one of + our credentials. */ + p = malloc(sizeof(*p)); + ZeroMemory(p, sizeof(*p)); + + p->dwSize = sizeof(*p); + p->dwFlags = 0; + p->hInstance = hResModule; + p->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED); + p->pfnDlgProc = pp_cred_dlg_proc; + p->lParam = (LPARAM) ps; + khui_ps_add_page(ps, credtype_id, 0, p, NULL); + } + + return KHM_ERROR_SUCCESS; +} + +/* End a property sheet */ +khm_int32 +handle_kmsg_cred_pp_end(khui_property_sheet * ps) { + /* TODO: Handle the end of a property sheet. */ + + khui_property_page * p = NULL; + + khui_ps_find_page(ps, credtype_id, &p); + if (p) { + if (p->p_page) + free(p->p_page); + p->p_page = NULL; + } + + return KHM_ERROR_SUCCESS; +} + +/* IP address change notification */ +khm_int32 +handle_kmsg_cred_addr_change(void) { + /* TODO: Handle this message. */ + + return KHM_ERROR_SUCCESS; +} + +/* Message dispatcher for credentials messages. */ +khm_int32 KHMAPI +handle_kmsg_cred(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + khm_int32 rv = KHM_ERROR_SUCCESS; + + switch(msg_subtype) { + case KMSG_CRED_REFRESH: + return handle_kmsg_cred_refresh(); + + case KMSG_CRED_DESTROY_CREDS: + return handle_kmsg_cred_destroy_creds((khui_action_context *) vparam); + + case KMSG_CRED_PP_BEGIN: + return handle_kmsg_cred_pp_begin((khui_property_sheet *) vparam); + + case KMSG_CRED_PP_END: + return handle_kmsg_cred_pp_end((khui_property_sheet *) vparam); + + case KMSG_CRED_ADDR_CHANGE: + return handle_kmsg_cred_addr_change(); + + default: + /* Credentials acquisition messages are all handled in a + different source file. */ + if (IS_CRED_ACQ_MSG(msg_subtype)) + return handle_cred_acq_msg(msg_type, msg_subtype, + uparam, vparam); + } + + return rv; +} + + +/* This is the main message handler for our plugin. All the plugin + messages end up here where we either handle it directly or dispatch + it to other handlers. */ +khm_int32 KHMAPI plugin_msg_proc(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + + switch(msg_type) { + case KMSG_SYSTEM: + return handle_kmsg_system(msg_type, msg_subtype, uparam, vparam); + + case KMSG_CRED: + return handle_kmsg_cred(msg_type, msg_subtype, uparam, vparam); + } + + return KHM_ERROR_SUCCESS; +} diff --git a/src/windows/identity/sample/templates/credprov/proppage.c b/src/windows/identity/sample/templates/credprov/proppage.c index 734a58ee4..eaffde23e 100644 --- a/src/windows/identity/sample/templates/credprov/proppage.c +++ b/src/windows/identity/sample/templates/credprov/proppage.c @@ -1,59 +1,59 @@ -/*
- * Copyright (c) 2006 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 "credprov.h"
-
-/* Dialog procedure and support code for displaying property sheets
- for credentials of type MyCred. */
-
-/* Dialog procedure for the property sheet. This will run under the
- UI thread when a property sheet is being displayed for one of our
- credentials.. */
-INT_PTR CALLBACK
-pp_cred_dlg_proc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam) {
-
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- khui_property_sheet * ps;
- PROPSHEETPAGE * p;
-
- p = (PROPSHEETPAGE *) lParam;
- ps = (khui_property_sheet *) p->lParam;
-
- /* TODO: Populate the property sheet controls with values
- extracted from the credential. (ps->cred) */
-
- return FALSE;
- }
- }
-
- return FALSE;
-}
-
+/* + * Copyright (c) 2006 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 "credprov.h" + +/* Dialog procedure and support code for displaying property sheets + for credentials of type MyCred. */ + +/* Dialog procedure for the property sheet. This will run under the + UI thread when a property sheet is being displayed for one of our + credentials.. */ +INT_PTR CALLBACK +pp_cred_dlg_proc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + + switch (uMsg) { + case WM_INITDIALOG: + { + khui_property_sheet * ps; + PROPSHEETPAGE * p; + + p = (PROPSHEETPAGE *) lParam; + ps = (khui_property_sheet *) p->lParam; + + /* TODO: Populate the property sheet controls with values + extracted from the credential. (ps->cred) */ + + return FALSE; + } + } + + return FALSE; +} + |
