Skip to content

Commit

Permalink
inetcpl.cpl: Add proxy server settings dialog.
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Caban <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
PiotrCW authored and julliard committed Jul 3, 2018
1 parent 8686448 commit 2499f22
Show file tree
Hide file tree
Showing 51 changed files with 1,393 additions and 0 deletions.
1 change: 1 addition & 0 deletions dlls/inetcpl.cpl/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ IMPORTS = comctl32 shlwapi user32 advapi32
DELAYIMPORTS = cryptui wininet ole32 urlmon shell32

C_SRCS = \
connections.c \
content.c \
general.c \
inetcpl.c \
Expand Down
178 changes: 178 additions & 0 deletions dlls/inetcpl.cpl/connections.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
* Copyright 2018 Piotr cabna 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/

#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wininet.h>
#include <winuser.h>
#include <winreg.h>

#include "inetcpl.h"
#include "wine/debug.h"
#include "wine/unicode.h"

WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);

static const WCHAR internet_settings[] = {'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};
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 BOOL initdialog_done;

static void connections_on_initdialog(HWND hwnd)
{
DWORD type, size, enabled;
WCHAR address[INTERNET_MAX_URL_LENGTH], *port;
HKEY hkey;
LONG res;

SendMessageW(GetDlgItem(hwnd, IDC_EDIT_PROXY_SERVER),
EM_LIMITTEXT, INTERNET_MAX_URL_LENGTH-10, 0);
SendMessageW(GetDlgItem(hwnd, IDC_EDIT_PROXY_PORT), EM_LIMITTEXT, 8, 0);

res = RegOpenKeyW(HKEY_CURRENT_USER, internet_settings, &hkey);
if(res)
return;

size = sizeof(enabled);
res = RegQueryValueExW(hkey, proxy_enable, NULL, &type, (BYTE*)&enabled, &size);
if(res || type != REG_DWORD)
enabled = 0;
size = sizeof(address);
res = RegQueryValueExW(hkey, proxy_server, NULL, &type, (BYTE*)address, &size);
if(res || type != REG_SZ)
address[0] = 0;
RegCloseKey(hkey);

TRACE("ProxyEnable = %x\n", enabled);
TRACE("ProxyServer = %s\n", wine_dbgstr_w(address));

if(enabled)
{
CheckDlgButton(hwnd, IDC_USE_PROXY_SERVER, BST_CHECKED);
EnableWindow(GetDlgItem(hwnd, IDC_EDIT_PROXY_SERVER), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_EDIT_PROXY_PORT), TRUE);
}

port = strchrW(address, ':');
if(port)
{
*port = 0;
port++;
}
SetDlgItemTextW(hwnd, IDC_EDIT_PROXY_SERVER, address);
if(port)
SetDlgItemTextW(hwnd, IDC_EDIT_PROXY_PORT, port);

return;
}

