/** * Fetch the header of the message and the first <code>n</code> lines * of the raw content of the message. The headers and data are * available in the returned InputStream. * * @param n number of lines of content to fetch * @return InputStream containing the message headers and n content lines * @exception MessagingException for failures */ public InputStream top(int n) throws MessagingException { try { synchronized (this) { return folder.getProtocol().top(msgnum, n); } } catch (EOFException eex) { folder.close(false); throw new FolderClosedException(folder, eex.toString()); } catch (IOException ex) { throw new MessagingException("error getting size", ex); } }
/** * Only the name "INBOX" is supported. */ @Override public Folder getFolder(String name) throws MessagingException { checkConnected(); return new POP3Folder(this, name); }
@Override public synchronized Message getMessage(int msgno) throws MessagingException { checkOpen(); POP3Message m; // Assuming that msgno is <= total if ((m = message_cache[msgno-1]) == null) { m = createMessage(this, msgno); message_cache[msgno-1] = m; } return m; }
/** * Produce the raw bytes of the content. The data is fetched using * the POP3 RETR command. * * @see #contentStream */ protected synchronized InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); InputStream cstream = getRawStream(true); /* * Keep a hard reference to the data if we're using a file * cache or if the "mail.pop3.keepmessagecontent" prop is set. */ TempFile cache = folder.getFileCache(); if (cache != null || ((POP3Store)(folder.getStore())).keepMessageContent) contentStream = ((SharedInputStream)cstream).newStream(0, -1); return cstream; }
checkReadable(); if (!doneUidl && store.supportsUidl && fp.contains(UIDFolder.FetchProfileItem.UID)) { return; } catch (EOFException eex) { close(false); throw new FolderClosedException(this, eex.toString()); } catch (IOException ex) { if (uids[i] == null) continue; POP3Message m = (POP3Message)getMessage(i + 1); m.uid = uids[i];
checkClosed(); if (!exists) throw new FolderNotFoundException(this, "folder is not INBOX"); doneUidl = false; notifyConnectionListeners(ConnectionEvent.OPENED);
rawcontent = rawData.get(); if (rawcontent == null) { TempFile cache = folder.getFileCache(); if (cache != null) { if (folder.logger.isLoggable(Level.FINE)) BufferedOutputStream bos = new BufferedOutputStream(os); try { folder.getProtocol().retr(msgnum, bos); } finally { bos.close(); rawcontent = folder.getProtocol().retr(msgnum, msgSize > 0 ? msgSize + hdrSize : 0); ((POP3Store)(folder.getStore())).forgetTopHeaders) { headers = new InternetHeaders(rawcontent); hdrSize = folder.close(false); throw new FolderClosedException(folder, eex.toString()); } catch (IOException ex) {
return; InputStream hdrs = null; if (((POP3Store)(folder.getStore())).disableTop || (hdrs = folder.getProtocol().top(msgnum, 0)) == null) { folder.close(false); throw new FolderClosedException(folder, eex.toString()); } catch (IOException ex) {
@Override public synchronized void close(boolean expunge) throws MessagingException { checkOpen(); message_cache = null; opened = false; notifyConnectionListeners(ConnectionEvent.CLOSED); if (fileCache != null) { fileCache.close();
InputStream rawcontent = rawData.get(); if (rawcontent == null && ignoreList == null && !((POP3Store)(folder.getStore())).cacheWriteTo) { if (folder.logger.isLoggable(Level.FINE)) folder.logger.fine("streaming msg " + msgnum); if (!folder.getProtocol().retr(msgnum, os)) { expunged = true; throw new MessageRemovedException("can't retrieve message #" +
/** * Will not change while the folder is open because the POP3 * protocol doesn't support notification of new messages * arriving in open folders. */ @Override public synchronized int getMessageCount() throws MessagingException { if (!opened) return -1; checkReadable(); return total; }
/** * Return the unique ID string for this message, or null if * not available. Uses the POP3 UIDL command. * * @param msg the message * @return unique ID string * @exception MessagingException for failures */ public synchronized String getUID(Message msg) throws MessagingException { checkOpen(); if (!(msg instanceof POP3Message)) throw new MessagingException("message is not a POP3Message"); POP3Message m = (POP3Message)msg; try { if (!store.supportsUidl) return null; if (m.uid == POP3Message.UNKNOWN) m.uid = port.uidl(m.getMessageNumber()); return m.uid; } catch (EOFException eex) { close(false); throw new FolderClosedException(this, eex.toString()); } catch (IOException ex) { throw new MessagingException("error getting UIDL", ex); } }
/** * Centralize access to the Protocol object by POP3Message * objects so that they will fail appropriately when the folder * is closed. */ Protocol getProtocol() throws MessagingException { Protocol p = port; // read it before close() can set it to null checkOpen(); // close() might happen here return p; }
/** * Close the folder when we're finalized. */ protected void finalize() throws Throwable { forceClose = !store.finalizeCleanClose; try { if (opened) close(false); } finally { super.finalize(); forceClose = false; } }
public synchronized void fetch(Message[] msgs, FetchProfile fp) throws MessagingException { checkReadable(); if (!doneUidl && store.supportsUidl && fp.contains(UIDFolder.FetchProfileItem.UID)) { return; } catch (EOFException eex) { close(false); throw new FolderClosedException(this, eex.toString()); } catch (IOException ex) { if (uids[i] == null) continue; POP3Message m = (POP3Message)getMessage(i + 1); m.uid = uids[i];
checkClosed(); if (!exists) throw new FolderNotFoundException(this, "folder is not INBOX"); doneUidl = false; notifyConnectionListeners(ConnectionEvent.OPENED);
rawcontent = rawData.get(); if (rawcontent == null) { TempFile cache = folder.getFileCache(); if (cache != null) { if (folder.logger.isLoggable(Level.FINE)) BufferedOutputStream bos = new BufferedOutputStream(os); try { folder.getProtocol().retr(msgnum, bos); } finally { bos.close(); rawcontent = folder.getProtocol().retr(msgnum, msgSize > 0 ? msgSize + hdrSize : 0); ((POP3Store)(folder.getStore())).forgetTopHeaders) { headers = new InternetHeaders(rawcontent); hdrSize = folder.close(false); throw new FolderClosedException(folder, eex.toString()); } catch (IOException ex) {
return; InputStream hdrs = null; if (((POP3Store)(folder.getStore())).disableTop || (hdrs = folder.getProtocol().top(msgnum, 0)) == null) { folder.close(false); throw new FolderClosedException(folder, eex.toString()); } catch (IOException ex) {
/** * Produce the raw bytes of the content. The data is fetched using * the POP3 RETR command. * * @see #contentStream */ @Override protected synchronized InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); InputStream cstream = getRawStream(true); /* * Keep a hard reference to the data if we're using a file * cache or if the "mail.pop3.keepmessagecontent" prop is set. */ TempFile cache = folder.getFileCache(); if (cache != null || ((POP3Store)(folder.getStore())).keepMessageContent) contentStream = ((SharedInputStream)cstream).newStream(0, -1); return cstream; }
public synchronized void close(boolean expunge) throws MessagingException { checkOpen(); message_cache = null; opened = false; notifyConnectionListeners(ConnectionEvent.CLOSED); if (fileCache != null) { fileCache.close();