aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async/pop/MCPOPAsyncSession.cc
blob: 39f356db961e5953aa90673afcd4898547787aa5 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//
//  MCPopAsyncSession.cpp
//  mailcore2
//
//  Created by DINH Viêt Hoà on 1/16/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#include "MCPOPAsyncSession.h"

#include "MCPOP.h"
#include "MCPOPFetchHeaderOperation.h"
#include "MCPOPFetchMessageOperation.h"
#include "MCPOPDeleteMessagesOperation.h"
#include "MCPOPFetchMessagesOperation.h"
#include "MCPOPCheckAccountOperation.h"

using namespace mailcore;

POPAsyncSession::POPAsyncSession()
{
    mSession = new POPSession();
    mQueue = new OperationQueue();
}

POPAsyncSession::~POPAsyncSession()
{
    MC_SAFE_RELEASE(mSession);
    MC_SAFE_RELEASE(mQueue);
}

void POPAsyncSession::setHostname(String * hostname)
{
    mSession->setHostname(hostname);
}

String * POPAsyncSession::hostname()
{
    return mSession->hostname();
}

void POPAsyncSession::setPort(unsigned int port)
{
    mSession->setPort(port);
}

unsigned int POPAsyncSession::port()
{
    return mSession->port();
}

void POPAsyncSession::setUsername(String * username)
{
    mSession->setUsername(username);
}

String * POPAsyncSession::username()
{
    return mSession->username();
}

void POPAsyncSession::setPassword(String * password)
{
    mSession->setPassword(password);
}

String * POPAsyncSession::password()
{
    return mSession->password();
}

void POPAsyncSession::setAuthType(AuthType authType)
{
    mSession->setAuthType(authType);
}

AuthType POPAsyncSession::authType()
{
    return mSession->authType();
}

void POPAsyncSession::setConnectionType(ConnectionType connectionType)
{
    mSession->setConnectionType(connectionType);
}

ConnectionType POPAsyncSession::connectionType()
{
    return mSession->connectionType();
}

void POPAsyncSession::setTimeout(time_t timeout)
{
    mSession->setTimeout(timeout);
}

time_t POPAsyncSession::timeout()
{
    return mSession->timeout();
}

void POPAsyncSession::setCheckCertificateEnabled(bool enabled)
{
    mSession->setCheckCertificateEnabled(enabled);
}

bool POPAsyncSession::isCheckCertificateEnabled()
{
    return mSession->isCheckCertificateEnabled();
}

POPFetchMessagesOperation * POPAsyncSession::fetchMessagesOperation()
{
    POPFetchMessagesOperation * op = new POPFetchMessagesOperation();
    op->setSession(this);
    op->autorelease();
    return op;
}

POPFetchHeaderOperation * POPAsyncSession::fetchHeaderOperation(unsigned int index)
{
    POPFetchHeaderOperation * op = new POPFetchHeaderOperation();
    op->setSession(this);
    op->setMessageIndex(index);
    op->autorelease();
    return op;
}

POPFetchMessageOperation * POPAsyncSession::fetchMessageOperation(unsigned int index)
{
    POPFetchMessageOperation * op = new POPFetchMessageOperation();
    op->setSession(this);
    op->setMessageIndex(index);
    op->autorelease();
    return op;
}

POPOperation * POPAsyncSession::deleteMessagesOperation(IndexSet * indexes)
{
    POPDeleteMessagesOperation * op = new POPDeleteMessagesOperation();
    op->setSession(this);
    op->setMessageIndexes(indexes);
    op->autorelease();
    return op;
}

POPOperation * POPAsyncSession::disconnectOperation()
{
    return deleteMessagesOperation(IndexSet::indexSet());
}

POPOperation * POPAsyncSession::checkAccountOperation()
{
    POPCheckAccountOperation * op = new POPCheckAccountOperation();
    op->setSession(this);
    op->autorelease();
    return op;
}

POPSession * POPAsyncSession::session()
{
    return mSession;
}

void POPAsyncSession::runOperation(POPOperation * operation)
{
#warning disconnect after delay
    mQueue->addOperation(operation);
}