mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
wininet: Add a regular authentication dialog.
This commit is contained in:
parent
29162c6506
commit
6b15db8717
@ -94,6 +94,34 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* WININET_GetServer
|
||||
*
|
||||
* Determine the name of the web server
|
||||
*/
|
||||
static BOOL WININET_GetServer( HINTERNET hRequest, LPWSTR szBuf, DWORD sz )
|
||||
{
|
||||
http_request_t *lpwhr;
|
||||
http_session_t *lpwhs = NULL;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
lpwhr = (http_request_t*) WININET_GetObject( hRequest );
|
||||
if (NULL == lpwhr)
|
||||
goto done;
|
||||
|
||||
lpwhs = lpwhr->lpHttpSession;
|
||||
if (NULL == lpwhs)
|
||||
goto done;
|
||||
|
||||
lstrcpynW(szBuf, lpwhs->lpszHostName, sz);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
WININET_Release( &lpwhr->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* WININET_GetAuthRealm
|
||||
*
|
||||
@ -348,6 +376,90 @@ static INT_PTR WINAPI WININET_ProxyPasswordDialog(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* WININET_PasswordDialog
|
||||
*/
|
||||
static INT_PTR WINAPI WININET_PasswordDialog(
|
||||
HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
HWND hitem;
|
||||
struct WININET_ErrorDlgParams *params;
|
||||
WCHAR szRealm[0x80], szServer[0x80];
|
||||
|
||||
if( uMsg == WM_INITDIALOG )
|
||||
{
|
||||
TRACE("WM_INITDIALOG (%08lx)\n", lParam);
|
||||
|
||||
/* save the parameter list */
|
||||
params = (struct WININET_ErrorDlgParams*) lParam;
|
||||
SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
|
||||
|
||||
/* extract the Realm from the response and show it */
|
||||
if( WININET_GetAuthRealm( params->hRequest,
|
||||
szRealm, sizeof szRealm/sizeof(WCHAR), FALSE ) )
|
||||
{
|
||||
hitem = GetDlgItem( hdlg, IDC_REALM );
|
||||
SetWindowTextW( hitem, szRealm );
|
||||
}
|
||||
|
||||
/* extract the name of the server */
|
||||
if( WININET_GetServer( params->hRequest,
|
||||
szServer, sizeof szServer/sizeof(WCHAR)) )
|
||||
{
|
||||
hitem = GetDlgItem( hdlg, IDC_SERVER );
|
||||
SetWindowTextW( hitem, szServer );
|
||||
}
|
||||
|
||||
WININET_GetSetPassword( hdlg, szServer, szRealm, FALSE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
params = (struct WININET_ErrorDlgParams*)
|
||||
GetWindowLongPtrW( hdlg, GWLP_USERDATA );
|
||||
|
||||
switch( uMsg )
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if( wParam == IDOK )
|
||||
{
|
||||
WCHAR username[0x20], password[0x20];
|
||||
|
||||
username[0] = 0;
|
||||
hitem = GetDlgItem( hdlg, IDC_USERNAME );
|
||||
if( hitem )
|
||||
GetWindowTextW( hitem, username, sizeof username/sizeof(WCHAR) );
|
||||
|
||||
password[0] = 0;
|
||||
hitem = GetDlgItem( hdlg, IDC_PASSWORD );
|
||||
if( hitem )
|
||||
GetWindowTextW( hitem, password, sizeof password/sizeof(WCHAR) );
|
||||
|
||||
hitem = GetDlgItem( hdlg, IDC_SAVEPASSWORD );
|
||||
if( hitem &&
|
||||
SendMessageW( hitem, BM_GETSTATE, 0, 0 ) &&
|
||||
WININET_GetAuthRealm( params->hRequest,
|
||||
szRealm, sizeof szRealm/sizeof(WCHAR), FALSE ) &&
|
||||
WININET_GetServer( params->hRequest,
|
||||
szServer, sizeof szServer/sizeof(WCHAR)) )
|
||||
{
|
||||
WININET_GetSetPassword( hdlg, szServer, szRealm, TRUE );
|
||||
}
|
||||
WININET_SetAuthorization( params->hRequest, username, password, FALSE );
|
||||
|
||||
EndDialog( hdlg, ERROR_INTERNET_FORCE_RETRY );
|
||||
return TRUE;
|
||||
}
|
||||
if( wParam == IDCANCEL )
|
||||
{
|
||||
EndDialog( hdlg, 0 );
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* WININET_GetConnectionStatus
|
||||
*/
|
||||
@ -392,17 +504,23 @@ DWORD WINAPI InternetErrorDlg(HWND hWnd, HINTERNET hRequest,
|
||||
switch( dwError )
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
if( !(dwFlags & FLAGS_ERROR_UI_FILTER_FOR_ERRORS ) )
|
||||
return 0;
|
||||
dwStatus = WININET_GetConnectionStatus( hRequest );
|
||||
if( HTTP_STATUS_PROXY_AUTH_REQ != dwStatus )
|
||||
return ERROR_SUCCESS;
|
||||
return DialogBoxParamW( hwininet, MAKEINTRESOURCEW( IDD_PROXYDLG ),
|
||||
hWnd, WININET_ProxyPasswordDialog, (LPARAM) ¶ms );
|
||||
|
||||
case ERROR_INTERNET_INCORRECT_PASSWORD:
|
||||
return DialogBoxParamW( hwininet, MAKEINTRESOURCEW( IDD_PROXYDLG ),
|
||||
hWnd, WININET_ProxyPasswordDialog, (LPARAM) ¶ms );
|
||||
if( !dwError && !(dwFlags & FLAGS_ERROR_UI_FILTER_FOR_ERRORS ) )
|
||||
return 0;
|
||||
|
||||
dwStatus = WININET_GetConnectionStatus( hRequest );
|
||||
switch (dwStatus)
|
||||
{
|
||||
case HTTP_STATUS_PROXY_AUTH_REQ:
|
||||
return DialogBoxParamW( hwininet, MAKEINTRESOURCEW( IDD_PROXYDLG ),
|
||||
hWnd, WININET_ProxyPasswordDialog, (LPARAM) ¶ms );
|
||||
case HTTP_STATUS_DENIED:
|
||||
return DialogBoxParamW( hwininet, MAKEINTRESOURCEW( IDD_AUTHDLG ),
|
||||
hWnd, WININET_PasswordDialog, (LPARAM) ¶ms );
|
||||
default:
|
||||
WARN("unhandled status %u\n", dwStatus);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
|
||||
case ERROR_INTERNET_INVALID_CA:
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <windef.h>
|
||||
#include <winuser.h>
|
||||
|
||||
#define IDD_AUTHDLG 0x399
|
||||
#define IDD_PROXYDLG 0x400
|
||||
|
||||
#define IDC_PROXY 0x401
|
||||
@ -28,5 +29,6 @@
|
||||
#define IDC_USERNAME 0x403
|
||||
#define IDC_PASSWORD 0x404
|
||||
#define IDC_SAVEPASSWORD 0x405
|
||||
#define IDC_SERVER 0x406
|
||||
|
||||
#define IDS_LANCONNECTION 0x500
|
||||
|
@ -40,6 +40,26 @@ FONT 8, "MS Shell Dlg"
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
IDD_AUTHDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Authentication Required"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
LTEXT "Please enter your username and password:", -1, 40, 6, 150, 15
|
||||
LTEXT "Server", -1, 40, 26, 50, 10
|
||||
LTEXT "Realm", -1, 40, 46, 50, 10
|
||||
LTEXT "User", -1, 40, 66, 50, 10
|
||||
LTEXT "Password", -1, 40, 86, 50, 10
|
||||
LTEXT "" IDC_SERVER, 80, 26, 150, 14, 0
|
||||
LTEXT "" IDC_REALM, 80, 46, 150, 14, 0
|
||||
EDITTEXT IDC_USERNAME, 80, 66, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
|
||||
EDITTEXT IDC_PASSWORD, 80, 86, 150, 14, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | ES_PASSWORD
|
||||
CHECKBOX "&Save this password (insecure)", IDC_SAVEPASSWORD,
|
||||
80, 106, 150, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
|
||||
PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP
|
||||
}
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
{
|
||||
IDS_LANCONNECTION "LAN Connection"
|
||||
|
Loading…
Reference in New Issue
Block a user