Skip to content

Commit

Permalink
fix: testing debugging config ui extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jgutenplan committed May 1, 2024
1 parent c86899f commit 11e9065
Show file tree
Hide file tree
Showing 9 changed files with 2,848 additions and 69 deletions.
12 changes: 6 additions & 6 deletions src/CiscoCodecConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ public class CiscoCodecConfig
/// They are used to pass back UI Extension Widget events
/// </summary>
[JsonProperty("Widgets")]
public Dictionary<string, WidgetConfig> WidgetBlocks { get; set; }

public CiscoCodecConfig()
public Dictionary<string, WidgetConfig> WidgetBlocks { get; set; }

[JsonProperty("extensions")]
public Extensions Extensions { get; set; }

public CiscoCodecConfig()
{
CameraInfo = new List<CameraInfo>();
PhonebookMode = "corporate";
}

[JsonProperty("extensions")]
public Extensions Extensions { get; set; }
}

public class SharingProperties
Expand Down
2,719 changes: 2,718 additions & 1 deletion src/CiscoRoomOsCodec.cs

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions src/UserInterfaceExtensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Extensions: ICiscoCodecUiExtensions
[XmlElement("Version")]
public string Version { get; set; }

[XmlIgnore]
[JsonProperty("configId")] //0-40
public ushort ConfigId { get; set; }

Expand All @@ -31,16 +32,21 @@ public class Extensions: ICiscoCodecUiExtensions
public List<Panel> Panels { get; set; }
//other extensions later

[JsonIgnore]
[XmlIgnore]
public PanelsHandler PanelsHandler { get; set; }

public void Initialize(IKeyed parent, IBasicCommunication coms)
public void Initialize(IKeyed parent, IBasicCommunication coms, Action<string> enqueueCommand)
{
PanelsHandler = new PanelsHandler(parent, coms, Panels);
coms.SendText(xCommand());
Debug.LogMessage(LogEventLevel.Debug, "Extensions Initialize, Panels from config: null: {0}, length: {1}", parent, Panels == null, Panels.Count);
PanelsHandler = new PanelsHandler(parent, coms, enqueueCommand, Panels);
Debug.LogMessage(LogEventLevel.Debug, xCommand(), parent);
enqueueCommand(xCommand());
//coms.SendText(xCommand());
}

/// <summary>
/// string literal for multiline command
/// string literal for multiline command
/// </summary>
/// <returns></returns>
public string xCommand() => $@"xCommand UserInterface Extensions Set ConfigId: {ConfigId}
Expand Down
2 changes: 1 addition & 1 deletion src/UserInterfaceExtensions/ICiscoCodecUiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface ICiscoCodecUiExtensions

PanelsHandler PanelsHandler { get; }

void Initialize(IKeyed parent, IBasicCommunication coms);
void Initialize(IKeyed parent, IBasicCommunication coms, Action<string> enqueueCommand);

string xCommand();
}
Expand Down
93 changes: 54 additions & 39 deletions src/UserInterfaceExtensions/Panels/PanelsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,65 @@
namespace epi_videoCodec_ciscoExtended.UserInterfaceExtensions.Panels
{

public class PanelsHandler: ICiscoCodecUiExtensionsHandler
{
private readonly IKeyed _parent;
private readonly IBasicCommunication _coms;
private readonly List<Panel> _panelConfigs;
public class PanelsHandler : ICiscoCodecUiExtensionsHandler
{
private readonly IKeyed _parent;
private readonly IBasicCommunication _coms;
private readonly List<Panel> _panelConfigs;
private Action<string> EnqueueCommand;

public PanelsHandler(IKeyed parent, IBasicCommunication coms, List<Panel> config)
{
_parent = parent;
_coms = coms;
_panelConfigs = config;
if (config == null || config.Count == 0)
{
Debug.LogMessage(
Serilog.Events.LogEventLevel.Information,
"No Cisco Panels Configured {0}", _parent, config);
return;
}
RegisterFeedback();
}
public PanelsHandler(IKeyed parent, IBasicCommunication coms, Action<string> enqueueCommand, List<Panel> config)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Constructing PanelsHandler", parent);
_parent = parent;
_coms = coms;
_panelConfigs = config;
EnqueueCommand = enqueueCommand;
if (config == null || config.Count == 0)
{
Debug.LogMessage(
Serilog.Events.LogEventLevel.Information,
"No Cisco Panels Configured {0}", _parent, config);
return;
}
RegisterFeedback();
}

public void ParseStatus(CiscoCodecEvents.Panel panel)
{
var pconfig = _panelConfigs.FirstOrDefault((Panel p) => p.PanelId == panel.Clicked.PanelId.Value);
if (pconfig == null) return;
pconfig.OnClickedEvent();
}
public void ParseStatus(CiscoCodecEvents.Panel panel)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "PanelsHandler Parse Status Panel Clicked: {0}", _parent, panel.Clicked.PanelId.Value);
var pconfig = _panelConfigs.FirstOrDefault((Panel p) => p.PanelId == panel.Clicked.PanelId.Value);
if (pconfig == null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Panel not found in config id: {0}", _parent, panel.Id);
return;
}
pconfig.OnClickedEvent();
}

public void RegisterFeedback()
{
//detect button changes for panel buttons ROOM OS
_coms.SendText("xfeedback register /Event/UserInterface/Extensions/Panel/Clicked" + CiscoCodec.Delimiter);
}
public void RegisterFeedback()
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "PanelsHandler RegisterFeedback", _parent);
//detect button changes for panel buttons ROOM OS
var cmd = "xfeedback register /Event/UserInterface/Extensions/Panel/Clicked" + CiscoCodec.Delimiter;
//_coms.SendText(cmd);
EnqueueCommand(cmd);
}

