// // MCOIMAPCapabilityOperation.m // mailcore2 // // Created by DINH Viêt Hoà on 3/25/13. // Copyright (c) 2013 MailCore. All rights reserved. // #import "MCOIMAPCapabilityOperation.h" #include "MCAsyncIMAP.h" #import "MCOOperation+Private.h" #import "MCOUtils.h" typedef void (^completionType)(NSError *error, MCOIndexSet * capabilities); @implementation MCOIMAPCapabilityOperation { completionType _completionBlock; } #define nativeType mailcore::IMAPCapabilityOperation + (void) load { MCORegisterClass(self, &typeid(nativeType)); } + (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object { nativeType * op = (nativeType *) object; return [[[self alloc] initWithMCOperation:op] autorelease]; } - (void) dealloc { [_completionBlock release]; [super dealloc]; } - (void)start:(void (^)(NSError *error, MCOIndexSet * capabilities))completionBlock { _completionBlock = [completionBlock copy]; [self start]; } - (void)operationCompleted { nativeType *op = MCO_NATIVE_INSTANCE; if (op->error() == mailcore::ErrorNone) { _completionBlock(nil, MCO_TO_OBJC(op->capabilities())); } else { _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); } } @end