-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Finished Amazon search authentication - Made Info.plist's preprocessed - Refactored out a base class for REST based searches
- Loading branch information
Showing
24 changed files
with
650 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
build | ||
junk | ||
sparkle_private.pem | ||
Plugins/Amazon/Access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// MZRESTSearch.h | ||
// MetaZ | ||
// | ||
// Created by Brian Olsen on 18/11/09. | ||
// Copyright 2009 Maven-Group. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <MetaZKit/MZRESTWrapper.h> | ||
#import <MetaZKit/MZSearchProvider.h> | ||
|
||
@interface MZRESTSearch : NSOperation <MZRESTWrapperDelegate> | ||
{ | ||
id provider; | ||
MZRESTWrapper* wrapper; | ||
id<MZSearchProviderDelegate> delegate; | ||
NSURL* searchURL; | ||
NSString* verb; | ||
NSDictionary* parameters; | ||
BOOL isFinished; | ||
BOOL isExecuting; | ||
} | ||
@property(assign) BOOL isFinished; | ||
@property(assign) BOOL isExecuting; | ||
|
||
- (id)initWithProvider:(id)provider delegate:(id<MZSearchProviderDelegate>)delegate url:(NSURL *)url usingVerb:(NSString *)verb parameters:(NSDictionary *)params; | ||
- (void)start; | ||
- (BOOL)isConcurrent; | ||
- (BOOL)isExecuting; | ||
- (BOOL)isFinished; | ||
- (void)cancel; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// | ||
// MZRESTSearch.m | ||
// MetaZ | ||
// | ||
// Created by Brian Olsen on 18/11/09. | ||
// Copyright 2009 Maven-Group. All rights reserved. | ||
// | ||
|
||
#import "MZRESTSearch.h" | ||
#import "MZSearchProvider.h" | ||
|
||
@implementation MZRESTSearch | ||
@synthesize isFinished; | ||
@synthesize isExecuting; | ||
|
||
- (id)initWithProvider:(id)theProvider delegate:(id<MZSearchProviderDelegate>)theDelegate url:(NSURL *)url usingVerb:(NSString *)theVerb parameters:(NSDictionary *)params; | ||
{ | ||
self = [super init]; | ||
if(self) | ||
{ | ||
searchURL = [url retain]; | ||
verb = [theVerb retain]; | ||
parameters = [params retain]; | ||
provider = [theProvider retain]; | ||
delegate = [theDelegate retain]; | ||
wrapper = [[MZRESTWrapper alloc] init]; | ||
wrapper.delegate = self; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
self.isExecuting = NO; | ||
self.isFinished = YES; | ||
[parameters release]; | ||
[searchURL release]; | ||
[verb release]; | ||
[wrapper cancelConnection]; | ||
[wrapper release]; | ||
[delegate release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (void)start | ||
{ | ||
self.isExecuting = YES; | ||
if([self isCancelled]) | ||
{ | ||
id del = delegate; | ||
[del performSelectorOnMainThread:@selector(searchFinished) withObject:nil waitUntilDone:NO]; | ||
//[delegate searchFinished]; | ||
self.isExecuting = NO; | ||
self.isFinished = YES; | ||
} | ||
else | ||
[wrapper sendRequestTo:searchURL usingVerb:verb withParameters:parameters]; | ||
} | ||
|
||
- (BOOL)isConcurrent | ||
{ | ||
return YES; | ||
} | ||
|
||
/* | ||
- (BOOL)isExecuting | ||
{ | ||
return wrapper.connection != nil; | ||
} | ||
- (BOOL)isFinished | ||
{ | ||
return self.finished; | ||
} | ||
*/ | ||
|
||
- (void)cancel | ||
{ | ||
[super cancel]; | ||
if(self.isExecuting) | ||
[wrapper cancelConnection]; | ||
} | ||
|
||
#pragma mark - MZRESTWrapperDelegate | ||
|
||
- (void)wrapper:(MZRESTWrapper *)theWrapper didRetrieveData:(NSData *)data | ||
{ | ||
//NSLog(@"Got response:\n%@", [theWrapper responseAsText]); | ||
[delegate searchProvider:provider result:[NSArray array]]; | ||
[delegate searchFinished]; | ||
self.isExecuting = NO; | ||
self.isFinished = YES; | ||
} | ||
|
||
- (void)wrapper:(MZRESTWrapper *)theWrapper didFailWithError:(NSError *)error | ||
{ | ||
NSLog(@"%@ search failed: %@", [self class], [error localizedDescription]); | ||
[delegate searchFinished]; | ||
self.isExecuting = NO; | ||
self.isFinished = YES; | ||
} | ||
|
||
- (void)wrapper:(MZRESTWrapper *)theWrapper didReceiveStatusCode:(int)statusCode | ||
{ | ||
NSLog(@"%@ got status code: %d", [self class], statusCode); | ||
[delegate searchFinished]; | ||
self.isExecuting = NO; | ||
self.isFinished = YES; | ||
} | ||
|
||
- (void)wrapperWasCanceled:(MZRESTWrapper *)theWrapper | ||
{ | ||
if(self.isExecuting) | ||
[delegate searchFinished]; | ||
self.isExecuting = NO; | ||
self.isFinished = YES; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.