mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-23 00:25:04 +00:00
Compare commits
2 Commits
1.8.5-pr69
...
1.8.5-hotf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4cec8e97d | ||
|
|
451160dd2d |
@@ -36,7 +36,6 @@ namespace PepperDash.Essentials
|
|||||||
Thread.MaxNumberOfUserThreads = 400;
|
Thread.MaxNumberOfUserThreads = 400;
|
||||||
Global.ControlSystem = this;
|
Global.ControlSystem = this;
|
||||||
DeviceManager.Initialize(this);
|
DeviceManager.Initialize(this);
|
||||||
SecretsManager.Initialize();
|
|
||||||
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
|
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ namespace PepperDash.Essentials
|
|||||||
CrestronConsole.AddNewConsoleCommand(s =>
|
CrestronConsole.AddNewConsoleCommand(s =>
|
||||||
{
|
{
|
||||||
foreach (var tl in TieLineCollection.Default)
|
foreach (var tl in TieLineCollection.Default)
|
||||||
CrestronConsole.ConsoleCommandResponse(" {0}\r\n", tl);
|
CrestronConsole.ConsoleCommandResponse(" {0}\r", tl);
|
||||||
},
|
},
|
||||||
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
|
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
@@ -86,8 +85,8 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(s =>
|
CrestronConsole.AddNewConsoleCommand(s =>
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("This system can be found at the following URLs:\r\n" +
|
CrestronConsole.ConsoleCommandResponse("This system can be found at the following URLs:\r" +
|
||||||
"System URL: {0}\r\n" +
|
"System URL: {0}\r" +
|
||||||
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
|
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
|
||||||
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
|
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
public JoinDataComplete OutputAudio = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 },
|
public JoinDataComplete OutputAudio = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 },
|
||||||
new JoinMetadata { Description = "DM Chassis Output Audio Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
|
new JoinMetadata { Description = "DM Chassis Output Audio Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
|
||||||
|
|
||||||
|
[JoinName("OutputAudioSourceDevice")] public JoinDataComplete OutputAudioSourceDevice =
|
||||||
|
new JoinDataComplete(new JoinData {JoinNumber = 401, JoinSpan = 32},
|
||||||
|
new JoinMetadata
|
||||||
|
{
|
||||||
|
Description = "DMPS HDMI/DM Output Source Device selection",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
|
||||||
|
JoinType = eJoinType.Analog
|
||||||
|
});
|
||||||
|
|
||||||
[JoinName("InputNames")]
|
[JoinName("InputNames")]
|
||||||
public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 },
|
public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 },
|
||||||
new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
public GenericComm(DeviceConfig config)
|
public GenericComm(DeviceConfig config)
|
||||||
: base(config)
|
: base(config)
|
||||||
{
|
{
|
||||||
|
|
||||||
PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);
|
PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);
|
||||||
|
|
||||||
var commPort = CommFactory.CreateCommForDevice(config);
|
var commPort = CommFactory.CreateCommForDevice(config);
|
||||||
|
|||||||
@@ -30,19 +30,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
[JsonProperty("properties")]
|
[JsonProperty("properties")]
|
||||||
[JsonConverter(typeof(DevicePropertiesConverter))]
|
[JsonConverter(typeof(DevicePropertiesConverter))]
|
||||||
public JToken Properties { get; set; }
|
public JToken Properties { get; set; }
|
||||||
|
|
||||||
public DeviceConfig(DeviceConfig dc)
|
|
||||||
{
|
|
||||||
Key = dc.Key;
|
|
||||||
Uid = dc.Uid;
|
|
||||||
Name = dc.Name;
|
|
||||||
Group = dc.Group;
|
|
||||||
Type = dc.Type;
|
|
||||||
Properties = JToken.FromObject(dc.Properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceConfig() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
public static class JsonExtensions
|
|
||||||
{
|
|
||||||
public static List<JToken> FindTokens(this JToken containerToken, string name)
|
|
||||||
{
|
|
||||||
List<JToken> matches = new List<JToken>();
|
|
||||||
FindTokens(containerToken, name, matches);
|
|
||||||
return matches;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void FindTokens(JToken containerToken, string name, List<JToken> matches)
|
|
||||||
{
|
|
||||||
if (containerToken.Type == JTokenType.Object)
|
|
||||||
{
|
|
||||||
foreach (JProperty child in containerToken.Children<JProperty>())
|
|
||||||
{
|
|
||||||
if (child.Name == name)
|
|
||||||
{
|
|
||||||
matches.Add(child.Value);
|
|
||||||
}
|
|
||||||
FindTokens(child.Value, name, matches);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (containerToken.Type == JTokenType.Array)
|
|
||||||
{
|
|
||||||
foreach (JToken child in containerToken.Children())
|
|
||||||
{
|
|
||||||
FindTokens(child, name, matches);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,6 @@ using Crestron.SimplSharpPro;
|
|||||||
using Crestron.SimplSharpPro.GeneralIO;
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.CrestronIO;
|
using PepperDash.Essentials.Core.CrestronIO;
|
||||||
@@ -85,81 +83,33 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method };
|
var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method };
|
||||||
DeviceFactory.FactoryMethods.Add(typeName, wrapper);
|
DeviceFactory.FactoryMethods.Add(typeName, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckForSecrets(IEnumerable<JProperty> obj)
|
/// <summary>
|
||||||
{
|
/// The factory method for Core "things". Also iterates the Factory methods that have
|
||||||
foreach (var prop in obj.Where(prop => prop.Value as JObject != null))
|
/// been loaded from plugins
|
||||||
{
|
/// </summary>
|
||||||
if (prop.Name.ToLower() == "secret")
|
/// <param name="dc"></param>
|
||||||
{
|
/// <returns></returns>
|
||||||
var secret = GetSecret(prop.Children().First().ToObject<SecretsPropertiesConfig>());
|
public static IKeyed GetDevice(DeviceConfig dc)
|
||||||
//var secret = GetSecret(JsonConvert.DeserializeObject<SecretsPropertiesConfig>(prop.Children().First().ToString()));
|
{
|
||||||
prop.Parent.Replace(secret);
|
var key = dc.Key;
|
||||||
}
|
var name = dc.Name;
|
||||||
var recurseProp = prop.Value as JObject;
|
var type = dc.Type;
|
||||||
if (recurseProp == null) return;
|
var properties = dc.Properties;
|
||||||
CheckForSecrets(recurseProp.Properties());
|
|
||||||
}
|
var typeName = dc.Type.ToLower();
|
||||||
}
|
|
||||||
|
// Check for types that have been added by plugin dlls.
|
||||||
private static string GetSecret(SecretsPropertiesConfig data)
|
if (FactoryMethods.ContainsKey(typeName))
|
||||||
{
|
{
|
||||||
var secretProvider = SecretsManager.GetSecretProviderByKey(data.Provider);
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type);
|
||||||
if (secretProvider == null) return null;
|
return FactoryMethods[typeName].FactoryMethod(dc);
|
||||||
var secret = secretProvider.GetSecret(data.Key);
|
}
|
||||||
if (secret != null) return (string) secret.Value;
|
|
||||||
Debug.Console(1,
|
return null;
|
||||||
"Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider",
|
}
|
||||||
data.Provider, data.Key);
|
|
||||||
return String.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The factory method for Core "things". Also iterates the Factory methods that have
|
|
||||||
/// been loaded from plugins
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dc"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IKeyed GetDevice(DeviceConfig dc)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type);
|
|
||||||
|
|
||||||
var localDc = new DeviceConfig(dc);
|
|
||||||
|
|
||||||
var key = localDc.Key;
|
|
||||||
var name = localDc.Name;
|
|
||||||
var type = localDc.Type;
|
|
||||||
var properties = localDc.Properties;
|
|
||||||
//var propRecurse = properties;
|
|
||||||
|
|
||||||
var typeName = localDc.Type.ToLower();
|
|
||||||
|
|
||||||
|
|
||||||
var jObject = properties as JObject;
|
|
||||||
if (jObject != null)
|
|
||||||
{
|
|
||||||
var jProp = jObject.Properties();
|
|
||||||
|
|
||||||
CheckForSecrets(jProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(2, "typeName = {0}", typeName);
|
|
||||||
// Check for types that have been added by plugin dlls.
|
|
||||||
return !FactoryMethods.ContainsKey(typeName) ? null : FactoryMethods[typeName].FactoryMethod(localDc);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message);
|
|
||||||
|
|
||||||
Debug.Console(2, "{0}", ex.StackTrace);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints the type names and associated metadata from the FactoryMethods collection.
|
/// Prints the type names and associated metadata from the FactoryMethods collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -209,7 +209,6 @@
|
|||||||
<Compile Include="DeviceTypeInterfaces\IHasFarEndContentStatus.cs" />
|
<Compile Include="DeviceTypeInterfaces\IHasFarEndContentStatus.cs" />
|
||||||
<Compile Include="DeviceTypeInterfaces\IHasPhoneDialing.cs" />
|
<Compile Include="DeviceTypeInterfaces\IHasPhoneDialing.cs" />
|
||||||
<Compile Include="DeviceTypeInterfaces\IMobileControl.cs" />
|
<Compile Include="DeviceTypeInterfaces\IMobileControl.cs" />
|
||||||
<Compile Include="Extensions\JsonExtensions.cs" />
|
|
||||||
<Compile Include="Factory\DeviceFactory.cs" />
|
<Compile Include="Factory\DeviceFactory.cs" />
|
||||||
<Compile Include="Factory\IDeviceFactory.cs" />
|
<Compile Include="Factory\IDeviceFactory.cs" />
|
||||||
<Compile Include="Factory\ReadyEventArgs.cs" />
|
<Compile Include="Factory\ReadyEventArgs.cs" />
|
||||||
@@ -321,10 +320,6 @@
|
|||||||
<Compile Include="Feedbacks\BoolFeedbackPulseExtender.cs" />
|
<Compile Include="Feedbacks\BoolFeedbackPulseExtender.cs" />
|
||||||
<Compile Include="Routing\RoutingPortNames.cs" />
|
<Compile Include="Routing\RoutingPortNames.cs" />
|
||||||
<Compile Include="Routing\TieLineConfig.cs" />
|
<Compile Include="Routing\TieLineConfig.cs" />
|
||||||
<Compile Include="Secrets\CrestronSecretsProvider.cs" />
|
|
||||||
<Compile Include="Secrets\Interfaces.cs" />
|
|
||||||
<Compile Include="Secrets\SecretsManager.cs" />
|
|
||||||
<Compile Include="Secrets\SecretsPropertiesConfig.cs" />
|
|
||||||
<Compile Include="Shades\Shade Interfaces.cs" />
|
<Compile Include="Shades\Shade Interfaces.cs" />
|
||||||
<Compile Include="Shades\ShadeBase.cs" />
|
<Compile Include="Shades\ShadeBase.cs" />
|
||||||
<Compile Include="Shades\ShadeController.cs" />
|
<Compile Include="Shades\ShadeController.cs" />
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.CrestronDataStore;
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
public class CrestronSecretsProvider : ISecretProvider
|
|
||||||
{
|
|
||||||
public string Key { get; set; }
|
|
||||||
//Added for reference
|
|
||||||
private static readonly bool SecureSupported;
|
|
||||||
public CrestronSecretsProvider(string key)
|
|
||||||
{
|
|
||||||
Key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CrestronSecretsProvider()
|
|
||||||
{
|
|
||||||
//Added for future encrypted reference
|
|
||||||
SecureSupported = CrestronSecureStorage.Supported;
|
|
||||||
|
|
||||||
CrestronDataStoreStatic.InitCrestronDataStore();
|
|
||||||
if (SecureSupported)
|
|
||||||
{
|
|
||||||
//doThingsFuture
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set secret for item in the CrestronSecretsProvider
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Secret Key</param>
|
|
||||||
/// <param name="value">Secret Value</param>
|
|
||||||
public bool SetSecret(string key, object value)
|
|
||||||
{
|
|
||||||
var secret = value as string;
|
|
||||||
if (String.IsNullOrEmpty(secret))
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Unable to set secret for {0}:{1} - value is empty.", Key, key);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var setErrorCode = CrestronDataStoreStatic.SetLocalStringValue(key, secret);
|
|
||||||
switch (setErrorCode)
|
|
||||||
{
|
|
||||||
case CrestronDataStore.CDS_ERROR.CDS_SUCCESS:
|
|
||||||
Debug.Console(1, this,"Secret Successfully Set for {0}:{1}", Key, key);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Notice, "Unable to set secret for {0}:{1} - {2}", Key, key, setErrorCode.ToString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve secret for item in the CrestronSecretsProvider
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Secret Key</param>
|
|
||||||
/// <returns>ISecret Object containing key, provider, and value</returns>
|
|
||||||
public ISecret GetSecret(string key)
|
|
||||||
{
|
|
||||||
string mySecret;
|
|
||||||
var getErrorCode = CrestronDataStoreStatic.GetLocalStringValue(key, out mySecret);
|
|
||||||
|
|
||||||
switch (getErrorCode)
|
|
||||||
{
|
|
||||||
case CrestronDataStore.CDS_ERROR.CDS_SUCCESS:
|
|
||||||
Debug.Console(2, this, "Secret Successfully retrieved for {0}:{1}", Key, key);
|
|
||||||
return new CrestronSecret(key, mySecret, this);
|
|
||||||
default:
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Unable to retrieve secret for {0}:{1} - {2}",
|
|
||||||
Key, key, getErrorCode.ToString());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Special container class for CrestronSecret provider
|
|
||||||
/// </summary>
|
|
||||||
public class CrestronSecret : ISecret
|
|
||||||
{
|
|
||||||
public ISecretProvider Provider { get; private set; }
|
|
||||||
public string Key { get; private set; }
|
|
||||||
|
|
||||||
public object Value { get; private set; }
|
|
||||||
|
|
||||||
public CrestronSecret(string key, string value, ISecretProvider provider)
|
|
||||||
{
|
|
||||||
Key = key;
|
|
||||||
Value = value;
|
|
||||||
Provider = provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// All ISecrecretProvider classes must implement this interface.
|
|
||||||
/// </summary>
|
|
||||||
public interface ISecretProvider : IKeyed
|
|
||||||
{
|
|
||||||
bool SetSecret(string key, object value);
|
|
||||||
|
|
||||||
ISecret GetSecret(string key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// interface for delivering secrets in Essentials.
|
|
||||||
/// </summary>
|
|
||||||
public interface ISecret
|
|
||||||
{
|
|
||||||
ISecretProvider Provider { get; }
|
|
||||||
string Key { get; }
|
|
||||||
object Value { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,281 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
public static class SecretsManager
|
|
||||||
{
|
|
||||||
public static Dictionary<string, ISecretProvider> Secrets { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialize the SecretsManager
|
|
||||||
/// </summary>
|
|
||||||
public static void Initialize()
|
|
||||||
{
|
|
||||||
|
|
||||||
AddSecretProvider("default", new CrestronSecretsProvider("default"));
|
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(SetSecretProcess, "setsecret",
|
|
||||||
"Adds secrets to secret provider",
|
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(UpdateSecretProcess, "updatesecret",
|
|
||||||
"Updates secrets in secret provider",
|
|
||||||
ConsoleAccessLevelEnum.AccessAdministrator);
|
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(DeleteSecretProcess, "deletesecret",
|
|
||||||
"Deletes secrets in secret provider",
|
|
||||||
ConsoleAccessLevelEnum.AccessAdministrator);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SecretsManager()
|
|
||||||
{
|
|
||||||
Secrets = new Dictionary<string, ISecretProvider>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get Secret Provider from dictionary by key
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Dictionary Key for provider</param>
|
|
||||||
/// <returns>ISecretProvider</returns>
|
|
||||||
public static ISecretProvider GetSecretProviderByKey(string key)
|
|
||||||
{
|
|
||||||
ISecretProvider secret;
|
|
||||||
|
|
||||||
Secrets.TryGetValue(key, out secret);
|
|
||||||
|
|
||||||
if (secret == null)
|
|
||||||
{
|
|
||||||
Debug.Console(1, "SecretsManager unable to retrieve SecretProvider with the key '{0}'", key);
|
|
||||||
}
|
|
||||||
return secret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add secret provider to secrets dictionary
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Key of new entry</param>
|
|
||||||
/// <param name="provider">New Provider Entry</param>
|
|
||||||
public static void AddSecretProvider(string key, ISecretProvider provider)
|
|
||||||
{
|
|
||||||
if (!Secrets.ContainsKey(key))
|
|
||||||
{
|
|
||||||
Secrets.Add(key, provider);
|
|
||||||
Debug.Console(1, "Secrets provider '{0}' added to SecretsManager", key);
|
|
||||||
}
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to add Provider '{0}' to Secrets. Provider with that key already exists", key );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add secret provider to secrets dictionary, with optional overwrite parameter
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Key of new entry</param>
|
|
||||||
/// <param name="provider">New provider entry</param>
|
|
||||||
/// <param name="overwrite">true to overwrite any existing providers in the dictionary</param>
|
|
||||||
public static void AddSecretProvider(string key, ISecretProvider provider, bool overwrite)
|
|
||||||
{
|
|
||||||
if (!Secrets.ContainsKey(key))
|
|
||||||
{
|
|
||||||
Secrets.Add(key, provider);
|
|
||||||
Debug.Console(1, "Secrets provider '{0}' added to SecretsManager", key);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (overwrite)
|
|
||||||
{
|
|
||||||
Secrets.Add(key, provider);
|
|
||||||
Debug.Console(1, Debug.ErrorLogLevel.Notice, "Provider with the key '{0}' already exists in secrets. Overwriting with new secrets provider.", key);
|
|
||||||
|
|
||||||
}
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to add Provider '{0}' to Secrets. Provider with that key already exists", key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetSecretProcess(string cmd)
|
|
||||||
{
|
|
||||||
string response;
|
|
||||||
var args = cmd.Split(' ');
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
//some Instructional Text
|
|
||||||
response = "Adds secrets to secret provider. Format 'setsecret <provider> <secretKey> <secret>";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Length == 1 && args[0] == "?")
|
|
||||||
{
|
|
||||||
response = "Adds secrets to secret provider. Format 'setsecret <provider> <secretKey> <secret>";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Length < 3)
|
|
||||||
{
|
|
||||||
response = "Improper number of arguments";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var provider = GetSecretProviderByKey(args[0]);
|
|
||||||
|
|
||||||
if (provider == null)
|
|
||||||
{
|
|
||||||
//someFail
|
|
||||||
response = "Provider key invalid";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var key = args[1];
|
|
||||||
var secret = args[2];
|
|
||||||
|
|
||||||
if (provider.GetSecret(key) == null)
|
|
||||||
{
|
|
||||||
|
|
||||||
response = provider.SetSecret(key, secret)
|
|
||||||
? String.Format(
|
|
||||||
"Secret successfully set for {0}:{1}",
|
|
||||||
provider.Key, key)
|
|
||||||
: String.Format(
|
|
||||||
"Unable to set secret for {0}:{1}",
|
|
||||||
provider.Key, key);
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
response =
|
|
||||||
String.Format(
|
|
||||||
"Unable to set secret for {0}:{1} - Please use the 'UpdateSecret' command to modify it");
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void UpdateSecretProcess(string cmd)
|
|
||||||
{
|
|
||||||
string response;
|
|
||||||
var args = cmd.Split(' ');
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
//some Instructional Text
|
|
||||||
response = "Updates secrets in secret provider. Format 'updatesecret <provider> <secretKey> <secret>";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Length == 1 && args[0] == "?")
|
|
||||||
{
|
|
||||||
response = "Updates secrets in secret provider. Format 'updatesecret <provider> <secretKey> <secret>";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (args.Length < 3)
|
|
||||||
{
|
|
||||||
//someFail
|
|
||||||
response = "Improper number of arguments";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var provider = GetSecretProviderByKey(args[0]);
|
|
||||||
|
|
||||||
if (provider == null)
|
|
||||||
{
|
|
||||||
//someFail
|
|
||||||
response = "Provider key invalid";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var key = args[1];
|
|
||||||
var secret = args[2];
|
|
||||||
|
|
||||||
if (provider.GetSecret(key) != null)
|
|
||||||
{
|
|
||||||
response = provider.SetSecret(key, secret)
|
|
||||||
? String.Format(
|
|
||||||
"Secret successfully set for {0}:{1}",
|
|
||||||
provider.Key, key)
|
|
||||||
: String.Format(
|
|
||||||
"Unable to set secret for {0}:{1}",
|
|
||||||
provider.Key, key);
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
response =
|
|
||||||
String.Format(
|
|
||||||
"Unable to update secret for {0}:{1} - Please use the 'SetSecret' command to create a new secret");
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void DeleteSecretProcess(string cmd)
|
|
||||||
{
|
|
||||||
string response;
|
|
||||||
var args = cmd.Split(' ');
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
//some Instructional Text
|
|
||||||
response = "Deletes secrets in secret provider. Format 'deletesecret <provider> <secretKey>";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (args.Length == 1 && args[0] == "?")
|
|
||||||
{
|
|
||||||
response = "Deletes secrets in secret provider. Format 'deletesecret <provider> <secretKey>";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (args.Length < 2)
|
|
||||||
{
|
|
||||||
//someFail
|
|
||||||
response = "Improper number of arguments";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var provider = GetSecretProviderByKey(args[0]);
|
|
||||||
|
|
||||||
if (provider == null)
|
|
||||||
{
|
|
||||||
//someFail
|
|
||||||
response = "Provider key invalid";
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var key = args[1];
|
|
||||||
|
|
||||||
|
|
||||||
provider.SetSecret(key, "");
|
|
||||||
response = provider.SetSecret(key, "")
|
|
||||||
? String.Format(
|
|
||||||
"Secret successfully deleted for {0}:{1}",
|
|
||||||
provider.Key, key)
|
|
||||||
: String.Format(
|
|
||||||
"Unable to delete secret for {0}:{1}",
|
|
||||||
provider.Key, key);
|
|
||||||
CrestronConsole.ConsoleCommandResponse(response);
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Provide a way to easily deserialize into a secret object from config
|
|
||||||
/// </summary>
|
|
||||||
public class SecretsPropertiesConfig
|
|
||||||
{
|
|
||||||
[JsonProperty("provider")]
|
|
||||||
public string Provider { get; set; }
|
|
||||||
[JsonProperty("key")]
|
|
||||||
public string Key { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,6 +32,7 @@ namespace PepperDash.Essentials.DM
|
|||||||
// Feedbacks for EssentialDM
|
// Feedbacks for EssentialDM
|
||||||
public Dictionary<uint, IntFeedback> VideoOutputFeedbacks { get; private set; }
|
public Dictionary<uint, IntFeedback> VideoOutputFeedbacks { get; private set; }
|
||||||
public Dictionary<uint, IntFeedback> AudioOutputFeedbacks { get; private set; }
|
public Dictionary<uint, IntFeedback> AudioOutputFeedbacks { get; private set; }
|
||||||
|
public Dictionary<uint, IntFeedback> AudioOutputSourceDeviceFeedbacks { get; private set; }
|
||||||
public Dictionary<uint, BoolFeedback> VideoInputSyncFeedbacks { get; private set; }
|
public Dictionary<uint, BoolFeedback> VideoInputSyncFeedbacks { get; private set; }
|
||||||
public Dictionary<uint, BoolFeedback> InputEndpointOnlineFeedbacks { get; private set; }
|
public Dictionary<uint, BoolFeedback> InputEndpointOnlineFeedbacks { get; private set; }
|
||||||
public Dictionary<uint, BoolFeedback> OutputEndpointOnlineFeedbacks { get; private set; }
|
public Dictionary<uint, BoolFeedback> OutputEndpointOnlineFeedbacks { get; private set; }
|
||||||
@@ -125,6 +126,7 @@ namespace PepperDash.Essentials.DM
|
|||||||
|
|
||||||
VideoOutputFeedbacks = new Dictionary<uint, IntFeedback>();
|
VideoOutputFeedbacks = new Dictionary<uint, IntFeedback>();
|
||||||
AudioOutputFeedbacks = new Dictionary<uint, IntFeedback>();
|
AudioOutputFeedbacks = new Dictionary<uint, IntFeedback>();
|
||||||
|
AudioOutputSourceDeviceFeedbacks = new Dictionary<uint, IntFeedback>();
|
||||||
VideoInputSyncFeedbacks = new Dictionary<uint, BoolFeedback>();
|
VideoInputSyncFeedbacks = new Dictionary<uint, BoolFeedback>();
|
||||||
InputNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
InputNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
||||||
OutputNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
OutputNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
||||||
@@ -231,6 +233,8 @@ namespace PepperDash.Essentials.DM
|
|||||||
o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Video));
|
o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Video));
|
||||||
trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin,
|
trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin,
|
||||||
o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Audio));
|
o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Audio));
|
||||||
|
trilist.SetUShortSigAction(joinMap.OutputAudioSourceDevice.JoinNumber + ioSlotJoin, u =>
|
||||||
|
SetAudioOutputSourceDevice(ioSlot, u));
|
||||||
|
|
||||||
trilist.SetStringSigAction(joinMap.OutputNames.JoinNumber + ioSlotJoin, s =>
|
trilist.SetStringSigAction(joinMap.OutputNames.JoinNumber + ioSlotJoin, s =>
|
||||||
{
|
{
|
||||||
@@ -269,6 +273,15 @@ namespace PepperDash.Essentials.DM
|
|||||||
{
|
{
|
||||||
AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]);
|
AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntFeedback audioOutSourceDeviceFeedback;
|
||||||
|
|
||||||
|
|
||||||
|
if (AudioOutputSourceDeviceFeedbacks.TryGetValue(ioSlot, out audioOutSourceDeviceFeedback))
|
||||||
|
{
|
||||||
|
audioOutSourceDeviceFeedback.LinkInputSig(
|
||||||
|
trilist.UShortInput[joinMap.OutputAudioSourceDevice.JoinNumber + ioSlotJoin]);
|
||||||
|
}
|
||||||
if (OutputNameFeedbacks[ioSlot] != null)
|
if (OutputNameFeedbacks[ioSlot] != null)
|
||||||
{
|
{
|
||||||
OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]);
|
OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]);
|
||||||
@@ -291,6 +304,33 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetAudioOutputSourceDevice(uint output, ushort sourceDevice)
|
||||||
|
{
|
||||||
|
var card = Dmps.SwitcherOutputs[output];
|
||||||
|
|
||||||
|
if (sourceDevice > 3)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Invalid audio out device {0}. Valid values are 0 (NoSource), 1 (DigitalMixer1), 2 (DigitalMixer2), 3(AudioFollowVideo)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//try to cast to dm output
|
||||||
|
var dmOut = card as Card.Dmps3DmOutputBackend;
|
||||||
|
var hdmiOut = card as Card.Dmps3HdmiOutputBackend;
|
||||||
|
|
||||||
|
if (dmOut != null)
|
||||||
|
{
|
||||||
|
dmOut.AudioOutSourceDevice = (eDmps34KAudioOutSourceDevice) sourceDevice;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hdmiOut == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hdmiOut.AudioOutSourceDevice = (eDmps34KAudioOutSourceDevice) sourceDevice;
|
||||||
|
}
|
||||||
|
|
||||||
private void LinkInputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap)
|
private void LinkInputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap)
|
||||||
{
|
{
|
||||||
for (uint i = 1; i <= Dmps.SwitcherInputs.Count; i++)
|
for (uint i = 1; i <= Dmps.SwitcherInputs.Count; i++)
|
||||||
@@ -572,6 +612,11 @@ namespace PepperDash.Essentials.DM
|
|||||||
|
|
||||||
var cecPort = hdmiOutputCard.HdmiOutputPort;
|
var cecPort = hdmiOutputCard.HdmiOutputPort;
|
||||||
|
|
||||||
|
hdmiOutputCard.AudioOutSourceDevice = eDmps34KAudioOutSourceDevice.DigitalMixer1;
|
||||||
|
|
||||||
|
AudioOutputSourceDeviceFeedbacks.Add(outputCard.Number,
|
||||||
|
new IntFeedback(() => (int) hdmiOutputCard.AudioOutSourceDeviceFeedback));
|
||||||
|
|
||||||
AddHdmiOutputPort(number, cecPort);
|
AddHdmiOutputPort(number, cecPort);
|
||||||
}
|
}
|
||||||
else if (outputCard is Card.Dmps3DmOutput)
|
else if (outputCard is Card.Dmps3DmOutput)
|
||||||
@@ -580,6 +625,11 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
else if (outputCard is Card.Dmps3DmOutputBackend)
|
else if (outputCard is Card.Dmps3DmOutputBackend)
|
||||||
{
|
{
|
||||||
|
var dmCard = outputCard as Card.Dmps3DmOutputBackend;
|
||||||
|
|
||||||
|
AudioOutputSourceDeviceFeedbacks.Add(outputCard.Number,
|
||||||
|
new IntFeedback(() => (int) dmCard.AudioOutSourceDeviceFeedback));
|
||||||
|
|
||||||
AddDmOutputPort(number);
|
AddDmOutputPort(number);
|
||||||
}
|
}
|
||||||
else if (outputCard is Card.Dmps3ProgramOutput)
|
else if (outputCard is Card.Dmps3ProgramOutput)
|
||||||
@@ -801,6 +851,12 @@ namespace PepperDash.Essentials.DM
|
|||||||
{
|
{
|
||||||
AudioOutputFeedbacks[output].FireUpdate();
|
AudioOutputFeedbacks[output].FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AudioOutputSourceDeviceFeedbacks.ContainsKey(output))
|
||||||
|
{
|
||||||
|
AudioOutputSourceDeviceFeedbacks[output].FireUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.EventId == DMOutputEventIds.OutputNameEventId
|
else if (args.EventId == DMOutputEventIds.OutputNameEventId
|
||||||
@@ -871,16 +927,10 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//DMOutput dmOutputCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput;
|
|
||||||
|
|
||||||
//if (inCard != null)
|
|
||||||
//{
|
|
||||||
// NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES
|
// NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES
|
||||||
if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video)
|
if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video)
|
||||||
{
|
{
|
||||||
|
output.VideoOut = input;
|
||||||
output.VideoOut = input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)
|
if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)
|
||||||
|
|||||||
Reference in New Issue
Block a user