diff options
author | Matt Ronge <mronge@mronge.com> | 2013-02-01 13:31:50 -0600 |
---|---|---|
committer | Matt Ronge <mronge@mronge.com> | 2013-02-01 13:31:50 -0600 |
commit | 77a7278e3157d902ad7a1b5041c0fe40c9a90369 (patch) | |
tree | 917c65b1500c5d2b87c3a4ef2c751c803eb7e63f /src/objc | |
parent | e759990770cde316ce5d74d3fec155b9bf8d00bb (diff) |
Changed the API around to reflect when Hoa and I decided on for async
Diffstat (limited to 'src/objc')
-rw-r--r-- | src/objc/imap/MCOCheckAccountOperation.h | 1 | ||||
-rw-r--r-- | src/objc/imap/MCOCheckAccountOperation.mm | 11 | ||||
-rw-r--r-- | src/objc/imap/MCOFetchFoldersOperation.h | 2 | ||||
-rw-r--r-- | src/objc/imap/MCOFetchFoldersOperation.mm | 14 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPSession.h | 4 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPSession.mm | 8 | ||||
-rw-r--r-- | src/objc/imap/MCOOperation+Internals.h | 1 | ||||
-rw-r--r-- | src/objc/imap/MCOOperation.h | 6 |
8 files changed, 29 insertions, 18 deletions
diff --git a/src/objc/imap/MCOCheckAccountOperation.h b/src/objc/imap/MCOCheckAccountOperation.h index 340eb4fc..9e66f013 100644 --- a/src/objc/imap/MCOCheckAccountOperation.h +++ b/src/objc/imap/MCOCheckAccountOperation.h @@ -9,4 +9,5 @@ #import <mailcore/MCOOperation.h> @interface MCOCheckAccountOperation : MCOOperation +- (void)start:(void (^)(NSError *error))completionBlock; @end diff --git a/src/objc/imap/MCOCheckAccountOperation.mm b/src/objc/imap/MCOCheckAccountOperation.mm index 2c3c2239..47ea0fc8 100644 --- a/src/objc/imap/MCOCheckAccountOperation.mm +++ b/src/objc/imap/MCOCheckAccountOperation.mm @@ -14,12 +14,21 @@ using namespace mailcore; +@interface MCOCheckAccountOperation () +@property (nonatomic, copy) void (^completionBlock)(NSError *error); +@end + @implementation MCOCheckAccountOperation +- (void)start:(void (^)(NSError *error))completionBlock { + self.completionBlock = completionBlock; + [self start]; +} + - (void)operationCompleted { IMAPOperation *op = dynamic_cast<IMAPOperation *>(self.operation); NSError *error = [NSError mco_errorWithErrorCode:op->error()]; - self.completionBlock(error, self, nil); // No data to return + self.completionBlock(error); } @end diff --git a/src/objc/imap/MCOFetchFoldersOperation.h b/src/objc/imap/MCOFetchFoldersOperation.h index 67a23214..747ca162 100644 --- a/src/objc/imap/MCOFetchFoldersOperation.h +++ b/src/objc/imap/MCOFetchFoldersOperation.h @@ -9,5 +9,5 @@ #import <mailcore/MCOOperation.h> @interface MCOFetchFoldersOperation : MCOOperation - +- (void)start:(void (^)(NSError *error, NSArray *folder))completionBlock; @end diff --git a/src/objc/imap/MCOFetchFoldersOperation.mm b/src/objc/imap/MCOFetchFoldersOperation.mm index 2418666b..8189d294 100644 --- a/src/objc/imap/MCOFetchFoldersOperation.mm +++ b/src/objc/imap/MCOFetchFoldersOperation.mm @@ -16,7 +16,17 @@ using namespace mailcore; +@interface MCOFetchFoldersOperation () +@property (nonatomic, copy) void (^completionBlock)(NSError *error, NSArray *folder); +@end + @implementation MCOFetchFoldersOperation + +- (void)start:(void (^)(NSError *error, NSArray *folder))completionBlock { + self.completionBlock = completionBlock; + [self start]; +} + - (void)operationCompleted { IMAPFetchFoldersOperation *op = dynamic_cast<IMAPFetchFoldersOperation *>(self.operation); if (op->error() == ErrorNone) { @@ -27,9 +37,9 @@ using namespace mailcore; [nsfolders addObject:folder]; } - self.completionBlock(nil, self, nsfolders); + self.completionBlock(nil, nsfolders); } else { - self.completionBlock([NSError mco_errorWithErrorCode:op->error()], self, nil); + self.completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); } } @end diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index ab4a0863..538becec 100644 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -26,6 +26,6 @@ @property (nonatomic, assign) BOOL VoIPEnabled; @property (nonatomic, strong) NSString *delimiter; -- (MCOCheckAccountOperation *)checkAccount:(MCOCompletionBlock)completionBlock; -- (MCOFetchFoldersOperation *)fetchAllFolders:(MCOCompletionBlock)completionBlock; +- (MCOCheckAccountOperation *)checkAccountOperation; +- (MCOFetchFoldersOperation *)fetchAllFoldersOperation; @end diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index c01c6a87..9139f077 100644 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -120,20 +120,16 @@ using namespace mailcore; #pragma mark - Operations -- (MCOCheckAccountOperation *)checkAccount:(MCOCompletionBlock)completionBlock { +- (MCOCheckAccountOperation *)checkAccountOperation { IMAPOperation *coreOp = self.session->checkAccountOperation(); MCOCheckAccountOperation *op = [[MCOCheckAccountOperation alloc] initWithOperation:coreOp]; - op.completionBlock = completionBlock; - [op start]; return [op autorelease]; } -- (MCOFetchFoldersOperation *)fetchAllFolders:(MCOCompletionBlock)completionBlock { +- (MCOFetchFoldersOperation *)fetchAllFoldersOperation { IMAPOperation *coreOp = self.session->fetchAllFoldersOperation(); MCOFetchFoldersOperation *op = [[MCOFetchFoldersOperation alloc] initWithOperation:coreOp]; - op.completionBlock = completionBlock; - [op start]; return [op autorelease]; } diff --git a/src/objc/imap/MCOOperation+Internals.h b/src/objc/imap/MCOOperation+Internals.h index 3f12338d..58b10559 100644 --- a/src/objc/imap/MCOOperation+Internals.h +++ b/src/objc/imap/MCOOperation+Internals.h @@ -14,4 +14,5 @@ @interface MCOOperation () - (id)initWithOperation:(mailcore::Operation *)op; - (mailcore::Operation *)operation; +- (void)start; @end
\ No newline at end of file diff --git a/src/objc/imap/MCOOperation.h b/src/objc/imap/MCOOperation.h index bd13a343..deafa165 100644 --- a/src/objc/imap/MCOOperation.h +++ b/src/objc/imap/MCOOperation.h @@ -8,14 +8,8 @@ #import <Foundation/Foundation.h> -@class MCOOperation; - -typedef void (^MCOCompletionBlock)(NSError *error, MCOOperation *op, id response); - @interface MCOOperation : NSObject -@property (copy) MCOCompletionBlock completionBlock; @property (readonly) BOOL isCancelled; - (void)cancel; -- (void)start; @end |