/// <summary> /// Initializes a new OVPNLogManager object. /// </summary> /// <param name="parent">the parent</param> internal LogManager(Connection parent) { m_ovpn = parent; }
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; } }
private void Dispose(bool disposing) { if (!disposed) { if (disposing) { m_ovpnComm.Dispose(); } m_logs = null; m_ovpnMParser = null; m_pkcs11details = null; m_todo = null; m_ovpn = null; disposed = true; } }
/// <summary> /// (re)initialize all controls and data<br /> /// this is needed if the configuration has changed /// </summary> private void init() { if (m_parent.InvokeRequired) { try { m_parent.Invoke(new UtilsHelper.Action(init)); } catch (ObjectDisposedException) { } return; } m_vpn = null; m_menu.DropDownItems.Clear(); m_status.Hide(); try { if (!m_isService) { m_vpn = new UserSpaceConnection(m_bin, m_file, new EventHandler<LogEventArgs>(addLog), m_dbglevel, m_smartCard); } else { m_vpn = new ServiceConnection(m_file, new EventHandler<LogEventArgs>(addLog), m_dbglevel, m_smartCard); } } catch (ApplicationException e) { m_error_message = e.Message; } Name = VPNConfig.GetDescriptiveName(m_file); if (m_isService) Name += " (" + Program.res.GetString("DIALOG_Service") + ")"; m_menu.Text = Name; m_infobox.Init(); if (m_error_message != null) { m_menu_error = new ToolStripMenuItem(Program.res.GetString("TRAY_Error_Information")); m_menu_error.Click += new EventHandler(m_menu_error_Click); m_menu.DropDownItems.Add(m_menu_error); return; } m_vpn.Logs.DebugLevel = m_dbglevel; m_vpn.State.StateChanged += new EventHandler<StateChangedEventArgs>(State_StateChanged); m_vpn.NeedCardId += new EventHandler<NeedCardIdEventArgs>(m_vpn_needCardID); m_vpn.NeedPassword += new EventHandler<NeedPasswordEventArgs>(m_vpn_needPassword); m_vpn.NeedLoginAndPassword += new EventHandler<NeedLoginAndPasswordEventArgs>(m_vpn_needLoginAndPassword); m_status.Init(); m_menu_connect = new ToolStripMenuItem(Program.res.GetString("TRAY_Connect")); m_menu_connect.Image = Properties.Resources.BUTTON_Connect; m_menu_connect.Click += new EventHandler(m_menu_connect_Click); m_menu.DropDownItems.Add(m_menu_connect); m_menu_disconnect = new ToolStripMenuItem(Program.res.GetString("TRAY_Disconnect")); m_menu_disconnect.Image = Properties.Resources.BUTTON_Disconnect; m_menu_disconnect.Click += new EventHandler(m_menu_disconnect_Click); m_menu_disconnect.Visible = false; m_menu.DropDownItems.Add(m_menu_disconnect); m_menu_show = new ToolStripMenuItem(Program.res.GetString("TRAY_Show")); m_menu_show.Image = Properties.Resources.BUTTON_Details; m_menu_show.Click += new EventHandler(m_menu_show_Click); m_menu.DropDownItems.Add(m_menu_show); m_menu_edit = new ToolStripMenuItem(Program.res.GetString("TRAY_Edit")); m_menu_edit.Enabled = !m_isService; m_menu_edit.Image = Properties.Resources.BUTTON_Edit; m_menu_edit.Click += new EventHandler(m_menu_edit_Click); m_menu.DropDownItems.Add(m_menu_edit); m_menu.Image = Properties.Resources.STATE_Stopped; }
/// <summary> /// Creates a new ManagementLogic object. /// </summary> /// <param name="ovpn">parent</param> /// <param name="host">host to connect to (e.g. 127.0.0.1)</param> /// <param name="port">port to connect to</param> /// <param name="logs">LogManager to write the logs to</param> /// <param name="receiveOldLogs">Should old log lines be received?</param> public ManagementLogic(Connection ovpn, string host, int port, LogManager logs, bool receiveOldLogs) { m_ovpn = ovpn; m_logs = logs; m_releaselock = true; m_receiveOldLogs = receiveOldLogs; // initialize required components m_ovpnComm = new Communicator(host, port, logs); m_ovpnMParser = new ManagementParser(m_ovpnComm, this); m_pkcs11details = new List<PKCS11Detail>(); m_ovpnComm.connectionClosed += new System.EventHandler(m_ovpnComm_connectionClosed); }