From 5a47986ccb3d1c14fc5540642f7d71e05921d510 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Sat, 9 Jul 2016 15:14:36 -0400 Subject: [PATCH] Make options saved in registry editable by user Option ediitng dialogs are in two tabs: General and Advanced. Proxy related options are left in the proxy tab. Options config_dir, config_ext, log_dir, script timeouts and service-only flag are in the Advanced tab. All other more commonly used flags and options are in the General tab. - As options are editable, save values in registry only when they differ from the default values. This leaves the registry clean and makes changing options and their defaults during updates easier. - Entries for config_dir and log_dir must be absolute paths. Environemental variables such as %PROFILEDIR% may be used to construct these. - Empty config_dir, config_ext and log_dir entries are silently ignored (i.e., the current values are left unchanged). - Store all numeric and boolean parameters in registry as DWORD instead of strings. - On startup, the default parameters are loaded, then the registry is read and finally command-line parameters parsedi. - Out of range script timeout values in registry truncated with a warning instead of fatal error. This allows the user to access the settings dialog and make corrections. - Save proxy and language settings under the same HKCU\Software\OpenVPN-GUI key as other options instead of under Nilings. - Save the current version of the GUI in regsitry so that updates can be detected and any needed registry cleanup done. - If no version info is present in the registry any values in OpenVPN-GUI key in HKCU are deleted for a clean start as this is the first version to save registry values in HKCU. Language and proxy data if present under Nilings is migrated. Note: new controls in the General tab and newly added Advanced tab dialog are copied to all language files from the English version. These need to be translated. Signed-off-by: Selva Nair --- Makefile.am | 1 + localization.c | 28 +++ main.c | 36 ++-- main.h | 5 +- openvpn-gui-res.h | 27 +++ openvpn.c | 21 +- openvpn_config.c | 1 + options.c | 242 ++++++++++++++++++++++- options.h | 31 +-- proxy.c | 10 +- registry.c | 390 +++++++++++++++++++++++--------------- registry.h | 4 +- res/openvpn-gui-res-de.rc | 39 ++++ res/openvpn-gui-res-dk.rc | 39 ++++ res/openvpn-gui-res-en.rc | 42 +++- res/openvpn-gui-res-es.rc | 39 ++++ res/openvpn-gui-res-fi.rc | 39 ++++ res/openvpn-gui-res-fr.rc | 39 ++++ res/openvpn-gui-res-it.rc | 39 ++++ res/openvpn-gui-res-jp.rc | 39 ++++ res/openvpn-gui-res-nl.rc | 39 ++++ res/openvpn-gui-res-no.rc | 39 ++++ res/openvpn-gui-res-pl.rc | 39 ++++ res/openvpn-gui-res-pt.rc | 39 ++++ res/openvpn-gui-res-ru.rc | 39 ++++ res/openvpn-gui-res-se.rc | 39 ++++ res/openvpn-gui-res-tr.rc | 39 ++++ res/openvpn-gui-res-ua.rc | 39 ++++ scripts.c | 12 +- tray.c | 12 +- 30 files changed, 1226 insertions(+), 221 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4394643..c799037 100644 --- a/Makefile.am +++ b/Makefile.am @@ -105,6 +105,7 @@ openvpn_gui_LDADD = \ -lcrypt32 \ -lnetapi32 \ -lole32 \ + -lshlwapi \ -lsecur32 openvpn-gui-res.o: $(openvpn_gui_RESOURCES) $(srcdir)/openvpn-gui-res.h diff --git a/localization.c b/localization.c index b67b930..0220c53 100644 --- a/localization.c +++ b/localization.c @@ -427,6 +427,19 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar if (GetLaunchOnStartup()) Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP), BST_CHECKED); + if (o.log_append) + Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_LOG_APPEND), BST_CHECKED); + if (o.silent_connection) + Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_SILENT), BST_CHECKED); + if (o.show_balloon == 0) + CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON0); + else if (o.show_balloon == 1) + CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON1); + else if (o.show_balloon == 2) + CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON2); + if (o.show_script_window) + Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN), BST_CHECKED); + break; case WM_NOTIFY: @@ -441,6 +454,21 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar SetLaunchOnStartup(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP)) == BST_CHECKED); + o.log_append = + (Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_LOG_APPEND)) == BST_CHECKED); + o.silent_connection = + (Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SILENT)) == BST_CHECKED); + if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON0)) + o.show_balloon = 0; + else if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON2)) + o.show_balloon = 2; + else + o.show_balloon = 1; + o.show_script_window = + (Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN)) == BST_CHECKED); + + SaveRegistryKeys(); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); return TRUE; } diff --git a/main.c b/main.c index eb95b38..f94ba9e 100644 --- a/main.c +++ b/main.c @@ -161,9 +161,6 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, #endif - /* Parse command-line options */ - ProcessCommandLine(&o, GetCommandLine()); - /* Check if a previous instance is already running. */ if ((FindWindow (szClassName, NULL)) != NULL) { @@ -172,9 +169,12 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, exit(1); } - if (!GetRegistryKeys()) { - exit(1); - } + UpdateRegistry(); /* Checks version change and update keys/values */ + + GetRegistryKeys(); + /* Parse command-line options */ + ProcessCommandLine(&o, GetCommandLine()); + EnsureDirExists(o.config_dir); if (!CheckVersion()) { @@ -327,7 +327,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM CreatePopupMenus(); /* Create popup menus */ ShowTrayIcon(); - if (o.service_only[0]=='1') + if (o.service_only) CheckServiceStatus(); // Check if service is running or not if (!AutoStartConnections()) { SendMessage(hwnd, WM_CLOSE, 0, 0); @@ -444,11 +444,21 @@ AboutDialogFunc(UNUSED HWND hDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam) static void ShowSettingsDialog() { - PROPSHEETPAGE psp[3]; + PROPSHEETPAGE psp[4]; int page_number = 0; + /* General tab */ + psp[page_number].dwSize = sizeof(PROPSHEETPAGE); + psp[page_number].dwFlags = PSP_DLGINDIRECT; + psp[page_number].hInstance = o.hInstance; + psp[page_number].pResource = LocalizedDialogResource(ID_DLG_GENERAL); + psp[page_number].pfnDlgProc = GeneralSettingsDlgProc; + psp[page_number].lParam = 0; + psp[page_number].pfnCallback = NULL; + ++page_number; + /* Proxy tab */ - if (o.service_only[0] == '0') { + if (o.service_only == 0) { psp[page_number].dwSize = sizeof(PROPSHEETPAGE); psp[page_number].dwFlags = PSP_DLGINDIRECT; psp[page_number].hInstance = o.hInstance; @@ -459,12 +469,12 @@ ShowSettingsDialog() ++page_number; } - /* General tab */ + /* Advanced tab */ psp[page_number].dwSize = sizeof(PROPSHEETPAGE); psp[page_number].dwFlags = PSP_DLGINDIRECT; psp[page_number].hInstance = o.hInstance; - psp[page_number].pResource = LocalizedDialogResource(ID_DLG_GENERAL); - psp[page_number].pfnDlgProc = GeneralSettingsDlgProc; + psp[page_number].pResource = LocalizedDialogResource(ID_DLG_ADVANCED); + psp[page_number].pfnDlgProc = AdvancedSettingsDlgProc; psp[page_number].lParam = 0; psp[page_number].pfnCallback = NULL; ++page_number; @@ -521,7 +531,7 @@ void ImportConfigFile() { - TCHAR filter[37]; + TCHAR filter[2*_countof(o.ext_string)+5]; _sntprintf_0(filter, _T("*.%s%c*.%s%c"), o.ext_string, _T('\0'), o.ext_string, _T('\0')); diff --git a/main.h b/main.h index 1a16a73..c85b983 100644 --- a/main.h +++ b/main.h @@ -35,10 +35,7 @@ //#define DISABLE_CHANGE_PASSWORD /* Registry key for User Settings */ -#define GUI_REGKEY_HKCU _T("Software\\Nilings\\OpenVPN-GUI") - -/* Registry key for Global Settings */ -#define GUI_REGKEY_HKLM _T("SOFTWARE\\OpenVPN-GUI") +#define GUI_REGKEY_HKCU _T("Software\\OpenVPN-GUI") #define MAX_LOG_LENGTH 1024/* Max number of characters per log line */ #define MAX_LOG_LINES 500 /* Max number of lines in LogWindow */ diff --git a/openvpn-gui-res.h b/openvpn-gui-res.h index 8f7b478..5e38139 100644 --- a/openvpn-gui-res.h +++ b/openvpn-gui-res.h @@ -79,12 +79,39 @@ #define ID_CMB_LANGUAGE 231 #define ID_TXT_LANGUAGE 232 #define ID_CHK_STARTUP 233 +#define ID_CHK_SERVICE_ONLY 234 +#define ID_TXT_LOG_APPEND 235 +#define ID_CHK_LOG_APPEND 236 +#define ID_CHK_SILENT 237 +#define ID_TXT_BALLOON 238 +#define ID_RB_BALLOON0 239 +#define ID_RB_BALLOON1 240 +#define ID_RB_BALLOON2 241 +#define ID_CHK_SHOW_SCRIPT_WIN 242 /* Proxy Auth Dialog */ #define ID_DLG_PROXY_AUTH 250 #define ID_EDT_PROXY_USER 251 #define ID_EDT_PROXY_PASS 252 +/* Advanced dialog */ +#define ID_DLG_ADVANCED 270 +#define ID_TXT_FOLDER 271 +#define ID_TXT_EXTENSION 272 +#define ID_EDT_CONFIG_DIR 274 +#define ID_EDT_CONFIG_EXT 275 +#define ID_EDT_LOG_DIR 276 +#define ID_BTN_CONFIG_DIR 277 +#define ID_BTN_LOG_DIR 278 +#define ID_TXT_PRECONNECT_TIMEOUT 279 +#define ID_TXT_CONNECT_TIMEOUT 280 +#define ID_TXT_DISCONNECT_TIMEOUT 281 +#define ID_EDT_PRECONNECT_TIMEOUT 282 +#define ID_EDT_CONNECT_TIMEOUT 283 +#define ID_EDT_DISCONNECT_TIMEOUT 284 + +/* Connections dialog */ +#define ID_DLG_CONNECTIONS 290 /* * String Table Resources diff --git a/openvpn.c b/openvpn.c index cf8cc71..30b3c22 100644 --- a/openvpn.c +++ b/openvpn.c @@ -170,9 +170,9 @@ OnStateChange(connection_t *c, char *data) MultiByteToWideChar(CP_ACP, 0, local_ip, -1, c->ip, _countof(c->ip)); /* Show connection tray balloon */ - if ((c->state == connecting && o.show_balloon[0] != '0') - || (c->state == resuming && o.show_balloon[0] != '0') - || (c->state == reconnecting && o.show_balloon[0] == '2')) + if ((c->state == connecting && o.show_balloon != 0) + || (c->state == resuming && o.show_balloon != 0) + || (c->state == reconnecting && o.show_balloon == 2)) { TCHAR msg[256]; LoadLocalizedStringBuf(msg, _countof(msg), IDS_NFO_NOW_CONNECTED, c->config_name); @@ -466,7 +466,7 @@ OnStop(connection_t *c, UNUSED char *msg) SetStatusWinIcon(c->hwndStatus, ID_ICO_DISCONNECTED); EnableWindow(GetDlgItem(c->hwndStatus, ID_DISCONNECT), FALSE); EnableWindow(GetDlgItem(c->hwndStatus, ID_RESTART), FALSE); - if (o.silent_connection[0] == '0') + if (o.silent_connection == 0) { SetForegroundWindow(c->hwndStatus); ShowWindow(c->hwndStatus, SW_SHOW); @@ -493,7 +493,7 @@ OnStop(connection_t *c, UNUSED char *msg) EnableWindow(GetDlgItem(c->hwndStatus, ID_RESTART), FALSE); SetStatusWinIcon(c->hwndStatus, ID_ICO_DISCONNECTED); SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(txt_id)); - if (o.silent_connection[0] == '0') + if (o.silent_connection == 0) { SetForegroundWindow(c->hwndStatus); ShowWindow(c->hwndStatus, SW_SHOW); @@ -982,7 +982,7 @@ ThreadOpenVPNStatus(void *p) else wait_event = c->hProcess; - if (o.silent_connection[0] == '0') + if (o.silent_connection == 0) ShowWindow(c->hwndStatus, SW_SHOW); /* Run the message loop for the status window */ @@ -1057,13 +1057,6 @@ StartOpenVPN(connection_t *c) RunPreconnectScript(c); - /* Check that log append flag has a valid value */ - if ((o.append_string[0] != '0') && (o.append_string[0] != '1')) - { - ShowLocalizedMsg(IDS_ERR_LOG_APPEND_BOOL, o.append_string); - return FALSE; - } - /* Create thread to show the connection's status dialog */ hThread = CreateThread(NULL, 0, ThreadOpenVPNStatus, c, CREATE_SUSPENDED, &c->threadId); if (hThread == NULL) @@ -1089,7 +1082,7 @@ StartOpenVPN(connection_t *c) "--setenv IV_GUI_VER \"%S\" --service %s 0 --auth-retry interact " "--management %S %hd stdin --management-query-passwords %s" "--management-hold"), - (o.append_string[0] == '1' ? _T("-append") : _T("")), c->log_path, + (o.log_append ? _T("-append") : _T("")), c->log_path, c->config_file, PACKAGE_STRING, exit_event_name, inet_ntoa(c->manage.skaddr.sin_addr), ntohs(c->manage.skaddr.sin_port), (o.proxy_source != config ? _T("--management-query-proxy ") : _T(""))); diff --git a/openvpn_config.c b/openvpn_config.c index 8d95a00..03e8498 100644 --- a/openvpn_config.c +++ b/openvpn_config.c @@ -3,6 +3,7 @@ * * Copyright (C) 2004 Mathias Sundman * 2010 Heiko Hund + * 2016 Selva Nair * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/options.c b/options.c index 87efe46..454f3a5 100644 --- a/options.c +++ b/options.c @@ -3,6 +3,7 @@ * * Copyright (C) 2004 Mathias Sundman * 2010 Heiko Hund + * 2016 Selva Nair * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,20 +27,56 @@ #endif #include +#include +#include #include #include #include +#include +#include #include "options.h" #include "main.h" #include "openvpn-gui-res.h" #include "localization.h" #include "misc.h" +#include "registry.h" #define streq(x, y) (_tcscmp((x), (y)) == 0) extern options_t o; +static version_t +MakeVersion (short ma, short mi, short b, short r) +{ + version_t v = {ma, mi, b, r}; + return v; +} + +static void +ExpandString (WCHAR *str, int max_len) +{ + WCHAR expanded_string[MAX_PATH]; + int len = ExpandEnvironmentStringsW (str, expanded_string, _countof(expanded_string)); + + if (len > max_len || len > (int) _countof(expanded_string)) + { + PrintDebug (L"Failed to expanded env vars in '%s'. String too long", str); + return; + } + wcsncpy (str, expanded_string, max_len); +} + +void +ExpandOptions (void) +{ + ExpandString (o.exe_path, _countof(o.exe_path)); + ExpandString (o.config_dir, _countof(o.config_dir)); + ExpandString (o.log_dir, _countof(o.log_dir)); + ExpandString (o.editor, _countof(o.editor)); + ExpandString (o.log_viewer, _countof(o.log_viewer)); +} + static int add_option(options_t *options, int i, TCHAR **p) { @@ -87,10 +124,11 @@ add_option(options_t *options, int i, TCHAR **p) ++i; _tcsncpy(options->priority_string, p[1], _countof(options->priority_string) - 1); } - else if (streq(p[0], _T("append_string")) && p[1]) + else if ( (streq(p[0], _T("append_string")) || + streq(p[0], _T("log_append"))) && p[1] ) { ++i; - _tcsncpy(options->append_string, p[1], _countof(options->append_string) - 1); + options->log_append = _ttoi(p[1]) ? 1 : 0; } else if (streq(p[0], _T("log_viewer")) && p[1]) { @@ -125,22 +163,22 @@ add_option(options_t *options, int i, TCHAR **p) else if (streq(p[0], _T("show_balloon")) && p[1]) { ++i; - _tcsncpy(options->show_balloon, p[1], _countof(options->show_balloon) - 1); + options->show_balloon = _ttoi(p[1]); } else if (streq(p[0], _T("service_only")) && p[1]) { ++i; - _tcsncpy(options->service_only, p[1], _countof(options->service_only) - 1); + options->service_only = _ttoi(p[1]) ? 1 : 0; } else if (streq(p[0], _T("show_script_window")) && p[1]) { ++i; - _tcsncpy(options->show_script_window, p[1], _countof(options->show_script_window) - 1); + options->show_script_window = _ttoi(p[1]) ? 1 : 0; } else if (streq(p[0], _T("silent_connection")) && p[1]) { ++i; - _tcsncpy(options->silent_connection, p[1], _countof(options->silent_connection) - 1); + options->silent_connection = _ttoi(p[1]) ? 1 : 0; } else if (streq(p[0], _T("passphrase_attempts")) && p[1]) { @@ -150,17 +188,17 @@ add_option(options_t *options, int i, TCHAR **p) else if (streq(p[0], _T("connectscript_timeout")) && p[1]) { ++i; - _tcsncpy(options->connectscript_timeout_string, p[1], _countof(options->connectscript_timeout_string) - 1); + options->connectscript_timeout = _ttoi(p[1]); } else if (streq(p[0], _T("disconnectscript_timeout")) && p[1]) { ++i; - _tcsncpy(options->disconnectscript_timeout_string, p[1], _countof(options->disconnectscript_timeout_string) - 1); + options->disconnectscript_timeout = _ttoi(p[1]); } else if (streq(p[0], _T("preconnectscript_timeout")) && p[1]) { ++i; - _tcsncpy(options->preconnectscript_timeout_string, p[1], _countof(options->preconnectscript_timeout_string) - 1); + options->preconnectscript_timeout = _ttoi(p[1]); } else { @@ -212,6 +250,7 @@ InitOptions(options_t *opt) { CLEAR(*opt); opt->netcmd_semaphore = InitSemaphore (); + opt->version = MakeVersion (PACKAGE_VERSION_RESOURCE); } @@ -277,6 +316,8 @@ ProcessCommandLine(options_t *options, TCHAR *command_line) parse_argv(options, argc, argv); free(argv); + + ExpandOptions (); } @@ -307,3 +348,186 @@ GetConnByManagement(SOCKET sk) } return NULL; } + +/* callback to set the initial value of folder browse selection */ +static int CALLBACK +BrowseCallback (HWND h, UINT msg, UNUSED LPARAM l, LPARAM data) +{ + if (msg == BFFM_INITIALIZED) + SendMessage (h, BFFM_SETSELECTION, TRUE, data); + + return 0; +} + +static BOOL +BrowseFolder (const WCHAR *initial_path, WCHAR *selected_path) +{ + BOOL ret = false; + BROWSEINFO bi; + + CLEAR(bi); + bi.lpszTitle = L"Select folder..."; + bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + bi.lpfn = BrowseCallback; + bi.lParam = (LPARAM) initial_path; + + PIDLIST_ABSOLUTE idlist = SHBrowseForFolder (&bi); + + if (idlist) + { + ret = SHGetPathFromIDList (idlist, selected_path); + CoTaskMemFree (idlist); + } + + return ret; +} + +static BOOL +CheckAdvancedDlgParams (HWND hdlg) +{ + WCHAR tmp_path[MAX_PATH]; + + /* replace empty entries by current values */ + if (GetWindowTextLength (GetDlgItem(hdlg, ID_EDT_CONFIG_DIR)) == 0) + SetDlgItemText (hdlg, ID_EDT_CONFIG_DIR, o.config_dir); + if (GetWindowTextLength (GetDlgItem(hdlg, ID_EDT_LOG_DIR)) == 0) + SetDlgItemText (hdlg, ID_EDT_LOG_DIR, o.log_dir); + if (GetWindowTextLength (GetDlgItem(hdlg, ID_EDT_CONFIG_EXT)) == 0) + SetDlgItemText (hdlg, ID_EDT_CONFIG_EXT, o.ext_string); + + /* ensure paths are absolute */ + GetDlgItemText (hdlg, ID_EDT_CONFIG_DIR, tmp_path, _countof(tmp_path)); + ExpandString (tmp_path, _countof(tmp_path)); + if (PathIsRelativeW (tmp_path)) + { + MessageBox (NULL, L"Specified config directory is not an absolute path", + L"Option error", MB_OK); + return false; + } + + GetDlgItemText (hdlg, ID_EDT_LOG_DIR, tmp_path, _countof(tmp_path)); + ExpandString (tmp_path, _countof(tmp_path)); + if (PathIsRelativeW (tmp_path)) + { + MessageBox (NULL, L"Specified log directory is not an absolute path", + L"Option error", MB_OK); + return false; + } + return true; +} + +static BOOL +SaveAdvancedDlgParams (HWND hdlg) +{ + WCHAR tmp_path[MAX_PATH], tmp_path1[MAX_PATH]; + UINT tmp; + BOOL status; + + GetDlgItemText (hdlg, ID_EDT_CONFIG_DIR, o.config_dir, _countof(o.config_dir)); + + GetDlgItemText (hdlg, ID_EDT_LOG_DIR, tmp_path, _countof(tmp_path)); + wcsncpy (tmp_path1, tmp_path, _countof(tmp_path1)); + ExpandString (tmp_path1, _countof(tmp_path1)); + + if (EnsureDirExists (tmp_path1)) /* this will try to create the path if needed */ + wcsncpy (o.log_dir, tmp_path, _countof(o.log_dir)); /* save unexpanded path */ + else + { + ShowLocalizedMsg(IDS_ERR_CREATE_PATH, L"Log", tmp_path1); + return false; + } + + GetDlgItemText (hdlg, ID_EDT_CONFIG_EXT, o.ext_string, _countof(o.ext_string)); + + tmp = GetDlgItemInt (hdlg, ID_EDT_PRECONNECT_TIMEOUT, &status, FALSE); + if (status && tmp > 0) o.preconnectscript_timeout = tmp; + + tmp = GetDlgItemInt (hdlg, ID_EDT_CONNECT_TIMEOUT, &status, FALSE); + if (status) o.connectscript_timeout = tmp; + + tmp = GetDlgItemInt (hdlg, ID_EDT_DISCONNECT_TIMEOUT, &status, FALSE); + if (status && tmp > 0) o.disconnectscript_timeout = tmp; + + SaveRegistryKeys (); + ExpandOptions (); + + return true; +} + +static void +LoadAdvancedDlgParams (HWND hdlg) +{ + SetDlgItemText (hdlg, ID_EDT_CONFIG_DIR, o.config_dir); + SetDlgItemText (hdlg, ID_EDT_CONFIG_EXT, o.ext_string); + SetDlgItemText (hdlg, ID_EDT_LOG_DIR, o.log_dir); + SetDlgItemInt (hdlg, ID_EDT_PRECONNECT_TIMEOUT, o.preconnectscript_timeout, FALSE); + SetDlgItemInt (hdlg, ID_EDT_CONNECT_TIMEOUT, o.connectscript_timeout, FALSE); + SetDlgItemInt (hdlg, ID_EDT_DISCONNECT_TIMEOUT, o.disconnectscript_timeout, FALSE); +} + +INT_PTR CALLBACK +AdvancedSettingsDlgProc (HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam) +{ + LPPSHNOTIFY psn; + + switch(msg) { + + case WM_INITDIALOG: + /* Limit extension editbox to 4 chars. */ + SendMessage (GetDlgItem(hwndDlg, ID_EDT_CONFIG_EXT), EM_SETLIMITTEXT, 4, 0); + /* Populate UI */ + LoadAdvancedDlgParams (hwndDlg); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + WCHAR path[MAX_PATH]; + + case ID_BTN_CONFIG_DIR: + GetDlgItemText (hwndDlg, ID_EDT_CONFIG_DIR, path, _countof(path)); + if (BrowseFolder (path, path)) + SetDlgItemText (hwndDlg, ID_EDT_CONFIG_DIR, path); + break; + + case ID_BTN_LOG_DIR: + GetDlgItemText (hwndDlg, ID_EDT_LOG_DIR, path, _countof(path)); + if (BrowseFolder (path, path)) + SetDlgItemText (hwndDlg, ID_EDT_LOG_DIR, path); + break; + } + break; + + case WM_NOTIFY: + psn = (LPPSHNOTIFY) lParam; + if (psn->hdr.code == (UINT) PSN_KILLACTIVE) + { + SetWindowLongPtr (hwndDlg, DWLP_MSGRESULT, (CheckAdvancedDlgParams(hwndDlg) ? FALSE : TRUE)); + return TRUE; + } + if (psn->hdr.code == (UINT) PSN_APPLY) + { + BOOL status = SaveAdvancedDlgParams (hwndDlg); + SetWindowLongPtr (hwndDlg, DWLP_MSGRESULT, status? PSNRET_NOERROR:PSNRET_INVALID); + return TRUE; + } + break; + } + + return FALSE; +} + +int +CompareStringExpanded (const WCHAR *str1, const WCHAR *str2) +{ + WCHAR str1_cpy[MAX_PATH], str2_cpy[MAX_PATH]; + + wcsncpy (str1_cpy, str1, _countof(str1_cpy)); + wcsncpy (str2_cpy, str2, _countof(str2_cpy)); + str1_cpy[MAX_PATH-1] = L'\0'; + str2_cpy[MAX_PATH-1] = L'\0'; + + ExpandString (str1_cpy, _countof(str1_cpy)); + ExpandString (str2_cpy, _countof(str2_cpy)); + + return wcsicmp (str1_cpy, str2_cpy); +} diff --git a/options.h b/options.h index 19904ef..0910e64 100644 --- a/options.h +++ b/options.h @@ -3,6 +3,7 @@ * * Copyright (C) 2004 Mathias Sundman * 2010 Heiko Hund + * 2016 Selva Nair * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,6 +87,10 @@ typedef struct { #define FLAG_SAVE_AUTH_PASS 1<<5 #define ALLOW_CHANGE_PASSPHRASE (1<<1) +typedef struct { + unsigned short major, minor, build, revision; +} version_t; + /* Connections parameters */ struct connection { TCHAR config_file[MAX_PATH]; /* Name of the config file */ @@ -129,9 +134,6 @@ typedef struct { int num_configs; /* Number of configs */ service_state_t service_state; /* State of the OpenVPN Service */ - int connectscript_timeout; /* Connect Script execution timeout (sec) */ - int disconnectscript_timeout; /* Disconnect Script execution timeout (sec) */ - int preconnectscript_timeout; /* Preconnect Script execution timeout (sec) */ /* Proxy Settings */ proxy_source_t proxy_source; /* Where to get proxy information from */ @@ -150,16 +152,16 @@ typedef struct { TCHAR config_dir[MAX_PATH]; TCHAR ext_string[16]; TCHAR log_dir[MAX_PATH]; - TCHAR append_string[2]; + DWORD log_append; TCHAR log_viewer[MAX_PATH]; TCHAR editor[MAX_PATH]; - TCHAR silent_connection[2]; - TCHAR service_only[2]; - TCHAR show_balloon[2]; - TCHAR show_script_window[2]; - TCHAR connectscript_timeout_string[4]; - TCHAR disconnectscript_timeout_string[4]; - TCHAR preconnectscript_timeout_string[4]; + DWORD silent_connection; + DWORD service_only; + DWORD show_balloon; + DWORD show_script_window; + DWORD connectscript_timeout; /* Connect Script execution timeout (sec) */ + DWORD disconnectscript_timeout; /* Disconnect Script execution timeout (sec) */ + DWORD preconnectscript_timeout; /* Preconnect Script execution timeout (sec) */ #ifdef DEBUG FILE *debug_fp; @@ -169,10 +171,17 @@ typedef struct { HINSTANCE hInstance; BOOL session_locked; HANDLE netcmd_semaphore; + version_t version; } options_t; void InitOptions(options_t *); void ProcessCommandLine(options_t *, TCHAR *); int CountConnState(conn_state_t); connection_t* GetConnByManagement(SOCKET); +INT_PTR CALLBACK ScriptSettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK ConnectionSettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK AdvancedSettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +void ExpandOptions(void); +int CompareStringExpanded(const WCHAR *str1, const WCHAR *str2); #endif diff --git a/proxy.c b/proxy.c index 574a495..de4fcb4 100644 --- a/proxy.c +++ b/proxy.c @@ -224,6 +224,7 @@ SaveProxySettings(HWND hwndDlg) DWORD dwDispos; TCHAR proxy_source_string[2] = _T("0"); TCHAR proxy_type_string[2] = _T("0"); + TCHAR proxy_subkey[MAX_PATH]; /* Save Proxy Settings Source */ if (IsDlgButtonChecked(hwndDlg, ID_RB_PROXY_OPENVPN) == BST_CHECKED) @@ -265,11 +266,12 @@ SaveProxySettings(HWND hwndDlg) } /* Open Registry for writing */ - if (RegCreateKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, _T(""), REG_OPTION_NON_VOLATILE, + _sntprintf_0(proxy_subkey, _T("%s\\proxy"), GUI_REGKEY_HKCU); + if (RegCreateKeyEx(HKEY_CURRENT_USER, proxy_subkey, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®key, &dwDispos) != ERROR_SUCCESS) { /* error creating Registry-Key */ - ShowLocalizedMsg(IDS_ERR_CREATE_REG_HKCU_KEY, GUI_REGKEY_HKCU); + ShowLocalizedMsg(IDS_ERR_CREATE_REG_HKCU_KEY, proxy_subkey); return; } @@ -292,9 +294,11 @@ GetProxyRegistrySettings() HKEY regkey; TCHAR proxy_source_string[2] = _T("0"); TCHAR proxy_type_string[2] = _T("0"); + TCHAR proxy_subkey[MAX_PATH]; /* Open Registry for reading */ - status = RegOpenKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, KEY_READ, ®key); + _sntprintf_0(proxy_subkey, _T("%s\\proxy"), GUI_REGKEY_HKCU); + status = RegOpenKeyEx(HKEY_CURRENT_USER, proxy_subkey, 0, KEY_READ, ®key); if (status != ERROR_SUCCESS) return; diff --git a/registry.c b/registry.c index 569a475..9f6d6cb 100644 --- a/registry.c +++ b/registry.c @@ -2,6 +2,7 @@ * OpenVPN-GUI -- A Windows GUI for OpenVPN. * * Copyright (C) 2004 Mathias Sundman + * 2016 Selva Nair * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,25 +37,42 @@ extern options_t o; -static void -ExpandString (WCHAR *str, int max_len) -{ - WCHAR expanded_string[MAX_PATH]; - int len = ExpandEnvironmentStringsW(str, expanded_string, _countof(expanded_string)); +struct regkey_str { + const WCHAR *name; + WCHAR *var; + int len; + const WCHAR *value; +} regkey_str[] = { + {L"config_dir", o.config_dir, _countof(o.config_dir), L"%USERPROFILE%\\OpenVPN\\config"}, + {L"config_ext", o.ext_string, _countof(o.ext_string), L"ovpn"}, + {L"log_dir", o.log_dir, _countof(o.log_dir), L"%USERPROFILE%\\OpenVPN\\log"} + }; - if (len > max_len || len > (int) _countof(expanded_string)) - { - PrintDebug (L"Failed to expanded env vars in '%s'. String too long", str); - return; - } - wcsncpy(str, expanded_string, max_len); +struct regkey_int { + const WCHAR *name; + DWORD *var; + DWORD value; +} regkey_int[] = { + {L"log_append", &o.log_append, 0}, + {L"show_balloon", &o.show_balloon, 1}, + {L"silent_connection", &o.silent_connection, 0}, + {L"preconnectscript_timeout", &o.preconnectscript_timeout, 10}, + {L"connectscript_timeout", &o.connectscript_timeout, 30}, + {L"disconnectscript_timeout", &o.disconnectscript_timeout, 10}, + {L"show_script_window", &o.show_script_window, 0}, + {L"service_only", &o.service_only, 0} + }; + +static int +RegValueExists (HKEY regkey, const WCHAR *name) +{ + return (RegQueryValueEx (regkey, name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS); } -int -GetRegistryKeys() +static int +GetGlobalRegistryKeys() { TCHAR windows_dir[MAX_PATH]; - TCHAR temp_path[MAX_PATH]; TCHAR openvpn_path[MAX_PATH]; TCHAR profile_dir[MAX_PATH]; HKEY regkey; @@ -72,7 +90,7 @@ GetRegistryKeys() /* Get path to OpenVPN installation. */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\OpenVPN"), 0, KEY_READ, ®key) - != ERROR_SUCCESS) + != ERROR_SUCCESS) { /* registry key not found */ ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY); @@ -100,165 +118,231 @@ GetRegistryKeys() _tcsncpy(o.ovpn_admin_group, OVPN_ADMIN_GROUP, _countof(o.ovpn_admin_group)-1); } - if (o.exe_path[0] != L'\0') /* set by cmd-line */ - ExpandString (o.exe_path, _countof(o.exe_path)); - else if (!GetRegistryValue(regkey, _T("exe_path"), o.exe_path, _countof(o.exe_path))) + if (!GetRegistryValue(regkey, _T("exe_path"), o.exe_path, _countof(o.exe_path))) { _sntprintf_0(o.exe_path, _T("%sbin\\openvpn.exe"), openvpn_path); } - if (o.priority_string[0] != L'\0') /* set by cmd-line */ - ExpandString (o.priority_string, _countof(o.priority_string)); if (!GetRegistryValue(regkey, _T("priority"), o.priority_string, _countof(o.priority_string))) { _tcsncpy(o.priority_string, _T("NORMAL_PRIORITY_CLASS"), _countof(o.priority_string)-1); } RegCloseKey(regkey); - - /* user-sepcific config_dir in user's profile by default */ - _sntprintf_0(temp_path, _T("%s\\OpenVPN\\config"), profile_dir); - if (!GetRegKey(_T("config_dir"), o.config_dir, - temp_path, _countof(o.config_dir))) return(false); - - if (!GetRegKey(_T("config_ext"), o.ext_string, _T("ovpn"), _countof(o.ext_string))) return(false); - - _sntprintf_0(temp_path, _T("%s\\OpenVPN\\log"), profile_dir); - if (!GetRegKey(_T("log_dir"), o.log_dir, - temp_path, _countof(o.log_dir))) return(false); - - if (!GetRegKey(_T("log_append"), o.append_string, _T("0"), _countof(o.append_string))) return(false); - - if (o.editor[0] != L'\0') /* set by cmd-line */ - ExpandString (o.editor, _countof(o.editor)); - else - _sntprintf_0(o.editor, _T("%s\\system32\\notepad.exe"), windows_dir); - - if (o.log_viewer[0] != L'\0') /* set by cmd-line */ - ExpandString (o.log_viewer, _countof(o.log_viewer)); - else - _sntprintf_0(o.log_viewer, _T("%s\\system32\\notepad.exe"), windows_dir); - - if (!GetRegKey(_T("service_only"), o.service_only, _T("0"), _countof(o.service_only))) return(false); - - if (!GetRegKey(_T("show_balloon"), o.show_balloon, _T("1"), _countof(o.show_balloon))) return(false); - - if (!GetRegKey(_T("silent_connection"), o.silent_connection, _T("0"), _countof(o.silent_connection))) return(false); - - if (!GetRegKey(_T("show_script_window"), o.show_script_window, _T("1"), _countof(o.show_script_window))) return(false); - - if (!GetRegKey(_T("connectscript_timeout"), o.connectscript_timeout_string, _T("15"), - _countof(o.connectscript_timeout_string))) return(false); - o.connectscript_timeout = _ttoi(o.connectscript_timeout_string); - if ((o.connectscript_timeout < 0) || (o.connectscript_timeout > 99)) - { - /* 0 <= connectscript_timeout <= 99 */ - ShowLocalizedMsg(IDS_ERR_CONN_SCRIPT_TIMEOUT); - return(false); - } - - if (!GetRegKey(_T("disconnectscript_timeout"), o.disconnectscript_timeout_string, _T("10"), - _countof(o.disconnectscript_timeout_string))) return(false); - o.disconnectscript_timeout = _ttoi(o.disconnectscript_timeout_string); - if ((o.disconnectscript_timeout <= 0) || (o.disconnectscript_timeout > 99)) - { - /* 0 < disconnectscript_timeout <= 99 */ - ShowLocalizedMsg(IDS_ERR_DISCONN_SCRIPT_TIMEOUT); - return(false); - } - - if (!GetRegKey(_T("preconnectscript_timeout"), o.preconnectscript_timeout_string, _T("10"), - _countof(o.preconnectscript_timeout_string))) return(false); - o.preconnectscript_timeout = _ttoi(o.preconnectscript_timeout_string); - if ((o.preconnectscript_timeout <= 0) || (o.preconnectscript_timeout > 99)) - { - /* 0 < disconnectscript_timeout <= 99 */ - ShowLocalizedMsg(IDS_ERR_PRECONN_SCRIPT_TIMEOUT); - return(false); - } - - return(true); + return true; } - -int GetRegKey(const TCHAR name[], TCHAR *data, const TCHAR default_data[], DWORD len) +int +GetRegistryKeys () { - LONG status; - DWORD type; - HKEY openvpn_key; - HKEY openvpn_key_write; - DWORD dwDispos; - DWORD size = len * sizeof(*data); - DWORD max_len = len - 1; + HKEY regkey; + DWORD status; + int i; - /* If option is already set via cmd-line, return */ - if (data[0] != 0) + if (!GetGlobalRegistryKeys()) + return false; + + status = RegOpenKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, KEY_READ, ®key); + + for (i = 0 ; i < (int) _countof (regkey_str); ++i) { - ExpandString (data, len); - return(true); - } - - status = RegOpenKeyEx(HKEY_CURRENT_USER, - _T("SOFTWARE\\OpenVPN-GUI"), - 0, - KEY_READ, - &openvpn_key); - - if (status != ERROR_SUCCESS) - { - if (RegCreateKeyEx(HKEY_CURRENT_USER, - _T("Software\\OpenVPN-GUI"), - 0, - _T(""), - REG_OPTION_NON_VOLATILE, - KEY_READ | KEY_WRITE, - NULL, - &openvpn_key, - &dwDispos) != ERROR_SUCCESS) + if ( status != ERROR_SUCCESS || + !GetRegistryValue (regkey, regkey_str[i].name, regkey_str[i].var, regkey_str[i].len)) { - /* error creating registry key */ - ShowLocalizedMsg(IDS_ERR_CREATE_REG_HKCU_KEY, _T("OpenVPN-GUI")); - return(false); - } - } - - - /* get a registry string */ - status = RegQueryValueEx(openvpn_key, name, NULL, &type, (byte *) data, &size); - if (status != ERROR_SUCCESS || type != REG_SZ) - { - /* key did not exist - set default value */ - status = RegOpenKeyEx(HKEY_CURRENT_USER, - _T("SOFTWARE\\OpenVPN-GUI"), - 0, - KEY_READ | KEY_WRITE, - &openvpn_key_write); - - if (status != ERROR_SUCCESS) { - /* can't open registry for writing */ - ShowLocalizedMsg(IDS_ERR_WRITE_REGVALUE, _T("OpenVPN-GUI"), name); - return(false); - } - if(!SetRegistryValue(openvpn_key_write, name, default_data)) - { - /* cant read / set reg-key */ - return(false); + /* no value found in registry, use the default */ + wcsncpy (regkey_str[i].var, regkey_str[i].value, regkey_str[i].len); + regkey_str[i].var[regkey_str[i].len-1] = L'\0'; + PrintDebug(L"default: %s = %s", regkey_str[i].name, regkey_str[i].var); } - _tcsncpy(data, default_data, max_len); - RegCloseKey(openvpn_key_write); - + else + PrintDebug(L"from registry: %s = %s", regkey_str[i].name, regkey_str[i].var); } - else + + for (i = 0 ; i < (int) _countof (regkey_int); ++i) { - size /= sizeof(*data); - data[size - 1] = L'\0'; /* REG_SZ strings are not guaranteed to be null-terminated */ + if ( status != ERROR_SUCCESS || + !GetRegistryValueNumeric (regkey, regkey_int[i].name, regkey_int[i].var)) + { + /* no value found in registry, use the default */ + *regkey_int[i].var = regkey_int[i].value; + PrintDebug(L"default: %s = %lu", regkey_int[i].name, *regkey_int[i].var); + } + else + PrintDebug(L"from registry: %s = %lu", regkey_int[i].name, *regkey_int[i].var); } - RegCloseKey(openvpn_key); + if ( status != ERROR_SUCCESS) + RegCloseKey (regkey); - // Expand environment variables inside the string. - ExpandString (data, len); + if ((o.disconnectscript_timeout == 0)) + { + ShowLocalizedMsg(IDS_ERR_DISCONN_SCRIPT_TIMEOUT); + o.disconnectscript_timeout = 10; + } + if ((o.preconnectscript_timeout == 0)) + { + ShowLocalizedMsg(IDS_ERR_PRECONN_SCRIPT_TIMEOUT); + o.preconnectscript_timeout = 10; + } - return(true); + ExpandOptions (); + return true; +} + +int +SaveRegistryKeys () +{ + HKEY regkey; + DWORD status; + int i; + + status = RegCreateKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE|KEY_READ, NULL, ®key, NULL); + if (status != ERROR_SUCCESS) + { + ShowLocalizedMsg (IDS_ERR_CREATE_REG_HKCU_KEY, GUI_REGKEY_HKCU); + return false; + } + for (i = 0 ; i < (int) _countof (regkey_str); ++i) + { + /* save only if the value differs from default or already present in registry */ + if ( CompareStringExpanded (regkey_str[i].var, regkey_str[i].value) != 0 || + RegValueExists(regkey, regkey_str[i].name) ) + { + if (!SetRegistryValue (regkey, regkey_str[i].name, regkey_str[i].var)) + return false; + } + } + + for (i = 0 ; i < (int) _countof (regkey_int); ++i) + { + if ( *regkey_int[i].var != regkey_int[i].value || + RegValueExists(regkey, regkey_int[i].name) ) + { + if (!SetRegistryValueNumeric (regkey, regkey_int[i].name, *regkey_int[i].var)) + return false; + } + } + + RegCloseKey (regkey); + + return true; +} + +static BOOL +GetRegistryVersion (version_t *v) +{ + HKEY regkey; + CLEAR (*v); + DWORD len = sizeof(*v); + + if (RegOpenKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, KEY_READ, ®key) == ERROR_SUCCESS) + { + if (RegGetValueW (regkey, NULL, L"version", RRF_RT_REG_BINARY, NULL, v, &len) + != ERROR_SUCCESS) + CLEAR (*v); + RegCloseKey(regkey); + } + return true; +} + +static BOOL +SetRegistryVersion (const version_t *v) +{ + HKEY regkey; + DWORD status; + BOOL ret = false; + + status = RegCreateKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WRITE, NULL, ®key, NULL); + if (status == ERROR_SUCCESS) + { + ret = (RegSetValueEx(regkey, L"version", 0, REG_BINARY, (const BYTE*) v, sizeof(*v)) + != ERROR_SUCCESS); + RegCloseKey(regkey); + } + else + PrintDebug (L"Eror opening/creating 'HKCU\\%s' registry key", GUI_REGKEY_HKCU); + return ret; +} + +static int +MigrateNilingsKeys() +{ + DWORD status; + BOOL ret = false; + HKEY regkey, regkey_proxy, regkey_nilings; + + status = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Nilings\\OpenVPN-GUI", 0, + KEY_READ, ®key_nilings); + if (status != ERROR_SUCCESS) + return true; /* No old keys to migrate */ + + status = RegCreateKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, ®key, NULL); + if (status != ERROR_SUCCESS) + { + ShowLocalizedMsg (IDS_ERR_CREATE_REG_HKCU_KEY, GUI_REGKEY_HKCU); + RegCloseKey (regkey_nilings); + return false; + } + + /* For some reason this needs ALL_ACCESS for the CopyTree below to work */ + status = RegCreateKeyEx(regkey, L"proxy", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, ®key_proxy, NULL); + if (status == ERROR_SUCCESS) + { + DWORD ui_lang; + /* Move language setting from Nilings to GUI_REGKEY_HKCU */ + if (GetRegistryValueNumeric(regkey_nilings, L"ui_language", &ui_lang)) + SetRegistryValueNumeric (regkey, L"ui_language", ui_lang); + + status = RegCopyTree (regkey_nilings, NULL, regkey_proxy); + if (status == ERROR_SUCCESS) + { + RegDeleteValue (regkey_proxy, L"ui_language"); /* in case copied here */ + ret = true; + } + RegCloseKey (regkey_proxy); + } + else + PrintDebug (L"Error creating key 'proxy' in HKCU\\%s", GUI_REGKEY_HKCU); + + RegCloseKey (regkey); + RegCloseKey (regkey_nilings); + + return ret; +} + +int +UpdateRegistry (void) +{ + version_t v; + + GetRegistryVersion (&v); + + if (memcmp(&v, &o.version, sizeof(v)) == 0) + return true; + + switch (v.major) + { + case 0: /* Cleanup GUI_REGKEY_HKCU and migrate any values under Nilings */ + + RegDeleteTree (HKEY_CURRENT_USER, GUI_REGKEY_HKCU); /* delete all values and subkeys */ + + if (!MigrateNilingsKeys()) + return false; + /* fall through to handle further updates */ + case 11: + /* current version -- nothing to do */ + break; + default: + break; + } + + SetRegistryVersion (&o.version); + PrintDebug (L"Registry updated to version %hu.%hu", o.version.major, o.version.minor); + + return true; } LONG GetRegistryValue(HKEY regkey, const TCHAR *name, TCHAR *data, DWORD len) @@ -287,7 +371,7 @@ GetRegistryValueNumeric(HKEY regkey, const TCHAR *name, DWORD *data) DWORD type; DWORD size = sizeof(*data); LONG status = RegQueryValueEx(regkey, name, NULL, &type, (PBYTE) data, &size); - return (type == REG_DWORD ? status : ERROR_FILE_NOT_FOUND); + return (type == REG_DWORD && status == ERROR_SUCCESS) ? 1 : 0; } int SetRegistryValue(HKEY regkey, const TCHAR *name, const TCHAR *data) diff --git a/registry.h b/registry.h index 9a415e5..272e7c0 100644 --- a/registry.h +++ b/registry.h @@ -22,7 +22,9 @@ #ifndef REGISTRY_H #define REGISTRY_H -int GetRegistryKeys(); +int GetRegistryKeys(void); +int SaveRegistryKeys(void); +int UpdateRegistry(void); int GetRegKey(const TCHAR name[], TCHAR data[], const TCHAR default_data[], DWORD len); LONG GetRegistryValue(HKEY regkey, const TCHAR *name, TCHAR *data, DWORD len); LONG GetRegistryValueNumeric(HKEY regkey, const TCHAR *name, DWORD *data); diff --git a/res/openvpn-gui-res-de.rc b/res/openvpn-gui-res-de.rc index 4d566da..1b30a94 100644 --- a/res/openvpn-gui-res-de.rc +++ b/res/openvpn-gui-res-de.rc @@ -135,6 +135,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 51, 23, 177, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-dk.rc b/res/openvpn-gui-res-dk.rc index 732b410..9da656d 100644 --- a/res/openvpn-gui-res-dk.rc +++ b/res/openvpn-gui-res-dk.rc @@ -136,6 +136,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_DANISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-en.rc b/res/openvpn-gui-res-en.rc index 0180e96..e5596da 100644 --- a/res/openvpn-gui-res-en.rc +++ b/res/openvpn-gui-res-en.rc @@ -133,8 +133,48 @@ BEGIN GROUPBOX "User Interface", 201, 6, 12, 235, 30 LTEXT "Language:", ID_TXT_LANGUAGE, 17, 25, 52, 12 COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP + GROUPBOX "Startup", 202, 6, 47, 235, 30 - AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 100, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-es.rc b/res/openvpn-gui-res-es.rc index 7c61615..c10e6f4 100644 --- a/res/openvpn-gui-res-es.rc +++ b/res/openvpn-gui-res-es.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 45, 23, 183, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-fi.rc b/res/openvpn-gui-res-fi.rc index 50cb38c..ad6cdee 100644 --- a/res/openvpn-gui-res-fi.rc +++ b/res/openvpn-gui-res-fi.rc @@ -136,6 +136,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-fr.rc b/res/openvpn-gui-res-fr.rc index 72b79fa..74ecc01 100644 --- a/res/openvpn-gui-res-fr.rc +++ b/res/openvpn-gui-res-fr.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 47, 23, 181, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_FRENCH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-it.rc b/res/openvpn-gui-res-it.rc index e6281a5..a574a39 100644 --- a/res/openvpn-gui-res-it.rc +++ b/res/openvpn-gui-res-it.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 43, 23, 185, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_ITALIAN, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-jp.rc b/res/openvpn-gui-res-jp.rc index 7eadeb2..27c5e94 100644 --- a/res/openvpn-gui-res-jp.rc +++ b/res/openvpn-gui-res-jp.rc @@ -137,6 +137,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 39, 23, 189, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "ログファイルに追記", ID_CHK_LOG_APPEND, 17, 95, 200, 10 + AUTOCHECKBOX "スクリプト実行ウィンドウを表示する", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "接続時にステータスダイアログを表示しない", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "初期接続時", ID_RB_BALLOON1, 22, 155, 60, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "毎回の接続時", ID_RB_BALLOON2, 96, 155, 90, 10 + AUTORADIOBUTTON "表示しない", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT +BEGIN + GROUPBOX "設定ファイル", 201, 6, 12, 235, 45 + LTEXT "ディレクトリ:", ID_TXT_FOLDER, 17, 25, 52, 10 + LTEXT "拡張子:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 58, 23, 145, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 58, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "ログファイル", 202, 6, 62, 235, 30 + LTEXT "ディレクトリ:", ID_TXT_FOLDER, 17, 74, 52, 10 + EDITTEXT ID_EDT_LOG_DIR, 58, 72, 145, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "スクリプトの終了を待つ時間", 201, 6, 97, 235, 60 + LTEXT "接続前スクリプト:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 120, 10 + LTEXT "接続スクリプト:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 120, 10 + LTEXT "切断スクリプト:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 120, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 143, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 143, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 143, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "サービスのみのモードを有効にする", ID_CHK_SERVICE_ONLY, 6, 162, 200, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-nl.rc b/res/openvpn-gui-res-nl.rc index 66512a6..65aa0cb 100644 --- a/res/openvpn-gui-res-nl.rc +++ b/res/openvpn-gui-res-nl.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Opstarten", 202, 6, 47, 235, 30 AUTOCHECKBOX "Opstarten met Windows", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_DUTCH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-no.rc b/res/openvpn-gui-res-no.rc index c3b6b23..4312577 100644 --- a/res/openvpn-gui-res-no.rc +++ b/res/openvpn-gui-res-no.rc @@ -135,6 +135,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_NORWEGIAN, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-pl.rc b/res/openvpn-gui-res-pl.rc index e97c41e..9ff5c6f 100644 --- a/res/openvpn-gui-res-pl.rc +++ b/res/openvpn-gui-res-pl.rc @@ -136,6 +136,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-pt.rc b/res/openvpn-gui-res-pt.rc index 035969a..cffbaa5 100644 --- a/res/openvpn-gui-res-pt.rc +++ b/res/openvpn-gui-res-pt.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Inicialização", 202, 6, 47, 235, 30 AUTOCHECKBOX "Executar ao iniciar o Windows", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_PORTUGUESE, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-ru.rc b/res/openvpn-gui-res-ru.rc index e274970..3502c18 100644 --- a/res/openvpn-gui-res-ru.rc +++ b/res/openvpn-gui-res-ru.rc @@ -136,6 +136,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-se.rc b/res/openvpn-gui-res-se.rc index d3e0db9..3e9f3f0 100644 --- a/res/openvpn-gui-res-se.rc +++ b/res/openvpn-gui-res-se.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-tr.rc b/res/openvpn-gui-res-tr.rc index da6c668..da3ceb1 100644 --- a/res/openvpn-gui-res-tr.rc +++ b/res/openvpn-gui-res-tr.rc @@ -136,6 +136,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 31, 23, 197, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/res/openvpn-gui-res-ua.rc b/res/openvpn-gui-res-ua.rc index 07c2dd3..d8070f9 100644 --- a/res/openvpn-gui-res-ua.rc +++ b/res/openvpn-gui-res-ua.rc @@ -134,6 +134,45 @@ BEGIN COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "Startup", 202, 6, 47, 235, 30 AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12 + + GROUPBOX "Preferences", 202, 6, 82, 235, 90 + AUTOCHECKBOX "Append to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10 + AUTOCHECKBOX "Show script window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10 + AUTOCHECKBOX "Silent connection", ID_CHK_SILENT, 17, 125, 200, 10 + LTEXT "Show Balloon", ID_TXT_BALLOON, 17, 140, 100, 10 + AUTORADIOBUTTON "On connect", ID_RB_BALLOON1, 28, 155, 50, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "On connect/reconnect", ID_RB_BALLOON2, 86, 155, 90, 10 + AUTORADIOBUTTON "Never", ID_RB_BALLOON0, 181, 155, 40, 10 +END + +/* Advanced Dialog */ +ID_DLG_ADVANCED DIALOGEX 6, 18, 252, 218 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "Advanced" +FONT 8, "Microsoft Sans Serif" +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT +BEGIN + GROUPBOX "Configuration Files", 201, 6, 12, 235, 45 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 25, 32, 10 + LTEXT "Extension:", ID_TXT_EXTENSION, 17, 40, 52, 10 + EDITTEXT ID_EDT_CONFIG_DIR, 53, 23, 150, 12, ES_AUTOHSCROLL + EDITTEXT ID_EDT_CONFIG_EXT, 53, 38, 25, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_CONFIG_DIR, 208, 23, 25, 12 + + GROUPBOX "Log Files", 202, 6, 62, 235, 30 + LTEXT "Folder:", ID_TXT_FOLDER, 17, 74, 32, 10 + EDITTEXT ID_EDT_LOG_DIR, 53, 72, 150, 12, ES_AUTOHSCROLL + PUSHBUTTON "…", ID_BTN_LOG_DIR, 208, 72, 25, 12 + + GROUPBOX "Script Timeout", 201, 6, 97, 235, 60 + LTEXT "Preconnect script timeout:", ID_TXT_PRECONNECT_TIMEOUT, 17, 110, 100, 10 + LTEXT "Connect script timeout:", ID_TXT_CONNECT_TIMEOUT, 17, 125, 90, 10 + LTEXT "Disconnect script timeout:", ID_TXT_DISCONNECT_TIMEOUT, 17, 140, 90, 10 + EDITTEXT ID_EDT_PRECONNECT_TIMEOUT, 103, 108, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_CONNECT_TIMEOUT, 103, 123, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + EDITTEXT ID_EDT_DISCONNECT_TIMEOUT, 103, 138, 20, 12, ES_AUTOHSCROLL|ES_NUMBER + + AUTOCHECKBOX "Service only", ID_CHK_SERVICE_ONLY, 6, 162, 100, 12 END /* About Dialog */ diff --git a/scripts.c b/scripts.c index 3c8ca69..3c77f0e 100644 --- a/scripts.c +++ b/scripts.c @@ -69,11 +69,11 @@ RunPreconnectScript(connection_t *c) si.hStdOutput = NULL; if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, - (o.show_script_window[0] == '1' ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW), + (o.show_script_window ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW), NULL, c->config_dir, &si, &pi)) return; - for (i = 0; i <= o.preconnectscript_timeout; i++) + for (i = 0; i <= (int) o.preconnectscript_timeout; i++) { if (!GetExitCodeProcess(pi.hProcess, &exit_code)) goto out; @@ -122,7 +122,7 @@ RunConnectScript(connection_t *c, int run_as_service) si.hStdOutput = NULL; if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, - (o.show_script_window[0] == '1' ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW), + (o.show_script_window ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW), NULL, c->config_dir, &si, &pi)) { ShowLocalizedMsg(IDS_ERR_RUN_CONN_SCRIPT, cmdline); @@ -132,7 +132,7 @@ RunConnectScript(connection_t *c, int run_as_service) if (o.connectscript_timeout == 0) goto out; - for (i = 0; i <= o.connectscript_timeout; i++) + for (i = 0; i <= (int) o.connectscript_timeout; i++) { if (!GetExitCodeProcess(pi.hProcess, &exit_code)) { @@ -191,11 +191,11 @@ RunDisconnectScript(connection_t *c, int run_as_service) si.hStdOutput = NULL; if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, - (o.show_script_window[0] == '1' ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW), + (o.show_script_window ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW), NULL, c->config_dir, &si, &pi)) return; - for (i = 0; i <= o.disconnectscript_timeout; i++) + for (i = 0; i <= (int) o.disconnectscript_timeout; i++) { if (!GetExitCodeProcess(pi.hProcess, &exit_code)) goto out; diff --git a/tray.c b/tray.c index bcc75b6..4eaf1e0 100644 --- a/tray.c +++ b/tray.c @@ -60,7 +60,7 @@ CreatePopupMenus() if (o.num_configs == 1) { /* Create Main menu with actions */ - if (o.service_only[0] == '0') { + if (o.service_only == 0) { AppendMenu(hMenu, MF_STRING, IDM_CONNECTMENU, LoadLocalizedString(IDS_MENU_CONNECT)); AppendMenu(hMenu, MF_STRING, IDM_DISCONNECTMENU, LoadLocalizedString(IDS_MENU_DISCONNECT)); AppendMenu(hMenu, MF_STRING, IDM_STATUSMENU, LoadLocalizedString(IDS_MENU_STATUS)); @@ -100,7 +100,7 @@ CreatePopupMenus() if (o.num_configs > 0) AppendMenu(hMenu, MF_SEPARATOR, 0, 0); - if (o.service_only[0] == '1') { + if (o.service_only) { AppendMenu(hMenu, MF_STRING, IDM_SERVICE_START, LoadLocalizedString(IDS_MENU_SERVICEONLY_START)); AppendMenu(hMenu, MF_STRING, IDM_SERVICE_STOP, LoadLocalizedString(IDS_MENU_SERVICEONLY_STOP)); AppendMenu(hMenu, MF_STRING, IDM_SERVICE_RESTART, LoadLocalizedString(IDS_MENU_SERVICEONLY_RESTART)); @@ -114,7 +114,7 @@ CreatePopupMenus() /* Create popup menus for every connection */ for (i=0; i < o.num_configs; i++) { - if (o.service_only[0] == '0') { + if (o.service_only == 0) { AppendMenu(hMenuConn[i], MF_STRING, IDM_CONNECTMENU + i, LoadLocalizedString(IDS_MENU_CONNECT)); AppendMenu(hMenuConn[i], MF_STRING, IDM_DISCONNECTMENU + i, LoadLocalizedString(IDS_MENU_DISCONNECT)); AppendMenu(hMenuConn[i], MF_STRING, IDM_STATUSMENU + i, LoadLocalizedString(IDS_MENU_STATUS)); @@ -174,7 +174,7 @@ OnNotifyTray(LPARAM lParam) break; case WM_LBUTTONDBLCLK: - if (o.service_only[0] == '1') { + if (o.service_only) { /* Start or stop OpenVPN service */ if (o.service_state == service_disconnected) { MyStartService(); @@ -411,10 +411,10 @@ SetServiceMenuStatus() { HMENU hMenuHandle; - if (o.service_only[0] == '0') + if (o.service_only == 0) return; - if (o.service_only[0] == '1') + if (o.service_only) hMenuHandle = hMenu; else hMenuHandle = hMenuService;