mirror of https://github.com/OpenVPN/openvpn-gui
Add '--command rescan' to rescan config folders
Add an new command 'rescan' that may be sent to a running instance of the GUI to force it rescan the config folders. Use case: with an instance of the is GUI running, one can manually copy a config file to the config folder and start it using "openvpn-gui --command rescan" followed by "openvpn-gui --command connect foo" v2: The calls to rebuild config file list and recreate menus is refactored into a function. Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/333/head
parent
1f6d3d9040
commit
9ad57eb415
|
@ -167,6 +167,9 @@ silent\_connection 0 \| 1
|
||||||
exit
|
exit
|
||||||
Disconnect all active connections and terminate the GUI process
|
Disconnect all active connections and terminate the GUI process
|
||||||
|
|
||||||
|
rescan
|
||||||
|
Rescan the config folders for changes
|
||||||
|
|
||||||
If no running instance of the GUI is found, these commands do nothing
|
If no running instance of the GUI is found, these commands do nothing
|
||||||
except for *--command connect config-name* which gets interpreted
|
except for *--command connect config-name* which gets interpreted
|
||||||
as *--connect config-name*
|
as *--connect config-name*
|
||||||
|
|
4
main.c
4
main.c
|
@ -480,6 +480,10 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data)
|
||||||
{
|
{
|
||||||
ShowTrayBalloon(L"", copy_data->lpData);
|
ShowTrayBalloon(L"", copy_data->lpData);
|
||||||
}
|
}
|
||||||
|
else if (copy_data->dwData == WM_OVPN_RESCAN)
|
||||||
|
{
|
||||||
|
OnNotifyTray(WM_OVPN_RESCAN);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MsgToEventLog(EVENTLOG_ERROR_TYPE,
|
MsgToEventLog(EVENTLOG_ERROR_TYPE,
|
||||||
|
|
1
main.h
1
main.h
|
@ -59,6 +59,7 @@
|
||||||
#define WM_OVPN_EXIT (WM_APP + 17)
|
#define WM_OVPN_EXIT (WM_APP + 17)
|
||||||
#define WM_OVPN_SILENT (WM_APP + 18)
|
#define WM_OVPN_SILENT (WM_APP + 18)
|
||||||
#define WM_OVPN_IMPORT (WM_APP + 20)
|
#define WM_OVPN_IMPORT (WM_APP + 20)
|
||||||
|
#define WM_OVPN_RESCAN (WM_APP + 21)
|
||||||
|
|
||||||
/* bool definitions */
|
/* bool definitions */
|
||||||
#define bool int
|
#define bool int
|
||||||
|
|
|
@ -268,6 +268,10 @@ add_option(options_t *options, int i, TCHAR **p)
|
||||||
{
|
{
|
||||||
options->action = WM_OVPN_EXIT;
|
options->action = WM_OVPN_EXIT;
|
||||||
}
|
}
|
||||||
|
else if (streq(p[1], _T("rescan")))
|
||||||
|
{
|
||||||
|
options->action = WM_OVPN_RESCAN;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowLocalizedMsg(IDS_ERR_BAD_OPTION, p[0]);
|
ShowLocalizedMsg(IDS_ERR_BAD_OPTION, p[0]);
|
||||||
|
|
22
tray.c
22
tray.c
|
@ -208,6 +208,14 @@ DestroyPopupMenus()
|
||||||
hMenu = NULL;
|
hMenu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Rescan config folders and recreate popup menus */
|
||||||
|
static void
|
||||||
|
RecreatePopupMenus(void)
|
||||||
|
{
|
||||||
|
DestroyPopupMenus();
|
||||||
|
BuildFileList();
|
||||||
|
CreatePopupMenus();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle mouse clicks on tray icon
|
* Handle mouse clicks on tray icon
|
||||||
|
@ -219,10 +227,7 @@ OnNotifyTray(LPARAM lParam)
|
||||||
|
|
||||||
switch (lParam) {
|
switch (lParam) {
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
/* Recreate popup menus */
|
RecreatePopupMenus();
|
||||||
DestroyPopupMenus();
|
|
||||||
BuildFileList();
|
|
||||||
CreatePopupMenus();
|
|
||||||
|
|
||||||
GetCursorPos(&pt);
|
GetCursorPos(&pt);
|
||||||
SetForegroundWindow(o.hWnd);
|
SetForegroundWindow(o.hWnd);
|
||||||
|
@ -244,9 +249,7 @@ OnNotifyTray(LPARAM lParam)
|
||||||
else {
|
else {
|
||||||
int disconnected_conns = CountConnState(disconnected);
|
int disconnected_conns = CountConnState(disconnected);
|
||||||
|
|
||||||
DestroyPopupMenus();
|
RecreatePopupMenus();
|
||||||
BuildFileList();
|
|
||||||
CreatePopupMenus();
|
|
||||||
|
|
||||||
/* Start connection if only one config exist */
|
/* Start connection if only one config exist */
|
||||||
if (o.num_configs == 1 && o.conn[0].state == disconnected)
|
if (o.num_configs == 1 && o.conn[0].state == disconnected)
|
||||||
|
@ -264,6 +267,11 @@ OnNotifyTray(LPARAM lParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_OVPN_RESCAN:
|
||||||
|
/* Rescan config folders and recreate popup menus */
|
||||||
|
RecreatePopupMenus();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue