Treat --connect as --command connect in case GUI is already running

- This makes the behaviour more intuitive for those used to the
  auto connect option (--connect xxx). Note: this will work only for
  the first occurrence of --connect as --command allows only one profile
  to be speciifed.
- Also make '--command connect' behave as '--connect' if the GUI is not
  already running.

Based on comment by larson0815 here:
https://github.com/selvanair/openvpn-gui/issues/5

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/188/head
Selva Nair 8 years ago
parent 0f21030774
commit eb52950f7a

@ -101,6 +101,14 @@ add_option(options_t *options, int i, TCHAR **p)
exit(1); exit(1);
} }
options->auto_connect[auto_connect_nr++] = p[1]; options->auto_connect[auto_connect_nr++] = p[1];
/* Treat the first connect option to also mean --command connect profile.
* This gets used if we are not the first instance.
*/
if (auto_connect_nr == 1)
{
options->action = WM_OVPN_START;
options->action_arg = p[1];
}
} }
else if (streq(p[0], _T("exe_path")) && p[1]) else if (streq(p[0], _T("exe_path")) && p[1])
{ {
@ -209,6 +217,8 @@ add_option(options_t *options, int i, TCHAR **p)
/* command to be sent to a running instance */ /* command to be sent to a running instance */
if (streq(p[1], _T("connect")) && p[2]) if (streq(p[1], _T("connect")) && p[2])
{ {
/* Treat this as "--connect profile" in case this is the first instance */
add_option(options, i, &p[1]);
++i; ++i;
options->action = WM_OVPN_START; options->action = WM_OVPN_START;
options->action_arg = p[2]; options->action_arg = p[2];

Loading…
Cancel
Save