From 26bf7d8f736590a3326ba0d2b0e89e946c32fe63 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 17 Aug 2021 17:58:32 -0600 Subject: [PATCH] feat(essentials): #793 Implements IHasDirectoryHistoryStack on CiscoSparkCodec --- .../VideoCodec/CiscoCodec/CiscoSparkCodec.cs | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index ae740dbf..893d9b0d 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -24,9 +24,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { enum eCommandType { SessionStart, SessionEnd, Command, GetStatus, GetConfiguration }; public enum eExternalSourceType {camera, desktop, document_camera, mediaplayer, PC, whiteboard, other} - public enum eExternalSourceMode {Ready, NotReady, Hidden, Error} + public enum eExternalSourceMode {Ready, NotReady, Hidden, Error} - public class CiscoSparkCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectory, + public class CiscoSparkCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectoryHistoryStack, IHasScheduleAwareness, IOccupancyStatusProvider, IHasCodecLayouts, IHasCodecSelfView, ICommunicationMonitor, IRouting, IHasCodecCameras, IHasCameraAutoMode, IHasCodecRoomPresets, IHasExternalSourceSwitching, IHasBranding, IHasCameraOff, IHasCameraMute { @@ -106,6 +106,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// public CodecDirectory DirectoryRoot { get; private set; } + + private CodecDirectory _currentDirectoryResult; + /// /// Represents the current state of the directory and is computed on get /// @@ -113,10 +116,15 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { get { - if (DirectoryBrowseHistory.Count > 0) - return DirectoryBrowseHistory[DirectoryBrowseHistory.Count - 1]; - else - return DirectoryRoot; + return _currentDirectoryResult; + } + private set + { + _currentDirectoryResult = value; + + CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); + + OnDirectoryResultReturned(_currentDirectoryResult); } } @@ -127,6 +135,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// public List DirectoryBrowseHistory { get; private set; } + public Stack DirectoryBrowseHistoryStack { get; private set; } + public CodecScheduleAwareness CodecSchedule { get; private set; } /// @@ -362,9 +372,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco DirectoryBrowseHistory = new List(); - CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => DirectoryBrowseHistory.Count > 0); + DirectoryBrowseHistoryStack = new Stack(); - CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); + CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => CurrentDirectoryResult != DirectoryRoot); CodecSchedule = new CodecScheduleAwareness(); @@ -1024,6 +1034,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco PhonebookSyncState.PhonebookRootEntriesReceived(); + CurrentDirectoryResult = DirectoryRoot; + PrintDirectory(DirectoryRoot); } else if (PhonebookSyncState.InitialSyncComplete) @@ -1035,9 +1047,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco PrintDirectory(directoryResults); - DirectoryBrowseHistory.Add(directoryResults); - - OnDirectoryResultReturned(directoryResults); + CurrentDirectoryResult = directoryResults; } } @@ -1068,8 +1078,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// void OnDirectoryResultReturned(CodecDirectory result) { - CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); - // This will return the latest results to all UIs. Multiple indendent UI Directory browsing will require a different methodology var handler = DirectoryResultReturned; if (handler != null) @@ -1221,6 +1229,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// public void SearchDirectory(string searchString) { + DirectoryBrowseHistoryStack.Push(CurrentDirectoryResult); + SendText(string.Format("xCommand Phonebook Search SearchString: \"{0}\" PhonebookType: {1} ContactType: Contact Limit: {2}", searchString, PhonebookMode, PhonebookResultsLimit)); } @@ -1230,6 +1240,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// public void GetDirectoryFolderContents(string folderId) { + DirectoryBrowseHistoryStack.Push(CurrentDirectoryResult); + SendText(string.Format("xCommand Phonebook Search FolderId: {0} PhonebookType: {1} ContactType: Any Limit: {2}", folderId, PhonebookMode, PhonebookResultsLimit)); } @@ -1239,24 +1251,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// public void GetDirectoryParentFolderContents() { - var currentDirectory = new CodecDirectory(); - - if (DirectoryBrowseHistory.Count > 0) + if (DirectoryBrowseHistoryStack.Count == 0) { - var lastItemIndex = DirectoryBrowseHistory.Count - 1; - var parentDirectoryContents = DirectoryBrowseHistory[lastItemIndex]; - - DirectoryBrowseHistory.Remove(DirectoryBrowseHistory[lastItemIndex]); - - currentDirectory = parentDirectoryContents; - - } - else - { - currentDirectory = DirectoryRoot; + return; } - OnDirectoryResultReturned(currentDirectory); + CurrentDirectoryResult = DirectoryBrowseHistoryStack.Pop(); } /// @@ -1264,9 +1264,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco /// public void SetCurrentDirectoryToRoot() { - DirectoryBrowseHistory.Clear(); + DirectoryBrowseHistoryStack.Clear(); - OnDirectoryResultReturned(DirectoryRoot); + CurrentDirectoryResult = DirectoryRoot; } ///