Example #1
0
        public void Exit()
        {
            // if main interface not closed (triggered from auto-update) then properly close main window
            // let user save files etc..
            // do this before shutting down services so they're still available to do clean up
            if (Exited != null)
            {
                Exited(this);
            }


            CoreRunning = false;

            if (CoreThread != null && CoreThread.IsAlive)
            {
                ProcessEvent.Set();
                CoreThread.Join();
            }
            CoreThread = null;

            try
            {
                if (Network.IsLookup)
                {
                    Network.Lookup.Save(this);
                }
                else
                {
                    User.Save();
                }


                foreach (OpService service in ServiceMap.Values)
                {
                    service.Dispose();
                }

                Network.UPnPControl.Shutdown();
                Network.RudpControl.Shutdown();
                Network.UdpControl.Shutdown();
                Network.LanControl.Shutdown();
                Network.TcpControl.Shutdown();


                ServiceMap.Clear();
                ServiceBandwidth.Clear();


                if (Sim != null)
                {
                    Sim.Internet.UnregisterAddress(this);
                }
            }
            catch
            {
                Debug.Assert(false);
            }
        }
Example #2
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            // check for errors
            string error = ValidateFields();

            if (error != null)
            {
                MessageBox.Show(this, error, "User Settings");
                return;
            }

            bool verify = false;

            // set user name
            if (Profile.Settings.UserName != NameBox.Text)
            {
                verify = true;
            }

            // set password
            if (NewPassBox.Text != "")
            {
                verify = true;
            }

            // save
            if (verify && GuiUtils.VerifyPassphrase(Profile.Core, ThreatLevel.High))
            {
                Profile.Settings.UserName = NameBox.Text;

                if (NewPassBox.Text != "")
                {
                    Profile.SetNewPassword(NewPassBox.Text);
                }

                Profile.Core.RunInCoreAsync(delegate()
                {
                    Profile.Save();
                    Profile.Core.Trust.SaveLocal();
                });
            }


            Close();
        }
Example #3
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            string error = ValidateFields();

            if (error != null)
            {
                MessageBox.Show(this, error, "User Settings");
                return;
            }

            bool verify = false;

            if (Profile.Settings.Operation != OperationBox.Text)
            {
                verify = true;
            }

            if (Profile.OpIcon != SelectedIcon)
            {
                verify = true;
            }

            if (Profile.OpSplash != SelectedSplash)
            {
                verify = true;
            }

            if (verify && GuiUtils.VerifyPassphrase(Profile.Core, ThreatLevel.Medium))
            {
                Profile.Settings.Operation = OperationBox.Text;
                Profile.OpIcon             = SelectedIcon;
                Profile.OpSplash           = SelectedSplash;

                Profile.Core.RunInCoreAsync(delegate()
                {
                    Profile.Save();
                    Profile.Core.Trust.SaveLocal(); // triggers icon update
                });
            }

            Close();
        }