1 21 22 package org.armedbear.j.mail; 23 24 import org.armedbear.j.Editor; 25 26 final class LocalMessageBuffer extends MessageBuffer 27 { 28 LocalMessageBuffer(LocalMailbox mailbox, MailboxEntry entry) 29 { 30 super(); 31 this.mailbox = mailbox; 32 showFullHeaders = mailbox.showFullHeaders; 33 showRawText = mailbox.showRawText; 34 setEntry(entry); 35 initializeUndo(); 36 type = TYPE_NORMAL; 37 lineSeparator = "\n"; 38 mode = MessageMode.getMode(); 39 formatter = mode.getFormatter(this); 40 readOnly = true; 41 } 42 43 public int load() 44 { 45 if (mailbox.lock()) { 46 try { 47 loadMessage(null); 48 setLoaded(true); 49 return LOAD_COMPLETED; 50 } 51 finally { 52 mailbox.unlock(); 53 } 54 } else 55 Editor.currentEditor().status("Mailbox is locked"); 56 return LOAD_FAILED; 57 } 58 59 public void deleteMessage() 60 { 61 if (mailbox.lock()) { 62 try { 63 if (!entry.isDeleted()) { 64 entry.setFlags(entry.getFlags() | MailboxEntry.DELETED); 65 mailbox.setDirty(true); 66 mailbox.updateEntry(entry); 67 } 68 MailboxEntry nextEntry = mailbox.getNextUndeleted(entry); 69 if (nextEntry != null) { 70 setEntry(nextEntry); 71 loadMessage(null); 72 } else { 73 Editor editor = Editor.currentEditor(); 74 MailCommands.messageIndex(editor); 75 editor.status("Last undeleted message"); 76 } 77 } 78 finally { 79 mailbox.unlock(); 80 } 81 } 82 } 83 84 public void flagMessage() 85 { 86 if (mailbox.lock()) { 87 try { 88 if (entry.isFlagged()) 89 entry.unflag(); 90 else 91 entry.flag(); 92 mailbox.setDirty(true); 93 mailbox.updateEntry(entry); 94 MailboxEntry nextEntry = mailbox.getNextUndeleted(entry); 95 if (nextEntry != null) { 96 setEntry(nextEntry); 97 loadMessage(null); 98 } else { 99 Editor editor = Editor.currentEditor(); 100 MailCommands.messageIndex(editor); 101 editor.status("Last undeleted message"); 102 } 103 } 104 finally { 105 mailbox.unlock(); 106 } 107 } 108 } 109 } 110 | Popular Tags |