ReactOS 0.4.16-dev-295-g4aee028
connections.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <wininet.h>
#include <winuser.h>
#include <winreg.h>
#include "inetcpl.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for connections.c:

Go to the source code of this file.

Classes

struct  connection_settings
 

Macros

#define CONNECTION_SETTINGS_VERSION   0x46
 
#define CONNECTION_SETTINGS_MANUAL_PROXY   0x2
 
#define CONNECTION_SETTINGS_PAC_SCRIPT   0x4
 
#define CONNECTION_SETTINGS_WPAD   0x8
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (inetcpl)
 
static DWORD create_connection_settings (BOOL manual_proxy, const WCHAR *proxy_server, BOOL use_wpad, BOOL use_pac_script, const WCHAR *pac_url, connection_settings **ret)
 
static void connections_on_initdialog (HWND hwnd)
 
static INT_PTR connections_on_command (HWND hwnd, WPARAM wparam)
 
static INT_PTR connections_on_notify (HWND hwnd, WPARAM wparam, LPARAM lparam)
 
INT_PTR CALLBACK connections_dlgproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 

Variables

static const WCHAR auto_config_url [] = {'A','u','t','o','C','o','n','f','i','g','U','R','L',0}
 
static const WCHAR internet_settings []
 
static const WCHAR proxy_enable [] = {'P','r','o','x','y','E','n','a','b','l','e',0}
 
static const WCHAR proxy_server [] = {'P','r','o','x','y','S','e','r','v','e','r',0}
 
static const WCHAR connections [] = {'C','o','n','n','e','c','t','i','o','n','s',0}
 
static const WCHAR default_connection_settings []
 
static BOOL initdialog_done
 

Macro Definition Documentation

◆ CONNECTION_SETTINGS_MANUAL_PROXY

#define CONNECTION_SETTINGS_MANUAL_PROXY   0x2

Definition at line 48 of file connections.c.

◆ CONNECTION_SETTINGS_PAC_SCRIPT

#define CONNECTION_SETTINGS_PAC_SCRIPT   0x4

Definition at line 49 of file connections.c.

◆ CONNECTION_SETTINGS_VERSION

#define CONNECTION_SETTINGS_VERSION   0x46

Definition at line 47 of file connections.c.

◆ CONNECTION_SETTINGS_WPAD

#define CONNECTION_SETTINGS_WPAD   0x8

Definition at line 50 of file connections.c.

Function Documentation

◆ connections_dlgproc()

INT_PTR CALLBACK connections_dlgproc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)

Definition at line 349 of file connections.c.

350{
351 switch (msg)
352 {
353 case WM_INITDIALOG:
356 break;
357 case WM_COMMAND:
359 case WM_NOTIFY:
361 }
362 return FALSE;
363}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define msg(x)
Definition: auth_time.c:54
static INT_PTR connections_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam)
Definition: connections.c:248
static void connections_on_initdialog(HWND hwnd)
Definition: connections.c:123
static BOOL initdialog_done
Definition: connections.c:45
static INT_PTR connections_on_command(HWND hwnd, WPARAM wparam)
Definition: connections.c:216
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define WM_NOTIFY
Definition: richedit.h:61
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742

Referenced by display_cpl_sheets().

◆ connections_on_command()

static INT_PTR connections_on_command ( HWND  hwnd,
WPARAM  wparam 
)
static

Definition at line 216 of file connections.c.

217{
218 BOOL checked;
219
220 switch (wparam)
221 {
225 break;
230 }
231
232 switch (wparam)
233 {
234 case IDC_USE_WPAD:
242 return TRUE;
243 }
244
245 return FALSE;
246}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_EDIT_PROXY_PORT
Definition: inetcpl.h:101
#define IDC_EDIT_PAC_SCRIPT
Definition: inetcpl.h:98
#define IDC_USE_PAC_SCRIPT
Definition: inetcpl.h:97
#define IDC_EDIT_PROXY_SERVER
Definition: inetcpl.h:100
#define IDC_USE_PROXY_SERVER
Definition: inetcpl.h:99
#define IDC_USE_WPAD
Definition: inetcpl.h:96
if(dx< 0)
Definition: linetemp.h:194
#define PSM_CHANGED
Definition: prsht.h:164
UINT_PTR WPARAM
Definition: windef.h:207
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EN_CHANGE
Definition: winuser.h:2025

Referenced by connections_dlgproc().

◆ connections_on_initdialog()

static void connections_on_initdialog ( HWND  hwnd)
static

Definition at line 123 of file connections.c.

124{
128 HKEY hkey, con;
129 LONG res;
130
136
138 if(res)
139 return;
140
141 size = sizeof(enabled);
143 if(res || type != REG_DWORD)
144 enabled = 0;
145 size = sizeof(address);
147 if(res || type != REG_SZ)
148 address[0] = 0;
149 size = sizeof(pac_url);
150 res = RegQueryValueExW(hkey, auto_config_url, NULL, &type, (BYTE*)pac_url, &size);
151 if(res || type != REG_SZ)
152 pac_url[0] = 0;
153
154 res = RegOpenKeyW(hkey, connections, &con);
155 RegCloseKey(hkey);
156 if(!res)
157 {
159 size = 0;
160
163 {
165 if(!new_settings)
166 {
167 RegCloseKey(con);
169 return;
170 }
171 settings = new_settings;
172 }
173 RegCloseKey(con);
174
175 if(!res && type == REG_BINARY)
176 {
178 FIXME("unexpected structure version (%x)\n", settings->version);
179 else if(settings->flags & CONNECTION_SETTINGS_WPAD)
181 }
183 }
184
185 TRACE("ProxyEnable = %x\n", enabled);
186 TRACE("ProxyServer = %s\n", wine_dbgstr_w(address));
187 TRACE("AutoConfigURL = %s\n", wine_dbgstr_w(auto_config_url));
188
189 if(enabled)
190 {
194 }
195
196 port = wcschr(address, ':');
197 if(port)
198 {
199 *port = 0;
200 port++;
201 }
203 if(port)
205
206 if(pac_url[0])
207 {
211 }
212
213 return;
214}
struct mke2fs_defaults settings[]
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define FIXME(fmt,...)
Definition: precomp.h:53
#define RegCloseKey(hKey)
Definition: registry.h:49
static const WCHAR auto_config_url[]
Definition: connections.c:34
#define CONNECTION_SETTINGS_VERSION
Definition: connections.c:47
static const WCHAR connections[]
Definition: connections.c:41
static const WCHAR proxy_enable[]
Definition: connections.c:39
#define CONNECTION_SETTINGS_WPAD
Definition: connections.c:50
static const WCHAR default_connection_settings[]
Definition: connections.c:42
static const WCHAR internet_settings[]
Definition: connections.c:35
static const WCHAR proxy_server[]
Definition: connections.c:40
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define wcschr
Definition: compat.h:17
USHORT port
Definition: uri.c:228
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
GLuint res
Definition: glext.h:9613
GLuint address
Definition: glext.h:9393
#define wine_dbgstr_w
Definition: kernel32.h:34
#define REG_SZ
Definition: layer.c:22
#define REG_BINARY
Definition: nt_native.h:1496
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
#define TRACE(s)
Definition: solgame.cpp:4
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define EM_LIMITTEXT
Definition: winuser.h:2003
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define BST_CHECKED
Definition: winuser.h:197
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by connections_dlgproc().

◆ connections_on_notify()

static INT_PTR connections_on_notify ( HWND  hwnd,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 248 of file connections.c.

249{
250 connection_settings *default_connection;
253 PSHNOTIFY *psn = (PSHNOTIFY*)lparam;
254 DWORD proxy_len, port_len, pac_script_len;
255 DWORD use_proxy, use_pac_script, use_wpad, size;
256 LRESULT res;
257 HKEY hkey, con;
258
259 if(psn->hdr.code != PSN_APPLY)
260 return FALSE;
261
263 if(res)
264 return FALSE;
265
268 (BYTE*)&use_proxy, sizeof(use_proxy));
269 if(res)
270 {
271 RegCloseKey(hkey);
272 return FALSE;
273 }
274 TRACE("ProxyEnable set to %x\n", use_proxy);
275
277 if(proxy_len)
278 {
279 proxy[proxy_len++] = ':';
280 port_len = GetDlgItemTextW(hwnd, IDC_EDIT_PROXY_PORT, proxy+proxy_len,
281 ARRAY_SIZE(proxy)-proxy_len);
282 if(!port_len)
283 {
284 proxy[proxy_len++] = '8';
285 proxy[proxy_len++] = '0';
286 proxy[proxy_len] = 0;
287 }
288
290 (BYTE*)proxy, (proxy_len+port_len)*sizeof(WCHAR));
291 }
292 else
293 {
297 }
298 if(res)
299 {
300 RegCloseKey(hkey);
301 return FALSE;
302 }
303 TRACE("ProxtServer set to %s\n", wine_dbgstr_w(proxy));
304
305 use_pac_script = IsDlgButtonChecked(hwnd, IDC_USE_PAC_SCRIPT);
306 pac_script_len = GetDlgItemTextW(hwnd, IDC_EDIT_PAC_SCRIPT,
308 if(!pac_script_len) use_pac_script = FALSE;
309 if(use_pac_script)
310 {
312 (BYTE*)pac_script, pac_script_len*sizeof(WCHAR));
313 }
314 else
315 {
319 }
320 if(res)
321 {
322 RegCloseKey(hkey);
323 return FALSE;
324 }
325 TRACE("AutoConfigURL set to %s\n", wine_dbgstr_w(use_pac_script ? pac_script : NULL));
326
328
329 res = RegCreateKeyExW(hkey, connections, 0, NULL, 0, KEY_WRITE, NULL, &con, NULL);
330 RegCloseKey(hkey);
331 if(res)
332 return FALSE;
333
334 size = create_connection_settings(use_proxy, proxy, use_wpad,
335 use_pac_script, pac_script, &default_connection);
336 if(!size)
337 {
338 RegCloseKey(con);
339 return FALSE;
340 }
341
343 (BYTE*)default_connection, size);
344 heap_free(default_connection);
345 RegCloseKey(con);
346 return !res;
347}
#define ARRAY_SIZE(A)
Definition: main.h:20
static DWORD create_connection_settings(BOOL manual_proxy, const WCHAR *proxy_server, BOOL use_wpad, BOOL use_pac_script, const WCHAR *pac_url, connection_settings **ret)
Definition: connections.c:66
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
int proxy
Definition: main.c:67
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
#define PSN_APPLY
Definition: prsht.h:117
NMHDR hdr
Definition: prsht.h:330
UINT code
Definition: winuser.h:3162
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by connections_dlgproc().

