Commit a1c16d28 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Implement support for proxies with usernames and passwords.

parent d8c5f2bd
Makefile Makefile
rsrc.res
version.res version.res
wininet.dll.dbg.c wininet.dll.dbg.c
wininet.spec.c wininet.spec.c
......
...@@ -4,7 +4,7 @@ TOPOBJDIR = ../.. ...@@ -4,7 +4,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = wininet.dll MODULE = wininet.dll
IMPORTS = shlwapi user32 advapi32 kernel32 IMPORTS = mpr shlwapi user32 advapi32 kernel32
EXTRALIBS = $(LIBUNICODE) EXTRALIBS = $(LIBUNICODE)
LDDLLFLAGS = @LDDLLFLAGS@ LDDLLFLAGS = @LDDLLFLAGS@
...@@ -12,6 +12,7 @@ SYMBOLFILE = $(MODULE).tmp.o ...@@ -12,6 +12,7 @@ SYMBOLFILE = $(MODULE).tmp.o
C_SRCS = \ C_SRCS = \
cookie.c \ cookie.c \
dialogs.c \
ftp.c \ ftp.c \
http.c \ http.c \
internet.c \ internet.c \
...@@ -20,7 +21,9 @@ C_SRCS = \ ...@@ -20,7 +21,9 @@ C_SRCS = \
utility.c \ utility.c \
wininet_main.c wininet_main.c
RC_SRCS = version.rc RC_SRCS = \
rsrc.rc \
version.rc
SUBDIRS = tests SUBDIRS = tests
......
...@@ -209,6 +209,68 @@ BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl, ...@@ -209,6 +209,68 @@ BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl,
/*********************************************************************** /***********************************************************************
* INTERNET_ConfigureProxyFromReg
*
* FIXME:
* The proxy may be specified in the form 'http=proxy.my.org'
* Presumably that means there can be ftp=ftpproxy.my.org too.
*/
static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOA lpwai )
{
HKEY key;
DWORD r, keytype, len, enabled;
LPSTR lpszInternetSettings =
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
r = RegOpenKeyA(HKEY_CURRENT_USER, lpszInternetSettings, &key);
if ( r != ERROR_SUCCESS )
return FALSE;
len = sizeof enabled;
r = RegQueryValueExA( key, "ProxyEnable", NULL, &keytype,
(BYTE*)&enabled, &len);
if( (r == ERROR_SUCCESS) && enabled )
{
TRACE("Proxy is enabled.\n");
/* figure out how much memory the proxy setting takes */
r = RegQueryValueExA( key, "ProxyServer", NULL, &keytype,
NULL, &len);
if( (r == ERROR_SUCCESS) && len && (keytype == REG_SZ) )
{
LPSTR szProxy, p, szHttp = "http=";
szProxy=HeapAlloc( GetProcessHeap(), 0, len+1 );
RegQueryValueExA( key, "ProxyServer", NULL, &keytype,
(BYTE*)szProxy, &len);
/* find the http proxy, and strip away everything else */
p = strstr( szProxy, szHttp );
if( p )
{
p += strlen(szHttp);
strcpy( szProxy, p );
}
p = strchr( szProxy, ' ' );
if( p )
*p = 0;
lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
lpwai->lpszProxy = szProxy;
TRACE("http proxy = %s\n", lpwai->lpszProxy);
}
else
ERR("Couldn't read proxy server settings.\n");
}
else
TRACE("Proxy is not enabled.\n");
RegCloseKey(key);
return enabled;
}
/***********************************************************************
* InternetOpenA (WININET.@) * InternetOpenA (WININET.@)
* *
* Per-application initialization of wininet * Per-application initialization of wininet
...@@ -231,53 +293,42 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, ...@@ -231,53 +293,42 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOA)); lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOA));
if (NULL == lpwai) if (NULL == lpwai)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY); INTERNET_SetLastError(ERROR_OUTOFMEMORY);
else return NULL;
}
memset(lpwai, 0, sizeof(WININETAPPINFOA));
lpwai->hdr.htype = WH_HINIT;
lpwai->hdr.lpwhparent = NULL;
lpwai->hdr.dwFlags = dwFlags;
lpwai->dwAccessType = dwAccessType;
lpwai->lpszProxyUsername = NULL;
lpwai->lpszProxyPassword = NULL;
if (NULL != lpszAgent)
{ {
memset(lpwai, 0, sizeof(WININETAPPINFOA)); lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
lpwai->hdr.htype = WH_HINIT; strlen(lpszAgent)+1);
lpwai->hdr.lpwhparent = NULL; if (lpwai->lpszAgent)
lpwai->hdr.dwFlags = dwFlags; strcpy( lpwai->lpszAgent, lpszAgent );
if (NULL != lpszAgent) }
{ if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
if ((lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,strlen(lpszAgent)+1))) INTERNET_ConfigureProxyFromReg( lpwai );
strcpy( lpwai->lpszAgent, lpszAgent ); else if (NULL != lpszProxy)
} {
if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG) lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0,
{ strlen(lpszProxy)+1);
HKEY key; if (lpwai->lpszProxy)
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", &key)) strcpy( lpwai->lpszProxy, lpszProxy );
{ }
DWORD keytype, len, enabled;
RegQueryValueExA(key, "ProxyEnable", NULL, NULL, (BYTE*)&enabled, NULL); if (NULL != lpszProxyBypass)
if(enabled) {
{ lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0,
if(!RegQueryValueExA(key, "ProxyServer", NULL, &keytype, NULL, &len) && len && keytype == REG_SZ) strlen(lpszProxyBypass)+1);
{ if (lpwai->lpszProxyBypass)
lpwai->lpszProxy=HeapAlloc( GetProcessHeap(), 0, len+1 ); strcpy( lpwai->lpszProxyBypass, lpszProxyBypass );
RegQueryValueExA(key, "ProxyServer", NULL, &keytype, (BYTE*)lpwai->lpszProxy, &len);
TRACE("Proxy = %s\n", lpwai->lpszProxy);
dwAccessType = INTERNET_OPEN_TYPE_PROXY;
}
}
else
{
TRACE("Proxy is not enabled.\n");
}
RegCloseKey(key);
}
}
else if (NULL != lpszProxy)
{
if ((lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxy)+1 )))
strcpy( lpwai->lpszProxy, lpszProxy );
}
if (NULL != lpszProxyBypass)
{
if ((lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxyBypass)+1)))
strcpy( lpwai->lpszProxyBypass, lpszProxyBypass );
}
lpwai->dwAccessType = dwAccessType;
} }
TRACE("returning %p\n", (HINTERNET)lpwai); TRACE("returning %p\n", (HINTERNET)lpwai);
...@@ -648,6 +699,12 @@ VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai) ...@@ -648,6 +699,12 @@ VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai)
if (lpwai->lpszProxyBypass) if (lpwai->lpszProxyBypass)
HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass); HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
if (lpwai->lpszProxyUsername)
HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
if (lpwai->lpszProxyPassword)
HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
HeapFree(GetProcessHeap(), 0, lpwai); HeapFree(GetProcessHeap(), 0, lpwai);
} }
......
...@@ -73,6 +73,8 @@ typedef struct ...@@ -73,6 +73,8 @@ typedef struct
LPSTR lpszAgent; LPSTR lpszAgent;
LPSTR lpszProxy; LPSTR lpszProxy;
LPSTR lpszProxyBypass; LPSTR lpszProxyBypass;
LPSTR lpszProxyUsername;
LPSTR lpszProxyPassword;
DWORD dwAccessType; DWORD dwAccessType;
INTERNET_STATUS_CALLBACK lpfnStatusCB; INTERNET_STATUS_CALLBACK lpfnStatusCB;
} WININETAPPINFOA, *LPWININETAPPINFOA; } WININETAPPINFOA, *LPWININETAPPINFOA;
...@@ -281,6 +283,8 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession, ...@@ -281,6 +283,8 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo , DWORD dwStatusInfoLength); lpvStatusInfo , DWORD dwStatusInfoLength);
BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQA lpwhr,
LPCSTR username, LPCSTR password );
BOOL NETCON_connected(WININET_NETCONNECTION *connection); BOOL NETCON_connected(WININET_NETCONNECTION *connection);
void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL); void NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
......
/*
* Wininet resource definitions
*
* Copyright 2003 Mike McCormack for Codeweavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define IDD_PROXYDLG 0x400
#define IDC_PROXY 0x401
#define IDC_REALM 0x402
#define IDC_USERNAME 0x403
#define IDC_PASSWORD 0x404
#define IDC_SAVEPASSWORD 0x405
/*
* Top level resource file for Wininet
*
* Copyright 2003 Mike McCormack for Codeweavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "windef.h"
#include "winuser.h"
#include "winnls.h"
#include "resource.h"
/*
* Everything that does not depend on language,
* like textless bitmaps etc, go into the
* neutral language. This will prevent them from
* being duplicated for each language.
*/
/* #include "wininet_xx.rc" */
/*
* Everything specific to any language goes
* in one of the specific files.
* Note that you can and may override resources
* which also have a neutral version. This is to
* get localized bitmaps for example.
*/
#include "wininet_En.rc"
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
@ stdcall InternetCreateUrlW(ptr long ptr ptr) @ stdcall InternetCreateUrlW(ptr long ptr ptr)
@ stub InternetDebugGetLocalTime @ stub InternetDebugGetLocalTime
@ stub InternetDial @ stub InternetDial
@ stub InternetErrorDlg @ stdcall InternetErrorDlg(long long long long ptr)
@ stdcall InternetFindNextFileA(ptr ptr) @ stdcall InternetFindNextFileA(ptr ptr)
@ stub InternetFindNextFileW @ stub InternetFindNextFileW
@ stub InternetGetCertByURL @ stub InternetGetCertByURL
......
/*
* Copyright 2003 Mike McCormack for Codeweavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
IDD_PROXYDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 250, 154
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Enter Network Password"
FONT 8, "Helv"
{
LTEXT "Please enter your username and password:", -1, 40, 6, 150, 15
LTEXT "Proxy", -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_PROXY, 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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment