aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc
diff options
context:
space:
mode:
Diffstat (limited to 'src/objc')
-rw-r--r--src/objc/imap/MCOIMAPBaseOperation+Private.h20
-rw-r--r--src/objc/imap/MCOIMAPBaseOperation.mm15
-rw-r--r--src/objc/imap/MCOIMAPOperation.h4
-rw-r--r--src/objc/imap/MCOIMAPSession.mm70
-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
7 files changed, 122 insertions, 30 deletions
diff --git a/src/objc/imap/MCOIMAPBaseOperation+Private.h b/src/objc/imap/MCOIMAPBaseOperation+Private.h
new file mode 100644
index 00000000..e744355a
--- /dev/null
+++ b/src/objc/imap/MCOIMAPBaseOperation+Private.h
@@ -0,0 +1,20 @@
+//
+// Header.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 6/22/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCOIMAPBASEOPERATION_PRIVATE_H_
+#define __MAILCORE_MCOIMAPBASEOPERATION_PRIVATE_H_
+
+@class MCOIMAPSession;
+
+@interface MCOIMAPBaseOperation (Private)
+
+@property (nonatomic, retain) MCOIMAPSession * session;
+
+@end
+
+#endif
diff --git a/src/objc/imap/MCOIMAPBaseOperation.mm b/src/objc/imap/MCOIMAPBaseOperation.mm
index be398ece..ed67e34e 100644
--- a/src/objc/imap/MCOIMAPBaseOperation.mm
+++ b/src/objc/imap/MCOIMAPBaseOperation.mm
@@ -7,10 +7,12 @@
//
#import "MCOIMAPBaseOperation.h"
+#import "MCOIMAPBaseOperation+Private.h"
#import "MCOOperation+Private.h"
#import "MCAsyncIMAP.h"
+#import "MCOIMAPSession.h"
class MCOIMAPBaseOperationIMAPCallback : public mailcore::IMAPOperationCallback {
public:
@@ -33,6 +35,7 @@ private:
@implementation MCOIMAPBaseOperation {
MCOIMAPBaseOperationIMAPCallback * _imapCallback;
+ MCOIMAPSession * _session;
}
- (id) initWithMCOperation:(mailcore::Operation *)op
@@ -47,10 +50,22 @@ private:
- (void) dealloc
{
+ [_session release];
delete _imapCallback;
[super dealloc];
}
+- (void) setSession:(MCOIMAPSession *)session
+{
+ [_session release];
+ _session = [session retain];
+}
+
+- (MCOIMAPSession *) session
+{
+ return _session;
+}
+
- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum
{
}
diff --git a/src/objc/imap/MCOIMAPOperation.h b/src/objc/imap/MCOIMAPOperation.h
index b8ee37e4..6f286596 100644
--- a/src/objc/imap/MCOIMAPOperation.h
+++ b/src/objc/imap/MCOIMAPOperation.h
@@ -12,9 +12,9 @@
/** This class implements a generic IMAP operation */
-#import <MailCore/MCOOperation.h>
+#import <MailCore/MCOIMAPBaseOperation.h>
-@interface MCOIMAPOperation : MCOOperation
+@interface MCOIMAPOperation : MCOIMAPBaseOperation
/**
Starts the asynchronous append operation.
diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm
index a13724ae..a8df8aed 100644
--- a/src/objc/imap/MCOIMAPSession.mm
+++ b/src/objc/imap/MCOIMAPSession.mm
@@ -13,6 +13,7 @@
#import "MCOObjectWrapper.h"
#import "MCOIMAPOperation.h"
#import "MCOIMAPFetchFoldersOperation.h"
+#import "MCOIMAPBaseOperation+Private.h"
#import "MCOUtils.h"
@@ -60,57 +61,74 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
#pragma mark - Operations
+#define MCO_TO_OBJC_OP(op) [self _objcOperationFromNativeOp:op];
+#define OPAQUE_OPERATION(op) [self _objcOpaqueOperationFromNativeOp:op]
+
+- (id) _objcOperationFromNativeOp:(IMAPOperation *)op
+{
+ MCOIMAPBaseOperation * result = MCO_TO_OBJC(op);
+ [result setSession:self];
+ return result;
+}
+
+- (id) _objcOpaqueOperationFromNativeOp:(IMAPOperation *)op
+{
+ MCOIMAPOperation * result = [[[MCOIMAPOperation alloc] initWithMCOperation:op] autorelease];
+ [result setSession:self];
+ return result;
+}
+
- (MCOIMAPFolderInfoOperation *) folderInfoOperation:(NSString *)folder
{
IMAPFolderInfoOperation * coreOp = MCO_NATIVE_INSTANCE->folderInfoOperation([folder mco_mcString]);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFolderStatusOperation *) folderStatusOperation:(NSString *)folder
{
IMAPFolderStatusOperation * coreOp = MCO_NATIVE_INSTANCE->folderStatusOperation([folder mco_mcString]);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchFoldersOperation *) fetchSubscribedFoldersOperation
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->fetchSubscribedFoldersOperation();
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchFoldersOperation *)fetchAllFoldersOperation {
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->fetchAllFoldersOperation();
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPOperation *) renameFolderOperation:(NSString *)folder otherName:(NSString *)otherName
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->renameFolderOperation([folder mco_mcString], [otherName mco_mcString]);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPOperation *) deleteFolderOperation:(NSString *)folder
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->deleteFolderOperation([folder mco_mcString]);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPOperation *) createFolderOperation:(NSString *)folder
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->createFolderOperation([folder mco_mcString]);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPOperation *) subscribeFolderOperation:(NSString *)folder
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->subscribeFolderOperation([folder mco_mcString]);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPOperation *) unsubscribeFolderOperation:(NSString *)folder
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->unsubscribeFolderOperation([folder mco_mcString]);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPAppendMessageOperation *)appendMessageOperationWithFolder:(NSString *)folder
@@ -120,7 +138,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
IMAPAppendMessageOperation * coreOp = MCO_NATIVE_INSTANCE->appendMessageOperation([folder mco_mcString],
[messageData mco_mcData],
(MessageFlag) flags);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPCopyMessagesOperation *)copyMessagesOperationWithFolder:(NSString *)folder
@@ -130,14 +148,14 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
IMAPCopyMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->copyMessagesOperation([folder mco_mcString],
MCO_FROM_OBJC(IndexSet, uids),
[destFolder mco_mcString]);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPOperation *) expungeOperation:(NSString *)folder
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->expungeOperation([folder mco_mcString]);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPFetchMessagesOperation *) fetchMessagesByUIDOperationWithFolder:(NSString *)folder
@@ -147,7 +165,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
IMAPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->fetchMessagesByUIDOperation([folder mco_mcString],
(IMAPMessagesRequestKind) requestKind,
MCO_FROM_OBJC(IndexSet, uids));
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchMessagesOperation *) fetchMessagesByNumberOperationWithFolder:(NSString *)folder
@@ -157,7 +175,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
IMAPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->fetchMessagesByNumberOperation([folder mco_mcString],
(IMAPMessagesRequestKind) requestKind,
MCO_FROM_OBJC(IndexSet, numbers));
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchMessagesOperation *) syncMessagesByUIDWithFolder:(NSString *)folder
@@ -169,7 +187,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
(IMAPMessagesRequestKind) requestKind,
MCO_FROM_OBJC(IndexSet, uids),
modSeq);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchContentOperation *) fetchMessageByUIDOperationWithFolder:(NSString *)folder
@@ -177,7 +195,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
urgent:(BOOL)urgent
{
IMAPFetchContentOperation * coreOp = MCO_NATIVE_INSTANCE->fetchMessageByUIDOperation([folder mco_mcString], uid, urgent);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchContentOperation *) fetchMessageByUIDOperationWithFolder:(NSString *)folder
@@ -197,7 +215,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
[partID mco_mcString],
(Encoding) encoding,
urgent);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchContentOperation *) fetchMessageAttachmentByUIDOperationWithFolder:(NSString *)folder
@@ -217,7 +235,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
MCO_FROM_OBJC(IndexSet, uids),
(IMAPStoreFlagsRequestKind) kind,
(MessageFlag) flags);
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPOperation *) storeLabelsOperationWithFolder:(NSString *)folder
@@ -229,7 +247,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
MCO_FROM_OBJC(IndexSet, uids),
(IMAPStoreFlagsRequestKind) kind,
MCO_FROM_OBJC(Array, labels));
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPSearchOperation *) searchOperationWithFolder:(NSString *)folder
@@ -239,7 +257,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
IMAPSearchOperation * coreOp = MCO_NATIVE_INSTANCE->searchOperation([folder mco_mcString],
(IMAPSearchKind) kind,
[searchString mco_mcString]);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPSearchOperation *) searchExpressionOperationWithFolder:(NSString *)folder
@@ -247,20 +265,20 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
{
IMAPSearchOperation * coreOp = MCO_NATIVE_INSTANCE->searchOperation([folder mco_mcString],
MCO_FROM_OBJC(IMAPSearchExpression, expression));
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPIdleOperation *) idleOperationWithFolder:(NSString *)folder
lastKnownUID:(uint32_t)lastKnownUID
{
IMAPIdleOperation * coreOp = MCO_NATIVE_INSTANCE->idleOperation([folder mco_mcString], lastKnownUID);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPFetchNamespaceOperation *) fetchNamespaceOperation
{
IMAPFetchNamespaceOperation * coreOp = MCO_NATIVE_INSTANCE->fetchNamespaceOperation();
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPIdentityOperation *) identityOperationWithVendor:(NSString *)vendor
@@ -270,19 +288,19 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
IMAPIdentityOperation * coreOp = MCO_NATIVE_INSTANCE->identityOperation([vendor mco_mcString],
[name mco_mcString],
[version mco_mcString]);
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
- (MCOIMAPOperation *)checkAccountOperation
{
IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation();
- return [[[MCOIMAPOperation alloc] initWithMCOperation:coreOp] autorelease];
+ return OPAQUE_OPERATION(coreOp);
}
- (MCOIMAPCapabilityOperation *) capabilityOperation
{
IMAPCapabilityOperation * coreOp = MCO_NATIVE_INSTANCE->capabilityOperation();
- return MCO_TO_OBJC(coreOp);
+ return MCO_TO_OBJC_OP(coreOp);
}
@end
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