aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/pop/MCOPOPFetchHeaderOperation.mm
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-03-30 19:42:26 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-03-30 19:42:26 -0700
commit1e5482c0745a77b158ac07e1cc602f9ab2cc0caa (patch)
treecdcfff5920c926f0f3b681210905aa5ead1e9137 /src/objc/pop/MCOPOPFetchHeaderOperation.mm
parentc51a8a2b44e6934de9d45d74ddec4b70b00f1abb (diff)
Implemented ObjC API for SMTP and POP
Diffstat (limited to 'src/objc/pop/MCOPOPFetchHeaderOperation.mm')
-rw-r--r--src/objc/pop/MCOPOPFetchHeaderOperation.mm56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/objc/pop/MCOPOPFetchHeaderOperation.mm b/src/objc/pop/MCOPOPFetchHeaderOperation.mm
new file mode 100644
index 00000000..f7efea81
--- /dev/null
+++ b/src/objc/pop/MCOPOPFetchHeaderOperation.mm
@@ -0,0 +1,56 @@
+//
+// MCOFetchHeaderOperation.m
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 3/29/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#import "MCOPOPFetchHeaderOperation.h"
+
+#include "MCAsyncPOP.h"
+
+#import "MCOUtils.h"
+#import "MCOOperation+Private.h"
+
+typedef void (^CompletionType)(NSError *error, MCOMessageHeader * header);
+
+@implementation MCOPOPFetchHeaderOperation {
+ CompletionType _completionBlock;
+}
+
+#define nativeType mailcore::POPFetchHeaderOperation
+
++ (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, MCOMessageHeader * header))completionBlock
+{
+ _completionBlock = [completionBlock copy];
+ [self start];
+}
+
+- (void)operationCompleted {
+ nativeType *op = MCO_NATIVE_INSTANCE;
+ if (op->error() == mailcore::ErrorNone) {
+ _completionBlock(nil, MCO_TO_OBJC(op->header()));
+ } else {
+ _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil);
+ }
+}
+
+@end