Skip to content

Commit

Permalink
Merge pull request #7 from MohawkMEDIC/develop
Browse files Browse the repository at this point in the history
Develop merge for Fredricton Release
  • Loading branch information
Justin authored Nov 2, 2017
2 parents 57182b2 + 68d8713 commit 7890203
Show file tree
Hide file tree
Showing 105 changed files with 1,862 additions and 455 deletions.
76 changes: 53 additions & 23 deletions AppletCompiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand All @@ -46,6 +47,10 @@ class Program
/// </summary>
static int Main(string[] args)
{

Console.WriteLine("OpenIZ HTML Applet Compiler v{0} ({1})", Assembly.GetEntryAssembly().GetName().Version, Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion);
Console.WriteLine("Copyright (C) 2015-2017 Mohawk College of Applied Arts and Technology");

int retVal = 0;
ParameterParser<ConsoleParameters> parser = new ParameterParser<ConsoleParameters>();
var parameters = parser.Parse(args);
Expand Down Expand Up @@ -83,7 +88,7 @@ private static int Sign(ConsoleParameters parameters)
pkg.Save(fs);
return 0;
}
catch(Exception e)
catch (Exception e)
{
Console.Error.WriteLine("Cannot sign package: {0}", e);
return -0232;
Expand Down Expand Up @@ -295,7 +300,7 @@ private static IEnumerable<AppletAsset> ProcessDirectory(string source, String p
List<AppletAsset> retVal = new List<AppletAsset>();
foreach (var itm in Directory.GetFiles(source))
{
if(Path.GetFileName(itm).StartsWith("."))
if (Path.GetFileName(itm).StartsWith("."))
{
Console.WriteLine("\t Skipping {0}...", itm);
continue;
Expand All @@ -313,29 +318,54 @@ private static IEnumerable<AppletAsset> ProcessDirectory(string source, String p
XElement xe = XElement.Load(itm);

// Now we have to iterate throuh and add the asset\
AppletAssetHtml htmlAsset = new AppletAssetHtml();
htmlAsset.Layout = ResolveName(xe.Attribute(xs_openiz + "layout")?.Value);
htmlAsset.Titles = new List<LocaleString>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "title").Select(o => new LocaleString() { Language = o.Attribute("lang")?.Value, Value = o.Value }));
htmlAsset.Bundle = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "bundle").Select(o => ResolveName(o.Value)));
htmlAsset.Script = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "script").Select(o => ResolveName(o.Value)));
htmlAsset.Style = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "style").Select(o => ResolveName(o.Value)));
htmlAsset.Static = xe.Attribute(xs_openiz + "static")?.Value == "true";
htmlAsset.ViewState = xe.Elements().OfType<XElement>().Where(o => o.Name == xs_openiz + "state").Select(o => new AppletViewState()
AppletAssetHtml htmlAsset = null;

if (xe.Elements().OfType<XElement>().Any(o => o.Name == xs_openiz + "widget"))
{
var widgetEle = xe.Elements().OfType<XElement>().FirstOrDefault(o => o.Name == xs_openiz + "widget");
htmlAsset = new AppletWidget()
{
Icon = widgetEle.Element(xs_openiz + "icon")?.Value,
Type = (AppletWidgetType)Enum.Parse(typeof(AppletWidgetType), widgetEle.Attribute("type")?.Value),
Scope = (AppletWidgetScope)Enum.Parse(typeof(AppletWidgetScope), widgetEle.Attribute("scope")?.Value),
Description = widgetEle.Elements().Where(o => o.Name == xs_openiz + "description").Select(o => new LocaleString() { Value = o.Value, Language = o.Attribute("lang")?.Value }).ToList(),
Name = widgetEle.Attribute("name")?.Value,
Controller = widgetEle.Element(xs_openiz + "controller")?.Value,
};
}
else
{
Name = o.Attribute("name")?.Value,
Route = o.Elements().OfType<XElement>().FirstOrDefault(r => r.Name == xs_openiz + "url" || r.Name == xs_openiz + "route")?.Value,
IsAbstract = Boolean.Parse(o.Attribute("abstract")?.Value ?? "False"),
View = o.Elements().OfType<XElement>().Where(v => v.Name == xs_openiz + "view")?.Select(v => new AppletView()
htmlAsset = new AppletAssetHtml();
// View state data
htmlAsset.ViewState = xe.Elements().OfType<XElement>().Where(o => o.Name == xs_openiz + "state").Select(o => new AppletViewState()
{
Name = v.Attribute("name")?.Value,
Title = v.Elements().OfType<XElement>().Where(t => t.Name == xs_openiz + "title")?.Select(t => new LocaleString()
Name = o.Attribute("name")?.Value,
Route = o.Elements().OfType<XElement>().FirstOrDefault(r => r.Name == xs_openiz + "url" || r.Name == xs_openiz + "route")?.Value,
IsAbstract = Boolean.Parse(o.Attribute("abstract")?.Value ?? "False"),
View = o.Elements().OfType<XElement>().Where(v => v.Name == xs_openiz + "view")?.Select(v => new AppletView()
{
Language = t.Attribute("lang")?.Value,
Value = t?.Value
}).ToList(),
Controller = v.Element(xs_openiz + "controller")?.Value
}).ToList()
}).FirstOrDefault();
Name = v.Attribute("name")?.Value,
Title = v.Elements().OfType<XElement>().Where(t => t.Name == xs_openiz + "title")?.Select(t => new LocaleString()
{
Language = t.Attribute("lang")?.Value,
Value = t?.Value
}).ToList(),
Controller = v.Element(xs_openiz + "controller")?.Value
}).ToList()
}).FirstOrDefault();
htmlAsset.Layout = ResolveName(xe.Attribute(xs_openiz + "layout")?.Value);
htmlAsset.Static = xe.Attribute(xs_openiz + "static")?.Value == "true";
}

