update mac files

This commit is contained in:
Luke 2014-11-23 15:57:25 -05:00
parent f5b9882d1c
commit 8de74d2d37
5 changed files with 78 additions and 73 deletions

View File

@ -1,3 +1,8 @@
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Startup.Common.Browser;
using System; using System;
using MonoMac.Foundation; using MonoMac.Foundation;
using MonoMac.AppKit; using MonoMac.AppKit;
@ -7,6 +12,14 @@ namespace MediaBrowser.Server.Mac
[Register("AppController")] [Register("AppController")]
public partial class AppController : NSObject public partial class AppController : NSObject
{ {
private NSMenuItem browseMenuItem;
private NSMenuItem configureMenuItem;
private NSMenuItem developerMenuItem;
private NSMenuItem quitMenuItem;
private NSMenuItem githubMenuItem;
private NSMenuItem apiMenuItem;
private NSMenuItem communityMenuItem;
public AppController() public AppController()
{ {
@ -18,36 +31,78 @@ namespace MediaBrowser.Server.Mac
statusItem.Menu = statusMenu; statusItem.Menu = statusMenu;
statusItem.Image = NSImage.ImageNamed("touchicon"); statusItem.Image = NSImage.ImageNamed("touchicon");
statusItem.HighlightMode = true; statusItem.HighlightMode = true;
statusItem.Menu.RemoveAllItems ();
browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
Browse (this);
});
statusItem.Menu.AddItem (browseMenuItem);
configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
Configure (this);
});
statusItem.Menu.AddItem (configureMenuItem);
developerMenuItem = new NSMenuItem ("Developer Resources");
statusItem.Menu.AddItem (developerMenuItem);
var developerMenu = new NSMenu ();
developerMenuItem.Submenu = developerMenu;
apiMenuItem = new NSMenuItem ("Api Documentation", "a", delegate {
ApiDocs (this);
});
developerMenu.AddItem (apiMenuItem);
githubMenuItem = new NSMenuItem ("Github", "g", delegate {
Github (this);
});
developerMenu.AddItem (githubMenuItem);
communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
Community (this);
});
statusItem.Menu.AddItem (communityMenuItem);
quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
Quit (this);
});
statusItem.Menu.AddItem (quitMenuItem);
} }
partial void HelloWorld(NSObject sender) private IServerApplicationHost AppHost{ get; set;}
private ILogger Logger{ get; set;}
private void Quit(NSObject sender)
{ {
NSApplication.SharedApplication.Terminate(this);
//AppHost.Shutdown();
} }
partial void Quit(NSObject sender) private void Community(NSObject sender)
{ {
BrowserLauncher.OpenCommunity(Logger);
} }
partial void Configure(NSObject sender) private void Configure(NSObject sender)
{ {
BrowserLauncher.OpenDashboard(AppHost, Logger);
} }
partial void Browse(NSObject sender) private void Browse(NSObject sender)
{ {
BrowserLauncher.OpenWebClient(AppHost, Logger);
} }
partial void Github(NSObject sender) private void Github(NSObject sender)
{ {
BrowserLauncher.OpenGithub(Logger);
} }
partial void ApiDocs(NSObject sender) private void ApiDocs(NSObject sender)
{ {
BrowserLauncher.OpenSwagger(AppHost, Logger);
} }
} }
} }

View File

