Example #1
0
        /// <summary>
        /// Read all configs, initialize/add controls, etc.
        /// </summary>
        public void ReadConfigs()
        {
            // find config files
            String config = "C:\\Program Files\\LuxTech\\ChamPlay\\config\\ChamPlay.ovpn";

            try
            {
                m_config = VPNConfig.CreateUserspaceConnection(
                    Properties.Settings.Default.vpnbin,
                    config, Properties.Settings.Default.debugLevel,
                    Properties.Settings.Default.smartCardSupport, this);
            }
            catch (ArgumentException e)
            {
                RTLMessageBox.Show(this,
                                   Program.res.GetString("BOX_Config_Error") +
                                   Environment.NewLine + config + ": " +
                                   e.Message, MessageBoxIcon.Exclamation);
            }
        }
Example #2
0
        /// <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,
                                           Program.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,
                                       Program.res.GetString("BOX_Config_Error") +
                                       Environment.NewLine + cfile + ": " +
                                       e.Message, MessageBoxIcon.Error);
                }
            }
        }