Compare commits

...

8 Commits

Author SHA1 Message Date
Trevor Payne
d302a1b06b fix: merge in changes from issue #983
fix: DeviceInfo Null Check

Change IConvertiblePreset to abstract class ConvertiblePreset
2022-08-18 16:34:48 -05:00
Trevor Payne
780ec0aa4b fix: Check for local version 2022-08-17 13:22:48 -05:00
Trevor Payne
c2deaf9534 merge: feature/VideoCodec-Phonebook-Clear 2022-08-17 13:18:25 -05:00
Trevor Payne
cf3563d6b6 Merge branch 'feature/VideoCodec-Phonebook-Clear' into feature/explicit-essentials-version-check 2022-08-17 13:17:15 -05:00
Trevor Payne
e45643e9ab feat: add PluginDevelopmentDeviceFactory and associated Interfaces
feat: add method to Global to check against list of development versions
2022-08-17 13:01:21 -05:00
Trevor Payne
03a640d3d4 fix: Joinmap Index overwriting - adjusted 2022-08-12 16:18:58 -05:00
Trevor Payne
96cc263dbe feat: Resolves #982 2022-08-12 16:08:00 -05:00
Trevor Payne
9860e5f498 feat: Add method to clear selected phonebook entry 2022-08-12 15:58:19 -05:00
11 changed files with 156 additions and 59 deletions

View File

@@ -398,6 +398,22 @@ namespace PepperDash.Essentials.Core.Bridges.JoinMaps
JoinType = eJoinType.Digital
});
[JoinName("DirectoryClearSelection")]
public JoinDataComplete DirectoryClearSelection = new JoinDataComplete(
new JoinData
{
JoinNumber = 100,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Directory Search Busy FB",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("DirectoryEntryIsContact")]
public JoinDataComplete DirectoryEntryIsContact = new JoinDataComplete(
new JoinData
@@ -1256,11 +1272,12 @@ namespace PepperDash.Essentials.Core.Bridges.JoinMaps
},
new JoinMetadata
{
Description = "Directory Select Row",
Description = "Directory Select Row and Feedback",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Analog
});
[JoinName("SelectedContactMethodCount")]
public JoinDataComplete SelectedContactMethodCount = new JoinDataComplete(
new JoinData
@@ -1289,6 +1306,22 @@ namespace PepperDash.Essentials.Core.Bridges.JoinMaps
JoinType = eJoinType.Analog
});
[JoinName("DirectorySelectRowFeedback")]
public JoinDataComplete DirectorySelectRowFeedback = new JoinDataComplete(
new JoinData
{
JoinNumber = 104,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Directory Select Row and Feedback",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Analog
});
[JoinName("CameraPresetSelect")]
public JoinDataComplete CameraPresetSelect = new JoinDataComplete(
new JoinData

View File

@@ -131,4 +131,15 @@ namespace PepperDash.Essentials.Core
/// </summary>
public string MinimumEssentialsFrameworkVersion { get; protected set; }
}
public abstract class EssentialsPluginDevelopmentDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDevelopmentDeviceFactory where T : EssentialsDevice
{
/// <summary>
/// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33")
/// </summary>
public string MinimumEssentialsFrameworkVersion { get; protected set; }
public List<string> DevelopmentEssentialsFrameworkVersions { get; protected set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Globalization;
using Crestron.SimplSharp;
@@ -122,6 +123,38 @@ namespace PepperDash.Essentials.Core
AssemblyVersion = assemblyVersion;
}
public static bool IsRunningDevelopmentVersion(List<string> developmentVersions, string minimumVersion)
{
if (Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*").Groups[1].Value == "0")
{
Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
return true;
}
if (developmentVersions == null)
{
Debug.Console(0,
"Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version");
return IsRunningMinimumVersionOrHigher(minimumVersion);
}
Debug.Console(2, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions);
var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion);
if (String.IsNullOrEmpty(versionMatch))
{
Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load.");
return false;
}
Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion);
return IsRunningMinimumVersionOrHigher(minimumVersion);
}
/// <summary>
/// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true.
/// </summary>

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using PepperDash.Core;
@@ -15,5 +16,10 @@ namespace PepperDash.Essentials.Core
}
public interface IPluginDevelopmentDeviceFactory : IPluginDeviceFactory
{
List<string> DevelopmentEssentialsFrameworkVersions { get; }
}
}
}

