aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/pop/MCOPOPSession.h
blob: 6ecca042f8a5ce0e85d90a2b8533b78f9e668f63 (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
//
//  MCOPOPSession.h
//  mailcore2
//
//  Created by DINH Viêt Hoà on 3/29/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#ifndef __MAILCORE_MCOPOPSESSION_H_

#define __MAILCORE_MCOPOPSESSION_H_

#import <Foundation/Foundation.h>

#import <MailCore/MCOConstants.h>

@class MCOPOPFetchMessagesOperation;
@class MCOPOPFetchHeaderOperation;
@class MCOPOPFetchMessageOperation;
@class MCOPOPOperation;
@class MCOIndexSet;

/** This class implements asynchronous access to the POP3 protocol.*/

@interface MCOPOPSession : NSObject

/** This is the hostname of the POP3 server to connect to.*/
@property (nonatomic, copy) NSString * hostname;

/** This is the port of the POP3 server to connect to.*/
@property (nonatomic, assign) unsigned int port;

/** This is the username of the account.*/
@property (nonatomic, copy) NSString * username;

/** This is the password of the account.*/
@property (nonatomic, copy) NSString * password;

/** 
 This is the authentication type to use to connect.
 `MCOAuthTypeSASLNone` means that it uses the clear-text is used (and is the default).
 @warning *Important*: Over an encrypted connection like TLS, the password will still be secure
*/
@property (nonatomic, assign) MCOAuthType authType;

/** This is the encryption type to use.
See MCOConnectionType for more information.*/
@property (nonatomic, assign) MCOConnectionType connectionType;

/** This is the timeout of the connection.*/
@property (nonatomic, assign) NSTimeInterval timeout;

/** When set to YES, the connection will fail if the certificate is incorrect.*/
@property (nonatomic, assign, getter=isCheckCertificateEnabled) BOOL checkCertificateEnabled;

/** @name Operations */

/**
 Returns an operation that will fetch the list of messages.

     MCOPOPFetchMessagesOperation * op = [session fetchMessagesOperation];
     [op start:^(NSError * error, NSArray * messages) {
        // messages is an array of MCOPOPMessageInfo
        // [info index] can be used as reference for a given message in the other operations.
     }];
*/
- (MCOPOPFetchMessagesOperation *) fetchMessagesOperation;

/**
 Returns an operation that will fetch the header of the given message.

     MCOPOPFetchHeaderOperation * op = [session fetchHeaderOperationWithIndex:idx];
     [op start:^(NSError * error, MCOMessageHeader * header) {
          // header is the parsed header of the message.
     }];
*/  
- (MCOPOPFetchHeaderOperation *) fetchHeaderOperationWithIndex:(unsigned int)index;

/**
 Returns an operation that will fetch the content of the given message.

     MCOPOPFetchMessageOperation * op = [session fetchMessageOperationWithIndex:idx];
     [op start:^(NSError * error, NSData * messageData) {
          // messageData is the RFC 822 formatted message data.
     }];
*/
- (MCOPOPFetchMessageOperation *) fetchMessageOperationWithIndex:(unsigned int)index;

/**
 Returns an operation that will delete the given messages.
 Will disconnect when finished.

     MCOIndexSet * indexes = [MCOIndexSet indexSet];
     [indexes addIndex:1];
     [indexes addIndex:2];
     [indexes addIndex:3];
     MCOPOPOperation * op = [session deleteMessagesOperationWithIndexes:indexes];
     [op start:^(NSError * error) {
          ...
     }];
*/
- (MCOPOPOperation *) deleteMessagesOperationWithIndexes:(MCOIndexSet *)indexes;

/**
 Returns an operation that will disconnect the session.
 
 MCOPOPOperation * op = [session disconnectOperation];
 [op start:^(NSError * error) {
 ...
 }];
 */
- (MCOPOPOperation *) disconnectOperation;

/**
 Returns an operation that will check whether the POP account is valid.

     MCOPOPOperation * op = [session checkAccountOperation];
     [op start:^(NSError * error) {
          ...
     }];
*/
- (MCOPOPOperation *) checkAccountOperation;

@end

#endif