mirror of https://github.com/OpenVPN/openvpn-gui
commit
03c305bd4b
|
@ -62,10 +62,13 @@ match(const WIN32_FIND_DATA *find, const TCHAR *ext)
|
|||
}
|
||||
|
||||
static bool
|
||||
CheckReadAccess (const TCHAR *path)
|
||||
CheckReadAccess (const TCHAR *dir, const TCHAR *file)
|
||||
{
|
||||
HANDLE h;
|
||||
bool ret = FALSE;
|
||||
TCHAR path[MAX_PATH];
|
||||
|
||||
_sntprintf_0 (path, _T("%s\\%s"), dir, file);
|
||||
|
||||
h = CreateFile (path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
@ -127,7 +130,6 @@ BuildFileList0(const TCHAR *config_dir, bool warn_duplicates)
|
|||
HANDLE find_handle;
|
||||
TCHAR find_string[MAX_PATH];
|
||||
TCHAR subdir_table[MAX_CONFIG_SUBDIRS][MAX_PATH];
|
||||
TCHAR fullpath[MAX_PATH];
|
||||
int subdirs = 0;
|
||||
int i;
|
||||
|
||||
|
@ -148,8 +150,6 @@ BuildFileList0(const TCHAR *config_dir, bool warn_duplicates)
|
|||
match_t match_type = match(&find_obj, o.ext_string);
|
||||
if (match_type == match_file)
|
||||
{
|
||||
_sntprintf_0(fullpath, _T("%s\\%s"), config_dir, find_obj.cFileName);
|
||||
|
||||
if (ConfigAlreadyExists(find_obj.cFileName))
|
||||
{
|
||||
if (warn_duplicates)
|
||||
|
@ -157,7 +157,7 @@ BuildFileList0(const TCHAR *config_dir, bool warn_duplicates)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (CheckReadAccess (fullpath))
|
||||
if (CheckReadAccess (config_dir, find_obj.cFileName))
|
||||
AddConfigFileToList(o.num_configs++, find_obj.cFileName, config_dir);
|
||||
}
|
||||
else if (match_type == match_dir)
|
||||
|
@ -204,7 +204,8 @@ BuildFileList0(const TCHAR *config_dir, bool warn_duplicates)
|
|||
continue;
|
||||
}
|
||||
|
||||
AddConfigFileToList(o.num_configs++, find_obj.cFileName, subdir_table[i]);
|
||||
if (CheckReadAccess (subdir_table[i], find_obj.cFileName))
|
||||
AddConfigFileToList(o.num_configs++, find_obj.cFileName, subdir_table[i]);
|
||||
} while (FindNextFile(find_handle, &find_obj));
|
||||
|
||||
FindClose(find_handle);
|
||||
|
@ -216,7 +217,13 @@ BuildFileList()
|
|||
{
|
||||
static bool issue_warnings = true;
|
||||
|
||||
o.num_configs = 0;
|
||||
/*
|
||||
* If no connections are active reset num_configs and rescan
|
||||
* to make a new list. Else we keep all current configs and
|
||||
* rescan to add any new one's found
|
||||
*/
|
||||
if (CountConnState(disconnected) == o.num_configs)
|
||||
o.num_configs = 0;
|
||||
|
||||
BuildFileList0 (o.config_dir, issue_warnings);
|
||||
|
||||
|
|
16
tray.c
16
tray.c
|
@ -182,8 +182,7 @@ OnNotifyTray(LPARAM lParam)
|
|||
case WM_RBUTTONUP:
|
||||
/* Recreate popup menus */
|
||||
DestroyPopupMenus();
|
||||
if (CountConnState(disconnected) == o.num_configs)
|
||||
BuildFileList();
|
||||
BuildFileList();
|
||||
CreatePopupMenus();
|
||||
|
||||
GetCursorPos(&pt);
|
||||
|
@ -206,16 +205,13 @@ OnNotifyTray(LPARAM lParam)
|
|||
else {
|
||||
int disconnected_conns = CountConnState(disconnected);
|
||||
|
||||
if (disconnected_conns == o.num_configs) {
|
||||
/* Reread configs and recreate menus if no connection is running */
|
||||
DestroyPopupMenus();
|
||||
BuildFileList();
|
||||
CreatePopupMenus();
|
||||
DestroyPopupMenus();
|
||||
BuildFileList();
|
||||
CreatePopupMenus();
|
||||
|
||||
/* Start connection if only one config exist */
|
||||
if (o.num_configs == 1 && o.conn[0].state == disconnected)
|
||||
/* Start connection if only one config exist */
|
||||
if (o.num_configs == 1 && o.conn[0].state == disconnected)
|
||||
StartOpenVPN(&o.conn[0]);
|
||||
}
|
||||
else if (disconnected_conns == o.num_configs - 1) {
|
||||
/* Show status window if only one connection is running */
|
||||
int i;
|
||||
|
|
Loading…
Reference in New Issue