aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs52
1 files changed, 46 insertions, 6 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
index f1127ebfe..f10e84d05 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
@@ -12,6 +12,7 @@ using Tango.PMR.Integration;
using Tango.PPC.Common;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.UI.Dialogs;
namespace Tango.PPC.UI.ViewModels
{
@@ -24,6 +25,8 @@ namespace Tango.PPC.UI.ViewModels
{
private bool _disconnecting;
+ private const int KEEP_SAFETY_AUTHENTICATION_MINUTES = 5;
+
#region Properties
private ExternalBridgeClientConnectedEventArgs _connection;
@@ -79,7 +82,7 @@ namespace Tango.PPC.UI.ViewModels
LogManager.Log("Disconnecting current external bridge session.");
_disconnecting = true;
InvalidateRelayCommands();
- ExternalBridgeService.DisconnectSession();
+ ExternalBridgeService.DisconnectFullControlSession();
}
#endregion
@@ -103,7 +106,7 @@ namespace Tango.PPC.UI.ViewModels
public override void OnApplicationStarted()
{
ExternalBridgeService.ConnectionRequest += ExternalBridgeService_ConnectionRequest;
- ExternalBridgeService.ClientDisconnected += ExternalBridgeService_ClientDisconnected;
+ ExternalBridgeService.FullControlSessionDisconnected += ExternalBridgeService_FullControlSessionDisconnected;
}
#endregion
@@ -111,11 +114,11 @@ namespace Tango.PPC.UI.ViewModels
#region Event Handlers
/// <summary>
- /// Handles the <see cref="ExternalBridgeService.ClientDisconnected"/> event.
+ /// Handles the <see cref="ExternalBridgeService.FullControlSessionDisconnected"/> event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e)
+ private void ExternalBridgeService_FullControlSessionDisconnected(object sender, EventArgs e)
{
if (IsVisible)
{
@@ -133,13 +136,14 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="ExternalBridgeClientConnectedEventArgs"/> instance containing the event data.</param>
- private void ExternalBridgeService_ConnectionRequest(object sender, ExternalBridgeClientConnectedEventArgs e)
+ private async void ExternalBridgeService_ConnectionRequest(object sender, ExternalBridgeClientConnectedEventArgs e)
{
LogManager.Log($"External bridge connection request received.\n{e.ToJsonString()}");
if (!e.Request.Intent.RequiresPassword() || e.Request.Password == Settings.ExternalBridgePassword)
{
- e.Confirmed = true;
+ e.ApplicationInformation.Version = ApplicationManager.Version.ToString();
+ e.ApplicationInformation.StartupDate = ApplicationManager.StartUpDate.ToUniversalTime().ToString();
Connection = e;
@@ -150,6 +154,41 @@ namespace Tango.PPC.UI.ViewModels
LogManager.Log($"External bridge connection user has been identified as {User.Contact.FullName}");
}
+ if (e.Request.RequireSafetyLevelOperations)
+ {
+ DateTime lastAuthenticationTime;
+ bool bypassSafetyConfirmation = false;
+
+ if (ExternalBridgeReceiver.LastSafetyLevelContactsTimes.TryGetValue(e.Request.UserName, out lastAuthenticationTime))
+ {
+ if (DateTime.Now < lastAuthenticationTime.AddMinutes(KEEP_SAFETY_AUTHENTICATION_MINUTES))
+ {
+ bypassSafetyConfirmation = true;
+ e.Confirm();
+ }
+ }
+
+ if (!bypassSafetyConfirmation)
+ {
+ SafetyLevelOperationsConfirmationViewVM vm = new SafetyLevelOperationsConfirmationViewVM(e);
+ await NotificationProvider.ShowDialog(vm);
+
+ if (vm.DialogResult)
+ {
+ e.Confirm();
+ }
+ else
+ {
+ e.Decline("Safety level connection refused by the remote user.");
+ return;
+ }
+ }
+ }
+ else
+ {
+ e.Confirm();
+ }
+
if (e.Request.Intent == ExternalBridgeLoginIntent.FullControl)
{
LogManager.Log("Navigating to external bridge view...");
@@ -161,6 +200,7 @@ namespace Tango.PPC.UI.ViewModels
}
else
{
+ e.Decline("Connection password did not match the machine external bridge password.");
LogManager.Log("Connection password did not match the machine external bridge password.");
}
}