1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
//
// MCOSMTPSession.m
// mailcore2
//
// Created by DINH Viêt Hoà on 3/29/13.
// Copyright (c) 2013 MailCore. All rights reserved.
//
#import "MCOSMTPSession.h"
#include "MCAsyncSMTP.h"
#import "MCOUtils.h"
#import "MCOSMTPSendOperation.h"
#import "MCOSMTPOperation.h"
#import "MCOOperation+Private.h"
#import "MCOAddress.h"
#import "MCOSMTPOperation+Private.h"
@implementation MCOSMTPSession {
mailcore::SMTPAsyncSession * _session;
}
#define nativeType mailcore::SMTPAsyncSession
- (mailcore::Object *) mco_mcObject
{
return _session;
}
- (id)init {
self = [super init];
if (self) {
_session = new mailcore::SMTPAsyncSession();
}
return self;
}
- (void)dealloc {
_session->release();
[super dealloc];
}
MCO_OBJC_SYNTHESIZE_STRING(setHostname, hostname)
MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setPort, port)
MCO_OBJC_SYNTHESIZE_STRING(setUsername, username)
MCO_OBJC_SYNTHESIZE_STRING(setPassword, password)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOAuthType, mailcore::AuthType, setAuthType, authType)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConnectionType, connectionType)
MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout)
MCO_OBJC_SYNTHESIZE_BOOL(setCheckCertificateEnabled, isCheckCertificateEnabled)
MCO_OBJC_SYNTHESIZE_BOOL(setUseHeloIPEnabled, useHeloIPEnabled)
#pragma mark - Operations
- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData
{
mailcore::SMTPOperation * coreOp = MCO_NATIVE_INSTANCE->sendMessageOperation([messageData mco_mcData]);
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));
MCOSMTPOperation * result = [[[MCOSMTPOperation alloc] initWithMCOperation:coreOp] autorelease];
[result setSession:self];
return result;
}
@end
|