gnu.mail.providers.imap
Class IMAPStore

java.lang.Object
  extended by javax.mail.Service
      extended by javax.mail.Store
          extended by gnu.mail.providers.imap.IMAPStore

public class IMAPStore
extends Store

The storage class implementing the IMAP4rev1 mail protocol.

Author:
Chris Burdess

Field Summary
protected  gnu.inet.imap.IMAPConnection connection
          The connection to the IMAP server.
protected  IMAPFolder root
          Folder representing the root namespace of the IMAP connection.
protected  IMAPFolder selected
          The currently selected folder.
 
Fields inherited from class javax.mail.Service
debug, session, url
 
Constructor Summary
IMAPStore(Session session, URLName url)
          Constructor.
 
Method Summary
 void close()
          Closes the connection.
protected  gnu.inet.imap.IMAPConnection getConnection()
          Returns the IMAP connection used by this store.
 Folder getDefaultFolder()
          Returns the root folder.
 Folder getFolder(java.lang.String name)
          Returns the folder with the specified name.
 Folder getFolder(URLName urlname)
          Returns the folder whose name is the file part of the specified URLName.
 Folder[] getPersonalNamespaces()
          Returns a list of folders representing personal namespaces.
 gnu.inet.imap.Quota getQuota(java.lang.String root)
          Returns the quota for the specified quota root.
 Folder[] getSharedNamespaces()
          Returns a list of folders representing shared namespaces.
protected  javax.net.ssl.TrustManager getTrustManager()
          Returns a trust manager used for TLS negotiation.
 Folder[] getUserNamespaces()
          Returns a list of folders representing other users' namespaces.
 boolean isConnected()
          Uses a NOOP to ensure that the connection to the IMAP server is still valid.
protected  boolean isSelected(IMAPFolder folder)
          Indicates whether the specified folder is selected.
protected  void processAlerts()
          Process any alerts supplied by the server.
protected  boolean protocolConnect(java.lang.String host, int port, java.lang.String username, java.lang.String password)
          Connects to the IMAP server and authenticates with the specified parameters.
 void setQuota(java.lang.String root, gnu.inet.imap.Quota.Resource[] resources)
          Sets the quota resource set for the specified quota root.
protected  void setSelected(IMAPFolder folder)
          Sets the selected folder.
 
Methods inherited from class javax.mail.Store
addFolderListener, addStoreListener, getUserNamespaces, notifyFolderListeners, notifyFolderRenamedListeners, notifyStoreListeners, removeFolderListener, removeStoreListener
 
Methods inherited from class javax.mail.Service
addConnectionListener, connect, connect, connect, connect, getURLName, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

connection

protected gnu.inet.imap.IMAPConnection connection
The connection to the IMAP server.


root

protected IMAPFolder root
Folder representing the root namespace of the IMAP connection.


selected

protected IMAPFolder selected
The currently selected folder.

Constructor Detail

IMAPStore

public IMAPStore(Session session,
                 URLName url)
Constructor.

Method Detail

protocolConnect

protected boolean protocolConnect(java.lang.String host,
                                  int port,
                                  java.lang.String username,
                                  java.lang.String password)
                           throws MessagingException
Connects to the IMAP server and authenticates with the specified parameters.

Overrides:
protocolConnect in class Service
Parameters:
host - the name of the host to connect to
port - the port to use (-1 for the default port)
username - the username
password - the password
Returns:
true on success, false if authentication failed
Throws:
AuthenticationFailedException - on authentication failure
MessagingException - for non-authentication failures

getTrustManager

protected javax.net.ssl.TrustManager getTrustManager()
                                              throws MessagingException
Returns a trust manager used for TLS negotiation.

Throws:
MessagingException

close

public void close()
           throws MessagingException
Closes the connection.

Overrides:
close in class Service
Throws:
MessagingException

getDefaultFolder

public Folder getDefaultFolder()
                        throws MessagingException
Returns the root folder.

Specified by:
getDefaultFolder in class Store
Throws:
MessagingException

getFolder

public Folder getFolder(java.lang.String name)
                 throws MessagingException
Returns the folder with the specified name.

Specified by:
getFolder in class Store
Parameters:
name - the folder name
Throws:
MessagingException

getFolder

public Folder getFolder(URLName urlname)
                 throws MessagingException
Returns the folder whose name is the file part of the specified URLName.

Specified by:
getFolder in class Store
Parameters:
urlname - a URLName denoting a folder
Throws:
MessagingException

isConnected

public boolean isConnected()
Uses a NOOP to ensure that the connection to the IMAP server is still valid.

Overrides:
isConnected in class Service

getConnection

protected gnu.inet.imap.IMAPConnection getConnection()
                                              throws StoreClosedException
Returns the IMAP connection used by this store.

Throws:
StoreClosedException - if the store is not currently connected

isSelected

protected boolean isSelected(IMAPFolder folder)
Indicates whether the specified folder is selected.


setSelected

protected void setSelected(IMAPFolder folder)
Sets the selected folder.


processAlerts

protected void processAlerts()
Process any alerts supplied by the server.


getPersonalNamespaces

public Folder[] getPersonalNamespaces()
                               throws MessagingException
Returns a list of folders representing personal namespaces. See RFC 2342 for details.

Overrides:
getPersonalNamespaces in class Store
Throws:
MessagingException

getUserNamespaces

public Folder[] getUserNamespaces()
                           throws MessagingException
Returns a list of folders representing other users' namespaces. See RFC 2342 for details.

Throws:
MessagingException

getSharedNamespaces

public Folder[] getSharedNamespaces()
                             throws MessagingException
Returns a list of folders representing shared namespaces. See RFC 2342 for details.

Overrides:
getSharedNamespaces in class Store
Throws:
MessagingException

getQuota

public gnu.inet.imap.Quota getQuota(java.lang.String root)
                             throws MessagingException
Returns the quota for the specified quota root.

Parameters:
root - the quota root
Throws:
MessagingException

setQuota

public void setQuota(java.lang.String root,
                     gnu.inet.imap.Quota.Resource[] resources)
              throws MessagingException
Sets the quota resource set for the specified quota root.

Parameters:
root - the quota root
resources - the quota resources to set
Throws:
MessagingException


© Copyright 2003, 2004 The Free Software Foundation, All rights reserved