htmlAsset.Titles = new List<LocaleString>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "title").Select(o => new LocaleString() { Language = o.Attribute("lang")?.Value, Value = o.Value }));
htmlAsset.Bundle = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "bundle").Select(o => ResolveName(o.Value)));
htmlAsset.Script = new List<AssetScriptReference>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "script").Select(o => new AssetScriptReference()
{
Reference = ResolveName(o.Value),
IsStatic = Boolean.Parse(o.Attribute("static")?.Value ?? "true")
}));
htmlAsset.Style = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "style").Select(o => ResolveName(o.Value)));

var demand = xe.DescendantNodes().OfType<XElement>().Where(o => o.Name == xs_openiz + "demand").Select(o => o.Value).ToList();

var includes = xe.DescendantNodes().OfType<XComment>().Where(o => o?.Value?.Trim().StartsWith("#include virtual=\"") == true).ToList();
Expand All @@ -349,14 +379,14 @@ private static IEnumerable<AppletAsset> ProcessDirectory(string source, String p
var includeAsset = ResolveName(assetName);
inc.AddAfterSelf(new XComment(String.Format("#include virtual=\"{0}\"", includeAsset)));
inc.Remove();

}

var xel = xe.Descendants().OfType<XElement>().Where(o => o.Name.Namespace == xs_openiz).ToList();
if (xel != null)
foreach (var x in xel)
x.Remove();
htmlAsset.Html = xe;

retVal.Add(new AppletAsset()
{
Name = ResolveName(itm.Replace(path, "")),
Expand Down
2 changes: 1 addition & 1 deletion AppletCompiler/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("0.9.4.*")][assembly: AssemblyInformationalVersion("Chippewa")]
[assembly: AssemblyVersion("0.9.9.*")][assembly: AssemblyInformationalVersion("Fredericton CTP1")]
[assembly: AssemblyFileVersion("0.9.9.0")]
[assembly: AssemblyFileVersion("0.9.9.2")]
2 changes: 1 addition & 1 deletion BrainBug/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.9.*")]
[assembly: AssemblyFileVersion("0.9.9.0")]
[assembly: AssemblyFileVersion("0.9.9.2")]
2 changes: 1 addition & 1 deletion DisconnectedClient/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.9.*")]
[assembly: AssemblyFileVersion("0.9.9.0")]
[assembly: AssemblyFileVersion("0.9.9.2")]
[assembly: AssemblyInformationalVersion("Fredericton CTP1")]
40 changes: 38 additions & 2 deletions DisconnectedClient/WinFormsDialogProvider.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using DisconnectedClient.Core;
using System.Windows.Forms;
using CefSharp;

namespace DisconnectedClient
{
/// <summary>
/// Dialog provider
/// </summary>
public class WinFormsDialogProvider : IDialogProvider
public class WinFormsDialogProvider : IDialogProvider, IJsDialogHandler
{

/// <summary>
Expand All @@ -23,6 +24,41 @@ public bool Confirm(String text, String title) {
public void Alert(String text) {
MessageBox.Show (text);
}
}

/// <summary>
/// Chrome is showing a dialog
/// </summary>
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
{
switch(dialogType)
{
case CefJsDialogType.Alert:
this.Alert(messageText);
//suppressMessage = true;
callback.Continue(true);
break;
case CefJsDialogType.Confirm:
//suppressMessage = true;
var retVal = this.Confirm(messageText, "Confirm");
callback.Continue(retVal);
break;
}
return true;

}

public bool OnJSBeforeUnload(IWebBrowser browserControl, IBrowser browser, string message, bool isReload, IJsDialogCallback callback)
{
return false;
}

public void OnResetDialogState(IWebBrowser browserControl, IBrowser browser)
{
}

public void OnDialogClosed(IWebBrowser browserControl, IBrowser browser)
{
}
}
}

5 changes: 2 additions & 3 deletions DisconnectedClient/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,14 @@ private void InitializeChromium(string url)

this.m_browser = new ChromiumWebBrowser(url);
this.m_browser.RequestHandler = new DisconnectedClientRequestHandler();

#if !DEBUG
mnsTools.Visible = Program.Parameters.Debug;
#endif

this.m_browser.RegisterJsObject("OpenIZApplicationService", new AppletFunctionBridge(this));
this.pnlMain.Controls.Add(this.m_browser);
this.m_browser.Dock = DockStyle.Fill;

this.m_browser.JsDialogHandler = new WinFormsDialogProvider();
}

// Go dback
Expand Down
66 changes: 45 additions & 21 deletions Minims/MiniAppletManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,30 +205,55 @@ public object ResolveAppletAsset(AppletAsset navigateAsset)
XElement xe = XElement.Load(itmPath);

