aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/pop/MCPOPSession.h
blob: 1f9af5cc8de2e1a216e133a8e75b4d0678047f09 (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
#ifndef __MAILCORE_MCPOPSESSION_H_

#define __MAILCORE_MCPOPSESSION_H_

#include <mailcore/MCBaseTypes.h>
#include <mailcore/MCMessageConstants.h>
#include <libetpan/libetpan.h>

#ifdef __cplusplus

namespace mailcore {
	
	class POPMessageInfo;
	class POPProgressCallback;
	class MessageHeader;

	class POPSession : public Object {
	private:
		String * mHostname;
		unsigned int mPort;
		String * mUsername;
		String * mPassword;
		AuthType mAuthType;
		ConnectionType mConnectionType;
		bool mCheckCertificateEnabled;
		time_t mTimeout;
		
		mailpop3 * mPop;
		POPCapability mCapabilities;
		POPProgressCallback * mProgressCallback;
		int mState;
		
		void init();
		void bodyProgress(unsigned int current, unsigned int maximum);
		bool checkCertificate();
		static void body_progress(size_t current, size_t maximum, void * context);
		void setup();
		void unsetup();
		void connectIfNeeded(ErrorCode * pError);
		void loginIfNeeded(ErrorCode * pError);
		void listIfNeeded(ErrorCode * pError);
		
	public:
		POPSession();
		virtual ~POPSession();
		
		virtual void setHostname(String * hostname);
		virtual String * hostname();

		virtual void setPort(unsigned int port);
		virtual unsigned int port();

		virtual void setUsername(String * username);
		virtual String * username();

		virtual void setPassword(String * password);
		virtual String * password();

		virtual void setAuthType(AuthType authType);
		virtual AuthType authType();

		virtual void setConnectionType(ConnectionType connectionType);
		virtual ConnectionType connectionType();

		virtual void setTimeout(time_t timeout);
		virtual time_t timeout();
		
		virtual void setCheckCertificateEnabled(bool enabled);
		virtual bool isCheckCertificateEnabled();

		virtual void connect(ErrorCode * pError);
		virtual void disconnect();
		
		virtual void login(ErrorCode * pError);
		
		Array * /* POPMessageInfo */ fetchMessages(ErrorCode * pError);
		
		MessageHeader * fetchHeader(unsigned int index, ErrorCode * pError);
		MessageHeader * fetchHeader(POPMessageInfo * msg, ErrorCode * pError);
		
		Data * fetchMessage(unsigned int index, POPProgressCallback * callback, ErrorCode * pError);
		Data * fetchMessage(POPMessageInfo * msg, POPProgressCallback * callback, ErrorCode * pError);
		
		void deleteMessage(unsigned int index, ErrorCode * pError);
		void deleteMessage(POPMessageInfo * msg, ErrorCode * pError);
	};

}

#endif

#endif