View File

@@ -425,7 +425,11 @@ namespace PepperDash.Essentials
/// <param name="loadedAssembly"></param>
static void LoadCustomPlugin(IPluginDeviceFactory plugin, LoadedAssembly loadedAssembly)
{
var passed = Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion);
var developmentPlugin = plugin as IPluginDevelopmentDeviceFactory;
var passed = developmentPlugin != null ? Global.IsRunningDevelopmentVersion
(developmentPlugin.DevelopmentEssentialsFrameworkVersions, developmentPlugin.MinimumEssentialsFrameworkVersion)
: Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion);
if (!passed)
{

View File

@@ -108,7 +108,7 @@
<Compile Include="Codec\eCodecCallStatus.cs" />
<Compile Include="Codec\eMeetingPrivacy.cs" />
<Compile Include="Codec\iCodecAudio.cs" />
<Compile Include="VideoCodec\IConvertiblePreset.cs" />
<Compile Include="VideoCodec\ConvertiblePreset.cs" />
<Compile Include="Codec\IHasCallHold.cs" />
<Compile Include="Codec\IHasDoNotDisturb.cs" />
<Compile Include="Codec\IHasExternalSourceSwitching.cs" />

View File

@@ -1023,7 +1023,7 @@ ConnectorID: {2}"
if (tempPresets.Count > 0)
{
// Create temporary list to store the existing items from the CiscoCodecStatus.RoomPreset collection
var existingRoomPresets = new List<IConvertiblePreset>();
var existingRoomPresets = new List<CiscoCodecStatus.RoomPreset>();
// Add the existing items to the temporary list
existingRoomPresets.AddRange(CodecStatus.Status.RoomPreset);
// Populate the CodecStatus object (this will append new values to the RoomPreset collection
@@ -1031,8 +1031,6 @@ ConnectorID: {2}"
var jResponse = JObject.Parse(response);
List<CiscoCodecStatus.RoomPreset> convertedRoomPresets =
existingRoomPresets.Select(a => (CiscoCodecStatus.RoomPreset) a).ToList();
IList<JToken> roomPresets = jResponse["Status"]["RoomPreset"].Children().ToList();
// Iterate the new items in this response agains the temporary list. Overwrite any existing items and add new ones.
@@ -1041,7 +1039,7 @@ ConnectorID: {2}"
var preset = camPreset as CiscoCodecStatus.RoomPreset;
if (preset == null) continue;
// First fine the existing preset that matches the id
var existingPreset = convertedRoomPresets.FirstOrDefault(p => p.id.Equals(preset.id));
var existingPreset = existingRoomPresets.FirstOrDefault(p => p.id.Equals(preset.id));
if (existingPreset != null)
{
Debug.Console(1, this, "Existing Room Preset with ID: {0} found. Updating.", existingPreset.id);
@@ -1073,7 +1071,7 @@ ConnectorID: {2}"
CodecStatus.Status.RoomPreset = existingRoomPresets;
// Generecise the list
NearEndPresets = existingRoomPresets.GetGenericPresets<CodecRoomPreset>();
NearEndPresets = existingRoomPresets.GetGenericPresets<CiscoCodecStatus.RoomPreset, CodecRoomPreset>();
var handler = CodecRoomPresetsListHasChanged;
if (handler != null)

View File

@@ -32,12 +32,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
/// </summary>
/// <param name="presets"></param>
/// <returns></returns>
public static List<T> GetGenericPresets<T>(this List<IConvertiblePreset> presets)
public static List<TDestination> GetGenericPresets<TSource, TDestination>(this List<TSource> presets) where TSource : ConvertiblePreset where TDestination : PresetBase
{
return
presets.Select(preset => preset.ConvertCodecPreset())
.Where(newPreset => newPreset != null)
.Cast<T>()
.Cast<TDestination>()
.ToList();
}
}

View File

@@ -2186,7 +2186,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
}
}
public class RoomPreset : IConvertiblePreset
public class RoomPreset : ConvertiblePreset
{
public string id { get; set; }
public Defined Defined { get; set; }
@@ -2200,7 +2200,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Type = new Type5();
}
public PresetBase ConvertCodecPreset()
public override PresetBase ConvertCodecPreset()
{
try
{
@@ -2240,7 +2240,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Proximity Proximity { get; set; }
public RoomAnalytics RoomAnalytics { get; set; }
public List<IConvertiblePreset> RoomPreset { get; set; }
public List<RoomPreset> RoomPreset { get; set; }
public SIP SIP { get; set; }
public Security Security { get; set; }
@@ -2257,7 +2257,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Standby = new Standby();
Cameras = new Cameras();
RoomAnalytics = new RoomAnalytics();
RoomPreset = new List<IConvertiblePreset>();
RoomPreset = new List<RoomPreset>();
Conference = new Conference2();
SystemUnit = new SystemUnit();
Video = new Video();

View File

@@ -2,8 +2,8 @@
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public interface IConvertiblePreset
public abstract class ConvertiblePreset
{
PresetBase ConvertCodecPreset();
public abstract PresetBase ConvertCodecPreset();
}
}

View File

@@ -10,6 +10,7 @@ using PepperDash.Core;
using PepperDash.Core.Intersystem;
using PepperDash.Core.Intersystem.Tokens;
using PepperDash.Core.WebApi.Presets;
using Crestron.SimplSharp.Reflection;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
@@ -462,10 +463,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
}
SharingContentIsOnFeedback.FireUpdate();
trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall);
trilist.SetString(joinMap.CurrentCallData.JoinNumber, UpdateCallStatusXSig());
};
}
@@ -792,7 +789,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetSigFalseAction(joinMap.SourceShareStart.JoinNumber, StartSharing);
trilist.SetSigFalseAction(joinMap.SourceShareEnd.JoinNumber, StopSharing);
trilist.SetBoolSigAction(joinMap.SourceShareAutoStart.JoinNumber, (b) => AutoShareContentWhileInCall = b);
trilist.SetBoolSigAction(joinMap.SourceShareAutoStart.JoinNumber, b => AutoShareContentWhileInCall = b);
}
private List<Meeting> _currentMeetings = new List<Meeting>();
@@ -803,7 +800,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetUShortSigAction(joinMap.MinutesBeforeMeetingStart.JoinNumber, (i) =>
{
codec.CodecSchedule.MeetingWarningMinutes = i;
codec.CodecSchedule.MeetingWarningMinutes = i;
});
trilist.SetSigFalseAction(joinMap.DialMeeting1.JoinNumber, () =>
@@ -1001,6 +998,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetUShortSigAction(joinMap.DirectorySelectRow.JoinNumber, (i) => SelectDirectoryEntry(codec, i, trilist, joinMap));
trilist.SetBoolSigAction(joinMap.DirectoryClearSelection.JoinNumber,
delegate { SelectDirectoryEntry(codec, 0, trilist, joinMap); });
// Report feedback for number of contact methods for selected contact
trilist.SetSigFalseAction(joinMap.DirectoryRoot.JoinNumber, codec.SetCurrentDirectoryToRoot);
@@ -1015,7 +1015,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetString(joinMap.DirectoryEntries.JoinNumber,
Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length));
var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, !codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue);
var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot,
codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false);
Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length);
@@ -1030,8 +1031,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetString(joinMap.DirectoryEntries.JoinNumber,
Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length));
var directoryXSig = UpdateDirectoryXSig(args.Directory, !codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue);
var directoryXSig = UpdateDirectoryXSig(args.Directory,
codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false);
Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length);
trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig);
@@ -1041,21 +1042,21 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
if (!args.DeviceOnLine) return;
// TODO [ ] Issue #868
trilist.SetString(joinMap.DirectoryEntries.JoinNumber, "\xFC");
UpdateDirectoryXSig(codec.CurrentDirectoryResult,
!codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue);
var clearBytes = XSigHelpers.ClearOutputs();
trilist.SetString(joinMap.DirectoryEntries.JoinNumber,
Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length));
var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false);
trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig);
};
}
private void SelectDirectoryEntry(IHasDirectory codec, ushort i, BasicTriList trilist, VideoCodecControllerJoinMap joinMap)
{
if (i < 1 || i > codec.CurrentDirectoryResult.CurrentDirectoryResults.Count) return;
_selectedDirectoryItem = codec.CurrentDirectoryResult.CurrentDirectoryResults[i - 1];
if (i > codec.CurrentDirectoryResult.CurrentDirectoryResults.Count) return;
_selectedDirectoryItem = i == 0 ? null : codec.CurrentDirectoryResult.CurrentDirectoryResults[i - 1];
trilist.SetUshort(joinMap.DirectorySelectRow.JoinNumber, i);
if (_selectedDirectoryItem is DirectoryFolder)
{
@@ -1073,13 +1074,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetString(joinMap.DirectorySelectedFolderName.JoinNumber, string.Empty);
var selectedContact = _selectedDirectoryItem as DirectoryContact;
if (selectedContact != null)
{
trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, selectedContact.Name);
}
// Allow auto dial of selected line. Always dials first contact method
trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber,
selectedContact != null ? selectedContact.Name : string.Empty);
// Allow auto dial of selected line. Always dials first contact method
if (!trilist.GetBool(joinMap.DirectoryDisableAutoDialSelectedLine.JoinNumber))
{
var invitableEntry = _selectedDirectoryItem as IInvitableContact;
@@ -1092,12 +1091,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
var entryToDial = _selectedDirectoryItem as DirectoryContact;
trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber, selectedContact.ContactMethods[0].Number);
trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber,
selectedContact != null ? selectedContact.ContactMethods[0].Number : string.Empty);
if (entryToDial == null) return;
Dial(entryToDial.ContactMethods[0].Number);
return;
}
else
{
@@ -1185,32 +1184,45 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
private string UpdateDirectoryXSig(CodecDirectory directory, bool isRoot)
{
var contactIndex = 1;
var tokenArray = new XSigToken[directory.CurrentDirectoryResults.Count];
const int xSigMaxIndex = 1023;
var tokenArray = new XSigToken[directory.CurrentDirectoryResults.Count > xSigMaxIndex
? xSigMaxIndex
: directory.CurrentDirectoryResults.Count];
Debug.Console(2, this, "Is root {0} Directory Count: {1}", isRoot, directory.CurrentDirectoryResults.Count);
Debug.Console(2, this, "IsRoot: {0}, Directory Count: {1}, TokenArray.Length: {2}", isRoot, directory.CurrentDirectoryResults.Count, tokenArray.Length);
foreach (var entry in directory.CurrentDirectoryResults)
{
var arrayIndex = contactIndex - 1;
var contacts = directory.CurrentDirectoryResults.Count > xSigMaxIndex
? directory.CurrentDirectoryResults.Take(xSigMaxIndex)
: directory.CurrentDirectoryResults;
Debug.Console(2, this, "Entry Name: {0}, Folder ID: {1}", entry.Name, entry.FolderId);
var contactsToDisplay = isRoot
? contacts.Where(c => c.ParentFolderId == "root")
: contacts.Where(c => c.ParentFolderId != "root");
if (entry is DirectoryFolder && entry.ParentFolderId == "root")
{
tokenArray[arrayIndex] = new XSigSerialToken(contactIndex, String.Format("[+] {0}", entry.Name));
var counterIndex = 1;
foreach (var entry in contactsToDisplay)
{
var arrayIndex = counterIndex - 1;
var entryIndex = counterIndex;
contactIndex++;
Debug.Console(2, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}",
entry.Name, entry.FolderId, entryIndex, entry.GetType().GetCType().FullName, entry.ParentFolderId);
continue;
}
if (entry is DirectoryFolder)
{
tokenArray[arrayIndex] = new XSigSerialToken(entryIndex, String.Format("[+] {0}", entry.Name));
tokenArray[arrayIndex] = new XSigSerialToken(contactIndex, entry.Name);
counterIndex++;
contactIndex++;
}
continue;
}
return GetXSigString(tokenArray);
tokenArray[arrayIndex] = new XSigSerialToken(entryIndex, entry.Name);
counterIndex++;
}
return GetXSigString(tokenArray);
}
private void LinkVideoCodecCallControlsToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap)