From a524b1607d88391d5a648beb08e3f2bd8356f8c7 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 28 Sep 2022 12:28:37 -0600 Subject: [PATCH] fix(essentials): Updates to deal with layouts and default layout for ZoomRoom --- .../DeviceTypeInterfaces/IPasswordPrompt.cs | 109 +++++++++--------- .../VideoCodec/ZoomRoom/ResponseObjects.cs | 18 +++ .../VideoCodec/ZoomRoom/ZoomRoom.cs | 42 ++++--- .../ZoomRoom/ZoomRoomPropertiesConfig.cs | 7 +- 4 files changed, 98 insertions(+), 78 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs index 6b3bae57..da61bbc0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs @@ -1,61 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Core -{ - /// - /// Describes the functionality required to prompt a user to enter a password - /// - public interface IPasswordPrompt - { - /// - /// Notifies when a password is required or is entered incorrectly - /// - event EventHandler PasswordRequired; - - /// - /// Submits the password - /// - /// - void SubmitPassword(string password); +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + /// + /// Describes the functionality required to prompt a user to enter a password + /// + public interface IPasswordPrompt + { + /// + /// Notifies when a password is required or is entered incorrectly + /// + event EventHandler PasswordRequired; /// - /// Cancels the password submission + /// Submits the password /// - void CancelPasswordPrompt(); - } - - public class PasswordPromptEventArgs : EventArgs - { - /// - /// Indicates if the last submitted password was incorrect - /// - public bool LastAttemptWasIncorrect { get; private set; } - - /// - /// Indicates that the login attempt has failed - /// - public bool LoginAttemptFailed { get; private set; } - - /// - /// Indicates that the process was cancelled and the prompt should be dismissed - /// - public bool LoginAttemptCancelled { get; private set; } - - /// - /// A message to be displayed to the user - /// - public string Message { get; private set; } - - public PasswordPromptEventArgs(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) - { - LastAttemptWasIncorrect = lastAttemptIncorrect; - LoginAttemptFailed = loginFailed; - LoginAttemptCancelled = loginCancelled; - Message = message; - } - } + /// + void SubmitPassword(string password); + } + + public class PasswordPromptEventArgs : EventArgs + { + /// + /// Indicates if the last submitted password was incorrect + /// + public bool LastAttemptWasIncorrect { get; private set; } + + /// + /// Indicates that the login attempt has failed + /// + public bool LoginAttemptFailed { get; private set; } + + /// + /// Indicates that the process was cancelled and the prompt should be dismissed + /// + public bool LoginAttemptCancelled { get; private set; } + + /// + /// A message to be displayed to the user + /// + public string Message { get; private set; } + + public PasswordPromptEventArgs(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) + { + LastAttemptWasIncorrect = lastAttemptIncorrect; + LoginAttemptFailed = loginFailed; + LoginAttemptCancelled = loginCancelled; + Message = message; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs index 66b7fb1e..8ace1e71 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs @@ -627,6 +627,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom // backer variables private bool _can_Switch_Speaker_View; private bool _can_Switch_Wall_View; + private bool _can_Switch_Strip_View; private bool _can_Switch_Share_On_All_Screens; private bool _can_Switch_Floating_Share_Content; private bool _is_In_First_Page; @@ -714,6 +715,23 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } } + [JsonProperty("can_Switch_Strip_View")] + public bool can_Switch_Strip_View + { + get + { + return _can_Switch_Strip_View; + } + set + { + if (value != _can_Switch_Strip_View) + { + _can_Switch_Strip_View = value; + NotifyPropertyChanged("can_Switch_Strip_View"); + } + } + } + [JsonProperty("is_In_First_Page")] public bool is_In_First_Page { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs index d491fa59..61737c90 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs @@ -810,8 +810,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom Debug.Console(1, this, "Status.Layout.PropertyChanged a.PropertyName: {0}", a.PropertyName); switch (a.PropertyName.ToLower()) { - case "can_switch_speaker_view": + case "can_Switch_speaker_view": case "can_switch_wall_view": + case "can_switch_strip_view": + case "video_type": case "can_switch_share_on_all_screens": { ComputeAvailableLayouts(); @@ -827,7 +829,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom LayoutViewIsOnLastPageFeedback.FireUpdate(); break; } - case "can_Switch_Floating_Share_Content": + case "can_switch_floating_share_content": { CanSwapContentWithThumbnailFeedback.FireUpdate(); break; @@ -1559,7 +1561,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Sharing); - SetLayout(); + SetDefaultLayout(); break; } @@ -1935,7 +1937,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } } - private void SetLayout() + private void SetDefaultLayout() { if (!_props.AutoDefaultLayouts) return; @@ -1948,8 +1950,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } else { - SendText(String.Format("zconfiguration call layout style: {0}", - _props.DefaultCallLayout)); + if (_props.DefaultCallLayout == (_props.DefaultCallLayout & AvailableLayouts)) + { + SendText(String.Format("zconfiguration call layout style: {0}", + _props.DefaultCallLayout)); + } + else + Debug.Console(0, this, "Unable to set default Layout. {0} not currently an available layout based on meeting state", _props.DefaultCallLayout); } } @@ -2149,8 +2156,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue ); + + SetDefaultLayout(); } - // TODO [ ] Issue #868 + else if (item.Status == eCodecCallStatus.Disconnected) { MeetingInfo = new MeetingInfo( @@ -2171,11 +2180,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom Debug.Console(1, this, "[OnCallStatusChange] Current Call Status: {0}", Status.Call != null ? Status.Call.Status.ToString() : "no call"); - - if (_props.AutoDefaultLayouts) - { - SetLayout(); - } } private string GetSharingStatus() @@ -3264,7 +3268,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom // There is no property that directly reports if strip mode is valid, but API stipulates // that strip mode is available if the number of screens is 1 - if (Status.NumberOfScreens.NumOfScreens == 1) + if (Status.NumberOfScreens.NumOfScreens == 1 || Status.Layout.can_Switch_Strip_View || Status.Layout.video_type.ToLower() == "strip") { availableLayouts |= zConfiguration.eLayoutStyle.Strip; } @@ -3279,10 +3283,15 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom var handler = LayoutInfoChanged; if (handler != null) { + + var currentLayout = zConfiguration.eLayoutStyle.None; + + currentLayout = (zConfiguration.eLayoutStyle)Enum.Parse(typeof(zConfiguration.eLayoutStyle), string.IsNullOrEmpty(LocalLayoutFeedback.StringValue) ? "None" : LocalLayoutFeedback.StringValue, true); + handler(this, new LayoutInfoChangedEventArgs() { AvailableLayouts = AvailableLayouts, - CurrentSelectedLayout = (zConfiguration.eLayoutStyle)Enum.Parse(typeof(zConfiguration.eLayoutStyle),string.IsNullOrEmpty(LocalLayoutFeedback.StringValue) ? "None" : LocalLayoutFeedback.StringValue , true), + CurrentSelectedLayout = currentLayout, LayoutViewIsOnFirstPage = LayoutViewIsOnFirstPageFeedback.BoolValue, LayoutViewIsOnLastPage = LayoutViewIsOnLastPageFeedback.BoolValue, CanSwapContentWithThumbnail = CanSwapContentWithThumbnailFeedback.BoolValue, @@ -3415,11 +3424,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom //OnPasswordRequired(false, false, true, ""); } - public void CancelPasswordPrompt() - { - OnPasswordRequired(false, false, true, "Login Cancelled"); - } - void OnPasswordRequired(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) { var handler = PasswordRequired; diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs index 3f752f43..771cfe11 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -29,11 +30,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /* This layout will be selected when Sharing starts (either from Far end or locally)*/ [JsonProperty("defaultSharingLayout")] - public string DefaultSharingLayout { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + public zConfiguration.eLayoutStyle DefaultSharingLayout { get; set; } //This layout will be selected when a call is connected and no content is being shared [JsonProperty("defaultCallLayout")] - public string DefaultCallLayout { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + public zConfiguration.eLayoutStyle DefaultCallLayout { get; set; } [JsonProperty("minutesBeforeMeetingStart")] public int MinutesBeforeMeetingStart { get; set; }