Module: wine Branch: master Commit: cdb6e9ed8232fe085662610c9e8e1614fa054a86 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cdb6e9ed8232fe085662610c9e...
Author: Rob Shearman rob@codeweavers.com Date: Sat Nov 17 17:31:02 2007 +0000
credui: Enumerate saved credentials and use these to populate the combo box.
---
dlls/credui/credui_main.c | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/dlls/credui/credui_main.c b/dlls/credui/credui_main.c index 03550ba..83fb183 100644 --- a/dlls/credui/credui_main.c +++ b/dlls/credui/credui_main.c @@ -130,8 +130,44 @@ struct cred_dialog_params DWORD dwFlags; };
+static void CredDialogFillUsernameCombo(HWND hwndUsername, struct cred_dialog_params *params) +{ + DWORD count; + DWORD i; + PCREDENTIALW *credentials; + + if (!CredEnumerateW(NULL, 0, &count, &credentials)) + return; + + for (i = 0; i < count; i++) + { + COMBOBOXEXITEMW comboitem; + + if (params->dwFlags & CREDUI_FLAGS_GENERIC_CREDENTIALS) + { + if ((credentials[i]->Type != CRED_TYPE_GENERIC) || !credentials[i]->UserName) + continue; + } + else + { + if (credentials[i]->Type == CRED_TYPE_GENERIC) + continue; + } + + comboitem.mask = CBEIF_TEXT; + comboitem.iItem = -1; + comboitem.pszText = credentials[i]->UserName; + SendMessageW(hwndUsername, CBEM_INSERTITEMW, 0, (LPARAM)&comboitem); + } + + CredFree(credentials); +} + static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params) { + HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME); + HWND hwndPassword = GetDlgItem(hwndDlg, IDC_PASSWORD); + SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)params); if (params->pszMessageText) SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText); @@ -143,13 +179,15 @@ static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params) snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->pszTargetName); SetDlgItemTextW(hwndDlg, IDC_MESSAGE, message); } - SetDlgItemTextW(hwndDlg, IDC_USERNAME, params->pszUsername); - SetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword); + SetWindowTextW(hwndUsername, params->pszUsername); + SetWindowTextW(hwndPassword, params->pszPassword); + + CredDialogFillUsernameCombo(hwndUsername, params);
if (params->pszUsername[0]) - SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD)); + SetFocus(hwndPassword); else - SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME)); + SetFocus(hwndUsername);
if (params->pszCaptionText) SetWindowTextW(hwndDlg, params->pszCaptionText);