Class POP3MailBox

    • Constructor Detail

      • POP3MailBox

        public POP3MailBox​(String host,
                           int port,
                           String user,
                           String pass)
        Does not connect. Caller must call connectToServer() if desired.
        Parameters:
        host -
        port -
        user -
        pass -
    • Method Detail

      • getHeader

        public Buffer getHeader​(String uidl)
        Fetch the header. Does not cache.
        Parameters:
        uidl -
        Returns:
        Byte buffer containing header data or null
      • getBody

        public Buffer getBody​(String uidl,
                              Buffer buffer)
        Fetch the body. Does not cache.
        Parameters:
        uidl -
        Returns:
        the buffer containing body data or null
      • getBodies

        public void getBodies​(Collection<POP3MailBox.FetchRequest> requests)
        Fetch headers and/or bodies. Does not cache. ReadBuffer objects are inserted into the requests. No total time limit.
        Since:
        0.9.13
      • queueForDeletion

        public void queueForDeletion​(Collection<String> uidls)
        Queue for later deletion. Non-blocking.
        Since:
        0.9.13
      • queueForDeletion

        public void queueForDeletion​(String uidl)
        Queue for later deletion. Non-blocking.
        Since:
        0.9.13
      • deletePending

        void deletePending​(boolean noWait)
        Delete all pending deletions at once. If previously connected, leaves connected. If not previously connected, closes connection when done.
        Parameters:
        noWait - fire-and-forget mode, only if connected
        Since:
        0.9.13
      • getSize

        public int getSize​(String uidl)
        Get cached size of a message (via previous LIST command).
        Parameters:
        uidl -
        Returns:
        Message size in bytes or 0 if not found
      • isConnected

        boolean isConnected()
        Is the connection is still alive
        Returns:
        true or false
      • getLastActivity

        long getLastActivity()
        Timestamp.
        Since:
        0.9.13
      • getLastChecked

        long getLastChecked()
        Timestamp. When we last successfully got the UIDL list.
        Since:
        0.9.13
      • connectToServer

        public boolean connectToServer​(NewMailListener nml)
        Connect to pop3 server if not connected. Checks mail if already connected. Non-Blocking unless an action already in progress. This will NOT call any configured NewMailListener, only the one passed in. It will be called with the value true if the connect was successful, false if not. Call getNumMails() to see if there really was any new mail. After the callback is executed, the information on new mails, if any, is available via getNumMails(), getUIDLs(), and getSize(). The connection to the server will remain open, so that new emails may be retrieved via getHeader(), getBody(), and getBodies(). Failure info is available via lastError().
        Returns:
        true if nml will be called back, false on failure and nml will NOT be called back
        Since:
        0.9.13
      • blockingConnectToServer

        boolean blockingConnectToServer()
        Connect to pop3 server if not connected. Does nothing if already connected. Blocking. This will NOT call any configured NewMailListener. After the callback is executed, the information on new mails, if any, is available via getNumMails(), getUIDLs(), and getSize(). The connection to the server will remain open, so that new emails may be retrieved via getHeader(), getBody(), and getBodies(). Failure info is available via lastError().
        Returns:
        true if connected
        Since:
        0.9.13
      • getNumMails

        public int getNumMails()
        Warning - forces a connection.
        Returns:
        The amount of e-mails available.
      • lastError

        public String lastError()
        Returns:
        The most recent error message. Probably not terminated with a newline.
      • setNewMailListener

        public void setNewMailListener​(NewMailListener nml)
        Relay from the checker to the webmail session object, which relays to MailCache, which will fetch the mail from us in a big circle
        Since:
        0.9.13
      • foundNewMail

        public void foundNewMail​(boolean yes)
        Relay from the checker to the webmail session object, which relays to MailCache, which will fetch the mail from us in a big circle
        Specified by:
        foundNewMail in interface NewMailListener
        Since:
        0.9.13
      • destroy

        public void destroy()
        Close without waiting for response, and remove any delayed tasks and resources.
      • getLock

        Object getLock()
        For helper threads to lock
        Since:
        0.9.13
      • hasQueuedDeletions

        boolean hasQueuedDeletions()
        Do we have UIDLs to delete?
        Since:
        0.9.13
      • close

        public void close()
        Close without waiting for response. Deletes all queued deletions.
      • close

        void close​(boolean shouldWait)
        Close and optionally wait for response. Deletes all queued deletions.
        Since:
        0.9.13
      • getUIDLs

        public Collection<String> getUIDLs()
        Only if connected. Does not force a connect. If not connected, returns null.
        Returns:
        A new array of the available UIDLs. No particular order.