Skip to content

Commit

Permalink
Plugging in a few downloads ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Gutknecht committed May 9, 2009
1 parent 76da745 commit 377d913
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 12 deletions.
18 changes: 18 additions & 0 deletions Cuisine.xcodeproj/project.pbxproj
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -91,6 +93,9 @@
77A53AFD0FB5A4E700040FC6 /* KCCookbooksController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCCookbooksController.m; sourceTree = "<group>"; };
77A53B240FB5A75600040FC6 /* KCChefConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCChefConnection.h; sourceTree = "<group>"; };
77A53B250FB5A75600040FC6 /* KCChefConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCChefConnection.m; sourceTree = "<group>"; };
77A53B8F0FB5B48500040FC6 /* KCNetworkOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCNetworkOperation.h; sourceTree = "<group>"; };
77A53B900FB5B48500040FC6 /* KCNetworkOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCNetworkOperation.m; sourceTree = "<group>"; };
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 = "<group>"; };
77C484560FB309CB0098C82D /* KCSearchController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCSearchController.h; sourceTree = "<group>"; };
77C484570FB309CB0098C82D /* KCSearchController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCSearchController.m; sourceTree = "<group>"; };
Expand All @@ -107,6 +112,7 @@
buildActionMask = 2147483647;
files = (
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
77A53BBB0FB5C10D00040FC6 /* JSON.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -133,6 +139,7 @@
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
77A53BBA0FB5C10D00040FC6 /* JSON.framework */,
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
Expand Down Expand Up @@ -250,6 +257,8 @@
778EFA2F0FB2563200FE49FC /* KCNode.m */,
77A53B240FB5A75600040FC6 /* KCChefConnection.h */,
77A53B250FB5A75600040FC6 /* KCChefConnection.m */,
77A53B8F0FB5B48500040FC6 /* KCNetworkOperation.h */,
77A53B900FB5B48500040FC6 /* KCNetworkOperation.m */,
);
path = core;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
53 changes: 49 additions & 4 deletions English.lproj/LoginWindow.xib
Expand Up @@ -149,6 +149,13 @@
<string key="NSMinSize">{465, 146}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSUserDefaultsController" id="919473415">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>defaultServer</string>
</object>
<bool key="NSSharedInstance">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
Expand All @@ -169,6 +176,30 @@
</object>
<int key="connectionID">13</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">urlField</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="270198673"/>
</object>
<int key="connectionID">19</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: values.defaultServer</string>
<reference key="source" ref="270198673"/>
<reference key="destination" ref="919473415"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="270198673"/>
<reference key="NSDestination" ref="919473415"/>
<string key="NSLabel">value: values.defaultServer</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">values.defaultServer</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">21</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -214,8 +245,8 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="46080984"/>
<reference ref="270198673"/>
<reference ref="697515764"/>
<reference ref="270198673"/>
</object>
<reference key="parent" ref="1005"/>
</object>
Expand Down Expand Up @@ -261,6 +292,11 @@
<reference key="object" ref="513079397"/>
<reference key="parent" ref="697515764"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">20</int>
<reference key="object" ref="919473415"/>
<reference key="parent" ref="1002"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand Down Expand Up @@ -336,7 +372,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">13</int>
<int key="maxID">21</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -349,8 +385,17 @@
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">defaultButton</string>
<string key="NS.object.0">NSButton</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>defaultButton</string>
<string>urlField</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSButton</string>
<string>NSTextField</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
<string>com.fotonauts.${PRODUCT_NAME:identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
5 changes: 4 additions & 1 deletion gui/KCApplicationDelegate.h
Expand Up @@ -10,9 +10,12 @@


@interface KCApplicationDelegate : NSObject {

NSOperationQueue* queue;
}

@property (nonatomic, retain) NSOperationQueue* queue;


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;


Expand Down
2 changes: 2 additions & 0 deletions gui/KCApplicationDelegate.m
Expand Up @@ -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];
}
Expand Down
1 change: 1 addition & 0 deletions gui/KCLoginWindowController.h
Expand Up @@ -11,6 +11,7 @@

@interface KCLoginWindowController : NSWindowController {
IBOutlet NSButton *defaultButton;
IBOutlet NSTextField *urlField;
}

@property (nonatomic, retain) IBOutlet NSButton *defaultButton;
Expand Down
50 changes: 44 additions & 6 deletions gui/KCLoginWindowController.m
Expand Up @@ -8,21 +8,59 @@

#import "KCLoginWindowController.h"
#import "KCMainWindowController.h"
#import "KCNetworkOperation.h"
#import "KCApplicationDelegate.h"


@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

0 comments on commit 377d913

Please sign in to comment.