diff --git a/Cuisine.xcodeproj/project.pbxproj b/Cuisine.xcodeproj/project.pbxproj index 3b7e326..099d949 100644 --- a/Cuisine.xcodeproj/project.pbxproj +++ b/Cuisine.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 77A53AF90FB5A40D00040FC6 /* Cookbooks.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77A53AF80FB5A40D00040FC6 /* Cookbooks.xib */; }; 77A53AFE0FB5A4E700040FC6 /* KCCookbooksController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77A53AFD0FB5A4E700040FC6 /* KCCookbooksController.m */; }; 77A53B260FB5A75600040FC6 /* KCChefConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 77A53B250FB5A75600040FC6 /* KCChefConnection.m */; }; + 77A53B910FB5B48500040FC6 /* KCNetworkOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 77A53B900FB5B48500040FC6 /* KCNetworkOperation.m */; }; + 77A53BBB0FB5C10D00040FC6 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77A53BBA0FB5C10D00040FC6 /* JSON.framework */; }; 77C484540FB309980098C82D /* Search.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77C484530FB309980098C82D /* Search.xib */; }; 77C484580FB309CB0098C82D /* KCSearchController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C484570FB309CB0098C82D /* KCSearchController.m */; }; 77C5C2150FB34CA9006D6BC8 /* KCNodesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C5C2140FB34CA9006D6BC8 /* KCNodesController.m */; }; @@ -91,6 +93,9 @@ 77A53AFD0FB5A4E700040FC6 /* KCCookbooksController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCCookbooksController.m; sourceTree = ""; }; 77A53B240FB5A75600040FC6 /* KCChefConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCChefConnection.h; sourceTree = ""; }; 77A53B250FB5A75600040FC6 /* KCChefConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCChefConnection.m; sourceTree = ""; }; + 77A53B8F0FB5B48500040FC6 /* KCNetworkOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCNetworkOperation.h; sourceTree = ""; }; + 77A53B900FB5B48500040FC6 /* KCNetworkOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCNetworkOperation.m; sourceTree = ""; }; + 77A53BBA0FB5C10D00040FC6 /* JSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JSON.framework; path = ../../Library/Frameworks/JSON.framework; sourceTree = SOURCE_ROOT; }; 77C484510FB309940098C82D /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Search.xib; sourceTree = ""; }; 77C484560FB309CB0098C82D /* KCSearchController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCSearchController.h; sourceTree = ""; }; 77C484570FB309CB0098C82D /* KCSearchController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCSearchController.m; sourceTree = ""; }; @@ -107,6 +112,7 @@ buildActionMask = 2147483647; files = ( 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + 77A53BBB0FB5C10D00040FC6 /* JSON.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -133,6 +139,7 @@ 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { isa = PBXGroup; children = ( + 77A53BBA0FB5C10D00040FC6 /* JSON.framework */, 29B97324FDCFA39411CA2CEA /* AppKit.framework */, 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, 29B97325FDCFA39411CA2CEA /* Foundation.framework */, @@ -250,6 +257,8 @@ 778EFA2F0FB2563200FE49FC /* KCNode.m */, 77A53B240FB5A75600040FC6 /* KCChefConnection.h */, 77A53B250FB5A75600040FC6 /* KCChefConnection.m */, + 77A53B8F0FB5B48500040FC6 /* KCNetworkOperation.h */, + 77A53B900FB5B48500040FC6 /* KCNetworkOperation.m */, ); path = core; sourceTree = ""; @@ -341,6 +350,7 @@ 77A53AC00FB5916E00040FC6 /* KCNodeController.m in Sources */, 77A53AFE0FB5A4E700040FC6 /* KCCookbooksController.m in Sources */, 77A53B260FB5A75600040FC6 /* KCChefConnection.m in Sources */, + 77A53B910FB5B48500040FC6 /* KCNetworkOperation.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -443,6 +453,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../Library/Frameworks\"", + ); GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; @@ -460,6 +474,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../Library/Frameworks\"", + ); GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Cuisine_Prefix.pch; diff --git a/English.lproj/LoginWindow.xib b/English.lproj/LoginWindow.xib index f75bb85..25da45a 100644 --- a/English.lproj/LoginWindow.xib +++ b/English.lproj/LoginWindow.xib @@ -149,6 +149,13 @@ {465, 146} {3.40282e+38, 3.40282e+38} + + + YES + defaultServer + + YES + @@ -169,6 +176,30 @@ 13 + + + urlField + + + + 19 + + + + value: values.defaultServer + + + + + + value: values.defaultServer + value + values.defaultServer + 2 + + + 21 + @@ -214,8 +245,8 @@ YES - + @@ -261,6 +292,11 @@ + + 20 + + + @@ -336,7 +372,7 @@ - 13 + 21 @@ -349,8 +385,17 @@ id - defaultButton - NSButton + YES + + YES + defaultButton + urlField + + + YES + NSButton + NSTextField + IBProjectSource diff --git a/Info.plist b/Info.plist index 612b7da..d3e6c73 100644 --- a/Info.plist +++ b/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - com.yourcompany.${PRODUCT_NAME:identifier} + com.fotonauts.${PRODUCT_NAME:identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/gui/KCApplicationDelegate.h b/gui/KCApplicationDelegate.h index 2a7f0af..a7f8535 100644 --- a/gui/KCApplicationDelegate.h +++ b/gui/KCApplicationDelegate.h @@ -10,9 +10,12 @@ @interface KCApplicationDelegate : NSObject { - + NSOperationQueue* queue; } +@property (nonatomic, retain) NSOperationQueue* queue; + + - (void)applicationDidFinishLaunching:(NSNotification *)aNotification; diff --git a/gui/KCApplicationDelegate.m b/gui/KCApplicationDelegate.m index 0477037..a120d87 100644 --- a/gui/KCApplicationDelegate.m +++ b/gui/KCApplicationDelegate.m @@ -11,9 +11,11 @@ @implementation KCApplicationDelegate +@synthesize queue; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + [self setQueue:[[NSOperationQueue alloc] init]]; KCLoginWindowController *c = [[KCLoginWindowController alloc] initWithWindowNibName:@"LoginWindow"]; [c showWindow:self]; } diff --git a/gui/KCLoginWindowController.h b/gui/KCLoginWindowController.h index c6cea23..ebb4120 100644 --- a/gui/KCLoginWindowController.h +++ b/gui/KCLoginWindowController.h @@ -11,6 +11,7 @@ @interface KCLoginWindowController : NSWindowController { IBOutlet NSButton *defaultButton; + IBOutlet NSTextField *urlField; } @property (nonatomic, retain) IBOutlet NSButton *defaultButton; diff --git a/gui/KCLoginWindowController.m b/gui/KCLoginWindowController.m index bc4bad4..a993881 100644 --- a/gui/KCLoginWindowController.m +++ b/gui/KCLoginWindowController.m @@ -8,6 +8,8 @@ #import "KCLoginWindowController.h" #import "KCMainWindowController.h" +#import "KCNetworkOperation.h" +#import "KCApplicationDelegate.h" @implementation KCLoginWindowController @@ -15,14 +17,50 @@ @implementation KCLoginWindowController @synthesize defaultButton; +-(void)awakeFromNib +{ +} + +-(void)operationSuccess +{ +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if([keyPath isEqual:@"isFinished"]){ + [object removeObserver:self forKeyPath:@"isFinished"]; + KCNetworkOperation* op = (KCNetworkOperation*)object; + if (op.error!=nil) { + NSAlert* a = [NSAlert alertWithError:op.error]; + [a runModal]; + } + else { + KCChefConnection* chef = [[KCChefConnection alloc] init]; + chef.serverURL = [urlField stringValue]; + [chef initialFetch]; + + KCMainWindowController *c = [[KCMainWindowController alloc] initWithWindowNibName:@"MainWindow"]; + [c setChefConnection:chef]; + [c showWindow:self]; + [self close]; + } + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + -(void)connect:(id)sender { - KCChefConnection* chef = [[KCChefConnection alloc] init]; - chef.serverURL = @"https://chef.ftnx.net"; - KCMainWindowController *c = [[KCMainWindowController alloc] initWithWindowNibName:@"MainWindow"]; - [c setChefConnection:chef]; - [c showWindow:self]; - [self close]; + NSString* urlString = [urlField stringValue]; + NSURL* url = [NSURL URLWithString:urlString]; + if (url==nil) + return; + + NSOperationQueue* queue = [(KCApplicationDelegate*)[NSApp delegate] queue]; + KCNetworkOperation* op = [[KCNetworkOperation alloc] init]; + op.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/nodes.json", [url description]]]; // This is baroque, let's fix it + [op addObserver:self forKeyPath:@"isFinished" options:0 context:nil]; + [queue addOperation:op]; } @end