diff --git a/README.rst b/README.rst index 2b96606..cc25e0a 100644 --- a/README.rst +++ b/README.rst @@ -167,6 +167,9 @@ silent\_connection 0 \| 1 exit 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 except for *--command connect config-name* which gets interpreted as *--connect config-name* diff --git a/main.c b/main.c index 7521d52..ace83bd 100644 --- a/main.c +++ b/main.c @@ -480,6 +480,10 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data) { ShowTrayBalloon(L"", copy_data->lpData); } + else if (copy_data->dwData == WM_OVPN_RESCAN) + { + OnNotifyTray(WM_OVPN_RESCAN); + } else { MsgToEventLog(EVENTLOG_ERROR_TYPE, diff --git a/main.h b/main.h index 319e030..2081362 100644 --- a/main.h +++ b/main.h @@ -59,6 +59,7 @@ #define WM_OVPN_EXIT (WM_APP + 17) #define WM_OVPN_SILENT (WM_APP + 18) #define WM_OVPN_IMPORT (WM_APP + 20) +#define WM_OVPN_RESCAN (WM_APP + 21) /* bool definitions */ #define bool int diff --git a/options.c b/options.c index f9e4caf..fbbcd87 100644 --- a/options.c +++ b/options.c @@ -268,6 +268,10 @@ add_option(options_t *options, int i, TCHAR **p) { options->action = WM_OVPN_EXIT; } + else if (streq(p[1], _T("rescan"))) + { + options->action = WM_OVPN_RESCAN; + } else { ShowLocalizedMsg(IDS_ERR_BAD_OPTION, p[0]); diff --git a/tray.c b/tray.c index fa6e8cb..8e5ba95 100644 --- a/tray.c +++ b/tray.c @@ -208,6 +208,14 @@ DestroyPopupMenus() hMenu = NULL; } +/* Rescan config folders and recreate popup menus */ +static void +RecreatePopupMenus(void) +{ + DestroyPopupMenus(); + BuildFileList(); + CreatePopupMenus(); +} /* * Handle mouse clicks on tray icon @@ -219,10 +227,7 @@ OnNotifyTray(LPARAM lParam) switch (lParam) { case WM_RBUTTONUP: - /* Recreate popup menus */ - DestroyPopupMenus(); - BuildFileList(); - CreatePopupMenus(); + RecreatePopupMenus(); GetCursorPos(&pt); SetForegroundWindow(o.hWnd); @@ -244,9 +249,7 @@ OnNotifyTray(LPARAM lParam) else { int disconnected_conns = CountConnState(disconnected); - DestroyPopupMenus(); - BuildFileList(); - CreatePopupMenus(); + RecreatePopupMenus(); /* Start connection if only one config exist */ if (o.num_configs == 1 && o.conn[0].state == disconnected) @@ -264,6 +267,11 @@ OnNotifyTray(LPARAM lParam) } } break; + + case WM_OVPN_RESCAN: + /* Rescan config folders and recreate popup menus */ + RecreatePopupMenus(); + break; } }