Skip to content

Commit

Permalink
Reworked the authentication flow to give the user more information ab…
Browse files Browse the repository at this point in the history
…out what's going on
  • Loading branch information
georgebrock committed Feb 11, 2009
1 parent 94705b7 commit 2fa2c62
Show file tree
Hide file tree
Showing 13 changed files with 405 additions and 332 deletions.
4 changes: 4 additions & 0 deletions Lastify.xcodeproj/project.pbxproj
Expand Up @@ -14,6 +14,7 @@
C6BE8FF30F431AB5004BBEB7 /* icon_love.png in Resources */ = {isa = PBXBuildFile; fileRef = C6BE8FF00F431AB5004BBEB7 /* icon_love.png */; };
C6BE900D0F4321AE004BBEB7 /* LastifyDrawerView.m in Sources */ = {isa = PBXBuildFile; fileRef = C6BE900C0F4321AE004BBEB7 /* LastifyDrawerView.m */; };
C6BE903B0F4327E4004BBEB7 /* NSButton+Lastify.m in Sources */ = {isa = PBXBuildFile; fileRef = C6BE903A0F4327E4004BBEB7 /* NSButton+Lastify.m */; };
C6BE906B0F432D3A004BBEB7 /* icon_key.png in Resources */ = {isa = PBXBuildFile; fileRef = C6BE906A0F432D3A004BBEB7 /* icon_key.png */; };
C6D68B570F212558000CB3C6 /* LastifyController.m in Sources */ = {isa = PBXBuildFile; fileRef = C6D68B560F212558000CB3C6 /* LastifyController.m */; };
C6D68B5E0F212820000CB3C6 /* LastifyInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6D68B5D0F212820000CB3C6 /* LastifyInterface.xib */; };
C6D68B9E0F2136BE000CB3C6 /* SPController+Lastify.m in Sources */ = {isa = PBXBuildFile; fileRef = C6D68B9D0F2136BE000CB3C6 /* SPController+Lastify.m */; };
Expand All @@ -38,6 +39,7 @@
C6BE900C0F4321AE004BBEB7 /* LastifyDrawerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LastifyDrawerView.m; sourceTree = "<group>"; };
C6BE90390F4327E4004BBEB7 /* NSButton+Lastify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSButton+Lastify.h"; sourceTree = "<group>"; };
C6BE903A0F4327E4004BBEB7 /* NSButton+Lastify.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSButton+Lastify.m"; sourceTree = "<group>"; };
C6BE906A0F432D3A004BBEB7 /* icon_key.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_key.png; sourceTree = "<group>"; };
C6D68B550F212558000CB3C6 /* LastifyController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LastifyController.h; sourceTree = "<group>"; };
C6D68B560F212558000CB3C6 /* LastifyController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LastifyController.m; sourceTree = "<group>"; };
C6D68B5D0F212820000CB3C6 /* LastifyInterface.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LastifyInterface.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -95,6 +97,7 @@
C6BE8FEE0F431AB5004BBEB7 /* icon_tag.png */,
C6BE8FEF0F431AB5004BBEB7 /* icon_ban.png */,
C6BE8FF00F431AB5004BBEB7 /* icon_love.png */,
C6BE906A0F432D3A004BBEB7 /* icon_key.png */,
C6D68BF90F21418D000CB3C6 /* lastfm_black.png */,
8D5B49B7048680CD000E48DA /* Info.plist */,
089C167DFE841241C02AAC07 /* InfoPlist.strings */,
Expand Down Expand Up @@ -210,6 +213,7 @@
C6BE8FF10F431AB5004BBEB7 /* icon_tag.png in Resources */,
C6BE8FF20F431AB5004BBEB7 /* icon_ban.png in Resources */,
C6BE8FF30F431AB5004BBEB7 /* icon_love.png in Resources */,
C6BE906B0F432D3A004BBEB7 /* icon_key.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 3 additions & 1 deletion LastifyController.h
Expand Up @@ -20,6 +20,7 @@
IBOutlet NSButton *loveButton;
IBOutlet NSButton *banButton;
IBOutlet NSButton *tagButton;
IBOutlet NSButton *loginButton;

NSString *currentTrack;
NSString *currentArtist;
Expand All @@ -37,12 +38,13 @@
- (void)initLastfmConnection;
- (void)loadUserInterface;

- (IBAction)authComplete:(id)sender;
- (IBAction)loveTrack:(id)sender;
- (IBAction)banTrack:(id)sender;
- (IBAction)tagTrack:(id)sender;

- (IBAction)taggingOK:(id)sender;
- (IBAction)taggingCancel:(id)sender;

- (IBAction)auth:(id)sender;

@end
39 changes: 36 additions & 3 deletions LastifyController.m
Expand Up @@ -62,7 +62,7 @@ - (void)dealloc
- (void)initLastfmConnection
{
lastfm = [[LastifyLastfmClient alloc] initWithAPIKey:@"aa31898c9c79401a7ddaa6c8f089ccad" APISecret:@"92773b344ec2e14cd6f5780b83c06265"];
[lastfm authenticate];
[lastfm authenticateQuietly];
}

- (void)loadUserInterface
Expand All @@ -72,6 +72,7 @@ - (void)loadUserInterface
[loveButton setTextColor:[NSColor whiteColor]];
[banButton setTextColor:[NSColor whiteColor]];
[tagButton setTextColor:[NSColor whiteColor]];
[loginButton setTextColor:[NSColor whiteColor]];

[drawer setParentWindow:[[SPController sharedController] mainWindow]];
NSSize contentSize = NSMakeSize(71, 200);
Expand All @@ -85,9 +86,41 @@ - (void)loadUserInterface
[drawer setContentSize:contentSize];
}

- (IBAction)authComplete:(id)sender
- (IBAction)auth:(id)sender
{
[lastfm startNewSession];
if(lastfm.sessionKey)
return;

[lastfm authenticateQuietly];
if(lastfm.sessionKey)
return;

NSAlert *authAlert = [NSAlert
alertWithMessageText:@"You must authorise Lastify to access your Last.fm profile information"
defaultButton:@"Continue"
alternateButton:@"Cancel"
otherButton:nil
informativeTextWithFormat:@"If you click OK the Last.fm website will open so you can authorise Lastify"];

if([authAlert runModal] == NSAlertAlternateReturn)
return;

[lastfm authenticate];

if(lastfm.waitingForUserAuth)
{
NSAlert *authCompleteAlert = [NSAlert
alertWithMessageText:@"Authorisation is complete"
defaultButton:@"Continue"
alternateButton:@"Cancel"
otherButton:nil
informativeTextWithFormat:@"I've authorised Lastify to access my Last.fm profile"];

if([authCompleteAlert runModal] == NSAlertAlternateReturn)
return;

[lastfm startNewSession];
}
}

- (IBAction)loveTrack:(id)sender
Expand Down

0 comments on commit 2fa2c62

Please sign in to comment.