2008-11-01 17:32:06 -04:00
|
|
|
|
2008-12-16 18:34:01 -05:00
|
|
|
package com.android.email.mail;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
2009-10-21 20:41:06 -04:00
|
|
|
import java.util.List;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
|
2008-12-16 18:34:01 -05:00
|
|
|
import com.android.email.mail.store.ImapStore;
|
|
|
|
import com.android.email.mail.store.LocalStore;
|
|
|
|
import com.android.email.mail.store.Pop3Store;
|
|
|
|
import com.android.email.mail.store.WebDavStore;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Store is the access point for an email message store. It's location can be
|
|
|
|
* local or remote and no specific protocol is defined. Store is intended to
|
|
|
|
* loosely model in combination the JavaMail classes javax.mail.Store and
|
|
|
|
* javax.mail.Folder along with some additional functionality to improve
|
|
|
|
* performance on mobile devices. Implementations of this class should focus on
|
|
|
|
* making as few network connections as possible.
|
|
|
|
*/
|
2009-11-24 19:40:29 -05:00
|
|
|
public abstract class Store
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
/**
|
|
|
|
* A global suggestion to Store implementors on how much of the body
|
|
|
|
* should be returned on FetchProfile.Item.BODY_SANE requests.
|
|
|
|
*/
|
2009-05-20 00:27:51 -04:00
|
|
|
//Matching MessagingController.MAX_SMALL_MESSAGE_SIZE
|
2009-05-21 14:49:39 -04:00
|
|
|
public static final int FETCH_BODY_SANE_SUGGESTED_SIZE = (50 * 1024);
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
protected static final int SOCKET_CONNECT_TIMEOUT = 10000;
|
|
|
|
protected static final int SOCKET_READ_TIMEOUT = 60000;
|
|
|
|
|
|
|
|
private static HashMap<String, Store> mStores = new HashMap<String, Store>();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an instance of a mail store. The URI is parsed as a standard URI and
|
|
|
|
* the scheme is used to determine which protocol will be used. The
|
|
|
|
* following schemes are currently recognized: imap - IMAP with no
|
|
|
|
* connection security. Ex: imap://username:password@host/ imap+tls - IMAP
|
|
|
|
* with TLS connection security, if the server supports it. Ex:
|
|
|
|
* imap+tls://username:password@host imap+tls+ - IMAP with required TLS
|
|
|
|
* connection security. Connection fails if TLS is not available. Ex:
|
|
|
|
* imap+tls+://username:password@host imap+ssl+ - IMAP with required SSL
|
|
|
|
* connection security. Connection fails if SSL is not available. Ex:
|
|
|
|
* imap+ssl+://username:password@host
|
|
|
|
*
|
|
|
|
* @param uri The URI of the store.
|
|
|
|
* @return
|
|
|
|
* @throws MessagingException
|
|
|
|
*/
|
2009-11-24 19:40:29 -05:00
|
|
|
public synchronized static Store getInstance(String uri, Application application) throws MessagingException
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
Store store = mStores.get(uri);
|
2009-11-24 19:40:29 -05:00
|
|
|
if (store == null)
|
|
|
|
{
|
|
|
|
if (uri.startsWith("imap"))
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
store = new ImapStore(uri);
|
2009-11-24 19:40:29 -05:00
|
|
|
}
|
|
|
|
else if (uri.startsWith("pop3"))
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
store = new Pop3Store(uri);
|
2009-11-24 19:40:29 -05:00
|
|
|
}
|
|
|
|
else if (uri.startsWith("local"))
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
store = new LocalStore(uri, application);
|
2009-11-24 19:40:29 -05:00
|
|
|
}
|
|
|
|
else if (uri.startsWith("webdav"))
|
|
|
|
{
|
2008-12-06 19:29:11 -05:00
|
|
|
store = new WebDavStore(uri);
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2008-12-06 19:29:11 -05:00
|
|
|
|
2009-11-24 19:40:29 -05:00
|
|
|
if (store != null)
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
mStores.put(uri, store);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-24 19:40:29 -05:00
|
|
|
if (store == null)
|
|
|
|
{
|
2008-11-01 17:32:06 -04:00
|
|
|
throw new MessagingException("Unable to locate an applicable Store for " + uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
return store;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract Folder getFolder(String name) throws MessagingException;
|
|
|
|
|
|
|
|
public abstract Folder[] getPersonalNamespaces() throws MessagingException;
|
|
|
|
|
|
|
|
public abstract void checkSettings() throws MessagingException;
|
2009-11-24 19:40:29 -05:00
|
|
|
|
|
|
|
public boolean isCopyCapable()
|
|
|
|
{
|
|
|
|
return false;
|
2009-03-05 02:32:45 -05:00
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
public boolean isMoveCapable()
|
|
|
|
{
|
|
|
|
return false;
|
2009-03-05 02:32:45 -05:00
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
public boolean isPushCapable()
|
|
|
|
{
|
2009-10-21 20:41:06 -04:00
|
|
|
return false;
|
|
|
|
}
|
2009-10-24 22:58:26 -04:00
|
|
|
public boolean isSendCapable()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2009-11-24 19:40:29 -05:00
|
|
|
|
2009-10-24 22:58:26 -04:00
|
|
|
public void sendMessages(Message[] messages) throws MessagingException
|
|
|
|
{
|
|
|
|
}
|
2009-10-21 20:41:06 -04:00
|
|
|
|
|
|
|
public Pusher getPusher(PushReceiver receiver, List<String> names)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2009-03-05 02:32:45 -05:00
|
|
|
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|