Merge pull request #62 from selvanair/registry

Remove some registry keys/options and use file association for open/edit
pull/69/head
Samuli Seppänen 2016-08-23 18:47:58 +03:00 committed by GitHub
commit 2398e32b03
36 changed files with 1392 additions and 388 deletions

View File

@ -104,6 +104,8 @@ openvpn_gui_LDADD = \
-lwtsapi32 \ -lwtsapi32 \
-lcrypt32 \ -lcrypt32 \
-lnetapi32 \ -lnetapi32 \
-lole32 \
-lshlwapi \
-lsecur32 -lsecur32
openvpn-gui-res.o: $(openvpn_gui_RESOURCES) $(srcdir)/openvpn-gui-res.h openvpn-gui-res.o: $(openvpn_gui_RESOURCES) $(srcdir)/openvpn-gui-res.h

View File

@ -59,8 +59,9 @@ There are three ways to do this:
Using OpenVPN GUI Using OpenVPN GUI
################# #################
When OpenVPN GUI is started your OpenVPN config folder When OpenVPN GUI is started your OpenVPN config folders
(*C:\\Program Files\\OpenVPN\\config*) will be scanned for .ovpn files and the (*C:\\Users\\username\\OpenVPN\\config* and
*C:\\Program Files\\OpenVPN\\config*) will be scanned for .ovpn files and the
OpenVPN GUI icon will appear in the system tray. Each OpenVPN configuration OpenVPN GUI icon will appear in the system tray. Each OpenVPN configuration
file shows up as a separate menu item in the OpenVPN GUI tray, allowing you to file shows up as a separate menu item in the OpenVPN GUI tray, allowing you to
selectively connect to and disconnect to your VPNs. The config dir will be selectively connect to and disconnect to your VPNs. The config dir will be
@ -124,15 +125,41 @@ Disconnect If a file named "xxx_down.bat" exist in the config folder
Registry Values affecting the OpenVPN GUI operation Registry Values affecting the OpenVPN GUI operation
*************************************************** ***************************************************
All OpenVPN GUI registry values are located below the Parameters taken from the global registry values in
*HKEY_LOCAL_MACHINE\\SOFTWARE\\OpenVPN-GUI\\* key *HKEY_LOCAL_MACHINE\\SOFTWARE\\OpenVPN\\* key
The follow keys are used to control the OpenVPN GUI
config_dir config_dir
the system-wide configuration file directory, defaults to The global configuration file directory. Defaults to
*C:\\Program Files\\OpenVPN\\config*; the user-specific configuration file *C:\\Program Files\\OpenVPN\\config*
directory is hardcoded to *C:\\Users\\username\\OpenVPN\\config**.
exe_path
path to openvpn.exe, defaults to *C:\\Program Files\\OpenVPN\\bin\\openvpn.exe*
priority
the windows priority class for each instantiated OpenVPN process,
can be one of:
* IDLE_PRIORITY_CLASS
* BELOW_NORMAL_PRIORITY_CLASS
* NORMAL_PRIORITY_CLASS (default)
* ABOVE_NORMAL_PRIORITY_CLASS
* HIGH_PRIORITY_CLASS
ovpn_admin_group
The windows group whose membership allows the user to start any configuration file
in their profile (not just those installed by the administrator in the global
config directory). Default: "OpenVPN Administrators".
All other OpenVPN GUI registry values are located below the
*HKEY_CURRENT_USER\\SOFTWARE\\OpenVPN-GUI\\* key
The following keys are used to control the OpenVPN GUI
config_dir
The user-specific configuration file directory: defaults to
*C:\\Users\\username\\OpenVPN\\config*.
The GUI parses this directory for configuration files before
parsing the global config_dir.
config_ext config_ext
file extension on configuration files, defaults to *ovpn* file extension on configuration files, defaults to *ovpn*
@ -149,38 +176,13 @@ preconnectscript_timeout
Time in seconds to wait for the preconnect script to finish. Must be a Time in seconds to wait for the preconnect script to finish. Must be a
value between 1-99. value between 1-99.
exe_path
path to openvpn.exe, defaults to *C:\\Program Files\\OpenVPN\\bin\\openvpn.exe*
log_dir log_dir
log file directory, defaults to *C:\\Program Files\\OpenVPN\\log* log file directory, defaults to *C:\\Users\\username\\OpenVPN\\log*
log_append log_append
if set to "0", the log file will be truncated every time you start a if set to "0", the log file will be truncated every time you start a
connection. If set to "1", the log will be appended to the log file. connection. If set to "1", the log will be appended to the log file.
priority
the windows priority class for each instantiated OpenVPN process,
can be one of:
* IDLE_PRIORITY_CLASS
* BELOW_NORMAL_PRIORITY_CLASS
* NORMAL_PRIORITY_CLASS (default)
* ABOVE_NORMAL_PRIORITY_CLASS
* HIGH_PRIORITY_CLASS
allow_edit
If set to "1", the Edit config menu will be showed.
allow_password
If set to "1", the Change Password menu will be showed.
allow_proxy
If set to "1", the Proxy Settings menu will be showed.
allow_service
If set to "1", the Service control menu will be showed.
silent_connection silent_connection
If set to "1", the status window with the OpenVPN log output will If set to "1", the status window with the OpenVPN log output will
not be showed while connecting. not be showed while connecting.
@ -197,18 +199,7 @@ show_balloon
2: Show balloon even after re-connects 2: Show balloon even after re-connects
log_viewer All of these registry options are also available as cmd-line options.
The program used to view your log files, defaults to
*C:\\Windows\\System32\\notepad.exe*
editor
The program used to edit your config files, defaults to
*C:\\Windows\\System32\\notepad.exe*
passphrase_attempts
Number of attempts to enter the passphrase to allow.
All these registry options is also available as cmd-line options.
Use "openvpn-gui --help" for more info about cmd-line options. Use "openvpn-gui --help" for more info about cmd-line options.
Building OpenVPN GUI from source Building OpenVPN GUI from source

View File

@ -427,6 +427,19 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
if (GetLaunchOnStartup()) if (GetLaunchOnStartup())
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP), BST_CHECKED); 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; break;
case WM_NOTIFY: 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); 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); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
return TRUE; return TRUE;
} }

62
main.c
View File