@ -10,6 +10,7 @@ namespace MediaBrowser.Server.Mac
{ {
public AppDelegate () public AppDelegate ()
{ {
} }
public override void FinishedLaunching (NSObject notification) public override void FinishedLaunching (NSObject notification)

View File

@ -44,27 +44,19 @@
<object class="NSMenu" id="761139089"> <object class="NSMenu" id="761139089">
<string key="NSTitle"/> <string key="NSTitle"/>
<array class="NSMutableArray" key="NSMenuItems"> <array class="NSMutableArray" key="NSMenuItems">
<object class="NSMenuItem" id="92911173">
<reference key="NSMenu" ref="761139089"/>
<string key="NSTitle">Hello World</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<object class="NSCustomResource" key="NSOnImage" id="793232119">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="438564198">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
</object>
<object class="NSMenuItem" id="523607499"> <object class="NSMenuItem" id="523607499">
<reference key="NSMenu" ref="761139089"/> <reference key="NSMenu" ref="761139089"/>
<string key="NSTitle">Quit</string> <string key="NSTitle">Quit</string>
<string key="NSKeyEquiv"/> <string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int> <int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="793232119"/> <object class="NSCustomResource" key="NSOnImage">
<reference key="NSMixedImage" ref="438564198"/> <string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
</object> </object>
</array> </array>
</object> </object>
@ -87,14 +79,6 @@
</object> </object>
<int key="connectionID">540</int> <int key="connectionID">540</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">HelloWorld:</string>
<reference key="source" ref="67438171"/>
<reference key="destination" ref="92911173"/>
</object>
<int key="connectionID">542</int>
</object>
</array> </array>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects"> <array key="orderedObjects">
@ -141,17 +125,11 @@
<int key="objectID">536</int> <int key="objectID">536</int>
<reference key="object" ref="761139089"/> <reference key="object" ref="761139089"/>
<array class="NSMutableArray" key="children"> <array class="NSMutableArray" key="children">
<reference ref="92911173"/>
<reference ref="523607499"/> <reference ref="523607499"/>
</array> </array>
<reference key="parent" ref="0"/> <reference key="parent" ref="0"/>
<string key="objectName">MediaBrowser.Server.Mac</string> <string key="objectName">MediaBrowser.Server.Mac</string>
</object> </object>
<object class="IBObjectRecord">
<int key="objectID">537</int>
<reference key="object" ref="92911173"/>
<reference key="parent" ref="761139089"/>
</object>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">538</int> <int key="objectID">538</int>
<reference key="object" ref="523607499"/> <reference key="object" ref="523607499"/>
@ -167,7 +145,6 @@
<string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary> </dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>

View File

@ -29,7 +29,7 @@ namespace MediaBrowser.Server.Mono.Native
/// </summary> /// </summary>
public void Restart() public void Restart()
{ {
MainClass.Restart();
} }
/// <summary> /// <summary>

View File

@ -43,12 +43,6 @@ namespace MediaBrowser.Server.Mono
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
if (PerformUpdateIfNeeded(appPaths, logger))
{
logger.Info("Exiting to perform application update.");
return;
}
try try
{ {
RunApplication(appPaths, logManager, options); RunApplication(appPaths, logManager, options);
@ -71,8 +65,6 @@ namespace MediaBrowser.Server.Mono
return new ServerApplicationPaths(programDataPath, applicationPath); return new ServerApplicationPaths(programDataPath, applicationPath);
} }
private static readonly RemoteCertificateValidationCallback IgnoreCertificates = new RemoteCertificateValidationCallback(delegate { return true; });
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>(); private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options) private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
@ -80,7 +72,7 @@ namespace MediaBrowser.Server.Mono
SystemEvents.SessionEnding += SystemEvents_SessionEnding; SystemEvents.SessionEnding += SystemEvents_SessionEnding;
// Allow all https requests // Allow all https requests
ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificates; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
var fileSystem = new CommonFileSystem(logManager.GetLogger("FileSystem"), false, true); var fileSystem = new CommonFileSystem(logManager.GetLogger("FileSystem"), false, true);
@ -156,30 +148,10 @@ namespace MediaBrowser.Server.Mono
File.WriteAllText(path, builder.ToString()); File.WriteAllText(path, builder.ToString());
} }
/// <summary>
/// Performs the update if needed.
/// </summary>
/// <param name="appPaths">The app paths.</param>
/// <param name="logger">The logger.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
{
return false;
}
public static void Shutdown() public static void Shutdown()
{ {
ApplicationTaskCompletionSource.SetResult (true); ApplicationTaskCompletionSource.SetResult (true);
} }
public static void Restart()
{
// Second instance will start first, so dispose so that the http ports will be available to the new instance
_appHost.Dispose();
// Right now this method will just shutdown, but not restart
Shutdown ();
}
} }
class NoCheckCertificatePolicy : ICertificatePolicy class NoCheckCertificatePolicy : ICertificatePolicy