这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 77 additions & 7 deletions Control/Region.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* Xibo - Digitial Signage - http://www.xibo.org.uk
* Copyright (C) 2006-2016 Daniel Garner
/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand All @@ -24,6 +25,7 @@
using System.Xml;
using System.Diagnostics;
using XiboClient.Properties;
using System.Globalization;

namespace XiboClient
{
Expand All @@ -45,6 +47,7 @@ class Region : Panel
private RegionOptions _options;
private bool _hasExpired = false;
private bool _layoutExpired = false;
private bool _sizeResetRequired = false;
private int _currentSequence = -1;

/// <summary>
Expand Down Expand Up @@ -128,6 +131,21 @@ public bool hasExpired()
return _hasExpired;
}

private void SetDimensions(int left, int top, int width, int height)
{
// Evaluate the width, etc
Location = new System.Drawing.Point(left, top);
Size = new System.Drawing.Size(width, height);
}

private void SetDimensions(System.Drawing.Point location, System.Drawing.Size size)
{
Debug.WriteLine("Setting Dimensions to " + size.ToString() + ", " + location.ToString());
// Evaluate the width, etc
Size = size;
Location = location;
}

///<summary>
/// Evaulates the change in options
///</summary>
Expand All @@ -139,8 +157,7 @@ private void EvalOptions()
if (initialMedia)
{
// Evaluate the width, etc
Location = new System.Drawing.Point(_options.left, _options.top);
Size = new System.Drawing.Size(_options.width, _options.height);
SetDimensions(_options.left, _options.top, _options.width, _options.height);
}

// Try to populate a new media object for this region
Expand Down Expand Up @@ -214,6 +231,18 @@ private void EvalOptions()
// Start the new media
try
{
// See if we need to change our Region Dimensions
if (newMedia.RegionSizeChangeRequired())
{
SetDimensions(newMedia.GetRegionLocation(), newMedia.GetRegionSize());
_sizeResetRequired = true;
}
else if (_sizeResetRequired)
{
SetDimensions(_options.left, _options.top, _options.width, _options.height);
_sizeResetRequired = false;
}

StartMedia(newMedia);
}
catch (Exception ex)
Expand Down Expand Up @@ -263,6 +292,8 @@ private bool SetNextMediaNodeInOptions()
_options.uri = "";
_options.direction = "none";
_options.javaScript = "";
_options.FromDt = DateTime.MinValue;
_options.ToDt = DateTime.MaxValue;
_options.Dictionary = new MediaDictionary();

// Tidy up old audio if necessary
Expand Down Expand Up @@ -320,6 +351,12 @@ private bool SetNextMediaNodeInOptions()
if (nodeAttributes["id"].Value != null)
_options.mediaid = nodeAttributes["id"].Value;

// Set the file id
if (nodeAttributes["fileId"] != null)
{
_options.FileId = int.Parse(nodeAttributes["fileId"].Value);
}

