public MessagesWrapper search(List<SearchTerm> term) throws MessagingException {
   if (!folder.isOpen()) {
     folder.open(Folder.READ_ONLY);
   }
   Message[] messages = folder.search(and(term));
   return new MessagesWrapper(logger, Arrays.asList(messages), folder);
 }
 /*
  * Only keep text containing the given string.
  */
 public static List<String> filterProperties(String[] props, String containing) {
   final ArrayList<String> list = new ArrayList<String>(Arrays.asList(props));
   Iterator<String> it = list.iterator();
   while (it.hasNext()) {
     String foo = it.next();
     if (!foo.contains(containing)) it.remove();
   }
   return list;
 }
Ejemplo n.º 3
0
        public void messagesAdded(MessageCountEvent e) {
          try {
            // I don't think it matters where we put the new messages, but for the sanity of users
            // who don't sort, and because it's the cheapest option, we'll bung them at the end.
            Message[] newMessages = e.getMessages();

            // Work out where the new items will appear.
            final int firstNewRow = messages.size();
            final int lastNewRow = firstNewRow + newMessages.length - 1;

            // Actually insert the new items, and notify the listeners.
            messages.addAll(Arrays.asList(newMessages));
            fireTableRowsInserted(firstNewRow, lastNewRow);
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
Ejemplo n.º 4
0
  public void scanWholeFolder() throws MessagingException {
    if (folder.isOpen() == false) {
      folder.open(Folder.READ_WRITE);
    }

    // Bulk-fetch the message envelopes.
    Message[] newMessages = folder.getMessages();
    FetchProfile fetchProfile = new FetchProfile();
    // FIXME: add CONTENT_INFO if we start to display the size
    // fetchProfile.add(FetchProfile.Item.CONTENT_INFO);
    fetchProfile.add(FetchProfile.Item.ENVELOPE);
    fetchProfile.add(FetchProfile.Item.FLAGS);
    folder.fetch(newMessages, fetchProfile);

    this.messages = new ArrayList<Message>();
    messages.addAll(Arrays.asList(newMessages));

    fireTableDataChanged();
  }
 public MessagesWrapper markAsRead(Message... messagez) throws IOException, MessagingException {
   return markAsRead(Arrays.asList(messagez));
 }
 public MessagesWrapper search(SearchTerm... term) throws MessagingException {
   return search(Arrays.asList(term));
 }