diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-02-17 01:49:32 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-02-17 01:49:32 +0200 |
| commit | da39ba78af62aa19f40d755d870dbfe321fbde2e (patch) | |
| tree | ff95e65169635234ce10cdcf0c44b3f801ea17c5 /Software/Visual_Studio/PPC/Tango.PPC.Common | |
| parent | e2a5664b9425953e33b39c21dab8d5c24adfa78f (diff) | |
| parent | 5f3cb9b25e937a0e9a4a3102cd26e6e3b94e5dfa (diff) | |
| download | Tango-da39ba78af62aa19f40d755d870dbfe321fbde2e.tar.gz Tango-da39ba78af62aa19f40d755d870dbfe321fbde2e.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common')
9 files changed, 110 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index 5f0b35ce2..f07ba39a9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -41,6 +41,11 @@ namespace Tango.PPC.Common.Application event EventHandler SetupRequired; /// <summary> + /// Occurs when a system restart is required. + /// </summary> + event EventHandler SystemRestartRequired; + + /// <summary> /// Occurs when the application has encountered an error when initializing. /// </summary> event EventHandler<Exception> ApplicationInitializationError; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs index 766e25e40..46a1e2355 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs @@ -86,14 +86,14 @@ namespace Tango.PPC.Common.Connectivity return new WiFiAuthentication(new AuthRequest(AccessPoint)); } - public Task<bool> Connect(WiFiAuthentication request) + public Task<bool> Connect(WiFiAuthentication request, bool overwriteProfile) { return Task.Factory.StartNew<bool>(() => { try { Connecting = true; - return AccessPoint.Connect(request.AuthRequest, false); + return AccessPoint.Connect(request.AuthRequest, overwriteProfile); } catch (Exception) { @@ -126,5 +126,20 @@ namespace Tango.PPC.Common.Connectivity } }); } + + public Task Forget() + { + return Task.Factory.StartNew(() => + { + try + { + AccessPoint.DeleteProfile(); + } + catch + { + + } + }); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs index ac02422c0..e3129b970 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs @@ -21,5 +21,6 @@ namespace Tango.PPC.Common.Navigation ExternalBridgeView, HomeModule, ShutdownView, + RestartingSystemView } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index a073c1c5e..75e8d40dc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -10,6 +10,7 @@ using Tango.PPC.Common.Scripting; namespace Tango.PPC.Common.OS { using System.Collections.ObjectModel; + using System.Diagnostics; using Tango.Core; using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h @@ -124,5 +125,14 @@ namespace Tango.PPC.Common.OS CmdCommand cmd = new CmdCommand("tzutil", $"/s \"{timeZone.Id}\""); await cmd.Run(); } + + /// <summary> + /// Restarts the system. + /// </summary> + /// <returns></returns> + public void Restart() + { + Process.Start("shutdown.exe", "-r -t 0"); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs index d7898d174..0cdf85927 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs @@ -43,5 +43,11 @@ namespace Tango.PPC.Common.OS /// <param name="timeZone">The time zone.</param> /// <returns></returns> Task ChangeTimeZone(TimeZoneInfo timeZone); + + /// <summary> + /// Restarts the system. + /// </summary> + /// <returns></returns> + void Restart(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index 266bef3eb..05cd998e6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -43,6 +43,7 @@ <converters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter" /> <converters:ByteArrayToFileSizeConverter x:Key="ByteArrayToFileSizeConverter" /> <converters:EnumToVisibilityConverter x:Key="EnumToVisibilityConverter" /> + <converters:EnumToBooleanConverter x:Key="EnumToBooleanConverter" /> <converters:DateTimeUTCToStringConverter x:Key="DateTimeUTCToStringConverter" /> <converters:NullObjectToBooleanConverter x:Key="NullObjectToBooleanConverter" /> <converters:IsNullToVisibilityConverter x:Key="IsNullToVisibilityConverter" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 1b51876d7..124e6e276 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -193,6 +193,8 @@ <Compile Include="Update\PPCUpdateService.cs" /> <Compile Include="UWF\DefaultUnifiedWriteFilterManager.cs" /> <Compile Include="UWF\IUnifiedWriteFilterManager.cs" /> + <Compile Include="WatchDog\WatchDogClient.cs" /> + <Compile Include="WatchDog\WatchDogServer.cs" /> <Page Include="Connectivity\AvailableWiFiConnectionsControl.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -353,7 +355,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/WatchDog/WatchDogClient.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/WatchDog/WatchDogClient.cs new file mode 100644 index 000000000..47a24ea85 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/WatchDog/WatchDogClient.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.WatchDog +{ + public class WatchDogClient + { + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/WatchDog/WatchDogServer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/WatchDog/WatchDogServer.cs new file mode 100644 index 000000000..77bca2e30 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/WatchDog/WatchDogServer.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Pipes; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.WatchDog +{ + public class WatchDogServer + { + private NamedPipeServerStream _server; + private Thread _thread; + + public bool IsStarted { get; private set; } + + public void Start() + { + _thread = new Thread(ThreadMethod); + _thread.IsBackground = true; + _thread.Start(); + } + + private void ThreadMethod() + { + IsStarted = true; + + try + { + _server = new NamedPipeServerStream("Tango_Watch_Dog_Pipe"); + _server.WaitForConnection(); + StreamReader reader = new StreamReader(_server); + StreamWriter writer = new StreamWriter(_server); + + while (IsStarted) + { + var line = reader.ReadLine(); + writer.WriteLine(line); + writer.Flush(); + } + } + catch + { + IsStarted = false; + } + } + + public void Stop() + { + _server.Dispose(); + } + } +} |
