diff --git a/jellyfin-server-macos.xcodeproj/project.pbxproj b/jellyfin-server-macos.xcodeproj/project.pbxproj index ff4104b..04b1444 100644 --- a/jellyfin-server-macos.xcodeproj/project.pbxproj +++ b/jellyfin-server-macos.xcodeproj/project.pbxproj @@ -26,7 +26,7 @@ C4F0E82F1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4F0E82D1DA1B9CF00435310 /* STPreferencesGeneralViewController.xib */; }; C4F0E8381DA1CB0900435310 /* STPreferencesInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4F0E8361DA1CB0900435310 /* STPreferencesInfoViewController.m */; }; C4F0E8391DA1CB0900435310 /* STPreferencesInfoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4F0E8371DA1CB0900435310 /* STPreferencesInfoViewController.xib */; }; - C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */ = {isa = PBXBuildFile; fileRef = C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */; }; + C4FFB0661D0D7F870015D14A /* JellyfinMacOS.m in Sources */ = {isa = PBXBuildFile; fileRef = C4FFB0641D0D7E4C0015D14A /* JellyfinMacOS.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -81,8 +81,8 @@ C4F0E8351DA1CB0900435310 /* STPreferencesInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPreferencesInfoViewController.h; path = UI/STPreferencesWindow/STPreferencesInfoViewController.h; sourceTree = ""; }; C4F0E8361DA1CB0900435310 /* STPreferencesInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STPreferencesInfoViewController.m; path = UI/STPreferencesWindow/STPreferencesInfoViewController.m; sourceTree = ""; }; C4F0E8371DA1CB0900435310 /* STPreferencesInfoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STPreferencesInfoViewController.xib; path = UI/STPreferencesWindow/STPreferencesInfoViewController.xib; sourceTree = ""; }; - C4FFB0631D0D7E440015D14A /* XGSyncthing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XGSyncthing.h; sourceTree = ""; }; - C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XGSyncthing.m; sourceTree = ""; }; + C4FFB0631D0D7E440015D14A /* JellyfinMacOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JellyfinMacOS.h; sourceTree = ""; }; + C4FFB0641D0D7E4C0015D14A /* JellyfinMacOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JellyfinMacOS.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -145,8 +145,8 @@ children = ( 29AF1BA4210F11DE004212DE /* jellyfin-server-Bridging-Header.h */, 09004F8C238E70BF00F7E9C2 /* DaemonProcess.swift */, - C4FFB0631D0D7E440015D14A /* XGSyncthing.h */, - C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */, + C4FFB0631D0D7E440015D14A /* JellyfinMacOS.h */, + C4FFB0641D0D7E4C0015D14A /* JellyfinMacOS.m */, C4A415631D0D579D00DC6018 /* STApplication.h */, C4A415641D0D579D00DC6018 /* STApplication.m */, C4D567A11D3A8DFE002AD881 /* STLoginItem.m */, @@ -334,7 +334,7 @@ buildActionMask = 2147483647; files = ( C4D567A21D3A8DFE002AD881 /* STLoginItem.m in Sources */, - C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */, + C4FFB0661D0D7F870015D14A /* JellyfinMacOS.m in Sources */, C4A415681D0D579D00DC6018 /* main.m in Sources */, C4946B031D587878008447A2 /* STAboutWindowController.m in Sources */, C4D36D801DA3D53F0061FD08 /* STPreferencesAdvancedViewController.m in Sources */, @@ -411,7 +411,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "$(SRCROOT)/syncthing/Test"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/jellyfin-server/Test"; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -464,7 +464,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "$(SRCROOT)/syncthing/Test"; + HEADER_SEARCH_PATHS = "$(SRCROOT)/jellyfin-server/Test"; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; OTHER_CFLAGS = ""; diff --git a/jellyfin-server/Base.lproj/STApplication.xib b/jellyfin-server/Base.lproj/STApplication.xib index ce94625..d70af04 100644 --- a/jellyfin-server/Base.lproj/STApplication.xib +++ b/jellyfin-server/Base.lproj/STApplication.xib @@ -80,7 +80,6 @@ - diff --git a/jellyfin-server/XGSyncthing.h b/jellyfin-server/JellyfinMacOS.h similarity index 54% rename from jellyfin-server/XGSyncthing.h rename to jellyfin-server/JellyfinMacOS.h index 117a8c1..e2efe97 100644 --- a/jellyfin-server/XGSyncthing.h +++ b/jellyfin-server/JellyfinMacOS.h @@ -1,12 +1,11 @@ /** - * Syncthing Objective-C client library + * Jellyfin-Server-macOS Objective-C client library */ #import -@interface XGSyncthing : NSObject +@interface JellyfinMacOS : NSObject @property (nonatomic, copy) NSString *URI; -@property (nonatomic, copy) NSString *ApiKey; /** * Load configuration from XML file diff --git a/jellyfin-server/XGSyncthing.m b/jellyfin-server/JellyfinMacOS.m similarity index 86% rename from jellyfin-server/XGSyncthing.m rename to jellyfin-server/JellyfinMacOS.m index 91647af..df3c3e8 100644 --- a/jellyfin-server/XGSyncthing.m +++ b/jellyfin-server/JellyfinMacOS.m @@ -1,9 +1,9 @@ -#import "XGSyncthing.h" +#import "JellyfinMacOS.h" // How long we wait for one event poll #define EVENT_TIMEOUT 60.0 -@interface XGSyncthing() +@interface JellyfinMacOS() @property (nonatomic, strong) NSXMLParser *configParser; @property (nonatomic, strong) NSMutableArray *parsing; @@ -11,10 +11,10 @@ @end -@implementation XGSyncthing {} +@implementation JellyfinMacOS {} @synthesize URI = _URI; -@synthesize ApiKey = _apiKey; + @@ -29,7 +29,7 @@ appropriateForURL:nil create:NO error:&error]; - NSURL* configUrl = [supURL URLByAppendingPathComponent:@"jellyfin-Server/config.xml"]; + NSURL* configUrl = [supURL URLByAppendingPathComponent:@"jellyfin/config.xml"]; _parsing = [[NSMutableArray alloc] init]; _configParser = [[NSXMLParser alloc] initWithContentsOfURL:configUrl]; [_configParser setDelegate:self]; @@ -56,9 +56,7 @@ -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { NSString *keyPath = [_parsing componentsJoinedByString:@"."]; - if ([keyPath isEqualToString:@"configuration.gui.apikey"]) { - _apiKey = string; - } else if ([keyPath isEqualToString:@"configuration.gui.address"]) { + if ([keyPath isEqualToString:@"configuration.gui.address"]) { _URI = [_URI stringByAppendingString:string]; } } diff --git a/jellyfin-server/STApplication.h b/jellyfin-server/STApplication.h index ab8535c..46db5a0 100644 --- a/jellyfin-server/STApplication.h +++ b/jellyfin-server/STApplication.h @@ -8,11 +8,10 @@ #import -#import "XGSyncthing.h" +#import "JellyfinMacOS.h" #import "Controllers/STAboutWindowController.h" #import "Controllers/STPreferencesWindowController.h" #import "jellyfin_server_macos-Swift.h" -//#import "Syncthing-Swift.h" @interface STAppDelegate : NSObject diff --git a/jellyfin-server/STApplication.m b/jellyfin-server/STApplication.m index 0ea4a96..66e2544 100644 --- a/jellyfin-server/STApplication.m +++ b/jellyfin-server/STApplication.m @@ -6,7 +6,7 @@ @interface STAppDelegate () @property (nonatomic, strong, readwrite) NSStatusItem *statusItem; -@property (nonatomic, strong, readwrite) XGSyncthing *syncthing; +@property (nonatomic, strong, readwrite) JellyfinMacOS *jfmacos; @property (nonatomic, strong, readwrite) NSString *executable; @property (nonatomic, strong, readwrite) DaemonProcess *process; @property (strong) STPreferencesWindowController *preferencesWindow; @@ -16,9 +16,11 @@ @implementation STAppDelegate + - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { - _syncthing = [[XGSyncthing alloc] init]; - + _jfmacos = [[JellyfinMacOS alloc] init]; + + [self applicationLoadConfiguration]; _process = [[DaemonProcess alloc] initWithPath:_executable delegate:self]; @@ -45,10 +47,13 @@ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + // Watch out! This line gets data from the NSUserDefaults (defaults read org.jellyfin.server.macos) + // If you're updating this area, make sure you run "defaults delete org.jellyfin.server.macos" first! _executable = [defaults stringForKey:@"Executable"]; if (!_executable) { // We store the server and runtime files in ~/Library/Application Support/Jellyfin/server by default - _executable = [[self applicationSupportDirectoryFor:@"jellyfin-server/server"] stringByAppendingPathComponent:@"jellyfin"]; + // Then the appended path component is the actual executable to run + _executable = [[self applicationSupportDirectoryFor:@"jellyfin/server"] stringByAppendingPathComponent:@"jellyfin"]; [defaults setValue:_executable forKey:@"Executable"]; } @@ -60,12 +65,11 @@ return; } - _syncthing.URI = [defaults stringForKey:@"URI"]; - _syncthing.ApiKey = [defaults stringForKey:@"ApiKey"]; + _jfmacos.URI = [defaults stringForKey:@"URI"]; // If no values are set, read from XML and store in defaults - if (!_syncthing.URI.length && !_syncthing.ApiKey.length) { - BOOL success = [_syncthing loadConfigurationFromXML]; + if (!_jfmacos.URI.length) { + BOOL success = [_jfmacos loadConfigurationFromXML]; // If XML doesn't exist or is invalid, retry after delay if (!success && configLoadAttempt <= 3) { @@ -74,18 +78,12 @@ return; } - [defaults setObject:_syncthing.URI forKey:@"URI"]; - [defaults setObject:_syncthing.ApiKey forKey:@"ApiKey"]; + [defaults setObject:_jfmacos.URI forKey:@"URI"]; } - if (!_syncthing.URI) { - _syncthing.URI = @"http://localhost:8096"; - [defaults setObject:_syncthing.URI forKey:@"URI"]; - } - - if (!_syncthing.ApiKey) { - _syncthing.ApiKey = @""; - [defaults setObject:_syncthing.ApiKey forKey:@"ApiKey"]; + if (!_jfmacos.URI) { + _jfmacos.URI = @"http://localhost:8096"; + [defaults setObject:_jfmacos.URI forKey:@"URI"]; } if (![defaults objectForKey:@"StartAtLogin"]) { @@ -114,7 +112,7 @@ } // Copy the bundled executable to the desired location. Pass on return and error to the caller. - NSString *bundled = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"jellyfin"]; + NSString *bundled = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"server"]; return [manager copyItemAtPath:bundled toPath:path error:error]; } @@ -132,7 +130,7 @@ - (IBAction) clickedOpen:(id)sender { - NSURL *URL = [NSURL URLWithString:[_syncthing URI]]; + NSURL *URL = [NSURL URLWithString:[_jfmacos URI]]; [[NSWorkspace sharedWorkspace] openURL:URL]; } diff --git a/jellyfin-server/STConfiguration.m b/jellyfin-server/STConfiguration.m index 3045f66..e0b5c01 100644 --- a/jellyfin-server/STConfiguration.m +++ b/jellyfin-server/STConfiguration.m @@ -7,11 +7,11 @@ // #import "STConfiguration.h" -#import "XGSyncthing.h" +#import "JellyfinMacOS.h" @interface STConfiguration() -@property XGSyncthing *st; +@property JellyfinMacOS *st; @end diff --git a/jellyfin-server/STPreferencesGeneralViewController.h b/jellyfin-server/STPreferencesGeneralViewController.h index 4a0f447..be2f7bf 100644 --- a/jellyfin-server/STPreferencesGeneralViewController.h +++ b/jellyfin-server/STPreferencesGeneralViewController.h @@ -10,7 +10,7 @@ @interface STPreferencesGeneralViewController : NSViewController -@property (weak) IBOutlet NSTextField *Syncthing_URI; +@property (weak) IBOutlet NSTextField *Jellyfin_URI; @property (weak) IBOutlet NSButton *StartAtLogin; diff --git a/jellyfin-server/STPreferencesGeneralViewController.m b/jellyfin-server/STPreferencesGeneralViewController.m index 14f34d5..32bef2e 100644 --- a/jellyfin-server/STPreferencesGeneralViewController.m +++ b/jellyfin-server/STPreferencesGeneralViewController.m @@ -8,7 +8,7 @@ #import "STPreferencesGeneralViewController.h" #import "STLoginItem.h" -#import "XGSyncthing.h" +#import "JellyfinMacOS.h" @interface STPreferencesGeneralViewController () diff --git a/jellyfin-server/STPreferencesGeneralViewController.xib b/jellyfin-server/STPreferencesGeneralViewController.xib index 305d7d8..6ce0eea 100644 --- a/jellyfin-server/STPreferencesGeneralViewController.xib +++ b/jellyfin-server/STPreferencesGeneralViewController.xib @@ -1,15 +1,15 @@ - + - + + - @@ -28,7 +28,7 @@ - + @@ -36,9 +36,6 @@ - - - - + - + diff --git a/jellyfin-server/UI/STPreferencesWindowController.xib b/jellyfin-server/UI/STPreferencesWindowController.xib index c4bd5b5..680062d 100644 --- a/jellyfin-server/UI/STPreferencesWindowController.xib +++ b/jellyfin-server/UI/STPreferencesWindowController.xib @@ -1,8 +1,8 @@ - + - +