From 52ea75bd78fe37bea0d585903bb3c47d98a6ebe8 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sat, 22 Mar 2025 20:12:44 -0400 Subject: [PATCH] correct issue with call drop not setting the stream ID resulting in badness; add timestamp to the call history window; add settings option to snap the call history window to the right side of the console; --- dvmconsole/CallHistoryWindow.xaml | 3 +- dvmconsole/CallHistoryWindow.xaml.cs | 8 +++- dvmconsole/MainWindow.DMR.cs | 2 +- dvmconsole/MainWindow.P25.cs | 6 ++- dvmconsole/MainWindow.xaml | 1 + dvmconsole/MainWindow.xaml.cs | 68 +++++++++++++++++++++++++++- dvmconsole/SettingsManager.cs | 5 ++ 7 files changed, 88 insertions(+), 5 deletions(-) diff --git a/dvmconsole/CallHistoryWindow.xaml b/dvmconsole/CallHistoryWindow.xaml index abe2662..9d80de5 100644 --- a/dvmconsole/CallHistoryWindow.xaml +++ b/dvmconsole/CallHistoryWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:dvmconsole" mc:Ignorable="d" Icon="/dvmconsole;component/Assets/history.png" - Title="Call History" Height="450" Width="351" WindowStartupLocation="CenterOwner"> + Title="Call History" Height="450" Width="551" WindowStartupLocation="CenterOwner"> @@ -17,6 +17,7 @@ + diff --git a/dvmconsole/CallHistoryWindow.xaml.cs b/dvmconsole/CallHistoryWindow.xaml.cs index ec9ee6a..c14e1e2 100644 --- a/dvmconsole/CallHistoryWindow.xaml.cs +++ b/dvmconsole/CallHistoryWindow.xaml.cs @@ -42,6 +42,11 @@ namespace dvmconsole /// public int DstId { get; set; } + /// + /// Timestamp for entry. + /// + public string Timestamp { get; set; } + /// /// Background color for call entry. /// @@ -123,7 +128,7 @@ namespace dvmconsole /// /// /// - public void AddCall(string channel, int srcId, int dstId) + public void AddCall(string channel, int srcId, int dstId, string timestamp) { Dispatcher.Invoke(() => { @@ -132,6 +137,7 @@ namespace dvmconsole Channel = channel, SrcId = srcId, DstId = dstId, + Timestamp = timestamp, BackgroundColor = Brushes.Transparent }); }); diff --git a/dvmconsole/MainWindow.DMR.cs b/dvmconsole/MainWindow.DMR.cs index c839f5d..5b81ada 100644 --- a/dvmconsole/MainWindow.DMR.cs +++ b/dvmconsole/MainWindow.DMR.cs @@ -282,7 +282,7 @@ namespace dvmconsole systemStatuses[cpgChannel.Name + e.Slot].DMR_RxPILC = new PrivacyLC(); Log.WriteLine($"({system.Name}) TS {e.Slot + 1} [STREAM ID {e.StreamId}] RX_LC {FneUtils.HexDump(systemStatuses[cpgChannel.Name + e.Slot].DMR_RxLC.GetBytes())}"); - callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId); + callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString()); callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, false); // TODO: Encrypted state string alias = string.Empty; diff --git a/dvmconsole/MainWindow.P25.cs b/dvmconsole/MainWindow.P25.cs index 80af30f..d30ddd8 100644 --- a/dvmconsole/MainWindow.P25.cs +++ b/dvmconsole/MainWindow.P25.cs @@ -458,6 +458,9 @@ namespace dvmconsole if (cpgChannel.Tgid != e.DstId.ToString()) continue; + if (e.DUID == P25DUID.TSDU || e.DUID == P25DUID.PDU) + continue; + if (!systemStatuses.ContainsKey(cpgChannel.Name)) systemStatuses[cpgChannel.Name] = new SlotStatus(); @@ -494,7 +497,7 @@ namespace dvmconsole FneUtils.Memset(channel.mi, 0x00, P25Defines.P25_MI_LENGTH); - callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId); + callHistoryWindow.AddCall(cpgChannel.Name, (int)e.SrcId, (int)e.DstId, DateTime.Now.ToString()); callHistoryWindow.ChannelKeyed(cpgChannel.Name, (int)e.SrcId, encrypted); string alias = string.Empty; @@ -533,6 +536,7 @@ namespace dvmconsole if ((channel.algId != cpgChannel.GetAlgoId() || channel.kId != cpgChannel.GetKeyId()) && channel.algId != P25Defines.P25_ALGO_UNENCRYPT) { + slot.RxStreamId = e.StreamId; channel.Background = ChannelBox.RED_GRADIENT; Log.WriteLine($"({system.Name}) P25D: Traffic *CALL DROPPED * PEER {e.PeerId} SRC_ID {e.SrcId} TGID {e.DstId} [STREAM ID {e.StreamId}]"); continue; diff --git a/dvmconsole/MainWindow.xaml b/dvmconsole/MainWindow.xaml index 2ed7ce5..858d603 100644 --- a/dvmconsole/MainWindow.xaml +++ b/dvmconsole/MainWindow.xaml @@ -58,6 +58,7 @@ + diff --git a/dvmconsole/MainWindow.xaml.cs b/dvmconsole/MainWindow.xaml.cs index a180816..15645cb 100644 --- a/dvmconsole/MainWindow.xaml.cs +++ b/dvmconsole/MainWindow.xaml.cs @@ -169,10 +169,15 @@ namespace dvmconsole selectedChannelsManager.SelectedChannelsChanged += SelectedChannelsChanged; selectedChannelsManager.PrimaryChannelChanged += PrimaryChannelChanged; + + LocationChanged += MainWindow_LocationChanged; SizeChanged += MainWindow_SizeChanged; Loaded += MainWindow_Loaded; } + /// + /// + /// private void PrimaryChannelChanged() { var primaryChannel = selectedChannelsManager.PrimaryChannel; @@ -249,6 +254,11 @@ namespace dvmconsole { DisableControls(); + channelsCanvas.Children.Clear(); + systemStatuses.Clear(); + + fneSystemManager.ClearAll(); + try { var deserializer = new DeserializerBuilder() @@ -914,7 +924,11 @@ namespace dvmconsole if (!noSaveSettingsOnClose) { if (WindowState == WindowState.Maximized) + { settingsManager.Maximized = true; + if (settingsManager.SnapCallHistoryToWindow) + menuSnapCallHistory.IsChecked = false; + } settingsManager.SaveSettings(); } @@ -1007,6 +1021,22 @@ namespace dvmconsole /** WPF Window Events */ + /// + /// + /// + /// + /// + /// + private void MainWindow_LocationChanged(object sender, EventArgs e) + { + if (settingsManager.SnapCallHistoryToWindow && callHistoryWindow.Visibility == Visibility.Visible && + WindowState != WindowState.Maximized) + { + callHistoryWindow.Left = Left + ActualWidth + 5; + callHistoryWindow.Top = Top; + } + } + /// /// /// @@ -1042,6 +1072,14 @@ namespace dvmconsole else settingsManager.Maximized = false; + if (settingsManager.SnapCallHistoryToWindow && callHistoryWindow.Visibility == Visibility.Visible && + WindowState != WindowState.Maximized) + { + callHistoryWindow.Height = ActualHeight; + callHistoryWindow.Left = Left + ActualWidth + 5; + callHistoryWindow.Top = Top; + } + settingsManager.CanvasWidth = channelsCanvas.ActualWidth; settingsManager.CanvasHeight = channelsCanvas.ActualHeight; @@ -1061,6 +1099,7 @@ namespace dvmconsole // set PTT toggle mode (this must be done before channel widgets are defined) menuToggleLockWidgets.IsChecked = settingsManager.LockWidgets; + menuSnapCallHistory.IsChecked = settingsManager.SnapCallHistoryToWindow; menuTogglePTTMode.IsChecked = settingsManager.TogglePTTMode; if (!string.IsNullOrEmpty(settingsManager.LastCodeplugPath) && File.Exists(settingsManager.LastCodeplugPath)) @@ -1515,6 +1554,19 @@ namespace dvmconsole settingsManager.LockWidgets = !settingsManager.LockWidgets; } + /// + /// + /// + /// + /// + private void ToggleSnapCallHistory_Click(object sender, RoutedEventArgs e) + { + if (!windowLoaded) + return; + + settingsManager.SnapCallHistoryToWindow = !settingsManager.SnapCallHistoryToWindow; + } + /// /// /// @@ -2176,7 +2228,21 @@ namespace dvmconsole private void CallHist_Click(object sender, RoutedEventArgs e) { callHistoryWindow.Owner = this; - callHistoryWindow.Show(); + if (callHistoryWindow.Visibility == Visibility.Visible) + callHistoryWindow.Hide(); + else + { + callHistoryWindow.Show(); + + if (settingsManager.SnapCallHistoryToWindow && WindowState != WindowState.Maximized) + { + if (ActualHeight > callHistoryWindow.Height) + callHistoryWindow.Height = ActualHeight; + + callHistoryWindow.Left = Left + ActualWidth + 5; + callHistoryWindow.Top = Top; + } + } } /** fnecore Hooks / Helpers */ diff --git a/dvmconsole/SettingsManager.cs b/dvmconsole/SettingsManager.cs index f5ca3f6..9910e4a 100644 --- a/dvmconsole/SettingsManager.cs +++ b/dvmconsole/SettingsManager.cs @@ -90,6 +90,10 @@ namespace dvmconsole /// Flag indicating channel and other widgets are locked in place. /// public bool LockWidgets { get; set; } = true; + /// + /// Flag indicating whether or not the call history window should be snapped to the right of the main window. + /// + public bool SnapCallHistoryToWindow { get; set; } = false; /// /// Flag indicating window maximized state. @@ -159,6 +163,7 @@ namespace dvmconsole ChannelOutputDevices = loadedSettings.ChannelOutputDevices ?? new Dictionary(); TogglePTTMode = loadedSettings.TogglePTTMode; LockWidgets = loadedSettings.LockWidgets; + SnapCallHistoryToWindow = loadedSettings.SnapCallHistoryToWindow; Maximized = loadedSettings.Maximized; DarkMode = loadedSettings.DarkMode; WindowWidth = loadedSettings.WindowWidth;