// Now we have to iterate throuh and add the asset\
AppletAssetHtml htmlAsset = new AppletAssetHtml();
htmlAsset.Layout = ResolveName(xe.Attribute(xs_openiz + "layout")?.Value);
htmlAsset.Titles = new List<LocaleString>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "title").Select(o => new LocaleString() { Language = o.Attribute("lang")?.Value, Value = o.Value }));
htmlAsset.Bundle = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "bundle").Select(o => ResolveName(o.Value)));
htmlAsset.Script = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "script").Select(o => ResolveName(o.Value)));
htmlAsset.Style = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "style").Select(o => ResolveName(o.Value)));
var demand = new List<String>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "demand").Select(o => o.Value));
htmlAsset.ViewState = xe.Elements().OfType<XElement>().Where(o => o.Name == xs_openiz + "state").Select(o => new AppletViewState()
AppletAssetHtml htmlAsset = null;

if (xe.Elements().OfType<XElement>().Any(o => o.Name == xs_openiz + "widget"))
{
var widgetEle = xe.Elements().OfType<XElement>().FirstOrDefault(o => o.Name == xs_openiz + "widget");
htmlAsset = new AppletWidget()
{
Icon = widgetEle.Element(xs_openiz + "icon")?.Value,
Type = (AppletWidgetType)Enum.Parse(typeof(AppletWidgetType), widgetEle.Attribute("type")?.Value),
Scope = (AppletWidgetScope)Enum.Parse(typeof(AppletWidgetScope), widgetEle.Attribute("scope")?.Value),
Description = widgetEle.Elements().Where(o => o.Name == xs_openiz + "description").Select(o => new LocaleString() { Value = o.Value, Language = o.Attribute("lang")?.Value }).ToList(),
Name = widgetEle.Attribute("name")?.Value,
Controller = widgetEle.Element(xs_openiz + "controller")?.Value,
};
}
else
{
Name = o.Attribute("name")?.Value,
Route = o.Elements().OfType<XElement>().FirstOrDefault(r => r.Name == xs_openiz + "url" || r.Name == xs_openiz + "route")?.Value,
IsAbstract = Boolean.Parse(o.Attribute("abstract")?.Value ?? "False"),
View = o.Elements().OfType<XElement>().Where(v => v.Name == xs_openiz + "view").Select(v => new AppletView()
htmlAsset = new AppletAssetHtml();
// View state data
htmlAsset.ViewState = xe.Elements().OfType<XElement>().Where(o => o.Name == xs_openiz + "state").Select(o => new AppletViewState()
{
Name = v.Attribute("name")?.Value,
Title = v.Elements().OfType<XElement>().Where(t => t.Name == xs_openiz + "title").Select(t => new LocaleString()
Name = o.Attribute("name")?.Value,
Route = o.Elements().OfType<XElement>().FirstOrDefault(r => r.Name == xs_openiz + "url" || r.Name == xs_openiz + "route")?.Value,
IsAbstract = Boolean.Parse(o.Attribute("abstract")?.Value ?? "False"),
View = o.Elements().OfType<XElement>().Where(v => v.Name == xs_openiz + "view")?.Select(v => new AppletView()
{
Language = t.Attribute("lang")?.Value,
Value = t.Value
}).ToList(),
Controller = v.Element(xs_openiz + "controller")?.Value
}).ToList()
}).FirstOrDefault();
Name = v.Attribute("name")?.Value,
Title = v.Elements().OfType<XElement>().Where(t => t.Name == xs_openiz + "title")?.Select(t => new LocaleString()
{
Language = t.Attribute("lang")?.Value,
Value = t?.Value
}).ToList(),
Controller = v.Element(xs_openiz + "controller")?.Value
}).ToList()
}).FirstOrDefault();
htmlAsset.Layout = ResolveName(xe.Attribute(xs_openiz + "layout")?.Value);
htmlAsset.Static = xe.Attribute(xs_openiz + "static")?.Value == "true";
}

htmlAsset.Titles = new List<LocaleString>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "title").Select(o => new LocaleString() { Language = o.Attribute("lang")?.Value, Value = o.Value }));
htmlAsset.Bundle = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "bundle").Select(o => ResolveName(o.Value)));
htmlAsset.Script = new List<AssetScriptReference>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "script").Select(o => new AssetScriptReference()
{
Reference = ResolveName(o.Value),
IsStatic = Boolean.Parse(o.Attribute("static")?.Value ?? "true")
}));
htmlAsset.Style = new List<string>(xe.Descendants().OfType<XElement>().Where(o => o.Name == xs_openiz + "style").Select(o => ResolveName(o.Value)));

var demand = xe.DescendantNodes().OfType<XElement>().Where(o => o.Name == xs_openiz + "demand").Select(o => o.Value).ToList();

var includes = xe.DescendantNodes().OfType<XComment>().Where(o => o?.Value?.Trim().StartsWith("#include virtual=\"") == true).ToList();
foreach (var inc in includes)
Expand All @@ -241,7 +266,6 @@ public object ResolveAppletAsset(AppletAsset navigateAsset)
var includeAsset = ResolveName(assetName);
inc.AddAfterSelf(new XComment(String.Format("#include virtual=\"{0}\"", includeAsset)));
inc.Remove();

}

var xel = xe.Descendants().OfType<XElement>().Where(o => o.Name.Namespace == xs_openiz).ToList();
Expand Down
1 change: 1 addition & 0 deletions Minims/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static void Main(string[] args)
var cData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MINIMS");
if (Directory.Exists(appData)) Directory.Delete(cData, true);
if (Directory.Exists(appData)) Directory.Delete(appData, true);
Console.WriteLine("Environment Reset Successful");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Minims/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.9.*")]
[assembly: AssemblyFileVersion("0.9.9.0")]
[assembly: AssemblyFileVersion("0.9.9.2")]
Loading

0 comments on commit 7890203

Please sign in to comment.