Skip to content

Commit

Permalink
Launch a welcome window from the start. Now need to hook up the OAuth…
Browse files Browse the repository at this point in the history
… stuff. Closes gh-23.
  • Loading branch information
kylemacomber committed Mar 15, 2011
1 parent cf68f47 commit f7c1443
Show file tree
Hide file tree
Showing 6 changed files with 667 additions and 12 deletions.
39 changes: 37 additions & 2 deletions Draftimo/Draftimo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
/* Begin PBXBuildFile section */
A31189971329E758006C6A6B /* MPOAuth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A31189961329E758006C6A6B /* MPOAuth.framework */; };
A31189981329E77D006C6A6B /* MPOAuth.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A31189961329E758006C6A6B /* MPOAuth.framework */; };
A313E609132F1131006DDE67 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A313E608132F1131006DDE67 /* Localizable.strings */; };
A351766613284D7300AE4554 /* YahooLogin2.png in Resources */ = {isa = PBXBuildFile; fileRef = A351766313284D7300AE4554 /* YahooLogin2.png */; };
A351766713284D7300AE4554 /* YahooLogin3.png in Resources */ = {isa = PBXBuildFile; fileRef = A351766413284D7300AE4554 /* YahooLogin3.png */; };
A351766913284F7900AE4554 /* YahooLogin1.png in Resources */ = {isa = PBXBuildFile; fileRef = A351766813284F7900AE4554 /* YahooLogin1.png */; };
A351766B132854EE00AE4554 /* Yojimbo.png in Resources */ = {isa = PBXBuildFile; fileRef = A351766A132854EE00AE4554 /* Yojimbo.png */; };
A36647B51327E9E600052F6D /* DMConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = A36647B41327E9E600052F6D /* DMConstants.m */; };
A39E30C9132AE0B7007E0323 /* DMHelloWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A39E30C8132AE0B7007E0323 /* DMHelloWindowController.m */; };
A39E30F7132BD045007E0323 /* DMSplashScreenButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A39E30F6132BD043007E0323 /* DMSplashScreenButtonCell.m */; };
A3A8C5F613280C0F00FDB229 /* DMAuthWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A3A8C5F513280C0F00FDB229 /* DMAuthWindowController.m */; };
A3A8C5FE13280CD800FDB229 /* DMAuthWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A3A8C5FD13280CD800FDB229 /* DMAuthWindow.xib */; };
A3AE807613274EF9005A18B0 /* JSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3AE807513274EF9005A18B0 /* JSON.framework */; };
A3AE807A13274F07005A18B0 /* BWToolkitFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3AE807913274F07005A18B0 /* BWToolkitFramework.framework */; };
A3AE807C13274F36005A18B0 /* BWToolkitFramework.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A3AE807913274F07005A18B0 /* BWToolkitFramework.framework */; };
A3AE807E13274F36005A18B0 /* JSON.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A3AE807513274EF9005A18B0 /* JSON.framework */; };
A3BA7591132F086700548F00 /* DMHelloWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A3BA7590132F086700548F00 /* DMHelloWindow.xib */; };
A3E8AB8113295B5C00F31503 /* Status_Accepted.png in Resources */ = {isa = PBXBuildFile; fileRef = A3E8AB7F13295B5C00F31503 /* Status_Accepted.png */; };
A3E8AB8213295B5C00F31503 /* Status_Declined.png in Resources */ = {isa = PBXBuildFile; fileRef = A3E8AB8013295B5C00F31503 /* Status_Declined.png */; };
A3EA27681327461C0072AC66 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3EA27671327461C0072AC66 /* Cocoa.framework */; };
Expand All @@ -28,6 +32,9 @@
A3EA27781327461C0072AC66 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = A3EA27761327461C0072AC66 /* Credits.rtf */; };
A3EA277B1327461C0072AC66 /* DMAppController.m in Sources */ = {isa = PBXBuildFile; fileRef = A3EA277A1327461C0072AC66 /* DMAppController.m */; };
A3EA277E1327461C0072AC66 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A3EA277C1327461C0072AC66 /* MainMenu.xib */; };
A3EEA582132C4BF2006655E5 /* SplashScreenButtonCenter.png in Resources */ = {isa = PBXBuildFile; fileRef = A3EEA57F132C4BF2006655E5 /* SplashScreenButtonCenter.png */; };
A3EEA583132C4BF2006655E5 /* SplashScreenButtonLeft.png in Resources */ = {isa = PBXBuildFile; fileRef = A3EEA580132C4BF2006655E5 /* SplashScreenButtonLeft.png */; };
A3EEA584132C4BF2006655E5 /* SplashScreenButtonRight.png in Resources */ = {isa = PBXBuildFile; fileRef = A3EEA581132C4BF2006655E5 /* SplashScreenButtonRight.png */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -47,17 +54,23 @@

/* Begin PBXFileReference section */
A31189961329E758006C6A6B /* MPOAuth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MPOAuth.framework; sourceTree = "<group>"; };
A313E608132F1131006DDE67 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = Localizable.strings; path = ../../../../../../Active/Development/ObjectiveC/draftimo/Draftimo/Draftimo/Localizable.strings; sourceTree = "<group>"; };
A351766313284D7300AE4554 /* YahooLogin2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = YahooLogin2.png; sourceTree = "<group>"; };
A351766413284D7300AE4554 /* YahooLogin3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = YahooLogin3.png; sourceTree = "<group>"; };
A351766813284F7900AE4554 /* YahooLogin1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = YahooLogin1.png; sourceTree = "<group>"; };
A351766A132854EE00AE4554 /* Yojimbo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Yojimbo.png; sourceTree = "<group>"; };
A36647B31327E9E600052F6D /* DMConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DMConstants.h; sourceTree = "<group>"; };
A36647B41327E9E600052F6D /* DMConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DMConstants.m; sourceTree = "<group>"; wrapsLines = 0; };
A39E30C7132AE0B7007E0323 /* DMHelloWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DMHelloWindowController.h; path = ../../../../../../Active/Development/ObjectiveC/draftimo/Draftimo/Draftimo/DMHelloWindowController.h; sourceTree = "<group>"; };
A39E30C8132AE0B7007E0323 /* DMHelloWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DMHelloWindowController.m; path = ../../../../../../Active/Development/ObjectiveC/draftimo/Draftimo/Draftimo/DMHelloWindowController.m; sourceTree = "<group>"; wrapsLines = 0; };
A39E30F5132BD042007E0323 /* DMSplashScreenButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DMSplashScreenButtonCell.h; path = ../../../../../../Active/Development/ObjectiveC/draftimo/Draftimo/Draftimo/DMSplashScreenButtonCell.h; sourceTree = "<group>"; };
A39E30F6132BD043007E0323 /* DMSplashScreenButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DMSplashScreenButtonCell.m; path = ../../../../../../Active/Development/ObjectiveC/draftimo/Draftimo/Draftimo/DMSplashScreenButtonCell.m; sourceTree = "<group>"; };
A3A8C5F413280C0F00FDB229 /* DMAuthWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DMAuthWindowController.h; sourceTree = "<group>"; };
A3A8C5F513280C0F00FDB229 /* DMAuthWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DMAuthWindowController.m; sourceTree = "<group>"; };
A3A8C5FD13280CD800FDB229 /* DMAuthWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DMAuthWindow.xib; sourceTree = "<group>"; };
A3AE807513274EF9005A18B0 /* JSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JSON.framework; sourceTree = "<group>"; };
A3AE807913274F07005A18B0 /* BWToolkitFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = BWToolkitFramework.framework; sourceTree = "<group>"; };
A3BA7590132F086700548F00 /* DMHelloWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DMHelloWindow.xib; path = ../../../../../../Active/Development/ObjectiveC/draftimo/Draftimo/Draftimo/DMHelloWindow.xib; sourceTree = "<group>"; };
A3E8AB7F13295B5C00F31503 /* Status_Accepted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Status_Accepted.png; sourceTree = "<group>"; };
A3E8AB8013295B5C00F31503 /* Status_Declined.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Status_Declined.png; sourceTree = "<group>"; };
A3EA27631327461C0072AC66 /* Draftimo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Draftimo.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -73,6 +86,9 @@
A3EA27791327461C0072AC66 /* DMAppController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DMAppController.h; sourceTree = "<group>"; };
A3EA277A1327461C0072AC66 /* DMAppController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DMAppController.m; sourceTree = "<group>"; wrapsLines = 0; };
A3EA277D1327461C0072AC66 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
A3EEA57F132C4BF2006655E5 /* SplashScreenButtonCenter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SplashScreenButtonCenter.png; sourceTree = "<group>"; };
A3EEA580132C4BF2006655E5 /* SplashScreenButtonLeft.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SplashScreenButtonLeft.png; sourceTree = "<group>"; };
A3EEA581132C4BF2006655E5 /* SplashScreenButtonRight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SplashScreenButtonRight.png; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -93,6 +109,9 @@
A351766013284D6300AE4554 /* Resources */ = {
isa = PBXGroup;
children = (
A3EEA57F132C4BF2006655E5 /* SplashScreenButtonCenter.png */,
A3EEA580132C4BF2006655E5 /* SplashScreenButtonLeft.png */,
A3EEA581132C4BF2006655E5 /* SplashScreenButtonRight.png */,
A351766813284F7900AE4554 /* YahooLogin1.png */,
A351766313284D7300AE4554 /* YahooLogin2.png */,
A351766413284D7300AE4554 /* YahooLogin3.png */,
Expand All @@ -106,9 +125,14 @@
A3A8C5FF13280CE000FDB229 /* Draft Setup */ = {
isa = PBXGroup;
children = (
A39E30C7132AE0B7007E0323 /* DMHelloWindowController.h */,
A39E30C8132AE0B7007E0323 /* DMHelloWindowController.m */,
A3BA7590132F086700548F00 /* DMHelloWindow.xib */,
A3A8C5F413280C0F00FDB229 /* DMAuthWindowController.h */,
A3A8C5F513280C0F00FDB229 /* DMAuthWindowController.m */,
A3A8C5FD13280CD800FDB229 /* DMAuthWindow.xib */,
A39E30F5132BD042007E0323 /* DMSplashScreenButtonCell.h */,
A39E30F6132BD043007E0323 /* DMSplashScreenButtonCell.m */,
);
name = "Draft Setup";
sourceTree = "<group>";
Expand Down Expand Up @@ -183,6 +207,7 @@
A3EA27731327461C0072AC66 /* Draftimo-Prefix.pch */,
A3EA27741327461C0072AC66 /* main.m */,
A3EA27761327461C0072AC66 /* Credits.rtf */,
A313E608132F1131006DDE67 /* Localizable.strings */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -213,7 +238,10 @@
/* Begin PBXProject section */
A3EA275A1327461C0072AC66 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = A3EA275D1327461C0072AC66 /* Build configuration list for PBXProject "Draftimo" */;
attributes = {
ORGANIZATIONNAME = "Kyle Macomber";
};
buildConfigurationList = A3EA275D1327461C0072AC66 /* Build configuration list for PBXProject "draftimo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
Expand Down Expand Up @@ -245,6 +273,11 @@
A351766B132854EE00AE4554 /* Yojimbo.png in Resources */,
A3E8AB8113295B5C00F31503 /* Status_Accepted.png in Resources */,
A3E8AB8213295B5C00F31503 /* Status_Declined.png in Resources */,
A3EEA582132C4BF2006655E5 /* SplashScreenButtonCenter.png in Resources */,
A3EEA583132C4BF2006655E5 /* SplashScreenButtonLeft.png in Resources */,
A3EEA584132C4BF2006655E5 /* SplashScreenButtonRight.png in Resources */,
A3BA7591132F086700548F00 /* DMHelloWindow.xib in Resources */,
A313E609132F1131006DDE67 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -259,6 +292,8 @@
A3EA277B1327461C0072AC66 /* DMAppController.m in Sources */,
A36647B51327E9E600052F6D /* DMConstants.m in Sources */,
A3A8C5F613280C0F00FDB229 /* DMAuthWindowController.m in Sources */,
A39E30C9132AE0B7007E0323 /* DMHelloWindowController.m in Sources */,
A39E30F7132BD045007E0323 /* DMSplashScreenButtonCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -365,7 +400,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
A3EA275D1327461C0072AC66 /* Build configuration list for PBXProject "Draftimo" */ = {
A3EA275D1327461C0072AC66 /* Build configuration list for PBXProject "draftimo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A3EA277F1327461C0072AC66 /* Debug */,
Expand Down
57 changes: 47 additions & 10 deletions Draftimo/Draftimo/DMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
#import "DMAppController.h"
#import "DMConstants.h"
#import "DMAuthWindowController.h"
#import "DMHelloWindowController.h"
#import <MPOAuth/MPURLRequestParameter.h>

@interface DMAppController ()
@property (nonatomic, retain, readwrite) MPOAuthAPI *oauthAPI;
@property (nonatomic, retain) DMAuthWindowController *authWindowController;
@property (nonatomic, retain) DMHelloWindowController *helloWindowController;
@property (nonatomic, copy) NSString *oauthVerifier;

- (void)showAuthWindow;
- (void)showHelloWindow;
- (void)performedMethodLoadForURL:(NSURL *)inMethod withResponseBody:(NSString *)inResponseBody;
- (void)getUserGames;
@end

@implementation DMAppController
@synthesize oauthAPI;
@synthesize authWindowController;
@synthesize helloWindowController;
@synthesize oauthVerifier;

+ (DMAppController *)sharedAppController
Expand All @@ -36,7 +42,11 @@ - (void)dealloc
[super dealloc];
}

#pragma NSApplicationDelegate
#pragma mark API

//[[NSApplication sharedApplication] beginSheet:self.authWindowController.window modalForWindow:self.helloWindowController.window modalDelegate:nil didEndSelector:NULL contextInfo:NULL];

#pragma mark NSApplicationDelegate

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
Expand All @@ -60,12 +70,16 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessTokenRefreshed:) name:MPOAuthNotificationAccessTokenRefreshed object:nil];

NSDictionary *credentials = [NSDictionary dictionaryWithObjectsAndKeys:DMOAuthConsumerKey, kMPOAuthCredentialConsumerKey, DMOAuthConsumerSecret, kMPOAuthCredentialConsumerSecret, nil];
self.oauthAPI = [[[MPOAuthAPI alloc] initWithCredentials:credentials andBaseURL:[NSURL URLWithString:YAuthBaseURL]] autorelease];
self.oauthAPI = [[[MPOAuthAPI alloc] initWithCredentials:credentials authenticationURL:[NSURL URLWithString:YAuthBaseURL] andBaseURL:[NSURL URLWithString:YAuthBaseURL] autoStart:NO] autorelease];

[self showAuthWindow];
if ([[self.oauthAPI credentials] accessToken]) {
[self.oauthAPI authenticate];
} else {
[self showHelloWindow];
}
}

#pragma Window Launchers
#pragma mark Window Launchers

- (void)showAuthWindow
{
Expand All @@ -76,31 +90,54 @@ - (void)showAuthWindow
[self.authWindowController showWindow:nil];
}

#pragma MPOAuthNotifications
- (void)showHelloWindow
{
if (!self.helloWindowController) {
self.helloWindowController = [[[DMHelloWindowController alloc] init] autorelease];
}

[self.helloWindowController showWindow:nil];
}

#pragma mark MPOAuthNotifications

- (void)requestTokenReceived:(NSNotification *)notification
{
DLog(@"");
DLog(@"%@", notification);
}

- (void)requestTokenRejected:(NSNotification *)notification
{
DLog(@"");
DLog(@"%@", notification);
}

- (void)accessTokenReceived:(NSNotification *)notification
{
DLog(@"");
DLog(@"%@", notification);
[self getUserGames];
}

- (void)accessTokenRejected:(NSNotification *)notification
{
DLog(@"");
DLog(@"%@", notification);
}

- (void)accessTokenRefreshed:(NSNotification *)notification
{
DLog(@"");
DLog(@"%@", notification);
[self getUserGames];
}

#pragma mark Private Methods

- (void)performedMethodLoadForURL:(NSURL *)inMethod withResponseBody:(NSString *)inResponseBody
{
DLog(@"%@", inResponseBody);
}

- (void)getUserGames
{
[self.oauthAPI performMethod:@"http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games" withTarget:self andAction:@selector(performedMethodLoadForURL:withResponseBody:)];
}

@end
Loading

0 comments on commit f7c1443

Please sign in to comment.