// SPDX-License-Identifier: AGPL-3.0-only /** * Digital Voice Modem - Desktop Dispatch Console * AGPLv3 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * @package DVM / Desktop Dispatch Console * @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0) * * Copyright (C) 2025 Caleb, K4PHP * */ using System.Collections.ObjectModel; using System.Diagnostics; using System.Windows; using dvmconsole.Controls; namespace dvmconsole { /// /// /// public class KeyStatusItem { /* ** Properties */ /// /// /// public string ChannelName { get; set; } /// /// /// public string AlgId { get; set; } /// /// /// public string KeyId { get; set; } /// /// /// public string KeyStatus { get; set; } } // public class KeyStatusItem /// /// /// public partial class KeyStatusWindow : Window { private Codeplug Codeplug; private MainWindow mainWindow; /* ** Properties */ /// /// /// public ObservableCollection KeyStatusItems { get; private set; } = new ObservableCollection(); /* ** Methods */ /// /// Initializes a new instance of the class. /// /// /// public KeyStatusWindow(Codeplug codeplug, MainWindow mainWindow) { InitializeComponent(); this.Codeplug = codeplug; this.mainWindow = mainWindow; DataContext = this; LoadKeyStatus(); } /// /// /// private void LoadKeyStatus() { Dispatcher.Invoke(() => { KeyStatusItems.Clear(); foreach (var child in mainWindow.ChannelsCanvas.Children) { if (child == null) { Trace.WriteLine("A child in ChannelsCanvas.Children is null."); continue; } if (!(child is ChannelBox channelBox)) { continue; } Codeplug.System system = Codeplug.GetSystemForChannel(channelBox.ChannelName); if (system == null) { Trace.WriteLine($"System not found for {channelBox.ChannelName}"); continue; } Codeplug.Channel cpgChannel = Codeplug.GetChannelByName(channelBox.ChannelName); if (cpgChannel == null) { Trace.WriteLine($"Channel not found for {channelBox.ChannelName}"); continue; } if (cpgChannel.GetKeyId() == 0 || cpgChannel.GetAlgoId() == 0) continue; if (channelBox.Crypter == null) { Trace.WriteLine($"Crypter is null for channel {channelBox.ChannelName}"); continue; } bool hasKey = channelBox.Crypter.HasKey(cpgChannel.GetKeyId()); KeyStatusItems.Add(new KeyStatusItem { ChannelName = channelBox.ChannelName, AlgId = $"0x{cpgChannel.GetAlgoId():X2}", KeyId = $"0x{cpgChannel.GetKeyId():X4}", KeyStatus = hasKey ? "Key Available" : "No Key" }); } }); } } // public partial class KeyStatusWindow : Window } // namespace dvmconsole