/// <summary> /// refreshs the XML data, may reset hadErrors /// </summary> /// <param name="silence">don't show message boxes on error</param> public void refresh(bool silence) { XmlDocument doc; // TODO: Check what happens if we are not connected try { doc = new XmlDocument(); doc.Load(XmlReader.Create("http://openvpn.jowisoftware.de/versions.xml")); } catch (WebException e) { if (!silence) { RTLMessageBox.Show(m_parent, ProgramVPN.res.GetString( "BOX_UpdateError") + ": " + e.Message, MessageBoxIcon.Error); } return; } catch (XmlException e) { if (!silence) { RTLMessageBox.Show(m_parent, ProgramVPN.res.GetString( "BOX_UpdateFormat") + ": " + e.Message, MessageBoxIcon.Error); } return; } n = doc.DocumentElement.SelectSingleNode("application[@name='OpenVPN Manager']"); }
private void WarnServiceChange(string oldBin, string p) { if (ServiceIsInstalled() && oldBin != p) { RTLMessageBox.Show(ProgramVPN.res.GetString("BOX_UpdateService"), MessageBoxIcon.Information); } }
/// <summary> /// Show settings, if wanted, detect defaults. /// </summary> /// <param name="Detect"></param> public void ShowSettings(bool detect) { String runningConnections = ""; foreach (VPNConfig c in m_configs) { if (c.Running) { runningConnections += "\r\n" + c.Name; } } if (runningConnections != "") { if (RTLMessageBox.Show(this, ProgramVPN.res.GetString("BOX_Settings_Close") + "\r\n" + runningConnections, MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } } // remember visible-state, hide everything, unload everything bool reShow = Visible; niIcon.Visible = false; Hide(); if (Properties.Settings.Default.allowRemoteControl) { m_simpleComm.stopServer(); } UnloadConfigs(); // show settings, detect settings ViewVPNSettings m_settingsDialog = new ViewVPNSettings(); if (detect) { m_settingsDialog.Detect(); } Console.WriteLine("Oups I did it again ;)"); //m_settingsDialog.ShowDialog(); // reread settings, show icon, show form if needed ReadConfigs(); if (Properties.Settings.Default.allowRemoteControl) { m_simpleComm.startServer(); } niIcon.Visible = true; if (reShow) { Show(); } }
/// <summary> /// a listitem was been double clicked, show text in message box /// </summary> /// <param name="sender">ignored</param> /// <param name="e">ignored</param> private void lstLog_DoubleClick(object sender, EventArgs e) { // show the selected item if (lstLog.SelectedItem != null) { RTLMessageBox.Show(this, ((ColoredListBoxItem)lstLog.SelectedItem).Text, MessageBoxIcon.Information); } }
/*/// <summary> * /// returns the url to the update file itself * /// </summary> * /// <returns>the url to the update file itself</returns> * public string getDownloadFileUrl() * { * if (n == null) * return null; * * string url; * * try * { * url = n.SelectSingleNode("child::download").InnerText; * } * catch (NullReferenceException) * { * MessageBox.Show(ProgramVPN.res.GetString("BOX_UpdateMissing"), * "OpenVPN Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); * return null; * } * * return url; * }*/ /// <summary> /// returns the version of the update /// </summary> /// <returns>version of the update</returns> public string getVersion() { if (n == null) { return(null); } try { return(n.SelectSingleNode("child::version").InnerText); } catch (NullReferenceException) { RTLMessageBox.Show(m_parent, ProgramVPN.res.GetString("BOX_UpdateMissing"), MessageBoxIcon.Error); return(null); } }
/// <summary> /// returns the url to the update page /// </summary> /// <returns>the url to the update page</returns> public string getUpdateUrl() { if (n == null) { return(null); } string url; try { url = n.SelectSingleNode("child::url").InnerText; } catch (NullReferenceException) { RTLMessageBox.Show(m_parent, ProgramVPN.res.GetString("BOX_UpdateMissing"), MessageBoxIcon.Error); return(null); } return(url); }
private void llHowChange_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { RTLMessageBox.Show(this, ProgramVPN.res.GetString("BOX_Service_How_Change"), MessageBoxIcon.Information); }
private void llWhy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { RTLMessageBox.Show(this, m_error, MessageBoxIcon.Information); }
/// <summary> /// Read all configs, initialize/add controls, etc. /// </summary> public void ReadConfigs() { // unload config first, if needed UnloadConfigs(); // find config files List <String> configs = UtilsHelper.LocateOpenVPNConfigs(Properties.Settings.Default.vpnconf); configs.AddRange(UtilsHelper.LocateOpenVPNManagerConfigs(false)); // insert configs in context menu and panel int atIndex = 2; if (configs != null) { toolStripSeparator2.Visible = true; foreach (string cfile in configs) { try { VPNConfig c = VPNConfig.CreateUserspaceConnection( Properties.Settings.Default.vpnbin, cfile, Properties.Settings.Default.debugLevel, Properties.Settings.Default.smartCardSupport, this); m_configs.Add(c); contextMenu.Items.Insert(atIndex++, c.Menuitem); pnlStatus.Controls.Add(c.InfoBox); } catch (ArgumentException e) { RTLMessageBox.Show(this, ProgramVPN.res.GetString("BOX_Config_Error") + Environment.NewLine + cfile + ": " + e.Message, MessageBoxIcon.Exclamation); } } } configs = UtilsHelper.LocateOpenVPNManagerConfigs(true); if (Helper.CanUseService()) { configs.AddRange(Helper.LocateOpenVPNServiceConfigs()); } toolStripSeparator2.Visible = configs.Count > 0; foreach (string cfile in configs) { try { VPNConfig c = VPNConfig.CreateServiceConnection( cfile, Properties.Settings.Default.debugLevel, Properties.Settings.Default.smartCardSupport, this); m_configs.Add(c); contextMenu.Items.Insert(atIndex++, c.Menuitem); pnlStatus.Controls.Add(c.InfoBox); } catch (ArgumentException e) { RTLMessageBox.Show(this, ProgramVPN.res.GetString("BOX_Config_Error") + Environment.NewLine + cfile + ": " + e.Message, MessageBoxIcon.Error); } } }
/// <summary> /// Executes the given commandline. /// </summary> /// <param name="commands">Array of commands</param> private void parseCommandLine(string[] commands) { List <string> args = new List <string>(commands); int i = 0; bool found = false; string names; while (i < args.Count) { switch (args[i].ToUpperInvariant()) { // -connect "vpn name" case "-CONNECT": if (i == args.Count - 1) { RTLMessageBox.Show(this, String.Format( CultureInfo.InvariantCulture, ProgramVPN.res.GetString( "ARGS_Missing_Parameter"), args[i]), MessageBoxIcon.Error); return; } found = false; names = ""; foreach (VPNConfig c in m_configs) { names += c.Name + "\n"; if (c.Name.Equals(args[i + 1], StringComparison.OrdinalIgnoreCase)) { c.Connect(); found = true; } } if (!found) { RTLMessageBox.Show(this, String.Format( CultureInfo.InvariantCulture, ProgramVPN.res.GetString( "ARGS_Invalid_Parameter"), args[i], args[i + 1], names), MessageBoxIcon.Error); } ++i; break; case "-DISCONNECT": if (i == args.Count - 1) { RTLMessageBox.Show(this, String.Format( CultureInfo.InvariantCulture, ProgramVPN.res.GetString( "ARGS_Missing_Parameter"), args[i]), MessageBoxIcon.Error); return; } found = false; names = ""; foreach (VPNConfig c in m_configs) { names += c.Name + "\n"; if (c.Name.Equals(args[i + 1], StringComparison.OrdinalIgnoreCase)) { c.Disconnect(); found = true; } } if (!found) { RTLMessageBox.Show(this, String.Format( CultureInfo.InvariantCulture, ProgramVPN.res.GetString( "ARGS_Invalid_Parameter"), args[i], args[i + 1], names), MessageBoxIcon.Error); } ++i; break; case "-QUIT": case "-EXIT": m_quit = true; //this.Close(); break; default: RTLMessageBox.Show(this, String.Format( CultureInfo.InvariantCulture, ProgramVPN.res.GetString( "ARGS_Unknown_Parameter"), args[i]), MessageBoxIcon.Error); break; } ++i; } }