// Check isnt blacklisted
if (_blackList.BlackListed(_options.mediaid))
{
Expand All @@ -338,8 +375,19 @@ private bool SetNextMediaNodeInOptions()
// Parse the options for this media node
ParseOptionsForMediaNode(mediaNode, nodeAttributes);

// Is this widget inside the from/to date?
if (!(_options.FromDt <= DateTime.Now && _options.ToDt > DateTime.Now)) {
Trace.WriteLine(new LogMessage("Region", "SetNextMediaNode: Widget outside from/to date."), LogType.Audit.ToString());

// Increment the number of attempts and try again
numAttempts++;

// Carry on
continue;
}

// Is this a file based media node?
if (_options.type == "video" || _options.type == "flash" || _options.type == "image" || _options.type == "powerpoint" || _options.type == "audio")
if (_options.type == "video" || _options.type == "flash" || _options.type == "image" || _options.type == "powerpoint" || _options.type == "audio" || _options.type == "htmlpackage")
{
// Use the cache manager to determine if the file is valid
validNode = _cacheManager.IsValidPath(_options.uri);
Expand Down Expand Up @@ -392,6 +440,24 @@ private void ParseOptionsForMediaNode(XmlNode mediaNode, XmlAttributeCollection
Trace.WriteLine("Duration is Empty, using a default of 60.", "Region - SetNextMediaNode");
}

// Widget From/To dates (v2 onward)
try
{
if (nodeAttributes["fromDt"] != null)
{
_options.FromDt = DateTime.Parse(nodeAttributes["fromDt"].Value, CultureInfo.InvariantCulture);
}

if (nodeAttributes["toDt"] != null)
{
_options.ToDt = DateTime.Parse(nodeAttributes["toDt"].Value, CultureInfo.InvariantCulture);
}
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("Region", "ParseOptionsForMediaNode: Unable to parse widget from/to dates."), LogType.Error.ToString());
}

// We cannot have a 0 duration here... not sure why we would... but
if (_options.duration == 0 && _options.type != "video" && _options.type != "localvideo")
{
Expand Down Expand Up @@ -605,6 +671,10 @@ private Media CreateNextMediaNode(RegionOptions options)
media = new ShellCommand(options);
break;

case "htmlpackage":
media = new HtmlPackage(options);
break;

default:
throw new InvalidOperationException("Not a valid media node type: " + options.type);
}
Expand Down
15 changes: 8 additions & 7 deletions Logic/ApplicationSettings.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* Xibo - Digitial Signage - http://www.xibo.org.uk
* Copyright (C) 2006-18 Spring Signage Ltd
/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand Down Expand Up @@ -40,9 +41,9 @@ public class ApplicationSettings
private List<string> _globalProperties;

// Application Specific Settings we want to protect
private string _clientVersion = "1.8.12";
private string _version = "5";
private int _clientCodeVersion = 133;
private readonly string _clientVersion = "2 R200";
private readonly string _version = "5";
private readonly int _clientCodeVersion = 200;

public string ClientVersion { get { return _clientVersion; } }
public string Version { get { return _version; } }
Expand Down
17 changes: 13 additions & 4 deletions Logic/RegionOptions.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* Xibo - Digitial Signage - http://www.xibo.org.uk
* Copyright (C) 2013-16 Daniel Garner
/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand All @@ -19,6 +20,7 @@
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Xml;

Expand All @@ -38,6 +40,10 @@ struct RegionOptions
public int originalWidth;
public int originalHeight;

// Widget From/To dates
public DateTime FromDt { get; set; }
public DateTime ToDt { get; set; }

public int backgroundLeft;
public int backgroundTop;

Expand Down Expand Up @@ -67,6 +73,7 @@ struct RegionOptions
public string regionId;
public int scheduleId;
public int CurrentIndex;
public int FileId { get; set; }

//general options
public string backgroundImage;
Expand All @@ -76,6 +83,8 @@ struct RegionOptions

public DateTime LayoutModifiedDate { get; set; }

public Size LayoutSize { get; set; }

/// <summary>
/// Audio associated with the widget
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ private void PrepareLayout(string layoutPath)
_layoutWidth = int.Parse(layoutAttributes["width"].Value, CultureInfo.InvariantCulture);
_layoutHeight = int.Parse(layoutAttributes["height"].Value, CultureInfo.InvariantCulture);


// Scaling factor, will be applied to all regions
_scaleFactor = Math.Min(ClientSize.Width / _layoutWidth, ClientSize.Height / _layoutHeight);

Expand Down Expand Up @@ -657,6 +656,7 @@ private void PrepareLayout(string layoutPath)
_regions = new Collection<Region>();
RegionOptions options = new RegionOptions();
options.LayoutModifiedDate = layoutModifiedTime;
options.LayoutSize = ClientSize;

// Deal with the color
try
Expand Down
102 changes: 102 additions & 0 deletions Media/HtmlPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* Copyright (C) 2019 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace XiboClient
{
class HtmlPackage : IeWebMedia
{
public HtmlPackage(RegionOptions options)
: base(options)
{
string pathToMediaFile = Path.Combine(ApplicationSettings.Default.LibraryPath, options.uri);
string pathToPackageFolder = Path.Combine(ApplicationSettings.Default.LibraryPath, "package_" + options.FileId);
string pathToStatusFile = Path.Combine(pathToPackageFolder, "_updated");

// Configure the file path to indicate which file should be opened by the browser
_filePath = ApplicationSettings.Default.EmbeddedServerAddress + "package_" + options.FileId + "/" + options.Dictionary.Get("nominatedFile", "index.html");

// Check to see if our package has been extracted already
// if not, then extract it
if (!(Directory.Exists(pathToPackageFolder) && IsUpdated(pathToStatusFile, File.GetLastWriteTime(pathToMediaFile))))
{
// Extract our file into the specified folder.
ZipFile.ExtractToDirectory(pathToMediaFile, pathToPackageFolder);

// Add in our extraction date.
WriteUpdatedFlag(pathToStatusFile);
}
}

protected override bool IsNativeOpen()
{
return true;
}

/// <summary>
/// Updated Flag
/// </summary>
/// <param name="path"></param>
private void WriteUpdatedFlag(string path)
{
try
{
File.WriteAllText(path, DateTime.Now.ToString());
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("HtmlPackage", "WriteUpdatedFlag: Failed to update status file: " + path + ". e = " + e.Message), LogType.Error.ToString());
}
}

/// <summary>
/// Check whether we've updated recently
/// </summary>
/// <param name="path"></param>
/// <param name="lastModified"></param>
/// <returns></returns>
private bool IsUpdated(string path, DateTime lastModified)
{
// Check that it is up to date by looking for our special file.
try
{
string flag = File.ReadAllText(path);
DateTime updated = DateTime.Parse(flag);

return updated > lastModified;
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("HtmlPackage", "IsUpdated: Failed to read status file: " + path + ". e = " + e.Message), LogType.Error.ToString());
return false;
}
}
}
}
Loading