static INT_PTR connections_on_command(HWND hwnd, WPARAM wparam)
{
BOOL checked;

switch (wparam)
{
case IDC_USE_PROXY_SERVER:
checked = IsDlgButtonChecked(hwnd, IDC_USE_PROXY_SERVER);
EnableWindow(GetDlgItem(hwnd, IDC_EDIT_PROXY_SERVER), checked);
EnableWindow(GetDlgItem(hwnd, IDC_EDIT_PROXY_PORT), checked);
/* fallthrough */
case MAKEWPARAM(IDC_EDIT_PROXY_SERVER, EN_CHANGE):
case MAKEWPARAM(IDC_EDIT_PROXY_PORT, EN_CHANGE):
if(initdialog_done)
SendMessageW(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
return TRUE;
}

return FALSE;
}

static INT_PTR connections_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam)
{
WCHAR addr[INTERNET_MAX_URL_LENGTH];
PSHNOTIFY *psn = (PSHNOTIFY*)lparam;
DWORD addr_len, port_len, enabled;
LRESULT res;
HKEY hkey;

if(psn->hdr.code != PSN_APPLY)
return FALSE;

res = RegOpenKeyW(HKEY_CURRENT_USER, internet_settings, &hkey);
if(res)
return FALSE;

enabled = IsDlgButtonChecked(hwnd, IDC_USE_PROXY_SERVER);
res = RegSetValueExW(hkey, proxy_enable, 0, REG_DWORD,
(BYTE*)&enabled, sizeof(enabled));
if(res)
{
RegCloseKey(hkey);
return FALSE;
}
TRACE("ProxyEnable set to %x\n", enabled);

addr_len = GetDlgItemTextW(hwnd, IDC_EDIT_PROXY_SERVER,
addr, sizeof(addr)/sizeof(addr[0]));
if(addr_len)
{
addr[addr_len++] = ':';
port_len = GetDlgItemTextW(hwnd, IDC_EDIT_PROXY_PORT,
addr+addr_len, sizeof(addr)/sizeof(addr[0])-addr_len);
if(!port_len)
{
addr[addr_len++] = '8';
addr[addr_len++] = '0';
addr[addr_len] = 0;
}

res = RegSetValueExW(hkey, proxy_server, 0, REG_SZ,
(BYTE*)addr, (addr_len+port_len)*sizeof(WCHAR));
}
else
{
res = RegDeleteValueW(hkey, proxy_server);
if(res == ERROR_FILE_NOT_FOUND)
res = ERROR_SUCCESS;
}
TRACE("ProxtServer set to %s\n", wine_dbgstr_w(addr));
RegCloseKey(hkey);
return !res;
}

INT_PTR CALLBACK connections_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
connections_on_initdialog(hwnd);
initdialog_done = TRUE;
break;
case WM_COMMAND:
return connections_on_command(hwnd, wparam);
case WM_NOTIFY:
return connections_on_notify(hwnd, wparam, lparam);
}
return FALSE;
}
6 changes: 6 additions & 0 deletions dlls/inetcpl.cpl/inetcpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ static void display_cpl_sheets(HWND parent)
psp[id].pfnDlgProc = content_dlgproc;
id++;

psp[id].dwSize = sizeof (PROPSHEETPAGEW);
psp[id].hInstance = hcpl;
psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONNECTIONS);
psp[id].pfnDlgProc = connections_dlgproc;
id++;

/* Fill out the PROPSHEETHEADER */
psh.dwSize = sizeof (PROPSHEETHEADERW);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
Expand Down
6 changes: 6 additions & 0 deletions dlls/inetcpl.cpl/inetcpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <commctrl.h>

extern HMODULE hcpl;
INT_PTR CALLBACK connections_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
INT_PTR CALLBACK content_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
INT_PTR CALLBACK general_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
INT_PTR CALLBACK security_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
Expand Down Expand Up @@ -84,4 +85,9 @@ INT_PTR CALLBACK security_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
#define IDC_CERT 4100
#define IDC_CERT_PUBLISHER 4101

#define IDD_CONNECTIONS 5000
#define IDC_USE_PROXY_SERVER 5100
#define IDC_EDIT_PROXY_SERVER 5101
#define IDC_EDIT_PROXY_PORT 5102

#endif
14 changes: 14 additions & 0 deletions dlls/inetcpl.cpl/inetcpl.rc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ BEGIN

END

/* "Connections" propsheet */
IDD_CONNECTIONS DIALOG 0, 0, 320, 220
STYLE WS_CAPTION | WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
CAPTION "Connections"
BEGIN
GROUPBOX "Proxy server", IDC_STATIC, 4, 4, 312, 42
AUTOCHECKBOX "Use a proxy server", IDC_USE_PROXY_SERVER, 10, 14, 200, 14, BS_TOP | BS_MULTILINE
LTEXT "Address:", IDC_STATIC, 10, 28, 40, 14
EDITTEXT IDC_EDIT_PROXY_SERVER, 50, 28, 80, 14, WS_VISIBLE | ES_AUTOHSCROLL | WS_DISABLED
LTEXT "Port:", IDC_STATIC, 140, 28, 30, 14
EDITTEXT IDC_EDIT_PROXY_PORT, 170, 28, 40, 14, WS_VISIBLE | ES_AUTOHSCROLL | WS_DISABLED | ES_NUMBER
END

LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL

#define WINE_FILENAME_STR "inetcpl.cpl"
Expand Down
28 changes: 28 additions & 0 deletions po/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -3420,6 +3420,34 @@ msgstr "الشهادات..."
msgid "Publishers..."
msgstr "الناشرون..."

#: inetcpl.rc:123
#, fuzzy
#| msgid "LAN Connection"
msgid "Connections"
msgstr "اتصالات الشبكة المحلية"

#: inetcpl.rc:125
#, fuzzy
#| msgid "&Local server"
msgid "Proxy server"
msgstr "الخاد&وم المحلي"

#: inetcpl.rc:126
msgid "Use a proxy server"
msgstr ""

#: inetcpl.rc:127
#, fuzzy
#| msgid "Address"
msgid "Address:"
msgstr "العنوان"

#: inetcpl.rc:129
#, fuzzy
#| msgid "No Ports"
msgid "Port:"
msgstr "لا منافذ"

#: inetcpl.rc:31
msgid "Internet Settings"
msgstr "إعدادات الشابكة"
Expand Down
26 changes: 26 additions & 0 deletions po/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -3441,6 +3441,32 @@ msgstr "&Свойства на клетката"
msgid "Publishers..."
msgstr ""

#: inetcpl.rc:123
#, fuzzy
#| msgid "LAN Connection"
msgid "Connections"
msgstr "LAN връзка"

#: inetcpl.rc:125
#, fuzzy
msgid "Proxy server"
msgstr "Локален порт"

#: inetcpl.rc:126
msgid "Use a proxy server"
msgstr ""

#: inetcpl.rc:127
#, fuzzy
msgid "Address:"
msgstr "Локален порт"

#: inetcpl.rc:129
#, fuzzy
#| msgid "Local Port"
msgid "Port:"
msgstr "Локален порт"

#: inetcpl.rc:31
msgid "Internet Settings"
msgstr ""
Expand Down
28 changes: 28 additions & 0 deletions po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -3446,6 +3446,34 @@ msgstr "Certificats..."
msgid "Publishers..."
msgstr "Publicadors..."

#: inetcpl.rc:123
#, fuzzy
#| msgid "LAN Connection"
msgid "Connections"
msgstr "Connexió LAN"

#: inetcpl.rc:125
#, fuzzy
#| msgid "&Local server"
msgid "Proxy server"
msgstr "Servidor &local"

#: inetcpl.rc:126
msgid "Use a proxy server"
msgstr ""

#: inetcpl.rc:127
#, fuzzy
#| msgid "Address"
msgid "Address:"
msgstr "Adreça"

#: inetcpl.rc:129
#, fuzzy
#| msgid "No Ports"
msgid "Port:"
msgstr "Cap port"

#: inetcpl.rc:31
msgid "Internet Settings"
msgstr "Opcions d'Internet"
Expand Down
28 changes: 28 additions & 0 deletions po/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -3369,6 +3369,34 @@ msgstr "Certifikáty..."
msgid "Publishers..."
msgstr "Vydavatelé..."

#: inetcpl.rc:123
#, fuzzy
#| msgid "LAN Connection"
msgid "Connections"
msgstr "Připojení lokální sítě"

#: inetcpl.rc:125
#, fuzzy
#| msgid "&Local server"
msgid "Proxy server"
msgstr "&Místní server"

#: inetcpl.rc:126
msgid "Use a proxy server"
msgstr ""

#: inetcpl.rc:127
#, fuzzy
#| msgid "Address"
msgid "Address:"
msgstr "Adresa"

#: inetcpl.rc:129
#, fuzzy
#| msgid "No Ports"
msgid "Port:"
msgstr "Žádné porty"

#: inetcpl.rc:31
msgid "Internet Settings"
msgstr "Nastavení internetu"
Expand Down
Loading

0 comments on commit 2499f22

Please sign in to comment.