From e993e384491b082b6cdbc234d07fde37e6a42d8d Mon Sep 17 00:00:00 2001 From: slothbag Date: Tue, 3 Feb 2015 22:53:54 +1100 Subject: [PATCH] Fix OSX db storage issues --- NxtLite.iss | 2 +- NxtLite/Program.cs | 37 +++++++++++++++++++++++++++++++------ NxtLite/Utils.cs | 4 ++-- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/NxtLite.iss b/NxtLite.iss index 61d129a..aeb45b6 100644 --- a/NxtLite.iss +++ b/NxtLite.iss @@ -1,6 +1,6 @@ [Setup] AppName=NxtLite -AppVersion=0.1 +AppVersion=0.3 DefaultDirName={pf}\NxtLite DefaultGroupName=NxtLite UninstallDisplayIcon={app}\NxtLite.exe diff --git a/NxtLite/Program.cs b/NxtLite/Program.cs index b3b3b8e..0011d92 100644 --- a/NxtLite/Program.cs +++ b/NxtLite/Program.cs @@ -102,9 +102,6 @@ internal sealed class Program [STAThread] private static void Main(string[] args) { - var app = new Application(); - var myForm = new MyForm(); - //create the app config directory if (!System.IO.Directory.Exists(Utils.getAppDirectory)) { System.IO.Directory.CreateDirectory(Utils.getAppDirectory); @@ -115,13 +112,29 @@ private static void Main(string[] args) Nodes.ScanLatestBlockHeight(); } - //start the BoatNetCore + //manually enable localStorage for osx + Eto.Style.Add(null, h => + { + var webView = h.Control; + var path = new MonoMac.Foundation.NSString("~/.config/NxtLite"); + MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(webView.Preferences.Handle, MonoMac.ObjCRuntime.Selector.GetHandle("_setLocalStorageDatabasePath:"), path.Handle); + + MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_bool(webView.Preferences.Handle, MonoMac.ObjCRuntime.Selector.GetHandle("setLocalStorageEnabled:"), true); + MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_bool(webView.Preferences.Handle, MonoMac.ObjCRuntime.Selector.GetHandle("setDatabasesEnabled:"), true); + + h.Control.UIDelegate = new MyUIDelegate { Handler = h }; + }); + + var app = new Application(); + var myForm = new MyForm(); + + //start the Core var core = new WebServer.WebServer(); core.Run(); //set up app closing event app.Terminating += e_OnAppTerminating; - + //Then start the Gui which will connect to it app.Run(myForm); } @@ -130,4 +143,16 @@ static void e_OnAppTerminating(object sender, object e) { Nodes.SaveToDisk(); } } -} \ No newline at end of file + + public class MyUIDelegate : Eto.Mac.Forms.Controls.WebViewHandler.UIDelegate + { + [MonoMac.Foundation.Export("webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:")] + public void WebView (MonoMac.WebKit.WebView WebView, MonoMac.WebKit.WebFrame frame, IntPtr origin, MonoMac.Foundation.NSString databaseIdentifier) + { + MonoMac.Foundation.NSNumber quota = new MonoMac.Foundation.NSNumber(5 * 1024 * 1024); + MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(origin, MonoMac.ObjCRuntime.Selector.GetHandle("setQuota:"), quota.Handle); + } + } +} + + diff --git a/NxtLite/Utils.cs b/NxtLite/Utils.cs index 8060cbe..022b3c6 100644 --- a/NxtLite/Utils.cs +++ b/NxtLite/Utils.cs @@ -8,8 +8,8 @@ public class Utils { public static string getAppDirectory { get { string appdir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - string boatnet_appdir = Path.Combine(appdir, "NxtLite"); - return boatnet_appdir; + string nxtlite_appdir = Path.Combine(appdir, "NxtLite"); + return nxtlite_appdir; } } public static bool doRESTfullApi(string url, out string result) {