Skip to content

Commit

Permalink
Do not remove tray icon when WM_OVPN_STOPALL is processed
Browse files Browse the repository at this point in the history
- commit f8a243f introduced removing the tray icon during
  the wait for exit to avoid further user interaction. This
  is done in StopAllOpenVPN(). However, this function is also
  reused for processing WM_OVPN_STOPALL message received from
  a second instance via --comamnd disconnect_all. In this case
  the tray icon should not be removed as we are not exiting.

Fixes issue #607

Signed-off-by: Selva Nair <[email protected]>
  • Loading branch information
selvanair committed Mar 13, 2023
1 parent 4803c7a commit c51a37c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,14 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,


static void
StopAllOpenVPN()
StopAllOpenVPN(bool exiting)
{
int i;

RemoveTrayIcon();
if (exiting)
{
RemoveTrayIcon();
}

/* Stop all connections started by us -- we leave persistent ones
* at their current state. Use the disconnect menu to put them into
Expand Down Expand Up @@ -451,7 +454,9 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data)
ShowWindow(c->hwndStatus, SW_SHOW);
}
else if(copy_data->dwData == WM_OVPN_STOPALL)
StopAllOpenVPN();
{
StopAllOpenVPN(false);
}
else if(copy_data->dwData == WM_OVPN_SILENT && str)
{
if (_wtoi(str) == 0)
Expand Down Expand Up @@ -680,7 +685,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM

case WM_DESTROY:
WTSUnRegisterSessionNotification(hwnd);
StopAllOpenVPN();
StopAllOpenVPN(true);
OnDestroyTray(); /* Remove Tray Icon and destroy menus */
PostQuitMessage (0); /* Send a WM_QUIT to the message queue */
break;
Expand All @@ -690,7 +695,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM

case WM_ENDSESSION:
SaveAutoRestartList();
StopAllOpenVPN();
StopAllOpenVPN(true);
OnDestroyTray();
break;

Expand Down Expand Up @@ -980,7 +985,7 @@ ErrorExit(int exit_code, const wchar_t *msg)
MB_OK | MB_SETFOREGROUND | MB_ICONERROR | MBOX_RTL_FLAGS, GetGUILanguage());
if (o.hWnd)
{
StopAllOpenVPN();
StopAllOpenVPN(true);
PostQuitMessage(exit_code);
}
else
Expand Down

0 comments on commit c51a37c

Please sign in to comment.