public void DeregisterFeedback()
{
_coms.SendText("xfeedback deregister /Event/UserInterface/Extensions/Panel/Clicked" + CiscoCodec.Delimiter);
}
public void DeregisterFeedback()
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "PanelsHandler DeregisterFeedback", _parent);
var cmd = "xfeedback deregister /Event/UserInterface/Extensions/Panel/Clicked" + CiscoCodec.Delimiter;
//_coms.SendText(cmd);
EnqueueCommand(cmd);
}

public void LinkToApi(BasicTriList trilist, CiscoCodecJoinMap joinMap)
{
//add simpl stuff later
}
}
public void LinkToApi(BasicTriList trilist, CiscoCodecJoinMap joinMap)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "PanelsHandler LinkToApi. NOT IMPLEMENTED", _parent);
//add simpl stuff later
}
}
}

/*
Expand Down
15 changes: 12 additions & 3 deletions src/UserInterfaceExtensions/UiExtensionsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,40 @@ public class UiExtensionsHandler : ICiscoCodecUiExtensionsHandler, IVideoCodecUi
{
private readonly IKeyed _parent;
private readonly IBasicCommunication _coms;
private readonly Action<string> EnqueuCommand;

public Action<UiWebViewDisplayActionArgs> UiWebViewDisplayAction { get; set; }

public event EventHandler<UiExtensionsClickedEventArgs> UiExtensionsClickedEvent;

public UiExtensionsHandler(IKeyed parent, IBasicCommunication coms)
public UiExtensionsHandler(IKeyed parent, IBasicCommunication coms, Action<string> enqueueCommand)

{
_parent = parent;
_coms = coms;

EnqueuCommand = enqueueCommand;
//set the action that will run when called with args from elsewhere via interface
UiWebViewDisplayAction =
new Action<UiWebViewDisplayActionArgs>((UiWebViewDisplayActionArgs args) =>
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "WebViewDisplayAction URL: {0}", _parent, args.Url);
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "WebViewDisplayAction Header: {0}", _parent, args.Header);
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "WebViewDisplayAction Mode: {0}", _parent, args.Mode);
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "WebViewDisplayAction Title: {0}", _parent, args.Title);
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "WebViewDisplayAction Target: {0}", _parent, args.Target);
UiWebViewDisplay uwvd = new UiWebViewDisplay { Header = args.Header, Url = args.Url, Mode = args.Mode, Title = args.Title };
coms.SendText(uwvd.xCommand());
//coms.SendText(uwvd.xCommand());
EnqueuCommand(uwvd.xCommand());
});

}

public void ParseStatus(Panels.CiscoCodecEvents.Panel panel)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "UiExtensionsHandler Parse Status Panel Clicked: {0}", _parent, panel.Clicked.PanelId.Value);
if (panel.Clicked != null && panel.Clicked.PanelId != null && panel.Clicked.PanelId.Value != null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "UiExtensionsHandler Parse Status Panel Clicked Raise Event: {0}", _parent, panel.Clicked.PanelId.Value);
UiExtensionsClickedEvent?.Invoke(this, new UiExtensionsClickedEventArgs(true, panel.Clicked.PanelId.Value));
}
}
Expand Down
26 changes: 24 additions & 2 deletions src/UserInterfaceWebViewDisplay/UiWebViewDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,30 @@ public class UiWebViewDisplay
/// <returns></returns>
public string xCommand()
{
return string.Format($"xCommand UserInterface WebView Display Header: {Header} Mode: {Mode} Options: {Options} Target: {Target} Title: {Title} Url: {Url}{CiscoCodec.Delimiter}");
}
var command = "xCommand UserInterface WebView Display";

if (!string.IsNullOrEmpty(Header))
command += $" Header: \"{Header}\"";

if (!string.IsNullOrEmpty(Mode))
command += $" Mode: \"{Mode}\"";

if (!string.IsNullOrEmpty(Options))
command += $" Options: \"{Options}\"";

if (!string.IsNullOrEmpty(Target))
command += $" Target: \"{Target}\"";

if (!string.IsNullOrEmpty(Title))
command += $" Title: \"{Title}\"";

if (!string.IsNullOrEmpty(Url))
command += $" Url: \"{Url}\"";

command += CiscoCodec.Delimiter;

return command;
}

}
}
34 changes: 22 additions & 12 deletions src/Xml/XmlConverter.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace epi_videoCodec_ciscoExtended.Xml
{
public class XmlConverter
{
public static string SerializeObject<T>(T toSerialize)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (StringWriter textWriter = new StringWriter())
{
xmlSerializer.Serialize(textWriter, toSerialize);
return textWriter.ToString();
}
}
}
public static class XmlConverter
{
public static string SerializeObject<T>(T value)
{
var emptyNamespaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
var serializer = new XmlSerializer(value.GetType());
var settings = new XmlWriterSettings
{
OmitXmlDeclaration = true, // Do not include XML declaration
Indent = true, // Indent XML for readability
};

using (var stream = new StringWriter())
using (var writer = XmlWriter.Create(stream, settings))
{
serializer.Serialize(writer, value, emptyNamespaces);
return stream.ToString();
}
}
}

}
2 changes: 1 addition & 1 deletion src/epi-videoCodec-ciscoExtended.4Series.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PepperDashEssentials" Version="2.0.0-alpha-2444" />
<PackageReference Include="PepperDashEssentials" Version="2.0.0-alpha-2466" />
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
</ItemGroup>

Expand Down

0 comments on commit 11e9065

Please sign in to comment.