1 19 package org.columba.mail.folder.mailboximport; 20 21 import java.io.BufferedReader ; 22 import java.io.File ; 23 import java.io.FileReader ; 24 25 import org.columba.api.command.IWorkerStatusController; 26 import org.columba.mail.folder.IMailbox; 27 import org.columba.mail.util.MailResourceLoader; 28 29 33 public class EvolutionImporter extends AbstractMailboxImporter { 34 public EvolutionImporter() { 35 super(); 36 } 37 38 public EvolutionImporter(IMailbox destinationFolder, File [] sourceFiles) { 39 super(destinationFolder, sourceFiles); 40 } 41 42 public int getType() { 43 return TYPE_FILE; 44 } 45 46 public void importMailboxFile(File file, IWorkerStatusController worker, 47 IMailbox destFolder) throws Exception { 48 int count = 0; 49 boolean sucess = false; 50 51 StringBuffer strbuf = new StringBuffer (); 52 53 BufferedReader in = new BufferedReader (new FileReader (file)); 54 String str; 55 56 while ((str = in.readLine()) != null) { 58 if (worker.cancelled() == true) { 60 return; 61 } 62 63 if ((str.startsWith("From ") == false) || (str.length() == 0)) { 66 strbuf.append(str + "\n"); 67 } else { 68 if (str.indexOf("@") != -1) { 71 if (strbuf.length() != 0) { 72 saveMessage(strbuf.toString(), worker, 74 getDestinationFolder()); 75 76 count++; 77 78 sucess = true; 79 } 80 81 strbuf = new StringBuffer (); 82 } else { 83 strbuf.append(str + "\n"); 84 } 85 } 86 } 87 88 if ((sucess == true) && (strbuf.length() > 0)) { 91 saveMessage(strbuf.toString(), worker, getDestinationFolder()); 92 } 93 94 in.close(); 95 } 96 97 public String getDescription() { 98 return MailResourceLoader.getString("dialog", "mailboximport", 99 "Evolution_description"); 100 } 101 } 102 | Popular Tags |