static void Main(string[] args) { try { List <string> arguments = new List <string>(args); Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler( SystemEvents_PowerModeChanged); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Mutex appSingleton = new Mutex(false, Application.ProductName + ".SingleInstance"); m_mainform = new FrmGlobalStatus(); Application.Run(m_mainform); appSingleton.Close(); } catch (Exception ex) { //In case of 'something terible' dont disappear without a message. MessageBox.Show(ex.ToString()); } }
static void Main(string[] args) { try { List <string> arguments = new List <string>(args); Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler( SystemEvents_PowerModeChanged); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (CommandLineArgumentsContain(arguments, "INSTALL-AUTOSTART")) { Helper.InstallAutostart(); return; } else if (CommandLineArgumentsContain(arguments, "REMOVE-AUTOSTART")) { Helper.RemoveAutostart(); // Remove autostart, quit (for setup, e.g.) return; } else if (CommandLineArgumentsContain(arguments, "?") || CommandLineArgumentsContain(arguments, "HELP") || CommandLineArgumentsContain(arguments, "H")) { RTLMessageBox.Show(res.GetString("ARGS_Help"), // Show help MessageBoxIcon.Information); return; } Mutex appSingleton = new Mutex(false, Application.ProductName + ".SingleInstance"); if (appSingleton.WaitOne(0, false)) { m_mainform = new FrmGlobalStatus(arguments.ToArray()); Application.Run(m_mainform); } else { if (arguments.Count > 0) { SimpleComm sc = new SimpleComm(4911); if (!sc.client(arguments.ToArray())) { RTLMessageBox.Show(res.GetString("ARGS_Error"), MessageBoxIcon.Error); } } } appSingleton.Close(); } catch (Exception ex) { //In case of 'something terible' dont disappear without a message. MessageBox.Show(ex.ToString()); } }
static void Main(string[] args) { try { List<string> arguments = new List<string>(args); Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler( SystemEvents_PowerModeChanged); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (CommandLineArgumentsContain(arguments, "INSTALL-AUTOSTART")) { Helper.InstallAutostart(); return; } else if (CommandLineArgumentsContain(arguments, "REMOVE-AUTOSTART")) { Helper.RemoveAutostart(); // Remove autostart, quit (for setup, e.g.) return; } else if (CommandLineArgumentsContain(arguments, "?") || CommandLineArgumentsContain(arguments, "HELP") || CommandLineArgumentsContain(arguments, "H")) { RTLMessageBox.Show(res.GetString("ARGS_Help"), // Show help MessageBoxIcon.Information); return; } Mutex appSingleton = new Mutex(false, Application.ProductName + ".SingleInstance"); if (appSingleton.WaitOne(0, false)) { m_mainform = new FrmGlobalStatus(arguments.ToArray()); Application.Run(m_mainform); } else { if (arguments.Count > 0) { SimpleComm sc = new SimpleComm(4911); if (!sc.client(arguments.ToArray())) RTLMessageBox.Show(res.GetString("ARGS_Error"), MessageBoxIcon.Error); } } appSingleton.Close(); } catch (Exception ex) { //In case of 'something terible' dont disappear without a message. MessageBox.Show(ex.ToString()); } }
private void Dispose(bool disposing) { if (!disposed) { File.Delete(m_tempLog); if (disposing) { m_disconnectTimer.Dispose(); m_frmkey.Dispose(); m_frmlpw.Dispose(); m_frmpw.Dispose(); m_infobox.Dispose(); m_menu.Dispose(); m_menu_connect.Dispose(); m_menu_disconnect.Dispose(); m_menu_edit.Dispose(); m_menu_error.Dispose(); m_menu_show.Dispose(); m_parent.Dispose(); m_status.Dispose(); m_vpn.Dispose(); } m_vpn = null; m_status = null; m_parent = null; m_menu_show = null; m_menu_error = null; m_menu_edit = null; m_menu_disconnect = null; m_menu_connect = null; m_menu = null; m_infobox = null; m_frmpw = null; m_frmlpw = null; m_frmkey = null; m_disconnectTimer = null; disposed = true; } }
private void Dispose(bool disposing) { if (!disposed) { if (disposing) { m_disconnectTimer.Dispose(); m_frmlpw.Dispose(); m_parent.Dispose(); VPNConnection.Dispose(); } VPNConnection = null; m_parent = null; m_frmlpw = null; m_disconnectTimer = null; disposed = true; } }
private void Dispose(bool disposing) { if (!disposed) { if (disposing) { m_disconnectTimer.Dispose(); m_frmkey.Dispose(); m_frmlpw.Dispose(); m_frmpw.Dispose(); m_infobox.Dispose(); m_menu.Dispose(); m_menu_connect.Dispose(); m_menu_disconnect.Dispose(); m_menu_edit.Dispose(); m_menu_error.Dispose(); m_menu_show.Dispose(); m_parent.Dispose(); m_status.Dispose(); m_vpn.Dispose(); } m_vpn = null; m_status = null; m_parent = null; m_menu_show = null; m_menu_error = null; m_menu_edit = null; m_menu_disconnect = null; m_menu_connect = null; m_menu = null; m_infobox = null; m_frmpw = null; m_frmlpw = null; m_frmkey = null; m_disconnectTimer = null; disposed = true; } }
/// <summary> /// Constructs a new object. /// Loads the configuration and prepares a connection. /// A userspace VPN connection will be used. /// </summary> /// <param name="bin">path to the openvpn executable</param> /// <param name="file">path to the configuration of this openvpn</param> /// <param name="dbglevel">the debug level for internal logs</param> /// <param name="smartCardSupport">enable smartCard support</param> /// <param name="parent">the parent of the menu</param> /// <seealso cref="init" /> static public VPNConfig CreateUserspaceConnection(string bin, string file, int dbglevel, bool smartCardSupport, FrmGlobalStatus parent) { VPNConfig vc = new VPNConfig(); vc.m_file = file; vc.m_bin = bin; vc.m_parent = parent; vc.m_dbglevel = dbglevel; vc.m_isService = false; vc.m_smartCard = smartCardSupport; vc.init(); return vc; }
static void Main(string[] args) { bool noUserInteraction = false;//service process only try { List<string> arguments = new List<string>(args); Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler( SystemEvents_PowerModeChanged); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (CommandLineArgumentsContain(arguments, "INSTALL")) { ServiceHelper.installService(); return; } if (CommandLineArgumentsContain(arguments, "UNINSTALL")) { ServiceHelper.uninstallService(); return; } if (CommandLineArgumentsContain(arguments, "EXECUTESERVICE")) { // EXECUTESERVICE is not to be used by the end-user but only for service installation run command // this to be able to know it should start as a service. noUserInteraction = true; ServiceHelper.executeService(); return; } if (CommandLineArgumentsContain(arguments, "EXECUTESERVICEASCONSOLE")) { ServiceHelper.executeServiceAsConsole(); return; } else if (CommandLineArgumentsContain(arguments, "INSTALL-AUTOSTART")) { helper.installAutostart(); return; } else if (CommandLineArgumentsContain(arguments, "REMOVE-AUTOSTART")) { helper.removeAutostart(); // Remove autostart, quit (for setup, e.g.) return; } else if (CommandLineArgumentsContain(arguments, "?") || CommandLineArgumentsContain(arguments, "HELP") || CommandLineArgumentsContain(arguments, "H")) { RTLMessageBox.Show(res.GetString("ARGS_Help"), // Show help MessageBoxIcon.Information); return; } Mutex appSingleton = new Mutex(false, Application.ProductName + ".SingleInstance"); if (appSingleton.WaitOne(0, false)) { m_mainform = new FrmGlobalStatus(arguments.ToArray()); Application.Run(m_mainform); } else { if (arguments.Count > 0) { SimpleComm sc = new SimpleComm(4911); if (!sc.client(arguments.ToArray())) RTLMessageBox.Show(res.GetString("ARGS_Error"), MessageBoxIcon.Error); } } appSingleton.Close(); } catch (Exception ex) { if (noUserInteraction) { string eventlogAppName = "OpenVPNManager"; if (!EventLog.SourceExists(eventlogAppName)) EventLog.CreateEventSource(eventlogAppName, "Application"); EventLog.WriteEntry(eventlogAppName, ex.ToString(), EventLogEntryType.Error, 0); } else //In case of 'something terible' dont disappear without a message. MessageBox.Show(ex.ToString()); } }
/// <summary> /// Constructs a new object. /// Loads the configuration and prepares a connection. /// A userspace VPN connection will be used. /// </summary> /// <param name="bin">path to the openvpn executable</param> /// <param name="file">path to the configuration of this openvpn</param> /// <param name="dbglevel">the debug level for internal logs</param> /// <param name="smartCardSupport">enable smartCard support</param> /// <param name="parent">the parent of the menu</param> /// <seealso cref="init" /> static public VPNConfig CreateUserspaceConnection(string bin, string file, int dbglevel, bool smartCardSupport, FrmGlobalStatus parent) { VPNConfig vc = new VPNConfig(); vc.m_file = file; vc.m_bin = bin; vc.m_parent = parent; vc.m_dbglevel = dbglevel; vc.m_isService = false; vc.m_smartCard = smartCardSupport; vc.init(); return(vc); }
static void Main(string[] args) { bool noUserInteraction = false;//service process only try { List <string> arguments = new List <string>(args); Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler( SystemEvents_PowerModeChanged); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (CommandLineArgumentsContain(arguments, "INSTALL")) { ServiceHelper.installService(); return; } if (CommandLineArgumentsContain(arguments, "UNINSTALL")) { ServiceHelper.uninstallService(); return; } if (CommandLineArgumentsContain(arguments, "EXECUTESERVICE")) { // EXECUTESERVICE is not to be used by the end-user but only for service installation run command // this to be able to know it should start as a service. noUserInteraction = true; ServiceHelper.executeService(); return; } if (CommandLineArgumentsContain(arguments, "EXECUTESERVICEASCONSOLE")) { ServiceHelper.executeServiceAsConsole(); return; } else if (CommandLineArgumentsContain(arguments, "INSTALL-AUTOSTART")) { helper.installAutostart(); return; } else if (CommandLineArgumentsContain(arguments, "REMOVE-AUTOSTART")) { helper.removeAutostart(); // Remove autostart, quit (for setup, e.g.) return; } else if (CommandLineArgumentsContain(arguments, "?") || CommandLineArgumentsContain(arguments, "HELP") || CommandLineArgumentsContain(arguments, "H")) { RTLMessageBox.Show(res.GetString("ARGS_Help"), // Show help MessageBoxIcon.Information); return; } Mutex appSingleton = new Mutex(false, Application.ProductName + ".SingleInstance"); if (appSingleton.WaitOne(0, false)) { m_mainform = new FrmGlobalStatus(arguments.ToArray()); Application.Run(m_mainform); } else { if (arguments.Count > 0) { SimpleComm sc = new SimpleComm(4911); if (!sc.client(arguments.ToArray())) { RTLMessageBox.Show(res.GetString("ARGS_Error"), MessageBoxIcon.Error); } } } appSingleton.Close(); } catch (Exception ex) { if (noUserInteraction) { string eventlogAppName = "OpenVPNManager"; if (!EventLog.SourceExists(eventlogAppName)) { EventLog.CreateEventSource(eventlogAppName, "Application"); } EventLog.WriteEntry(eventlogAppName, ex.ToString(), EventLogEntryType.Error, 0); } else { //In case of 'something terible' dont disappear without a message. MessageBox.Show(ex.ToString()); } } }