01: package org.claros.mini.controllers;
02:
03: import org.claros.commons.mail.models.ConnectionMetaHandler;
04: import org.claros.commons.mail.models.ConnectionProfile;
05: import org.claros.commons.mail.protocols.ImapProtocolImpl;
06: import org.claros.commons.mail.protocols.ProtocolFactory;
07: import org.claros.commons.models.AuthProfile;
08:
09: /**
10: * @author Umut Gokbayrak
11: */
12: public class ImapInboxControllerImpl extends InboxControllerBase
13: implements InboxController {
14:
15: /**
16: * @param auth
17: * @param profile
18: * @param handler
19: */
20: public ImapInboxControllerImpl(AuthProfile auth,
21: ConnectionProfile profile, ConnectionMetaHandler handler) {
22: super (auth, profile, handler);
23: }
24:
25: /* (non-Javadoc)
26: * @see org.claros.groupware.webmail.controllers.InboxController#checkEmail()
27: */
28: public ConnectionMetaHandler checkEmail() throws Exception {
29: // fetch all messages from the remote pop3 server
30: ProtocolFactory factory = new ProtocolFactory(profile, auth,
31: handler);
32: ImapProtocolImpl protocol = (ImapProtocolImpl) factory
33: .getImap(null);
34:
35: if (handler == null || !handler.getStore().isConnected()) {
36: handler = protocol
37: .connect(org.claros.commons.mail.utility.Constants.CONNECTION_READ_WRITE);
38: }
39: // for imap fetching the message headers is enough. No need to fetch the whole message.
40: // pros: performance gain. cons: spam protection is done only with the message headers.
41: protocol.fetchAllHeadersAsMessages();
42:
43: return handler;
44: }
45: }
|