aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/provider/MCAccountValidator.h
blob: 74447ac3b886afa89b75125f32f9809c44da0c73 (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
//
//  MCAccountValidator.h
//  mailcore2
//
//  Created by Christopher Hockley on 22/01/15.
//  Copyright (c) 2015 MailCore. All rights reserved.
//

#ifndef MAILCORE_MCACCOUNTVALIDATOR_H

#define MAILCORE_MCACCOUNTVALIDATOR_H

#include <MailCore/MCBaseTypes.h>

#ifdef __cplusplus

namespace mailcore {

    class NetService;
    class MailProvider;
    class MXRecordResolverOperation;
    class IMAPAsyncSession;
    class POPAsyncSession;
    class SMTPAsyncSession;
    
    class MAILCORE_EXPORT AccountValidator : public Operation, public OperationCallback {
    public:
        AccountValidator();
        virtual ~AccountValidator();
        
        virtual void setEmail(String * email);
        virtual String * email(); /* for SMTP */
        virtual void setUsername(String * username);
        virtual String * username();
        virtual void setPassword(String * password);
        virtual String * password();
        virtual void setOAuth2Token(String * OAuth2Token);
        virtual String * OAuth2Token();
        
        virtual void setImapServices(Array * imapServices);
        virtual Array * /* NetService */ imapServices();
        virtual void setSmtpServices(Array * smtpServices);
        virtual Array * /* NetService */ smtpServices();
        virtual void setPopServices(Array * popServices);
        virtual Array * /* NetService */ popServices();
        
        // result
        virtual String * identifier();
        virtual NetService * imapServer();
        virtual NetService * popServer();
        virtual NetService * smtpServer();
        virtual ErrorCode imapError();
        virtual ErrorCode popError();
        virtual ErrorCode smtpError();
        
        virtual void start();
        virtual void cancel();
        
    private:
        String * mEmail; /* for SMTP */
        String * mUsername;
        String * mPassword;
        String * mOAuth2Token;
        
        Array * /* NetService */ mImapServices;
        Array * /* NetService */ mSmtpServices;
        Array * /* NetService */ mPopServices;
        
        // result
        String * mIdentifier;
        NetService * mImapServer;
        NetService * mPopServer;
        NetService * mSmtpServer;
        ErrorCode mImapError;
        ErrorCode mPopError;
        ErrorCode mSmtpError;
        
        MailProvider * mProvider;
        
        void resolveMX();
        void resolveMXDone();
        
        void startCheckingHosts();
        void checkNextHost();
        void checkNextHostDone();

        //indexs for services being tested
        int mCurrentServiceIndex;
        int mCurrentServiceTested;
        
        void init();

        Operation * mOperation;
        virtual void operationFinished(Operation * op);
        
        OperationQueue * mQueue;
        MXRecordResolverOperation * mResolveMX;
        
        IMAPAsyncSession * mImapSession;
        POPAsyncSession * mPopSession;
        SMTPAsyncSession * mSmtpSession;
    };
}

#endif

#endif