◆ create_connection_settings()

static DWORD create_connection_settings ( BOOL  manual_proxy,
const WCHAR proxy_server,
BOOL  use_wpad,
BOOL  use_pac_script,
const WCHAR pac_url,
connection_settings **  ret 
)
static

Definition at line 66 of file connections.c.

68{
70 DWORD proxy_server_len;
71 DWORD pac_url_len;
72
73 size += sizeof(DWORD);
74 if(proxy_server)
75 {
76 proxy_server_len = WideCharToMultiByte(CP_UTF8, 0, proxy_server, -1,
77 NULL, 0, NULL, NULL);
78 if(!proxy_server_len) return 0;
79 proxy_server_len--;
80 }
81 else
82 proxy_server_len = 0;
83 size += proxy_server_len;
84 if(pac_url)
85 {
86 pac_url_len = WideCharToMultiByte(CP_UTF8, 0, pac_url, -1,
87 NULL, 0, NULL, NULL);
88 if(!pac_url_len) return 0;
89 pac_url_len--;
90 }
91 else
92 pac_url_len = 0;
93 size += sizeof(DWORD)*10;
94
95 *ret = heap_alloc_zero(size);
96 if(!*ret) return 0;
97
98 (*ret)->version = CONNECTION_SETTINGS_VERSION;
99 (*ret)->flags = 1;
100 if(manual_proxy) (*ret)->flags |= CONNECTION_SETTINGS_MANUAL_PROXY;
101 if(use_pac_script) (*ret)->flags |= CONNECTION_SETTINGS_PAC_SCRIPT;
102 if(use_wpad) (*ret)->flags |= CONNECTION_SETTINGS_WPAD;
103 ((DWORD*)(*ret)->data)[0] = proxy_server_len;
104 pos = sizeof(DWORD);
105 if(proxy_server_len)
106 {
108 (char*)(*ret)->data+pos, proxy_server_len, NULL, NULL);
109 pos += proxy_server_len;
110 }
111 pos += sizeof(DWORD); /* skip proxy bypass list */
112 ((DWORD*)((*ret)->data+pos))[0] = pac_url_len;
113 pos += sizeof(DWORD);
114 if(pac_url_len)
115 {
116 WideCharToMultiByte(CP_UTF8, 0, pac_url, -1,
117 (char*)(*ret)->data+pos, pac_url_len, NULL, NULL);
118 pos += pac_url_len;
119 }
120 return size;
121}
#define CONNECTION_SETTINGS_PAC_SCRIPT
Definition: connections.c:49
#define CONNECTION_SETTINGS_MANUAL_PROXY
Definition: connections.c:48
#define WideCharToMultiByte
Definition: compat.h:111
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define DWORD
Definition: nt_native.h:44
#define CP_UTF8
Definition: nls.h:20
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int ret

Referenced by connections_on_notify().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( inetcpl  )

Variable Documentation

◆ auto_config_url

const WCHAR auto_config_url[] = {'A','u','t','o','C','o','n','f','i','g','U','R','L',0}
static

Definition at line 34 of file connections.c.

Referenced by connections_on_initdialog(), and connections_on_notify().

◆ connections

const WCHAR connections[] = {'C','o','n','n','e','c','t','i','o','n','s',0}
static

Definition at line 41 of file connections.c.

Referenced by connections_on_initdialog(), and connections_on_notify().

◆ default_connection_settings

const WCHAR default_connection_settings[]
static
Initial value:
= {'D','e','f','a','u','l','t',
'C','o','n','n','e','c','t','i','o','n','S','e','t','t','i','n','g','s',0}

Definition at line 42 of file connections.c.

Referenced by connections_on_initdialog(), and connections_on_notify().

◆ initdialog_done

BOOL initdialog_done
static

Definition at line 45 of file connections.c.

Referenced by connections_dlgproc(), and connections_on_command().

◆ internet_settings

const WCHAR internet_settings[]
static
Initial value:
= {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0}

Definition at line 35 of file connections.c.

Referenced by connections_on_initdialog(), connections_on_notify(), and proxy_active().

◆ proxy_enable

const WCHAR proxy_enable[] = {'P','r','o','x','y','E','n','a','b','l','e',0}
static

Definition at line 39 of file connections.c.

Referenced by connections_on_initdialog(), connections_on_notify(), and proxy_active().

◆ proxy_server

const WCHAR proxy_server[] = {'P','r','o','x','y','S','e','r','v','e','r',0}
static