Prefetch information about POP3 messages. If the FetchProfile contains UIDFolder.FetchProfileItem.UID , POP3 UIDs for all messages in the folder are fetched using the POP3 UIDL command. If the FetchProfile contains FetchProfile.Item.ENVELOPE , the headers and size of all mess
(Message[] msgs, FetchProfile fp)
| 396 | * and LIST commands. |
| 397 | */ |
| 398 | @Override |
| 399 | public synchronized void fetch(Message[] msgs, FetchProfile fp) |
| 400 | throws MessagingException { |
| 401 | checkReadable(); |
| 402 | if (!doneUidl && store.supportsUidl && |
| 403 | fp.contains(UIDFolder.FetchProfileItem.UID)) { |
| 404 | /* |
| 405 | * Since the POP3 protocol only lets us fetch the UID |
| 406 | * for a single message or for all messages, we go ahead |
| 407 | * and fetch UIDs for all messages here, ignoring the msgs |
| 408 | * parameter. We could be more intelligent and base this |
| 409 | * decision on the number of messages fetched, or the |
| 410 | * percentage of the total number of messages fetched. |
| 411 | */ |
| 412 | String[] uids = new String[message_cache.length]; |
| 413 | try { |
| 414 | if (!port.uidl(uids)) |
| 415 | return; |
| 416 | } catch (EOFException eex) { |
| 417 | close(false); |
| 418 | throw new FolderClosedException(this, eex.toString()); |
| 419 | } catch (IOException ex) { |
| 420 | throw new MessagingException("error getting UIDL", ex); |
| 421 | } |
| 422 | for (int i = 0; i < uids.length; i++) { |
| 423 | if (uids[i] == null) |
| 424 | continue; |
| 425 | POP3Message m = (POP3Message)getMessage(i + 1); |
| 426 | m.uid = uids[i]; |
| 427 | } |
| 428 | doneUidl = true; // only do this once |
| 429 | } |
| 430 | if (fp.contains(FetchProfile.Item.ENVELOPE)) { |
| 431 | for (int i = 0; i < msgs.length; i++) { |
| 432 | try { |
| 433 | POP3Message msg = (POP3Message)msgs[i]; |
| 434 | // fetch headers |
| 435 | msg.getHeader(""); |
| 436 | // fetch message size |
| 437 | msg.getSize(); |
| 438 | } catch (MessageRemovedException mex) { |
| 439 | // should never happen, but ignore it if it does |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Return the unique ID string for this message, or null if |
nothing calls this directly
no test coverage detected