Server/FormMain.cs
changeset 271 24aec939b286
parent 270 5dcd226539d4
child 272 10de0c7c2fed
     1.1 --- a/Server/FormMain.cs	Wed Oct 05 15:02:09 2016 +0200
     1.2 +++ b/Server/FormMain.cs	Sun Nov 27 19:56:09 2016 +0100
     1.3 @@ -1244,10 +1244,6 @@
     1.4              CheckFontHeight();
     1.5              //Check if "run on Windows startup" is enabled
     1.6              checkBoxAutoStart.Checked = iStartupManager.Startup;
     1.7 -
     1.8 -            //Harmony settings
     1.9 -            //Decrypt our password first
    1.10 -            iTextBoxLogitechPassword.Text = Secure.ToInsecureString(Secure.DecryptString(Properties.Settings.Default.LogitechPassword));
    1.11              
    1.12              //CEC settings
    1.13              comboBoxHdmiPort.SelectedIndex = Properties.Settings.Default.CecHdmiPort - 1;
    1.14 @@ -3059,12 +3055,15 @@
    1.15          /// Called whenever we loose connection with our HarmonyHub.
    1.16          /// </summary>
    1.17          /// <param name="aRequestWasCancelled"></param>
    1.18 -        private void HarmonyConnectionClosedByServer(object aSender, bool aRequestWasCancelled)
    1.19 +        private void HarmonyConnectionClosed(object aSender, bool aClosedByServer)
    1.20          {
    1.21 -            //Try reconnect then
    1.22 +            if (aClosedByServer)
    1.23 +            {
    1.24 +                //Try reconnect then
    1.25  #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
    1.26 -            BeginInvoke(new MethodInvoker(delegate () { ResetHarmonyAsync(); }));
    1.27 +                BeginInvoke(new MethodInvoker(delegate () { ResetHarmonyAsync(); }));
    1.28  #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
    1.29 +            }
    1.30          }
    1.31  
    1.32  
    1.33 @@ -3094,7 +3093,7 @@
    1.34              //First create our client and login
    1.35              //Tip: Set keep-alive to false when testing reconnection process
    1.36              Program.HarmonyClient = new HarmonyHub.Client(iTextBoxHarmonyHubAddress.Text, true);
    1.37 -            Program.HarmonyClient.OnConnectionClosedByServer += HarmonyConnectionClosedByServer;
    1.38 +            Program.HarmonyClient.OnConnectionClosed += HarmonyConnectionClosed;
    1.39  
    1.40              string authToken = Properties.Settings.Default.LogitechAuthToken;
    1.41              if (!string.IsNullOrEmpty(authToken) && !aForceAuth)
    1.42 @@ -3114,15 +3113,8 @@
    1.43                  Properties.Settings.Default.LogitechAuthToken = "";
    1.44                  Properties.Settings.Default.Save();
    1.45  
    1.46 -                //Then try connect using our password
    1.47 -                if (string.IsNullOrEmpty(iTextBoxLogitechPassword.Text))
    1.48 -                {
    1.49 -                    Trace.WriteLine("Harmony: Credentials missing!");
    1.50 -                    return;
    1.51 -                }
    1.52 -
    1.53                  Trace.WriteLine("Harmony: Authenticating with Logitech servers...");
    1.54 -                success = await Program.HarmonyClient.TryOpenAsync(iTextBoxLogitechUserName.Text, iTextBoxLogitechPassword.Text);
    1.55 +                success = await Program.HarmonyClient.TryOpenAsync();
    1.56                  //Persist our authentication token in our setting
    1.57                  if (success)
    1.58                  {
    1.59 @@ -3227,11 +3219,5 @@
    1.60              }
    1.61          }
    1.62  
    1.63 -        private void iTextBoxLogitechPassword_TextChanged(object sender, EventArgs e)
    1.64 -        {
    1.65 -            //Save our password after encryption
    1.66 -            Properties.Settings.Default.LogitechPassword = Secure.EncryptString(Secure.ToSecureString(iTextBoxLogitechPassword.Text));
    1.67 -            Properties.Settings.Default.Save();
    1.68 -        }
    1.69      }
    1.70  }