diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index b9e6e5f6..c3a25e0d 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -15,6 +15,7 @@ namespace PepperDash.Essentials public class ControlSystem : CrestronControlSystem { PepperDashPortalSyncClient PortalSync; + HttpLogoServer LogoServer; public ControlSystem() : base() @@ -63,6 +64,8 @@ namespace PepperDash.Essentials LoadTieLines(); LoadRooms(); + LogoServer = new HttpLogoServer(8080, @"\html\logo"); + DeviceManager.ActivateAll(); Debug.Console(0, "Essentials load complete\r" + "-------------------------------------------------------------"); @@ -198,6 +201,5 @@ namespace PepperDash.Essentials Debug.Console(0, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key); } } - } } diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index e19cb51f..ccb37bf3 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -165,6 +165,7 @@ + diff --git a/Essentials/PepperDashEssentials/UI/HttpLogoServer.cs b/Essentials/PepperDashEssentials/UI/HttpLogoServer.cs new file mode 100644 index 00000000..8ff93a07 --- /dev/null +++ b/Essentials/PepperDashEssentials/UI/HttpLogoServer.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.Net.Http; + +using PepperDash.Core; + +namespace PepperDash.Essentials +{ + public class HttpLogoServer + { + /// + /// + /// + HttpServer Server; + + /// + /// + /// + string FileDirectory; + + /// + /// + /// + public static Dictionary ExtensionContentTypes; + + /// + /// + /// + /// + /// + public HttpLogoServer(int port, string directory) + { + ExtensionContentTypes = new Dictionary + { + //{ ".css", "text/css" }, + //{ ".htm", "text/html" }, + //{ ".html", "text/html" }, + { ".jpg", "image/jpeg" }, + { ".jpeg", "image/jpeg" }, + //{ ".js", "application/javascript" }, + //{ ".json", "application/json" }, + //{ ".map", "application/x-navimap" }, + { ".pdf", "application.pdf" }, + { ".png", "image/png" }, + //{ ".txt", "text/plain" }, + }; + + Server = new HttpServer(); + Server.Port = port; + FileDirectory = directory; + Server.OnHttpRequest += new OnHttpRequestHandler(Server_OnHttpRequest); + Server.Open(); + + CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); + } + + /// + /// + /// + void Server_OnHttpRequest(object sender, OnHttpRequestArgs args) + { + var path = args.Request.Path; + Debug.Console(0, "########## PATH={0}", path); + + if (File.Exists(FileDirectory + @"\" + path)) + { + string filePath = path.Replace('/', '\\'); + string localPath = string.Format(@"{0}{1}", FileDirectory, filePath); + if (File.Exists(localPath)) + { + args.Response.Header.ContentType = GetContentType(new FileInfo(localPath).Extension); + args.Response.ContentStream = new FileStream(localPath, FileMode.Open, FileAccess.Read); + //args.Response.CloseStream = true; + } + else + { + args.Response.ContentString = string.Format("Not found: '{0}'", filePath); + args.Response.Code = 404; + } + } + } + + /// + /// + /// + void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) + { + if (programEventType == eProgramStatusEventType.Stopping) + Server.Close(); + } + + /// + /// + /// + /// + /// + public static string GetContentType(string extension) + { + string type; + if (ExtensionContentTypes.ContainsKey(extension)) + type = ExtensionContentTypes[extension]; + else + type = "text/plain"; + return type; + } + } +} \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/HuddleVTCPanelAvFunctionsDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/HuddleVTCPanelAvFunctionsDriver.cs index 8de877cb..da6f21c7 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/HuddleVTCPanelAvFunctionsDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/HuddleVTCPanelAvFunctionsDriver.cs @@ -282,9 +282,9 @@ namespace PepperDash.Essentials TriList.SetSigFalseAction(UIBoolJoin.TechPagesExitButton, () => PopupInterlock.HideAndClear()); - // Default Volume button + // Volume related things TriList.SetSigFalseAction(UIBoolJoin.VolumeDefaultPress, () => CurrentRoom.SetDefaultLevels()); - + TriList.SetString(UIStringJoin.AdvancedVolumeSlider1Text, "Room"); if (TriList is CrestronApp) TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = false; diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 480bd616..39091a7d 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index 8f39feb1..6b4b4515 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