@ -161,9 +161,6 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
#endif #endif
/* Parse command-line options */
ProcessCommandLine(&o, GetCommandLine());
/* Check if a previous instance is already running. */ /* Check if a previous instance is already running. */
if ((FindWindow (szClassName, NULL)) != NULL) if ((FindWindow (szClassName, NULL)) != NULL)
{ {
@ -172,9 +169,12 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
exit(1); exit(1);
} }
if (!GetRegistryKeys()) { UpdateRegistry(); /* Checks version change and update keys/values */
exit(1);
} GetRegistryKeys();
/* Parse command-line options */
ProcessCommandLine(&o, GetCommandLine());
EnsureDirExists(o.config_dir); EnsureDirExists(o.config_dir);
if (!CheckVersion()) { if (!CheckVersion()) {
@ -307,7 +307,6 @@ ResumeConnections()
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
static UINT s_uTaskbarRestart; static UINT s_uTaskbarRestart;
int i;
switch (message) { switch (message) {
case WM_CREATE: case WM_CREATE:
@ -328,7 +327,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CreatePopupMenus(); /* Create popup menus */ CreatePopupMenus(); /* Create popup menus */
ShowTrayIcon(); ShowTrayIcon();
if (o.allow_service[0]=='1' || o.service_only[0]=='1') if (o.service_only)
CheckServiceStatus(); // Check if service is running or not CheckServiceStatus(); // Check if service is running or not
if (!AutoStartConnections()) { if (!AutoStartConnections()) {
SendMessage(hwnd, WM_CLOSE, 0, 0); SendMessage(hwnd, WM_CLOSE, 0, 0);
@ -414,31 +413,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
} }
break; break;
case WM_POWERBROADCAST:
switch (wParam) {
case PBT_APMSUSPEND:
if (o.disconnect_on_suspend[0] == '1')
{
/* Suspend running connections */
for (i=0; i<o.num_configs; i++)
{
if (o.conn[i].state == connected)
SuspendOpenVPN(i);
}
/* Wait for all connections to suspend */
for (i=0; i<10; i++, Sleep(500))
if (CountConnState(suspending) == 0) break;
}
return FALSE;
case PBT_APMRESUMESUSPEND:
case PBT_APMRESUMECRITICAL:
if (CountConnState(suspended) != 0 && !o.session_locked)
ResumeConnections();
return FALSE;
}
default: /* for messages that we don't deal with */ default: /* for messages that we don't deal with */
if (message == s_uTaskbarRestart) if (message == s_uTaskbarRestart)
{ {
@ -470,11 +444,21 @@ AboutDialogFunc(UNUSED HWND hDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam)
static void static void
ShowSettingsDialog() ShowSettingsDialog()
{ {
PROPSHEETPAGE psp[3]; PROPSHEETPAGE psp[4];
int page_number = 0; 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 */ /* Proxy tab */
if (o.allow_proxy[0] == '1' && o.service_only[0] == '0') { if (o.service_only == 0) {
psp[page_number].dwSize = sizeof(PROPSHEETPAGE); psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
psp[page_number].dwFlags = PSP_DLGINDIRECT; psp[page_number].dwFlags = PSP_DLGINDIRECT;
psp[page_number].hInstance = o.hInstance; psp[page_number].hInstance = o.hInstance;
@ -485,12 +469,12 @@ ShowSettingsDialog()
++page_number; ++page_number;
} }
/* General tab */ /* Advanced tab */
psp[page_number].dwSize = sizeof(PROPSHEETPAGE); psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
psp[page_number].dwFlags = PSP_DLGINDIRECT; psp[page_number].dwFlags = PSP_DLGINDIRECT;
psp[page_number].hInstance = o.hInstance; psp[page_number].hInstance = o.hInstance;
psp[page_number].pResource = LocalizedDialogResource(ID_DLG_GENERAL); psp[page_number].pResource = LocalizedDialogResource(ID_DLG_ADVANCED);
psp[page_number].pfnDlgProc = GeneralSettingsDlgProc; psp[page_number].pfnDlgProc = AdvancedSettingsDlgProc;
psp[page_number].lParam = 0; psp[page_number].lParam = 0;
psp[page_number].pfnCallback = NULL; psp[page_number].pfnCallback = NULL;
++page_number; ++page_number;
@ -547,7 +531,7 @@ void
ImportConfigFile() 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')); _sntprintf_0(filter, _T("*.%s%c*.%s%c"), o.ext_string, _T('\0'), o.ext_string, _T('\0'));

5
main.h
View File

@ -35,10 +35,7 @@
//#define DISABLE_CHANGE_PASSWORD //#define DISABLE_CHANGE_PASSWORD
/* Registry key for User Settings */ /* Registry key for User Settings */
#define GUI_REGKEY_HKCU _T("Software\\Nilings\\OpenVPN-GUI") #define GUI_REGKEY_HKCU _T("Software\\OpenVPN-GUI")
/* Registry key for Global Settings */
#define GUI_REGKEY_HKLM _T("SOFTWARE\\OpenVPN-GUI")
#define MAX_LOG_LENGTH 1024/* Max number of characters per log line */ #define MAX_LOG_LENGTH 1024/* Max number of characters per log line */
#define MAX_LOG_LINES 500 /* Max number of lines in LogWindow */ #define MAX_LOG_LINES 500 /* Max number of lines in LogWindow */

18
misc.c
View File

@ -366,3 +366,21 @@ InitSemaphore (void)
} }
return semaphore; return semaphore;
} }
/* Check access rights on an existing file */
BOOL
CheckFileAccess (const TCHAR *path, int access)
{
HANDLE h;
bool ret = FALSE;
h = CreateFile (path, access, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if ( h != INVALID_HANDLE_VALUE )
{
ret = TRUE;
CloseHandle (h);
}
return ret;
}

1
misc.h
View File

@ -34,5 +34,6 @@ BOOL ForceForegroundWindow(HWND);
BOOL IsUserAdmin(VOID); BOOL IsUserAdmin(VOID);
HANDLE InitSemaphore (void); HANDLE InitSemaphore (void);
BOOL CheckFileAccess (const TCHAR *path, int access);
#endif #endif

View File

@ -79,12 +79,39 @@
#define ID_CMB_LANGUAGE 231 #define ID_CMB_LANGUAGE 231
#define ID_TXT_LANGUAGE 232 #define ID_TXT_LANGUAGE 232
#define ID_CHK_STARTUP 233 #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 */ /* Proxy Auth Dialog */
#define ID_DLG_PROXY_AUTH 250 #define ID_DLG_PROXY_AUTH 250
#define ID_EDT_PROXY_USER 251 #define ID_EDT_PROXY_USER 251
#define ID_EDT_PROXY_PASS 252 #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 * String Table Resources

View File

@ -170,9 +170,9 @@ OnStateChange(connection_t *c, char *data)
MultiByteToWideChar(CP_ACP, 0, local_ip, -1, c->ip, _countof(c->ip)); MultiByteToWideChar(CP_ACP, 0, local_ip, -1, c->ip, _countof(c->ip));
/* Show connection tray balloon */ /* Show connection tray balloon */
if ((c->state == connecting && o.show_balloon[0] != '0') if ((c->state == connecting && o.show_balloon != 0)
|| (c->state == resuming && o.show_balloon[0] != '0') || (c->state == resuming && o.show_balloon != 0)
|| (c->state == reconnecting && o.show_balloon[0] == '2')) || (c->state == reconnecting && o.show_balloon == 2))
{ {
TCHAR msg[256]; TCHAR msg[256];
LoadLocalizedStringBuf(msg, _countof(msg), IDS_NFO_NOW_CONNECTED, c->config_name); LoadLocalizedStringBuf(msg, _countof(msg), IDS_NFO_NOW_CONNECTED, c->config_name);
@ -199,8 +199,6 @@ OnStateChange(connection_t *c, char *data)
|| strcmp(message, "private-key-password-failure") == 0) || strcmp(message, "private-key-password-failure") == 0)
c->failed_psw_attempts++; c->failed_psw_attempts++;
if (c->failed_psw_attempts >= o.psw_attempts - 1)
ManagementCommand(c, "auth-retry none", NULL, regular);
if (strcmp(message, "auth-failure") == 0 && (c->flags & FLAG_SAVE_AUTH_PASS)) if (strcmp(message, "auth-failure") == 0 && (c->flags & FLAG_SAVE_AUTH_PASS))
SaveAuthPass(c->config_name, L""); SaveAuthPass(c->config_name, L"");
else if (strcmp(message, "private-key-password-failure") == 0 && (c->flags & FLAG_SAVE_KEY_PASS)) else if (strcmp(message, "private-key-password-failure") == 0 && (c->flags & FLAG_SAVE_KEY_PASS))
@ -388,7 +386,7 @@ PrivKeyPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDCANCEL: case IDCANCEL:
EndDialog(hwndDlg, LOWORD(wParam)); EndDialog(hwndDlg, LOWORD(wParam));
StopOpenVPN(c); StopOpenVPN (c);
return TRUE; return TRUE;
} }
break; break;
@ -468,7 +466,7 @@ OnStop(connection_t *c, UNUSED char *msg)
SetStatusWinIcon(c->hwndStatus, ID_ICO_DISCONNECTED); SetStatusWinIcon(c->hwndStatus, ID_ICO_DISCONNECTED);
EnableWindow(GetDlgItem(c->hwndStatus, ID_DISCONNECT), FALSE); EnableWindow(GetDlgItem(c->hwndStatus, ID_DISCONNECT), FALSE);
EnableWindow(GetDlgItem(c->hwndStatus, ID_RESTART), FALSE); EnableWindow(GetDlgItem(c->hwndStatus, ID_RESTART), FALSE);
if (o.silent_connection[0] == '0') if (o.silent_connection == 0)
{ {
SetForegroundWindow(c->hwndStatus); SetForegroundWindow(c->hwndStatus);
ShowWindow(c->hwndStatus, SW_SHOW); ShowWindow(c->hwndStatus, SW_SHOW);
@ -495,7 +493,7 @@ OnStop(connection_t *c, UNUSED char *msg)
EnableWindow(GetDlgItem(c->hwndStatus, ID_RESTART), FALSE); EnableWindow(GetDlgItem(c->hwndStatus, ID_RESTART), FALSE);
SetStatusWinIcon(c->hwndStatus, ID_ICO_DISCONNECTED); SetStatusWinIcon(c->hwndStatus, ID_ICO_DISCONNECTED);
SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(txt_id)); SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(txt_id));
if (o.silent_connection[0] == '0') if (o.silent_connection == 0)
{ {
SetForegroundWindow(c->hwndStatus); SetForegroundWindow(c->hwndStatus);
ShowWindow(c->hwndStatus, SW_SHOW); ShowWindow(c->hwndStatus, SW_SHOW);
@ -984,7 +982,7 @@ ThreadOpenVPNStatus(void *p)
else else
wait_event = c->hProcess; wait_event = c->hProcess;
if (o.silent_connection[0] == '0') if (o.silent_connection == 0)
ShowWindow(c->hwndStatus, SW_SHOW); ShowWindow(c->hwndStatus, SW_SHOW);
/* Run the message loop for the status window */ /* Run the message loop for the status window */
@ -1059,13 +1057,6 @@ StartOpenVPN(connection_t *c)
RunPreconnectScript(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 */ /* Create thread to show the connection's status dialog */
hThread = CreateThread(NULL, 0, ThreadOpenVPNStatus, c, CREATE_SUSPENDED, &c->threadId); hThread = CreateThread(NULL, 0, ThreadOpenVPNStatus, c, CREATE_SUSPENDED, &c->threadId);
if (hThread == NULL) if (hThread == NULL)
@ -1091,7 +1082,7 @@ StartOpenVPN(connection_t *c)
"--setenv IV_GUI_VER \"%S\" --service %s 0 --auth-retry interact " "--setenv IV_GUI_VER \"%S\" --service %s 0 --auth-retry interact "
"--management %S %hd stdin --management-query-passwords %s" "--management %S %hd stdin --management-query-passwords %s"
"--management-hold"), "--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, c->config_file, PACKAGE_STRING, exit_event_name,
inet_ntoa(c->manage.skaddr.sin_addr), ntohs(c->manage.skaddr.sin_port), inet_ntoa(c->manage.skaddr.sin_addr), ntohs(c->manage.skaddr.sin_port),
(o.proxy_source != config ? _T("--management-query-proxy ") : _T(""))); (o.proxy_source != config ? _T("--management-query-proxy ") : _T("")));

View File

@ -3,6 +3,7 @@
* *
* Copyright (C) 2004 Mathias Sundman <mathias@nilings.se> * Copyright (C) 2004 Mathias Sundman <mathias@nilings.se>
* 2010 Heiko Hund <heikoh@users.sf.net> * 2010 Heiko Hund <heikoh@users.sf.net>
* 2016 Selva Nair <selva.nair@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,6 +32,8 @@
#include "options.h" #include "options.h"
#include "localization.h" #include "localization.h"
#include "save_pass.h" #include "save_pass.h"
#include "misc.h"
#include "passphrase.h"
typedef enum typedef enum
{ {
@ -65,21 +68,11 @@ match(const WIN32_FIND_DATA *find, const TCHAR *ext)
static bool static bool
CheckReadAccess (const TCHAR *dir, const TCHAR *file) CheckReadAccess (const TCHAR *dir, const TCHAR *file)
{ {
HANDLE h;
bool ret = FALSE;
TCHAR path[MAX_PATH]; TCHAR path[MAX_PATH];
_sntprintf_0 (path, _T("%s\\%s"), dir, file); _sntprintf_0 (path, _T("%s\\%s"), dir, file);
h = CreateFile (path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, return CheckFileAccess (path, GENERIC_READ);
FILE_ATTRIBUTE_NORMAL, NULL);
if ( h != INVALID_HANDLE_VALUE )
{
ret = TRUE;
CloseHandle (h);
}
return ret;
} }
static int static int
@ -112,6 +105,9 @@ AddConfigFileToList(int config, const TCHAR *filename, const TCHAR *config_dir)
c->manage.skaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); c->manage.skaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
c->manage.skaddr.sin_port = htons(25340 + config); c->manage.skaddr.sin_port = htons(25340 + config);
if (CheckKeyFileWriteAccess (c))
c->flags |= ALLOW_CHANGE_PASSPHRASE;
/* Check if connection should be autostarted */ /* Check if connection should be autostarted */
for (i = 0; i < MAX_CONFIGS && o.auto_connect[i]; ++i) for (i = 0; i < MAX_CONFIGS && o.auto_connect[i]; ++i)
{ {

252
options.c
View File

@ -3,6 +3,7 @@
* *
* Copyright (C) 2004 Mathias Sundman <mathias@nilings.se> * Copyright (C) 2004 Mathias Sundman <mathias@nilings.se>
* 2010 Heiko Hund <heikoh@users.sf.net> * 2010 Heiko Hund <heikoh@users.sf.net>
* 2016 Selva Nair <selva.nair@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,20 +27,56 @@
#endif #endif
#include <windows.h> #include <windows.h>
#include <windowsx.h>
#include <prsht.h>
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <memory.h> #include <memory.h>
#include <shlobj.h>
#include <shlwapi.h>
#include "options.h" #include "options.h"
#include "main.h" #include "main.h"
#include "openvpn-gui-res.h" #include "openvpn-gui-res.h"
#include "localization.h" #include "localization.h"
#include "misc.h" #include "misc.h"
#include "registry.h"
#define streq(x, y) (_tcscmp((x), (y)) == 0) #define streq(x, y) (_tcscmp((x), (y)) == 0)
extern options_t o; 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 static int
add_option(options_t *options, int i, TCHAR **p) add_option(options_t *options, int i, TCHAR **p)
{ {
@ -87,10 +124,11 @@ add_option(options_t *options, int i, TCHAR **p)
++i; ++i;
_tcsncpy(options->priority_string, p[1], _countof(options->priority_string) - 1); _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; ++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]) else if (streq(p[0], _T("log_viewer")) && p[1])
{ {
@ -105,62 +143,62 @@ add_option(options_t *options, int i, TCHAR **p)
else if (streq(p[0], _T("allow_edit")) && p[1]) else if (streq(p[0], _T("allow_edit")) && p[1])
{ {
++i; ++i;
_tcsncpy(options->allow_edit, p[1], _countof(options->allow_edit) - 1); PrintDebug (L"Deprecated option: '%s' ignored.", p[0]);
} }
else if (streq(p[0], _T("allow_service")) && p[1]) else if (streq(p[0], _T("allow_service")) && p[1])
{ {
++i; ++i;
_tcsncpy(options->allow_service, p[1], _countof(options->allow_service) - 1); PrintDebug (L"Deprecated option: '%s' ignored.", p[0]);
} }
else if (streq(p[0], _T("allow_password")) && p[1]) else if (streq(p[0], _T("allow_password")) && p[1])
{ {
++i; ++i;
_tcsncpy(options->allow_password, p[1], _countof(options->allow_password) - 1); PrintDebug (L"Deprecated option: '%s' ignored.", p[0]);
} }
else if (streq(p[0], _T("allow_proxy")) && p[1]) else if (streq(p[0], _T("allow_proxy")) && p[1])
{ {
++i; ++i;
_tcsncpy(options->allow_proxy, p[1], _countof(options->allow_proxy) - 1); PrintDebug (L"Deprecated option: '%s' ignored.", p[0]);
} }
else if (streq(p[0], _T("show_balloon")) && p[1]) else if (streq(p[0], _T("show_balloon")) && p[1])
{ {
++i; ++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]) else if (streq(p[0], _T("service_only")) && p[1])
{ {
++i; ++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]) else if (streq(p[0], _T("show_script_window")) && p[1])
{ {
++i; ++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]) else if (streq(p[0], _T("silent_connection")) && p[1])
{ {
++i; ++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]) else if (streq(p[0], _T("passphrase_attempts")) && p[1])
{ {
++i; ++i;
_tcsncpy(options->psw_attempts_string, p[1], _countof(options->psw_attempts_string) - 1); PrintDebug (L"Deprecated option: '%s' ignored.", p[0]);
} }
else if (streq(p[0], _T("connectscript_timeout")) && p[1]) else if (streq(p[0], _T("connectscript_timeout")) && p[1])
{ {
++i; ++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]) else if (streq(p[0], _T("disconnectscript_timeout")) && p[1])
{ {
++i; ++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]) else if (streq(p[0], _T("preconnectscript_timeout")) && p[1])
{ {
++i; ++i;
_tcsncpy(options->preconnectscript_timeout_string, p[1], _countof(options->preconnectscript_timeout_string) - 1); options->preconnectscript_timeout = _ttoi(p[1]);
} }
else else
{ {
@ -212,6 +250,7 @@ InitOptions(options_t *opt)
{ {
CLEAR(*opt); CLEAR(*opt);
opt->netcmd_semaphore = InitSemaphore (); 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); parse_argv(options, argc, argv);
free(argv); free(argv);
ExpandOptions ();
} }
@ -307,3 +348,186 @@ GetConnByManagement(SOCKET sk)
} }
return NULL; 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);
}

View File

@ -3,6 +3,7 @@
* *
* Copyright (C) 2004 Mathias Sundman <mathias@nilings.se> * Copyright (C) 2004 Mathias Sundman <mathias@nilings.se>
* 2010 Heiko Hund <heikoh@users.sf.net> * 2010 Heiko Hund <heikoh@users.sf.net>
* 2016 Selva Nair <selva.nair@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -84,6 +85,11 @@ typedef struct {
#define FLAG_SAVE_KEY_PASS 1<<4 #define FLAG_SAVE_KEY_PASS 1<<4
#define FLAG_SAVE_AUTH_PASS 1<<5 #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 */ /* Connections parameters */
struct connection { struct connection {
@ -128,10 +134,6 @@ typedef struct {
int num_configs; /* Number of configs */ int num_configs; /* Number of configs */
service_state_t service_state; /* State of the OpenVPN Service */ service_state_t service_state; /* State of the OpenVPN Service */
int psw_attempts; /* Number of psw attemps to allow */
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 Settings */
proxy_source_t proxy_source; /* Where to get proxy information from */ proxy_source_t proxy_source; /* Where to get proxy information from */
@ -141,30 +143,25 @@ typedef struct {
TCHAR proxy_socks_address[100]; /* SOCKS Proxy Address */ TCHAR proxy_socks_address[100]; /* SOCKS Proxy Address */
TCHAR proxy_socks_port[6]; /* SOCKS Proxy Address */ TCHAR proxy_socks_port[6]; /* SOCKS Proxy Address */
/* Registry values */ /* HKLM Registry values */
TCHAR exe_path[MAX_PATH]; TCHAR exe_path[MAX_PATH];
TCHAR config_dir[MAX_PATH];
TCHAR global_config_dir[MAX_PATH]; TCHAR global_config_dir[MAX_PATH];
TCHAR priority_string[64];
TCHAR ovpn_admin_group[MAX_NAME];
/* HKCU registry values */
TCHAR config_dir[MAX_PATH];
TCHAR ext_string[16]; TCHAR ext_string[16];
TCHAR log_dir[MAX_PATH]; TCHAR log_dir[MAX_PATH];
TCHAR priority_string[64]; DWORD log_append;
TCHAR append_string[2];
TCHAR log_viewer[MAX_PATH]; TCHAR log_viewer[MAX_PATH];
TCHAR editor[MAX_PATH]; TCHAR editor[MAX_PATH];
TCHAR allow_edit[2]; DWORD silent_connection;
TCHAR allow_service[2]; DWORD service_only;
TCHAR allow_password[2]; DWORD show_balloon;
TCHAR allow_proxy[2]; DWORD show_script_window;
TCHAR silent_connection[2]; DWORD connectscript_timeout; /* Connect Script execution timeout (sec) */
TCHAR service_only[2]; DWORD disconnectscript_timeout; /* Disconnect Script execution timeout (sec) */
TCHAR show_balloon[2]; DWORD preconnectscript_timeout; /* Preconnect Script execution timeout (sec) */
TCHAR show_script_window[2];
TCHAR psw_attempts_string[2];
TCHAR disconnect_on_suspend[2];
TCHAR connectscript_timeout_string[4];
TCHAR disconnectscript_timeout_string[4];
TCHAR preconnectscript_timeout_string[4];
TCHAR ovpn_admin_group[MAX_NAME];
#ifdef DEBUG #ifdef DEBUG
FILE *debug_fp; FILE *debug_fp;
@ -174,10 +171,17 @@ typedef struct {
HINSTANCE hInstance; HINSTANCE hInstance;
BOOL session_locked; BOOL session_locked;
HANDLE netcmd_semaphore; HANDLE netcmd_semaphore;
version_t version;
} options_t; } options_t;
void InitOptions(options_t *); void InitOptions(options_t *);
void ProcessCommandLine(options_t *, TCHAR *); void ProcessCommandLine(options_t *, TCHAR *);
int CountConnState(conn_state_t); int CountConnState(conn_state_t);
connection_t* GetConnByManagement(SOCKET); 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 #endif

View File

@ -40,6 +40,7 @@
#include "openvpn-gui-res.h" #include "openvpn-gui-res.h"
#include "chartable.h" #include "chartable.h"
#include "localization.h" #include "localization.h"
#include "misc.h"
extern options_t o; extern options_t o;
@ -567,15 +568,15 @@ ParseKeyFilenameLine(connection_t *c, TCHAR *keyfilename, size_t keyfilenamesize
return(1); return(1);
} }
static int static int
GetKeyFilename(connection_t *c, TCHAR *keyfilename, size_t keyfilenamesize, int *keyfile_format) GetKeyFilename(connection_t *c, TCHAR *keyfilename, size_t keyfilenamesize, int *keyfile_format, bool silent)
{ {
FILE *fp; FILE *fp = NULL;
char line[256]; char line[256];
int found_key=0; int found_key=0;
int found_pkcs12=0; int found_pkcs12=0;
TCHAR configfile_path[MAX_PATH]; TCHAR configfile_path[MAX_PATH];
int ret = 0;
_tcsncpy(configfile_path, c->config_dir, _countof(configfile_path)); _tcsncpy(configfile_path, c->config_dir, _countof(configfile_path));
if (!(configfile_path[_tcslen(configfile_path)-1] == '\\')) if (!(configfile_path[_tcslen(configfile_path)-1] == '\\'))
@ -586,8 +587,9 @@ GetKeyFilename(connection_t *c, TCHAR *keyfilename, size_t keyfilenamesize, int
if (!(fp=_tfopen(configfile_path, _T("r")))) if (!(fp=_tfopen(configfile_path, _T("r"))))
{ {
/* can't open config file */ /* can't open config file */
ShowLocalizedMsg(IDS_ERR_OPEN_CONFIG, configfile_path); if (!silent)
return(0); ShowLocalizedMsg(IDS_ERR_OPEN_CONFIG, configfile_path);
goto out;
} }
while (fgets(line, sizeof (line), fp)) while (fgets(line, sizeof (line), fp))
@ -597,49 +599,57 @@ GetKeyFilename(connection_t *c, TCHAR *keyfilename, size_t keyfilenamesize, int
if (found_key) if (found_key)
{ {
/* only one key option */ /* only one key option */
ShowLocalizedMsg(IDS_ERR_ONLY_ONE_KEY_OPTION); if (!silent)
return(0); ShowLocalizedMsg(IDS_ERR_ONLY_ONE_KEY_OPTION);
goto out;
} }
if (found_pkcs12) if (found_pkcs12)
{ {
/* key XOR pkcs12 */ /* key XOR pkcs12 */
ShowLocalizedMsg(IDS_ERR_ONLY_KEY_OR_PKCS12); if (!silent)
return(0); ShowLocalizedMsg(IDS_ERR_ONLY_KEY_OR_PKCS12);
goto out;
} }
found_key=1; found_key=1;
*keyfile_format = KEYFILE_FORMAT_PEM; *keyfile_format = KEYFILE_FORMAT_PEM;
if (!ParseKeyFilenameLine(c, keyfilename, keyfilenamesize, &line[4])) if (!ParseKeyFilenameLine(c, keyfilename, keyfilenamesize, &line[4]))
return(0); goto out;
} }
if (LineBeginsWith(line, "pkcs12", 6)) if (LineBeginsWith(line, "pkcs12", 6))
{ {
if (found_pkcs12) if (found_pkcs12)
{ {
/* only one pkcs12 option */ /* only one pkcs12 option */
ShowLocalizedMsg(IDS_ERR_ONLY_ONE_PKCS12_OPTION); if (!silent)
return(0); ShowLocalizedMsg(IDS_ERR_ONLY_ONE_PKCS12_OPTION);
goto out;
} }
if (found_key) if (found_key)
{ {
/* only key XOR pkcs12 */ /* only key XOR pkcs12 */
ShowLocalizedMsg(IDS_ERR_ONLY_KEY_OR_PKCS12); if (!silent)
return(0); ShowLocalizedMsg(IDS_ERR_ONLY_KEY_OR_PKCS12);
goto out;
} }
found_pkcs12=1; found_pkcs12=1;
*keyfile_format = KEYFILE_FORMAT_PKCS12; *keyfile_format = KEYFILE_FORMAT_PKCS12;
if (!ParseKeyFilenameLine(c, keyfilename, keyfilenamesize, &line[7])) if (!ParseKeyFilenameLine(c, keyfilename, keyfilenamesize, &line[7]))
return(0); goto out;
} }
} }
if ((!found_key) && (!found_pkcs12)) if ((!found_key) && (!found_pkcs12))
{ {
/* must have key or pkcs12 option */ /* must have key or pkcs12 option */
ShowLocalizedMsg(IDS_ERR_HAVE_KEY_OR_PKCS12); if (!silent)
return(0); ShowLocalizedMsg(IDS_ERR_HAVE_KEY_OR_PKCS12);
goto out;
} }
ret = 1;
return(1); out:
if (fp)
fclose(fp);
return ret;
} }
@ -658,7 +668,7 @@ ChangePassphraseThread(LPVOID data)
conn_name[_tcslen(conn_name) - (_tcslen(o.ext_string)+1)]=0; conn_name[_tcslen(conn_name) - (_tcslen(o.ext_string)+1)]=0;
/* Get Key filename from config file */ /* Get Key filename from config file */
if (!GetKeyFilename(c, keyfilename, _countof(keyfilename), &keyfile_format)) if (!GetKeyFilename(c, keyfilename, _countof(keyfilename), &keyfile_format, false))
{ {
ExitThread(1); ExitThread(1);
} }
@ -685,6 +695,7 @@ ChangePassphraseThread(LPVOID data)
} }
} }
CloseHandle (hwndChangePSW);
ExitThread(0); ExitThread(0);
} }
@ -703,8 +714,18 @@ ShowChangePassphraseDialog(connection_t *c)
ShowLocalizedMsg(IDS_ERR_CREATE_PASS_THREAD); ShowLocalizedMsg(IDS_ERR_CREATE_PASS_THREAD);
return; return;
} }
CloseHandle (hThread);
} }
bool
CheckKeyFileWriteAccess (connection_t *c)
{
TCHAR keyfile[MAX_PATH];
int format = 0;
if (!GetKeyFilename (c, keyfile, _countof(keyfile), &format, true))
return FALSE;
else
return CheckFileAccess (keyfile, GENERIC_WRITE);
}
#endif #endif

View File

@ -30,5 +30,6 @@ BOOL GetRandomPassword(char *, size_t);
#ifndef DISABLE_CHANGE_PASSWORD #ifndef DISABLE_CHANGE_PASSWORD
void ShowChangePassphraseDialog(connection_t *); void ShowChangePassphraseDialog(connection_t *);
#endif #endif
BOOL CheckKeyFileWriteAccess (connection_t *);
#endif #endif

10
proxy.c
View File

@ -224,6 +224,7 @@ SaveProxySettings(HWND hwndDlg)
DWORD dwDispos; DWORD dwDispos;
TCHAR proxy_source_string[2] = _T("0"); TCHAR proxy_source_string[2] = _T("0");
TCHAR proxy_type_string[2] = _T("0"); TCHAR proxy_type_string[2] = _T("0");
TCHAR proxy_subkey[MAX_PATH];
/* Save Proxy Settings Source */ /* Save Proxy Settings Source */
if (IsDlgButtonChecked(hwndDlg, ID_RB_PROXY_OPENVPN) == BST_CHECKED) if (IsDlgButtonChecked(hwndDlg, ID_RB_PROXY_OPENVPN) == BST_CHECKED)
@ -265,11 +266,12 @@ SaveProxySettings(HWND hwndDlg)
} }
/* Open Registry for writing */ /* 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, &regkey, &dwDispos) != ERROR_SUCCESS) KEY_WRITE, NULL, &regkey, &dwDispos) != ERROR_SUCCESS)
{ {
/* error creating Registry-Key */ /* error creating Registry-Key */
ShowLocalizedMsg(IDS_ERR_CREATE_REG_HKCU_KEY, GUI_REGKEY_HKCU); ShowLocalizedMsg(IDS_ERR_CREATE_REG_HKCU_KEY, proxy_subkey);
return; return;
} }
@ -292,9 +294,11 @@ GetProxyRegistrySettings()
HKEY regkey; HKEY regkey;
TCHAR proxy_source_string[2] = _T("0"); TCHAR proxy_source_string[2] = _T("0");
TCHAR proxy_type_string[2] = _T("0"); TCHAR proxy_type_string[2] = _T("0");
TCHAR proxy_subkey[MAX_PATH];
/* Open Registry for reading */ /* Open Registry for reading */
status = RegOpenKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, KEY_READ, &regkey); _sntprintf_0(proxy_subkey, _T("%s\\proxy"), GUI_REGKEY_HKCU);
status = RegOpenKeyEx(HKEY_CURRENT_USER, proxy_subkey, 0, KEY_READ, &regkey);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return; return;

View File

@ -2,6 +2,7 @@
* OpenVPN-GUI -- A Windows GUI for OpenVPN. * OpenVPN-GUI -- A Windows GUI for OpenVPN.
* *
* Copyright (C) 2004 Mathias Sundman <mathias@nilings.se> * Copyright (C) 2004 Mathias Sundman <mathias@nilings.se>
* 2016 Selva Nair <selva.nair@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -36,11 +37,42 @@
extern options_t o; extern options_t o;
int struct regkey_str {
GetRegistryKeys() 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"}
};
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);
}
static int
GetGlobalRegistryKeys()
{ {
TCHAR windows_dir[MAX_PATH]; TCHAR windows_dir[MAX_PATH];
TCHAR temp_path[MAX_PATH];
TCHAR openvpn_path[MAX_PATH]; TCHAR openvpn_path[MAX_PATH];
TCHAR profile_dir[MAX_PATH]; TCHAR profile_dir[MAX_PATH];
HKEY regkey; HKEY regkey;
@ -58,7 +90,7 @@ GetRegistryKeys()
/* Get path to OpenVPN installation. */ /* Get path to OpenVPN installation. */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\OpenVPN"), 0, KEY_READ, &regkey) if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\OpenVPN"), 0, KEY_READ, &regkey)
!= ERROR_SUCCESS) != ERROR_SUCCESS)
{ {
/* registry key not found */ /* registry key not found */
ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY); ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY);
@ -80,186 +112,237 @@ GetRegistryKeys()
/* use default = openvpnpath\config */ /* use default = openvpnpath\config */
_sntprintf_0(o.global_config_dir, _T("%sconfig"), openvpn_path); _sntprintf_0(o.global_config_dir, _T("%sconfig"), openvpn_path);
} }
if (!GetRegistryValue(regkey, _T("ovpn_admin_group"), o.ovpn_admin_group, _countof(o.ovpn_admin_group))) if (!GetRegistryValue(regkey, _T("ovpn_admin_group"), o.ovpn_admin_group, _countof(o.ovpn_admin_group)))
{ {
_tcsncpy(o.ovpn_admin_group, OVPN_ADMIN_GROUP, _countof(o.ovpn_admin_group)); _tcsncpy(o.ovpn_admin_group, OVPN_ADMIN_GROUP, _countof(o.ovpn_admin_group)-1);
}
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 (!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); RegCloseKey(regkey);
return true;
/* 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("%sbin\\openvpn.exe"), openvpn_path);
if (!GetRegKey(_T("exe_path"), o.exe_path,
temp_path, _countof(o.exe_path))) 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 (!GetRegKey(_T("priority"), o.priority_string,
_T("NORMAL_PRIORITY_CLASS"), _countof(o.priority_string))) return(false);
_sntprintf_0(temp_path, _T("%s\\system32\\notepad.exe"), windows_dir);
if (!GetRegKey(_T("log_viewer"), o.log_viewer,
temp_path, _countof(o.log_viewer))) return(false);
_sntprintf_0(temp_path, _T("%s\\system32\\notepad.exe"), windows_dir);
if (!GetRegKey(_T("editor"), o.editor,
temp_path, _countof(o.editor))) return(false);
if (!GetRegKey(_T("allow_edit"), o.allow_edit, _T("1"), _countof(o.allow_edit))) return(false);
if (!GetRegKey(_T("allow_service"), o.allow_service, _T("0"), _countof(o.allow_service))) return(false);
if (!GetRegKey(_T("allow_password"), o.allow_password, _T("1"), _countof(o.allow_password))) return(false);
if (!GetRegKey(_T("allow_proxy"), o.allow_proxy, _T("1"), _countof(o.allow_proxy))) return(false);
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("disconnect_on_suspend"), o.disconnect_on_suspend, _T("0"),
_countof(o.disconnect_on_suspend))) return(false);
if (!GetRegKey(_T("passphrase_attempts"), o.psw_attempts_string, _T("3"),
_countof(o.psw_attempts_string))) return(false);
o.psw_attempts = _ttoi(o.psw_attempts_string);
if ((o.psw_attempts < 1) || (o.psw_attempts > 9))
{
/* 0 <= passphrase_attempts <= 9 */
ShowLocalizedMsg(IDS_ERR_PASSPHRASE_ATTEMPTS);
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);
} }
int
int GetRegKey(const TCHAR name[], TCHAR *data, const TCHAR default_data[], DWORD len) GetRegistryKeys ()
{ {
LONG status; HKEY regkey;
DWORD type; DWORD status;
HKEY openvpn_key; int i;
HKEY openvpn_key_write;
DWORD dwDispos;
TCHAR expanded_string[MAX_PATH];
DWORD size = len * sizeof(*data);
DWORD max_len = len - 1;
/* If option is already set via cmd-line, return */ if (!GetGlobalRegistryKeys())
if (data[0] != 0) return false;
status = RegOpenKeyEx(HKEY_CURRENT_USER, GUI_REGKEY_HKCU, 0, KEY_READ, &regkey);
for (i = 0 ; i < (int) _countof (regkey_str); ++i)
{ {
// Expand environment variables inside the string. if ( status != ERROR_SUCCESS ||
ExpandEnvironmentStrings(data, expanded_string, _countof(expanded_string)); !GetRegistryValue (regkey, regkey_str[i].name, regkey_str[i].var, regkey_str[i].len))
_tcsncpy(data, expanded_string, max_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)
{ {
/* error creating registry key */ /* no value found in registry, use the default */
ShowLocalizedMsg(IDS_ERR_CREATE_REG_HKCU_KEY, _T("OpenVPN-GUI")); wcsncpy (regkey_str[i].var, regkey_str[i].value, regkey_str[i].len);
return(false); regkey_str[i].var[regkey_str[i].len-1] = L'\0';
} PrintDebug(L"default: %s = %s", regkey_str[i].name, regkey_str[i].var);
}
/* 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);
} }
_tcsncpy(data, default_data, max_len); else
RegCloseKey(openvpn_key_write); 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); if ( status != ERROR_SUCCESS ||
data[size - 1] = L'\0'; /* REG_SZ strings are not guaranteed to be null-terminated */ !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. if ((o.disconnectscript_timeout == 0))
ExpandEnvironmentStrings(data, expanded_string, _countof(expanded_string)); {
_tcsncpy(data, expanded_string, max_len); 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, &regkey, 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, &regkey) == 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, &regkey, 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, &regkey_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, &regkey, 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, &regkey_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) LONG GetRegistryValue(HKEY regkey, const TCHAR *name, TCHAR *data, DWORD len)
@ -288,7 +371,7 @@ GetRegistryValueNumeric(HKEY regkey, const TCHAR *name, DWORD *data)
DWORD type; DWORD type;
DWORD size = sizeof(*data); DWORD size = sizeof(*data);
LONG status = RegQueryValueEx(regkey, name, NULL, &type, (PBYTE) data, &size); 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) int SetRegistryValue(HKEY regkey, const TCHAR *name, const TCHAR *data)

View File

@ -22,7 +22,9 @@
#ifndef REGISTRY_H #ifndef REGISTRY_H
#define 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); 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 GetRegistryValue(HKEY regkey, const TCHAR *name, TCHAR *data, DWORD len);
LONG GetRegistryValueNumeric(HKEY regkey, const TCHAR *name, DWORD *data); LONG GetRegistryValueNumeric(HKEY regkey, const TCHAR *name, DWORD *data);

View File

@ -135,6 +135,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 51, 23, 177, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 51, 23, 177, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -136,6 +136,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -86,7 +86,7 @@ END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */
ID_DLG_CHGPASS DIALOG 6, 18, 193, 82 ID_DLG_CHGPASS DIALOG 6, 18, 193, 82
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER
CAPTION "OpenVPN - Change Passphrase" CAPTION "OpenVPN - Change Private Key Passphrase"
FONT 8, "Microsoft Sans Serif" FONT 8, "Microsoft Sans Serif"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
BEGIN BEGIN
@ -133,8 +133,48 @@ BEGIN
GROUPBOX "User Interface", 201, 6, 12, 235, 30 GROUPBOX "User Interface", 201, 6, 12, 235, 30
LTEXT "Language:", ID_TXT_LANGUAGE, 17, 25, 52, 12 LTEXT "Language:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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 END
/* About Dialog */ /* About Dialog */
@ -313,7 +353,7 @@ BEGIN
/* passphrase - Resources */ /* passphrase - Resources */
IDS_ERR_CREATE_PASS_THREAD "CreateThread to show ChangePassphrase dialog failed." IDS_ERR_CREATE_PASS_THREAD "CreateThread to show ChangePassphrase dialog failed."
IDS_NFO_CHANGE_PWD "Change Password (%s)" IDS_NFO_CHANGE_PWD "Change Private Key Password (%s)"
IDS_ERR_PWD_DONT_MATCH "The passwords you typed do not match. Try again." IDS_ERR_PWD_DONT_MATCH "The passwords you typed do not match. Try again."
IDS_ERR_PWD_TO_SHORT "Your new password must be at least %d characters long." IDS_ERR_PWD_TO_SHORT "Your new password must be at least %d characters long."
IDS_NFO_EMPTY_PWD "Are you sure you want to set an EMPTY password?" IDS_NFO_EMPTY_PWD "Are you sure you want to set an EMPTY password?"

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 45, 23, 183, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 45, 23, 183, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -136,6 +136,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 47, 23, 181, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 47, 23, 181, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 43, 23, 185, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 43, 23, 185, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -137,6 +137,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 39, 23, 189, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 39, 23, 189, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Opstarten", 202, 6, 47, 235, 30 GROUPBOX "Opstarten", 202, 6, 47, 235, 30
AUTOCHECKBOX "Opstarten met Windows", ID_CHK_STARTUP, 17, 59, 200, 12 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 END
/* About Dialog */ /* About Dialog */

View File

@ -135,6 +135,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -136,6 +136,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Inicialização", 202, 6, 47, 235, 30 GROUPBOX "Inicialização", 202, 6, 47, 235, 30
AUTOCHECKBOX "Executar ao iniciar o Windows", ID_CHK_STARTUP, 17, 59, 200, 12 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 END
/* About Dialog */ /* About Dialog */

View File

@ -136,6 +136,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -136,6 +136,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 31, 23, 197, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 31, 23, 197, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -134,6 +134,45 @@ BEGIN
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30 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, 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 END
/* About Dialog */ /* About Dialog */

View File

@ -69,11 +69,11 @@ RunPreconnectScript(connection_t *c)
si.hStdOutput = NULL; si.hStdOutput = NULL;
if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 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)) NULL, c->config_dir, &si, &pi))
return; return;
for (i = 0; i <= o.preconnectscript_timeout; i++) for (i = 0; i <= (int) o.preconnectscript_timeout; i++)
{ {
if (!GetExitCodeProcess(pi.hProcess, &exit_code)) if (!GetExitCodeProcess(pi.hProcess, &exit_code))
goto out; goto out;
@ -122,7 +122,7 @@ RunConnectScript(connection_t *c, int run_as_service)
si.hStdOutput = NULL; si.hStdOutput = NULL;
if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 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)) NULL, c->config_dir, &si, &pi))
{ {
ShowLocalizedMsg(IDS_ERR_RUN_CONN_SCRIPT, cmdline); ShowLocalizedMsg(IDS_ERR_RUN_CONN_SCRIPT, cmdline);
@ -132,7 +132,7 @@ RunConnectScript(connection_t *c, int run_as_service)
if (o.connectscript_timeout == 0) if (o.connectscript_timeout == 0)
goto out; 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)) if (!GetExitCodeProcess(pi.hProcess, &exit_code))
{ {
@ -191,11 +191,11 @@ RunDisconnectScript(connection_t *c, int run_as_service)
si.hStdOutput = NULL; si.hStdOutput = NULL;
if (!CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 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)) NULL, c->config_dir, &si, &pi))
return; return;
for (i = 0; i <= o.disconnectscript_timeout; i++) for (i = 0; i <= (int) o.disconnectscript_timeout; i++)
{ {
if (!GetExitCodeProcess(pi.hProcess, &exit_code)) if (!GetExitCodeProcess(pi.hProcess, &exit_code))
goto out; goto out;

40
tray.c
View File

@ -60,7 +60,7 @@ CreatePopupMenus()
if (o.num_configs == 1) { if (o.num_configs == 1) {
/* Create Main menu with actions */ /* 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_CONNECTMENU, LoadLocalizedString(IDS_MENU_CONNECT));
AppendMenu(hMenu, MF_STRING, IDM_DISCONNECTMENU, LoadLocalizedString(IDS_MENU_DISCONNECT)); AppendMenu(hMenu, MF_STRING, IDM_DISCONNECTMENU, LoadLocalizedString(IDS_MENU_DISCONNECT));
AppendMenu(hMenu, MF_STRING, IDM_STATUSMENU, LoadLocalizedString(IDS_MENU_STATUS)); AppendMenu(hMenu, MF_STRING, IDM_STATUSMENU, LoadLocalizedString(IDS_MENU_STATUS));
@ -75,23 +75,16 @@ CreatePopupMenus()
AppendMenu(hMenu, MF_STRING, IDM_VIEWLOGMENU, LoadLocalizedString(IDS_MENU_VIEWLOG)); AppendMenu(hMenu, MF_STRING, IDM_VIEWLOGMENU, LoadLocalizedString(IDS_MENU_VIEWLOG));
if (o.allow_edit[0] == '1') AppendMenu(hMenu, MF_STRING, IDM_EDITMENU, LoadLocalizedString(IDS_MENU_EDITCONFIG));
AppendMenu(hMenu, MF_STRING, IDM_EDITMENU, LoadLocalizedString(IDS_MENU_EDITCONFIG));
AppendMenu(hMenu, MF_STRING, IDM_CLEARPASSMENU, LoadLocalizedString(IDS_MENU_CLEARPASS)); AppendMenu(hMenu, MF_STRING, IDM_CLEARPASSMENU, LoadLocalizedString(IDS_MENU_CLEARPASS));
#ifndef DISABLE_CHANGE_PASSWORD #ifndef DISABLE_CHANGE_PASSWORD
if (o.allow_password[0] == '1') if (o.conn[0].flags & ALLOW_CHANGE_PASSPHRASE)
AppendMenu(hMenu, MF_STRING, IDM_PASSPHRASEMENU, LoadLocalizedString(IDS_MENU_PASSPHRASE)); AppendMenu(hMenu, MF_STRING, IDM_PASSPHRASEMENU, LoadLocalizedString(IDS_MENU_PASSPHRASE));
#endif #endif
AppendMenu(hMenu, MF_SEPARATOR, 0, 0); AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
if (o.allow_service[0] == '1' && o.service_only[0] == '0')
{
AppendMenu(hMenu, MF_POPUP, (UINT_PTR) hMenuService, LoadLocalizedString(IDS_MENU_SERVICE));
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
}
AppendMenu(hMenu, MF_STRING, IDM_IMPORT, LoadLocalizedString(IDS_MENU_IMPORT)); AppendMenu(hMenu, MF_STRING, IDM_IMPORT, LoadLocalizedString(IDS_MENU_IMPORT));
AppendMenu(hMenu, MF_STRING ,IDM_SETTINGS, LoadLocalizedString(IDS_MENU_SETTINGS)); AppendMenu(hMenu, MF_STRING ,IDM_SETTINGS, LoadLocalizedString(IDS_MENU_SETTINGS));
AppendMenu(hMenu, MF_STRING ,IDM_CLOSE, LoadLocalizedString(IDS_MENU_CLOSE)); AppendMenu(hMenu, MF_STRING ,IDM_CLOSE, LoadLocalizedString(IDS_MENU_CLOSE));
@ -107,11 +100,7 @@ CreatePopupMenus()
if (o.num_configs > 0) if (o.num_configs > 0)
AppendMenu(hMenu, MF_SEPARATOR, 0, 0); AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
if (o.service_only[0] == '0' && o.allow_service[0] == '1') { if (o.service_only) {
AppendMenu(hMenu, MF_POPUP, (UINT_PTR) hMenuService, LoadLocalizedString(IDS_MENU_SERVICE));
AppendMenu(hMenu, MF_SEPARATOR, 0, 0);
}
else if (o.service_only[0] == '1') {
AppendMenu(hMenu, MF_STRING, IDM_SERVICE_START, LoadLocalizedString(IDS_MENU_SERVICEONLY_START)); 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_STOP, LoadLocalizedString(IDS_MENU_SERVICEONLY_STOP));
AppendMenu(hMenu, MF_STRING, IDM_SERVICE_RESTART, LoadLocalizedString(IDS_MENU_SERVICEONLY_RESTART)); AppendMenu(hMenu, MF_STRING, IDM_SERVICE_RESTART, LoadLocalizedString(IDS_MENU_SERVICEONLY_RESTART));
@ -125,7 +114,7 @@ CreatePopupMenus()
/* Create popup menus for every connection */ /* Create popup menus for every connection */
for (i=0; i < o.num_configs; i++) { 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_CONNECTMENU + i, LoadLocalizedString(IDS_MENU_CONNECT));
AppendMenu(hMenuConn[i], MF_STRING, IDM_DISCONNECTMENU + i, LoadLocalizedString(IDS_MENU_DISCONNECT)); AppendMenu(hMenuConn[i], MF_STRING, IDM_DISCONNECTMENU + i, LoadLocalizedString(IDS_MENU_DISCONNECT));
AppendMenu(hMenuConn[i], MF_STRING, IDM_STATUSMENU + i, LoadLocalizedString(IDS_MENU_STATUS)); AppendMenu(hMenuConn[i], MF_STRING, IDM_STATUSMENU + i, LoadLocalizedString(IDS_MENU_STATUS));
@ -134,12 +123,11 @@ CreatePopupMenus()
AppendMenu(hMenuConn[i], MF_STRING, IDM_VIEWLOGMENU + i, LoadLocalizedString(IDS_MENU_VIEWLOG)); AppendMenu(hMenuConn[i], MF_STRING, IDM_VIEWLOGMENU + i, LoadLocalizedString(IDS_MENU_VIEWLOG));
if (o.allow_edit[0] == '1') AppendMenu(hMenuConn[i], MF_STRING, IDM_EDITMENU + i, LoadLocalizedString(IDS_MENU_EDITCONFIG));
AppendMenu(hMenuConn[i], MF_STRING, IDM_EDITMENU + i, LoadLocalizedString(IDS_MENU_EDITCONFIG));
AppendMenu(hMenuConn[i], MF_STRING, IDM_CLEARPASSMENU + i, LoadLocalizedString(IDS_MENU_CLEARPASS)); AppendMenu(hMenuConn[i], MF_STRING, IDM_CLEARPASSMENU + i, LoadLocalizedString(IDS_MENU_CLEARPASS));
#ifndef DISABLE_CHANGE_PASSWORD #ifndef DISABLE_CHANGE_PASSWORD
if (o.allow_password[0] == '1') if (o.conn[i].flags & ALLOW_CHANGE_PASSPHRASE)
AppendMenu(hMenuConn[i], MF_STRING, IDM_PASSPHRASEMENU + i, LoadLocalizedString(IDS_MENU_PASSPHRASE)); AppendMenu(hMenuConn[i], MF_STRING, IDM_PASSPHRASEMENU + i, LoadLocalizedString(IDS_MENU_PASSPHRASE));
#endif #endif
@ -147,14 +135,6 @@ CreatePopupMenus()
} }
} }
/* Create service menu */
if (o.allow_service[0] == '1' && o.service_only[0] == '0')
{
AppendMenu(hMenuService, MF_STRING, IDM_SERVICE_START, LoadLocalizedString(IDS_MENU_SERVICE_START));
AppendMenu(hMenuService, MF_STRING, IDM_SERVICE_STOP, LoadLocalizedString(IDS_MENU_SERVICE_STOP));
AppendMenu(hMenuService, MF_STRING, IDM_SERVICE_RESTART, LoadLocalizedString(IDS_MENU_SERVICE_RESTART));
}
SetServiceMenuStatus(); SetServiceMenuStatus();
} }
@ -194,7 +174,7 @@ OnNotifyTray(LPARAM lParam)
break; break;
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
if (o.service_only[0] == '1') { if (o.service_only) {
/* Start or stop OpenVPN service */ /* Start or stop OpenVPN service */
if (o.service_state == service_disconnected) { if (o.service_state == service_disconnected) {
MyStartService(); MyStartService();
@ -431,10 +411,10 @@ SetServiceMenuStatus()
{ {
HMENU hMenuHandle; HMENU hMenuHandle;
if (o.allow_service[0] == '0' && o.service_only[0] == '0') if (o.service_only == 0)
return; return;
if (o.service_only[0] == '1') if (o.service_only)
hMenuHandle = hMenu; hMenuHandle = hMenu;
else else
hMenuHandle = hMenuService; hMenuHandle = hMenuService;

View File

@ -25,6 +25,8 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <shellapi.h>
#include <objbase.h>
#include "tray.h" #include "tray.h"
#include "openvpn.h" #include "openvpn.h"
@ -37,18 +39,29 @@ extern options_t o;
void ViewLog(int config) void ViewLog(int config)
{ {
TCHAR filename[200]; TCHAR filename[2*MAX_PATH];
STARTUPINFO start_info; STARTUPINFO start_info;
PROCESS_INFORMATION proc_info; PROCESS_INFORMATION proc_info;
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd; SECURITY_DESCRIPTOR sd;
HINSTANCE status;
CLEAR (start_info); CLEAR (start_info);
CLEAR (proc_info); CLEAR (proc_info);
CLEAR (sa); CLEAR (sa);
CLEAR (sd); CLEAR (sd);
/* Try first using file association */
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); /* Safe to init COM multiple times */
status = ShellExecuteW (o.hWnd, L"open", o.conn[config].log_path, NULL, o.log_dir, SW_SHOWNORMAL);
if (status > (HINSTANCE) 32) /* Success */
return;
else
PrintDebug (L"Opening log file using ShellExecute with verb = open failed"
" for config '%s' (status = %lu)", o.conn[config].config_name, status);
_sntprintf_0(filename, _T("%s \"%s\""), o.log_viewer, o.conn[config].log_path); _sntprintf_0(filename, _T("%s \"%s\""), o.log_viewer, o.conn[config].log_path);
/* fill in STARTUPINFO struct */ /* fill in STARTUPINFO struct */
@ -81,18 +94,30 @@ void ViewLog(int config)
void EditConfig(int config) void EditConfig(int config)
{ {
TCHAR filename[200]; TCHAR filename[2*MAX_PATH];
STARTUPINFO start_info; STARTUPINFO start_info;
PROCESS_INFORMATION proc_info; PROCESS_INFORMATION proc_info;
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd; SECURITY_DESCRIPTOR sd;
HINSTANCE status;
CLEAR (start_info); CLEAR (start_info);
CLEAR (proc_info); CLEAR (proc_info);
CLEAR (sa); CLEAR (sa);
CLEAR (sd); CLEAR (sd);
/* Try first using file association */
_sntprintf_0(filename, L"%s\\%s", o.conn[config].config_dir, o.conn[config].config_file);
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); /* Safe to init COM multiple times */
status = ShellExecuteW (o.hWnd, L"open", filename, NULL, o.conn[config].config_dir, SW_SHOWNORMAL);
if (status > (HINSTANCE) 32)
return;
else
PrintDebug (L"Opening config file using ShellExecute with verb = open failed"
" for config '%s' (status = %lu)", o.conn[config].config_name, status);
_sntprintf_0(filename, _T("%s \"%s\\%s\""), o.editor, o.conn[config].config_dir, o.conn[config].config_file); _sntprintf_0(filename, _T("%s \"%s\\%s\""), o.editor, o.conn[config].config_dir, o.conn[config].config_file);
/* fill in STARTUPINFO struct */ /* fill in STARTUPINFO struct */