aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/smtp
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-06-22 22:28:41 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-06-22 22:29:05 -0700
commit9682845dd6a6985f396a93ff95adc1dcdeae8861 (patch)
tree67e053e5e87b5c228191440116c1b839dbf2aecc /src/objc/smtp
parent74752eb7c987a2c1704f6f92486e4a4d3f77cbfb (diff)
Retain session when IMAP and SMTP operations are running. Fixed #127, fixed #128.
Diffstat (limited to 'src/objc/smtp')
-rw-r--r--src/objc/smtp/MCOSMTPOperation+Private.h20
-rw-r--r--src/objc/smtp/MCOSMTPOperation.mm14
-rw-r--r--src/objc/smtp/MCOSMTPSession.mm9
3 files changed, 41 insertions, 2 deletions
diff --git a/src/objc/smtp/MCOSMTPOperation+Private.h b/src/objc/smtp/MCOSMTPOperation+Private.h
new file mode 100644
index 00000000..5b9b5ee9
--- /dev/null
+++ b/src/objc/smtp/MCOSMTPOperation+Private.h
@@ -0,0 +1,20 @@
+//
+// MCOSMTPOperation+Private.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 6/22/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCOSMTPOPERATION_PRIVATE_H_
+#define __MAILCORE_MCOSMTPOPERATION_PRIVATE_H_
+
+@class MCOSMTPSession;
+
+@interface MCOSMTPOperation (Private)
+
+@property (nonatomic, retain) MCOSMTPSession * session;
+
+@end
+
+#endif
diff --git a/src/objc/smtp/MCOSMTPOperation.mm b/src/objc/smtp/MCOSMTPOperation.mm
index d95c434d..cd52ad13 100644
--- a/src/objc/smtp/MCOSMTPOperation.mm
+++ b/src/objc/smtp/MCOSMTPOperation.mm
@@ -12,17 +12,20 @@
#import "MCOUtils.h"
#import "MCOOperation+Private.h"
+#import "MCOSMTPSession.h"
typedef void (^CompletionType)(NSError *error);
@implementation MCOSMTPOperation {
CompletionType _completionBlock;
+ MCOSMTPSession * _session;
}
#define nativeType mailcore::SMTPOperation
- (void) dealloc
{
+ [_session release];
[_completionBlock release];
[super dealloc];
}
@@ -40,4 +43,15 @@ typedef void (^CompletionType)(NSError *error);
_completionBlock(error);
}
+- (void) setSession:(MCOSMTPSession *)session
+{
+ [_session release];
+ _session = [session retain];
+}
+
+- (MCOSMTPSession *) session
+{
+ return _session;
+}
+
@end
diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm
index ad8f212e..de6b54cd 100644
--- a/src/objc/smtp/MCOSMTPSession.mm
+++ b/src/objc/smtp/MCOSMTPSession.mm
@@ -15,6 +15,7 @@
#import "MCOSMTPOperation.h"
#import "MCOOperation+Private.h"
#import "MCOAddress.h"
+#import "MCOSMTPOperation+Private.h"
@implementation MCOSMTPSession {
mailcore::SMTPAsyncSession * _session;
@@ -55,13 +56,17 @@ MCO_OBJC_SYNTHESIZE_BOOL(setUseHeloIPEnabled, useHeloIPEnabled)
- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData
{
mailcore::SMTPOperation * coreOp = MCO_NATIVE_INSTANCE->sendMessageOperation([messageData mco_mcData]);
- return [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease];
+ MCOSMTPSendOperation * result = [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease];
+ [result setSession:self];
+ return result;
}
- (MCOOperation *) checkAccountOperationWithFrom:(MCOAddress *)from
{
mailcore::SMTPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(MCO_FROM_OBJC(mailcore::Address, from));
- return [[[MCOSMTPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ MCOSMTPOperation * result = [[[MCOSMTPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ [result setSession:self];
+ return result;
}
@end