Example #1
0
        public VPNSettings(StreamReroute reroute)
        {
            InitializeComponent();

            sReroute = reroute;

            whiteListCheckBox.IsChecked = Properties.Settings.Default.streamReroute;
            if (!Properties.Settings.Default.streamReroute)
            {
                whitelistGrid.IsEnabled = false;
            }
            netflixCheckBox.IsChecked = Properties.Settings.Default.rerouteNetflix;
            huluCheckBox.IsChecked    = Properties.Settings.Default.rerouteHulu;

            PopulateList();
        }
Example #2
0
        public MainWindow()
        {
            DataContext = this;

            wantsConnect = false;

            sReroute = new StreamReroute();

            InitializeComponent();

            if (Properties.Settings.Default.needsUpgrade)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.needsUpgrade = false;
                Properties.Settings.Default.Save();
            }

            this.Topmost = true;

            PopulateComboBox();

            bool needsLoginWindow = true;

            if (checkLogin())
            {
                // VPN for some reason still in place
                if (vpnControl.checkVPNExists())
                {
                    //initTimer();
                    needsLoginWindow = false;

                    setConnecting();
                }
                // else check certificate installed; then go ahead and add back VPN
                else if (VPNControl.checkCertificateInstalled() && !noInternet)
                {
                    needsLoginWindow = false;
                    vpnControl.addVPN(Properties.Settings.Default.region);

                    setConnecting();

                    //initTimer();
                }
                else if (noInternet && !needsLoginWindow)
                {
                    System.Windows.Forms.MessageBox.Show("Can't connect to server.");
                }
                else if (!VPNControl.checkCertificateInstalled() && !noInternet)
                {
                    // reinstall certificates
                    var getKeyResponse       = apiControl.getKey();
                    var getKeyResponseString = getKeyResponse.Result.Content.ReadAsStringAsync();

                    var getKeyDict = JsonConvert.DeserializeObject <Dictionary <string, string> >(getKeyResponseString.Result);

                    if (getKeyDict.ContainsKey("b64"))
                    {
                        string tempFile = System.IO.Path.GetTempFileName();

                        File.WriteAllBytes(tempFile, Convert.FromBase64String(getKeyDict["b64"]));

                        VPNControl.addCertificate(tempFile);

                        needsLoginWindow = false;
                        vpnControl.addVPN(Properties.Settings.Default.region);

                        setConnecting();
                    }
                }
                else
                {
                    needsLoginWindow = true;
                }
            }

            // if not ready to run VPN, send to login window
            if (needsLoginWindow)
            {
                handleLoginForm(false);
            }
            else
            {
                notifyIcon.Visible = true;
                initTimer();
            }
            //initNotifyIcon();

            // For crash testing
            //int x = 0;
            //int y = 1 / x;

            //SetWindowPosition();
        }