Skip to content

Commit

Permalink
Fix OSX db storage issues
Browse files Browse the repository at this point in the history
  • Loading branch information
slothbag committed Feb 3, 2015
1 parent 509fa56 commit e993e38
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NxtLite.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Setup]
AppName=NxtLite
AppVersion=0.1
AppVersion=0.3
DefaultDirName={pf}\NxtLite
DefaultGroupName=NxtLite
UninstallDisplayIcon={app}\NxtLite.exe
Expand Down
37 changes: 31 additions & 6 deletions NxtLite/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -115,13 +112,29 @@ private static void Main(string[] args)
Nodes.ScanLatestBlockHeight();
}

//start the BoatNetCore
//manually enable localStorage for osx
Eto.Style.Add<Eto.Mac.Forms.Controls.WebViewHandler>(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);
}
Expand All @@ -130,4 +143,16 @@ static void e_OnAppTerminating(object sender, object e) {
Nodes.SaveToDisk();
}
}
}

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);
}
}
}


4 changes: 2 additions & 2 deletions NxtLite/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e993e38

Please sign in to comment.