示例#1
0
        private void FindOrInstallOpenSshLocation()
        {
            ConnectButton.IsEnabled = false;
            LogLine("Looking for OpenSSH Installation...");

            Task.Run(() =>
            {
                string sshLocation = OpenSshController.LocateSshdExecutable();

                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    if (sshLocation == null)
                    {
                        OpenSshExecutableLocationTextBox.IsReadOnly = true;
                        DataBinding.OpenSshInstallLocation = DEFAULT_OPENSSH_LOCATION;
                        LogLine("OpenSSH is not currently installed. Flingr will install it in the following location: " + DEFAULT_OPENSSH_LOCATION);
                    }
                    else
                    {
                        OpenSshExecutableLocationTextBox.IsReadOnly = false;
                        DataBinding.OpenSshInstallLocation = sshLocation;
                        LogLine("OpenSSH is currently installed. This is where Flingr thinks it lives on the device: " + sshLocation);
                    }
                }));

                if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                {
                    bool installationSuccess = OpenSshController.InstallOpenSshd();
                    LogLine("OpenSSH Installed: " + installationSuccess);
                    if (installationSuccess)
                    {
                        Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            ConnectButton.IsEnabled = true;
                        }));
                    }
                }
                else
                {
                    LogLine("Could not install OpenSSH because network is not available");
                }
            });
        }