diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-21 10:58:27 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-21 10:58:27 +0300 |
| commit | 7592deb0d4b8c531204266afebb361ae3772d07e (patch) | |
| tree | 0305ab2014ff8d35a07561813d3bc52728323b3d /Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity | |
| parent | f84cb16dbe34a14249d5381e36f6c45abbd3ed96 (diff) | |
| download | Tango-7592deb0d4b8c531204266afebb361ae3772d07e.tar.gz Tango-7592deb0d4b8c531204266afebb361ae3772d07e.zip | |
Fixed issue with WiFi auto connect.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index e7aff7357..dabfc5893 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -27,6 +27,7 @@ namespace Tango.PPC.UI.Connectivity private Wifi _wifi; private INotificationProvider _notification; private IMachineProvider _machineProvider; + private Rfc2898Cryptographer _cryptographer; /// <summary> /// Occurs when the connectivity provider state has changed (e.g network connected/disconnected). @@ -83,6 +84,8 @@ namespace Tango.PPC.UI.Connectivity /// </summary> public DefaultConnectivityProvider(IPPCApplicationManager applicationManager, INotificationProvider notificationProvider, IMachineProvider machineProvider) { + _cryptographer = new Rfc2898Cryptographer(); + _notification = notificationProvider; _machineProvider = machineProvider; @@ -135,7 +138,8 @@ namespace Tango.PPC.UI.Connectivity if (auto_connect_network != null && !auto_connect_network.IsConnected) { - await Connect(auto_connect_network); + auto_connect_network.AutoConnect = true; + await Connect(auto_connect_network, _cryptographer.Decrypt(settings.AutoConnectWiFiPassword)); } }); } @@ -211,36 +215,45 @@ namespace Tango.PPC.UI.Connectivity /// </summary> /// <param name="network">The network.</param> /// <returns></returns> - public async Task<bool> Connect(WiFiNetwork network) + public async Task<bool> Connect(WiFiNetwork network, String password = null) { var auth = network.CreateAuthenticationRequest(); bool result = false; - if ((auth.IsPasswordRequired || auth.IsUserNameRequired) && !network.HasProfile) + if (password == null) { - var vm = await _notification.ShowDialog<WiFiAuthenticationViewVM>(new WiFiAuthenticationViewVM(auth, network)); - - if (vm.DialogResult) + if ((auth.IsPasswordRequired || auth.IsUserNameRequired) && !network.HasProfile) { - result = await network.Connect(auth, true); + var vm = await _notification.ShowDialog<WiFiAuthenticationViewVM>(new WiFiAuthenticationViewVM(auth, network)); - if (!result) + if (vm.DialogResult) { - await _notification.ShowError("Could not connect to the specified network. Please check your password."); - await network.Forget(); - } + result = await network.Connect(auth, true); - await RefreshAvailableWiFiNetworks(); + if (!result) + { + await _notification.ShowError("Could not connect to the specified network. Please check your password."); + await network.Forget(); + } + + await RefreshAvailableWiFiNetworks(); + } + else + { + return false; + } } else { - return false; + result = await network.Connect(auth, false); + await RefreshAvailableWiFiNetworks(); } } else { - result = await network.Connect(auth, false); + auth.Password = password; + result = await network.Connect(auth, true); await RefreshAvailableWiFiNetworks(); } @@ -249,6 +262,7 @@ namespace Tango.PPC.UI.Connectivity OnConnectionStateChanged(true); var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); settings.AutoConnectWiFiName = network.AutoConnect ? network.Name : null; + settings.AutoConnectWiFiPassword = _cryptographer.Encrypt(auth.Password); settings.Save(); } @@ -266,6 +280,7 @@ namespace Tango.PPC.UI.Connectivity { var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); settings.AutoConnectWiFiName = null; + settings.AutoConnectWiFiPassword = null; settings.Save(); network.AutoConnect = false; network.Disconnect().Wait(); |
