mrpostman-cvs Mailing List for MrPostman
Brought to you by:
chris_humphreys,
mrbook
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(100) |
Feb
(115) |
Mar
(29) |
Apr
(17) |
May
(18) |
Jun
|
Jul
(12) |
Aug
|
Sep
|
Oct
(6) |
Nov
(2) |
Dec
(10) |
2004 |
Jan
(14) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Neateye <nit...@ao...> - 2005-05-11 06:06:51
|
Call out Gouranga be happy!!! Gouranga Gouranga Gouranga .... That which brings the highest happiness!! |
From: <chr...@us...> - 2004-01-15 10:35:35
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom In directory sc8-pr-cvs1:/tmp/cvs-serv13660/mrpostman/src/org/mrbook/mrpostman/maildotcom Modified Files: MailDotComMessageParser.java MailDotComMessageParserTest.java Log Message: Ongoing fixes and tests. Index: MailDotComMessageParser.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom/MailDotComMessageParser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MailDotComMessageParser.java 12 Jan 2004 22:27:39 -0000 1.1 --- MailDotComMessageParser.java 15 Jan 2004 10:35:32 -0000 1.2 *************** *** 287,291 **** boolean addLineToBody = false; ! if (bodyDelimiter.equals(TEXT_BODY_START_DELIM)) { // check if we have finished the body part... --- 287,292 ---- boolean addLineToBody = false; ! String line2 = line; ! if (bodyDelimiter.equals(TEXT_BODY_START_DELIM)) { // check if we have finished the body part... *************** *** 297,300 **** --- 298,303 ---- state = FINDING_ATTACHMENT; } else { + // Text emails can contain HTML quoted characters e.g. > and "e... + line2 = unescape(line); //Add this line to our body content... addLineToBody = true; *************** *** 317,321 **** if (addLineToBody) { ! message.addBodyLine(line); } } --- 320,324 ---- if (addLineToBody) { ! message.addBodyLine(line2); } } Index: MailDotComMessageParserTest.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom/MailDotComMessageParserTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MailDotComMessageParserTest.java 12 Jan 2004 22:27:39 -0000 1.1 --- MailDotComMessageParserTest.java 15 Jan 2004 10:35:32 -0000 1.2 *************** *** 41,57 **** //FILE1 = HTML with TXT attachment... ! public static final String MSG_FILE1 = "test/mesg1.mail.htm"; //FILE2 = HTML with ZIP attachment... ! public static final String MSG_FILE2 = "test/mesg2.mail.htm"; //FILE3 = TEXT body... ! public static final String MSG_FILE3 = "test/mesg3.mail.htm"; //FILE4 = HTML with HTML attachment... ! public static final String MSG_FILE4 = "test/mesg4.mail.htm"; //FILE5 - HTML with image attachment... ! public static final String MSG_FILE5 = "test/mesg5.mail.htm"; //FILE6 - HTML with 2 zip attachments... ! public static final String MSG_FILE6 = "test/mesg6.mail.htm"; //FILE7 - Multipart/alternative HTML and TEXT ! public static final String MSG_FILE7 = "test/mesg7.mail.htm"; public MailDotComMessageParserTest(String name) { --- 41,61 ---- //FILE1 = HTML with TXT attachment... ! public static final String MSG_FILE1 = "test/maildotcom/mesg1.mail.htm"; //FILE2 = HTML with ZIP attachment... ! public static final String MSG_FILE2 = "test/maildotcom/mesg2.mail.htm"; //FILE3 = TEXT body... ! public static final String MSG_FILE3 = "test/maildotcom/mesg3.mail.htm"; //FILE4 = HTML with HTML attachment... ! public static final String MSG_FILE4 = "test/maildotcom/mesg4.mail.htm"; //FILE5 - HTML with image attachment... ! public static final String MSG_FILE5 = "test/maildotcom/mesg5.mail.htm"; //FILE6 - HTML with 2 zip attachments... ! public static final String MSG_FILE6 = "test/maildotcom/mesg6.mail.htm"; //FILE7 - Multipart/alternative HTML and TEXT ! public static final String MSG_FILE7 = "test/maildotcom/mesg7.mail.htm"; ! // FILE8 - TEXT with quoted HTML characters (reply) ! public static final String MSG_FILE8 = "test/maildotcom/mesg8.mail.htm"; ! // FILE9 - TEXT with quoted HTML characters (reply) ! public static final String MSG_FILE9 = "test/maildotcom/mesg9.mail.htm"; public MailDotComMessageParserTest(String name) { *************** *** 226,230 **** } } ! private MailMessage runParser(String fileName) throws Exception { BufferedReader br = new BufferedReader( new FileReader(fileName)); --- 230,264 ---- } } ! ! /** ! * This test verifies that the Header code and the TEXT body code works correctly. ! * when the text message contains quoted HTML characters e.g. > ! * @throws Exception ! */ ! public void testParserFile8() throws Exception { ! try { ! MailMessage msg = runParser(MSG_FILE8); ! // check headers... ! // correct! ! } catch (Exception e) { ! fail("Exception " + e.getMessage()); ! } ! } ! ! /** ! * This test verifies that the Header code and the TEXT body code works correctly. ! * when the text message contains quoted HTML characters e.g. > ! * @throws Exception ! */ ! public void testParserFile9() throws Exception { ! try { ! MailMessage msg = runParser(MSG_FILE9); ! // check headers... ! // correct! ! } catch (Exception e) { ! fail("Exception " + e.getMessage()); ! } ! } ! private MailMessage runParser(String fileName) throws Exception { BufferedReader br = new BufferedReader( new FileReader(fileName)); |
From: <chr...@us...> - 2004-01-15 10:35:20
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman In directory sc8-pr-cvs1:/tmp/cvs-serv13632/mrpostman/src/org/mrbook/mrpostman Modified Files: MrPostman.java Log Message: Removed static dependency on MrPostman. Fixed proxy setting bug. Index: MrPostman.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/MrPostman.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MrPostman.java 24 Apr 2003 22:30:32 -0000 1.19 --- MrPostman.java 15 Jan 2004 10:35:10 -0000 1.20 *************** *** 58,64 **** public static int DEFAULT_HELP_PORT = 22220; public static boolean DEFAULT_START_LOG = false; - private static MrPostman maininstance = null; private static HelpServer hs = null; ! public Preferences userprefs = null; private boolean serverRunning = false; private PopServer pops = null; --- 58,63 ---- public static int DEFAULT_HELP_PORT = 22220; public static boolean DEFAULT_START_LOG = false; private static HelpServer hs = null; ! private Preferences userprefs = null; private boolean serverRunning = false; private PopServer pops = null; *************** *** 69,79 **** MrPostman() { int port = 0; - maininstance = this; initPrefs(); port = getPropertyInt("ServerPort", DEFAULT_PORT); initModules(); ! try { ! pops = new PopServer(port); serverRunning = true; --- 68,78 ---- MrPostman() { int port = 0; initPrefs(); port = getPropertyInt("ServerPort", DEFAULT_PORT); initModules(); ! initialiseProxy(); ! try { ! pops = new PopServer(this, port); serverRunning = true; *************** *** 166,173 **** } - public static MrPostman getMainInstance() { - return maininstance; - } - public void startHelpServer() throws IOException { if (hs == null) { --- 165,168 ---- *************** *** 186,190 **** try { // start the help server... ! helpPort = getPropertyInt("HelpServerPort", DEFAULT_HELP_PORT); startHelpServer(); } catch (IOException e) { --- 181,185 ---- try { // start the help server... ! helpPort = getPropertyInt(MrPostmanGui.PREF_HELP_PORT, DEFAULT_HELP_PORT); startHelpServer(); } catch (IOException e) { *************** *** 333,335 **** --- 328,369 ---- logger.info("Finished starting application"); } + /** + * @return + */ + public Preferences getUserprefs() { + return userprefs; + } + + /** + * @param preferences + */ + public void setUserprefs(Preferences preferences) { + userprefs = preferences; + } + + private void initialiseProxy() { + logger.finest("initialiseProxy()"); + java.util.Properties systemProperties = System.getProperties(); + if (getUserprefs().getBoolean(MrPostmanGui.PREF_USE_PROXY, false)) { + String httpProxyAddr = getUserprefs().get(MrPostmanGui.PREF_PROXY_ADDR, null); + String httpProxyPort = getUserprefs().get(MrPostmanGui.PREF_PROXY_PORT, null); + systemProperties.setProperty("http.proxyHost", httpProxyAddr); + systemProperties.setProperty("http.proxyPort", httpProxyPort); + logger.info("Using HTTP proxy " + httpProxyAddr + ":" + httpProxyPort); + } else { + systemProperties.remove("http.proxyHost"); + systemProperties.remove("http.proxyPort"); + } + + if (getUserprefs().getBoolean(MrPostmanGui.PREF_USE_HTTPS_PROXY, false)) { + String httpsProxyAddr = getUserprefs().get(MrPostmanGui.PREF_HTTPS_PROXY_ADDR, null); + String httpsProxyPort = getUserprefs().get(MrPostmanGui.PREF_HTTPS_PROXY_PORT, null); + systemProperties.setProperty("https.proxyHost", httpsProxyAddr); + systemProperties.setProperty("https.proxyPort", httpsProxyPort); + logger.info("Using HTTPS proxy " + httpsProxyAddr + ":" + httpsProxyPort); + } else { + systemProperties.remove("https.proxyHost"); + systemProperties.remove("https.proxyPort"); + } + } } \ No newline at end of file |
From: <chr...@us...> - 2004-01-15 10:34:55
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman In directory sc8-pr-cvs1:/tmp/cvs-serv13540/mrpostman/src/org/mrbook/mrpostman Modified Files: MrPostmanService.java Log Message: Removed static dependency on MrPostman Index: MrPostmanService.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/MrPostmanService.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MrPostmanService.java 9 Feb 2003 23:38:12 -0000 1.5 --- MrPostmanService.java 15 Jan 2004 10:34:52 -0000 1.6 *************** *** 100,104 **** private boolean isSocketAllowed(Socket soc) { ! boolean allowRemoteHosts = MrPostman.getMainInstance().userprefs.getBoolean("AllowOtherHosts", false); System.out.println(soc.getLocalAddress() + " " + soc.getInetAddress()); --- 100,104 ---- private boolean isSocketAllowed(Socket soc) { ! boolean allowRemoteHosts = mpn.getUserprefs().getBoolean("AllowOtherHosts", false); System.out.println(soc.getLocalAddress() + " " + soc.getInetAddress()); |
From: <chr...@us...> - 2004-01-15 10:34:45
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/pop In directory sc8-pr-cvs1:/tmp/cvs-serv13504/mrpostman/src/org/mrbook/mrpostman/pop Modified Files: PopServer.java PopConnection.java Log Message: Removed static dependency on MrPostman Index: PopServer.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/pop/PopServer.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PopServer.java 24 Apr 2003 22:30:36 -0000 1.8 --- PopServer.java 15 Jan 2004 10:34:42 -0000 1.9 *************** *** 57,67 **** protected ServerSocket listenSocket; private Executor executor; ! ! public PopServer(int port) throws IOException { if (port == 0) { port = DEFAULT_PORT; } this.port = port; ! logger.info("Starting executor"); executor = new PooledExecutor(new BoundedBuffer(DEFAULT_BUFFERLENGTH), DEFAULT_MAXIMUM_THREADS); --- 57,69 ---- protected ServerSocket listenSocket; private Executor executor; ! private MrPostman mpn = null; ! ! public PopServer(MrPostman parent, int port) throws IOException { if (port == 0) { port = DEFAULT_PORT; } this.port = port; ! mpn = parent; ! logger.info("Starting PopServer on port " + port); executor = new PooledExecutor(new BoundedBuffer(DEFAULT_BUFFERLENGTH), DEFAULT_MAXIMUM_THREADS); *************** *** 71,75 **** ((PooledExecutor) executor).createThreads(DEFAULT_MINIMUM_THREADS); - logger.info("Starting PopServer on port " + port); listenSocket = new ServerSocket(port); this.start(); --- 73,76 ---- *************** *** 97,101 **** logger.info("Connection accepted for IP " + clientSocket.getInetAddress()); try { ! executor.execute(new PopConnection(clientSocket)); } catch (PooledExecutor.AbortException ex) { logger.warning("Too many connections! refused for IP " + clientSocket.getInetAddress()); --- 98,102 ---- logger.info("Connection accepted for IP " + clientSocket.getInetAddress()); try { ! executor.execute(new PopConnection(mpn, clientSocket)); } catch (PooledExecutor.AbortException ex) { logger.warning("Too many connections! refused for IP " + clientSocket.getInetAddress()); *************** *** 116,120 **** private boolean isSocketAllowed(Socket socket) { ! boolean allowRemoteHosts = MrPostman.getMainInstance().userprefs.getBoolean("AllowOtherHosts", false); logger.info(socket.getLocalAddress() + " " + socket.getInetAddress()); --- 117,121 ---- private boolean isSocketAllowed(Socket socket) { ! boolean allowRemoteHosts = mpn.getUserprefs().getBoolean("AllowOtherHosts", false); logger.info(socket.getLocalAddress() + " " + socket.getInetAddress()); Index: PopConnection.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/pop/PopConnection.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PopConnection.java 22 Nov 2003 14:58:10 -0000 1.15 --- PopConnection.java 15 Jan 2004 10:34:42 -0000 1.16 *************** *** 79,85 **** protected BufferedReader in; protected PrintWriter out; ! ! public PopConnection(Socket clientSocket) { setSocket(clientSocket); } public void setSocket(Socket clientSocket) { --- 79,87 ---- protected BufferedReader in; protected PrintWriter out; ! private MrPostman mpn = null; ! ! public PopConnection(MrPostman parent, Socket clientSocket) { setSocket(clientSocket); + this.mpn = parent; } public void setSocket(Socket clientSocket) { *************** *** 186,190 **** password = new String(matcher.group(1)); //logger.info("Found extension: " + usernameExtension); ! wms = MrPostman.getMainInstance().getModuleHandlerForExtension(usernameExtension); if (wms == null) { --- 188,192 ---- password = new String(matcher.group(1)); //logger.info("Found extension: " + usernameExtension); ! wms = mpn.getModuleHandlerForExtension(usernameExtension); if (wms == null) { *************** *** 459,463 **** /* GUI */ } else if (guiPat.matcher(line).find()) { ! MrPostman.getMainInstance().showGui(); sendOk("Showing the gui"); } else { --- 461,465 ---- /* GUI */ } else if (guiPat.matcher(line).find()) { ! mpn.showGui(); sendOk("Showing the gui"); } else { |
From: <chr...@us...> - 2004-01-15 10:34:29
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/help In directory sc8-pr-cvs1:/tmp/cvs-serv13477/mrpostman/src/org/mrbook/mrpostman/help Modified Files: HelpServer.java Log Message: Removed static dependency on MrPostman Index: HelpServer.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/help/HelpServer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HelpServer.java 9 Feb 2003 23:38:15 -0000 1.5 --- HelpServer.java 15 Jan 2004 10:34:26 -0000 1.6 *************** *** 52,55 **** --- 52,56 ---- this.port = port; listenSocket = new ServerSocket(port); + logger.info("Starting Help server on port " + port); } |
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui In directory sc8-pr-cvs1:/tmp/cvs-serv13375/mrpostman/src/org/mrbook/mrpostman/gui Modified Files: messages.properties MessageUtil.java messages_fr.properties messages_es.properties MrPostmanGui.java messages_de.properties Log Message: Added HelpPort field Index: messages.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages.properties,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** messages.properties 10 Dec 2003 00:35:11 -0000 1.11 --- messages.properties 15 Jan 2004 10:34:01 -0000 1.12 *************** *** 9,12 **** --- 9,14 ---- option.log-startup=Open Log window when program starts labels.serverport=Server Port : + labels.helpport=Help Port : + button.showlog=Show Log message.serverport.restartrequired=You must Restart MrPostman for this to take effect. Index: MessageUtil.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/MessageUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MessageUtil.java 9 Feb 2003 23:38:13 -0000 1.5 --- MessageUtil.java 15 Jan 2004 10:34:01 -0000 1.6 *************** *** 34,37 **** --- 34,38 ---- import java.util.logging.Level; import java.util.logging.Logger; + import java.util.Enumeration; *************** *** 97,99 **** --- 98,114 ---- } } + + public static String toStr() { + return instance.toStringInternal(); + } + + private String toStringInternal() { + StringBuffer buff = new StringBuffer(); + for(Enumeration keys = configBundle.getKeys(); keys.hasMoreElements(); ) { + String key = (String) keys.nextElement(); + String value = configBundle.getString(key); + buff.append(key).append("=").append(value).append("\n"); + } + return buff.toString(); + } } \ No newline at end of file Index: messages_fr.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages_fr.properties,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** messages_fr.properties 10 Dec 2003 00:35:11 -0000 1.16 --- messages_fr.properties 15 Jan 2004 10:34:01 -0000 1.17 *************** *** 22,25 **** --- 22,26 ---- labels.serverport=Port d'écoute + labels.helpport=Help Port : message.serverport.restartrequired=Vous devez relancer MrPostman pour que ce changement prenne effet. Index: messages_es.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages_es.properties,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** messages_es.properties 10 Dec 2003 00:35:11 -0000 1.10 --- messages_es.properties 15 Jan 2004 10:34:01 -0000 1.11 *************** *** 9,12 **** --- 9,13 ---- option.log-startup=Abrir la ventana de mensajes al correr el programa labels.serverport=Puerto del Servidor: + labels.helpport=Help Port : message.serverport.restartrequired=You must Restart MrPostman for this to take effect. Index: MrPostmanGui.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/MrPostmanGui.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** MrPostmanGui.java 12 Jan 2004 22:25:15 -0000 1.22 --- MrPostmanGui.java 15 Jan 2004 10:34:01 -0000 1.23 *************** *** 54,57 **** --- 54,58 ---- import javax.swing.JOptionPane; import javax.swing.JPanel; + import javax.swing.JTextField; /** *************** *** 62,66 **** public static final String CVSID = "$Id$"; private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.gui.MrPostmanGui"); ! MrPostman mpn = null; java.awt.Component logFrame = null; private DefaultListModel listmodel = null; --- 63,67 ---- public static final String CVSID = "$Id$"; private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.gui.MrPostmanGui"); ! private MrPostman mpn = null; java.awt.Component logFrame = null; private DefaultListModel listmodel = null; *************** *** 80,83 **** --- 81,85 ---- private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel jLabel1; + private javax.swing.JLabel helpPortLabel; private javax.swing.JMenu jMenu2; private javax.swing.JCheckBox openLogCheckBox; *************** *** 103,106 **** --- 105,109 ---- private javax.swing.JMenu jMenu1; private javax.swing.JTextField jTextField1; + private javax.swing.JTextField helpPortField; private javax.swing.JMenuItem CloseGuiMenuItem; private javax.swing.JMenuItem AboutMenuItem; *************** *** 111,116 **** private Image img; ! public MrPostmanGui(MrPostman parent) { mpn = parent; --- 114,126 ---- private Image img; + public static final String PREF_USE_PROXY = "useProxy"; + public static final String PREF_USE_HTTPS_PROXY = "useHttpsProxy"; + public static final String PREF_PROXY_ADDR = "proxyAddr"; + public static final String PREF_PROXY_PORT = "proxyPort"; + public static final String PREF_HTTPS_PROXY_ADDR = "httpsProxyAddr"; + public static final String PREF_HTTPS_PROXY_PORT = "httpsProxyPort"; ! public static final String PREF_HELP_PORT = "helpPort"; ! public MrPostmanGui(MrPostman parent) { mpn = parent; *************** *** 123,127 **** private void initListModel() { listmodel = new DefaultListModel(); ! Vector names = MrPostman.getMainInstance().getModuleNamesVector(); for (Iterator i = names.iterator(); i.hasNext();) { --- 133,137 ---- private void initListModel() { listmodel = new DefaultListModel(); ! Vector names = mpn.getModuleNamesVector(); for (Iterator i = names.iterator(); i.hasNext();) { *************** *** 147,151 **** super.show(); ! if (MrPostman.getMainInstance().userprefs.getBoolean("OpenLogStart", false)) { logFrame.setVisible(true); } --- 157,161 ---- super.show(); ! if (mpn.getUserprefs().getBoolean("OpenLogStart", false)) { logFrame.setVisible(true); } *************** *** 160,164 **** logFrame = (new LoggingPanel((String) null)).show(null); ((Frame) logFrame).setIconImage(img); ! logFrame.setVisible(MrPostman.getMainInstance().userprefs.getBoolean("OpenLogStart", false)); } --- 170,174 ---- logFrame = (new LoggingPanel((String) null)).show(null); ((Frame) logFrame).setIconImage(img); ! logFrame.setVisible(mpn.getUserprefs().getBoolean("OpenLogStart", false)); } *************** *** 206,209 **** --- 216,221 ---- httpsProxyAddr = new javax.swing.JTextField(16); httpsProxyPort = new javax.swing.JTextField(16); + helpPortLabel = new javax.swing.JLabel(); + helpPortField = new JTextField(); setTitle(MessageUtil.getMessage("application.title")); *************** *** 222,226 **** jPanel1.setLayout(new java.awt.GridBagLayout()); ! allowHostsCheckBox.setSelected((MrPostman.getMainInstance()).userprefs.getBoolean("AllowOtherHosts", false)); allowHostsCheckBox.setText(MessageUtil.getMessage("option.otherhosts")); allowHostsCheckBox.addActionListener(new java.awt.event.ActionListener() { --- 234,238 ---- jPanel1.setLayout(new java.awt.GridBagLayout()); ! allowHostsCheckBox.setSelected(mpn.getUserprefs().getBoolean("AllowOtherHosts", false)); allowHostsCheckBox.setText(MessageUtil.getMessage("option.otherhosts")); allowHostsCheckBox.addActionListener(new java.awt.event.ActionListener() { *************** *** 235,239 **** jPanel1.add(allowHostsCheckBox, gridBagConstraints); ! runGuiCheckBox.setSelected(MrPostman.getMainInstance().userprefs.getBoolean("RunGuiStart", true)); runGuiCheckBox.setText(MessageUtil.getMessage("option.gui-startup")); runGuiCheckBox.addActionListener(new java.awt.event.ActionListener() { --- 247,251 ---- jPanel1.add(allowHostsCheckBox, gridBagConstraints); ! runGuiCheckBox.setSelected(mpn.getUserprefs().getBoolean("RunGuiStart", true)); runGuiCheckBox.setText(MessageUtil.getMessage("option.gui-startup")); runGuiCheckBox.addActionListener(new java.awt.event.ActionListener() { *************** *** 258,262 **** jPanel1.add(jLabel1, gridBagConstraints); ! jTextField1.setText((new Integer(MrPostman.getMainInstance().userprefs.getInt("ServerPort", MrPostman.DEFAULT_PORT))).toString()); jTextField1.addActionListener(new java.awt.event.ActionListener() { --- 270,274 ---- jPanel1.add(jLabel1, gridBagConstraints); ! jTextField1.setText((new Integer(mpn.getUserprefs().getInt("ServerPort", MrPostman.DEFAULT_PORT))).toString()); jTextField1.addActionListener(new java.awt.event.ActionListener() { *************** *** 265,277 **** } }); ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 1; ! gridBagConstraints.gridy = 3; ! gridBagConstraints.ipadx = 20; ! gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10); ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; ! jPanel1.add(jTextField1, gridBagConstraints); applyPortChangeButton.setText(MessageUtil.getMessage("button.apply.label")); applyPortChangeButton.addActionListener(new java.awt.event.ActionListener() { --- 277,315 ---- } }); ! ! gridBagConstraints = new java.awt.GridBagConstraints(); ! gridBagConstraints.gridx = 1; ! gridBagConstraints.gridy = 3; ! gridBagConstraints.ipadx = 20; ! gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10); ! gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; ! gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; ! jPanel1.add(jTextField1, gridBagConstraints); + helpPortLabel.setText(MessageUtil.getMessage("labels.helpport")); + helpPortLabel.setToolTipText(""); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + jPanel1.add(helpPortLabel, gridBagConstraints); + + helpPortField.setText((new Integer(mpn.getUserprefs().getInt(PREF_HELP_PORT, + MrPostman.DEFAULT_HELP_PORT))).toString()); + helpPortField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + helpPortTextActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 4; + gridBagConstraints.ipadx = 20; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + jPanel1.add(helpPortField, gridBagConstraints); + applyPortChangeButton.setText(MessageUtil.getMessage("button.apply.label")); applyPortChangeButton.addActionListener(new java.awt.event.ActionListener() { *************** *** 287,291 **** jPanel1.add(applyPortChangeButton, gridBagConstraints); ! openLogCheckBox.setSelected(MrPostman.getMainInstance().userprefs.getBoolean("OpenLogStart", false)); openLogCheckBox.setText(MessageUtil.getMessage("option.log-startup")); --- 325,329 ---- jPanel1.add(applyPortChangeButton, gridBagConstraints); ! openLogCheckBox.setSelected(mpn.getUserprefs().getBoolean("OpenLogStart", false)); openLogCheckBox.setText(MessageUtil.getMessage("option.log-startup")); *************** *** 336,340 **** javax.swing.JLabel tmplabel; proxyPanel.setLayout(new java.awt.GridBagLayout()); ! useProxy.setSelected((MrPostman.getMainInstance()).userprefs.getBoolean("UseProxy", false)); useProxy.setText(MessageUtil.getMessage("proxy.useproxy")); gridBagConstraints = new java.awt.GridBagConstraints(); --- 374,378 ---- javax.swing.JLabel tmplabel; proxyPanel.setLayout(new java.awt.GridBagLayout()); ! useProxy.setSelected(mpn.getUserprefs().getBoolean(PREF_USE_PROXY, false)); useProxy.setText(MessageUtil.getMessage("proxy.useproxy")); gridBagConstraints = new java.awt.GridBagConstraints(); *************** *** 357,361 **** proxyPanel.add(tmplabel, gridBagConstraints); ! proxyAddr.setText(MrPostman.getMainInstance().userprefs.get("proxyAddr", "127.0.0.1")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; --- 395,399 ---- proxyPanel.add(tmplabel, gridBagConstraints); ! proxyAddr.setText(mpn.getUserprefs().get(PREF_PROXY_ADDR, "127.0.0.1")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; *************** *** 374,378 **** proxyPanel.add(tmplabel, gridBagConstraints); ! proxyPort.setText(new Integer(MrPostman.getMainInstance().userprefs.getInt("proxyPort", 8080)).toString()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; --- 412,416 ---- proxyPanel.add(tmplabel, gridBagConstraints); ! proxyPort.setText(new Integer(mpn.getUserprefs().getInt(PREF_PROXY_PORT, 8080)).toString()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; *************** *** 382,386 **** proxyPanel.add(proxyPort, gridBagConstraints); ! useHttpsProxy.setSelected((MrPostman.getMainInstance()).userprefs.getBoolean("UseHttpsProxy", false)); useHttpsProxy.setText(MessageUtil.getMessage("proxy.usehttpsproxy")); gridBagConstraints = new java.awt.GridBagConstraints(); --- 420,424 ---- proxyPanel.add(proxyPort, gridBagConstraints); ! useHttpsProxy.setSelected(mpn.getUserprefs().getBoolean(PREF_USE_HTTPS_PROXY, false)); useHttpsProxy.setText(MessageUtil.getMessage("proxy.usehttpsproxy")); gridBagConstraints = new java.awt.GridBagConstraints(); *************** *** 405,409 **** proxyPanel.add(tmplabel, gridBagConstraints); ! httpsProxyAddr.setText(MrPostman.getMainInstance().userprefs.get("httpsProxyAddr", "127.0.0.1")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; --- 443,447 ---- proxyPanel.add(tmplabel, gridBagConstraints); ! httpsProxyAddr.setText(mpn.getUserprefs().get(PREF_HTTPS_PROXY_ADDR, "127.0.0.1")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; *************** *** 422,426 **** proxyPanel.add(tmplabel, gridBagConstraints); ! httpsProxyPort.setText(new Integer(MrPostman.getMainInstance().userprefs.getInt("httpsProxyPort", 8081)).toString()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; --- 460,464 ---- proxyPanel.add(tmplabel, gridBagConstraints); ! httpsProxyPort.setText(new Integer(mpn.getUserprefs().getInt(PREF_HTTPS_PROXY_PORT, 8081)).toString()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; *************** *** 633,643 **** private void ExitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_ExitMenuItemActionPerformed // Add your handling code here: ! MrPostman.getMainInstance().userprefs.putBoolean("useProxy", useProxy.isSelected()); ! MrPostman.getMainInstance().userprefs.put("proxyAddr", proxyAddr.getText()); ! MrPostman.getMainInstance().userprefs.put("proxyPort", proxyPort.getText()); ! MrPostman.getMainInstance().userprefs.putBoolean("useHttpsProxy", useHttpsProxy.isSelected()); ! MrPostman.getMainInstance().userprefs.put("httpsProxyAddr", httpsProxyAddr.getText()); ! MrPostman.getMainInstance().userprefs.put("httpsProxyPort", httpsProxyPort.getText()); mpn.exit(); --- 671,681 ---- private void ExitMenuItemActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_ExitMenuItemActionPerformed // Add your handling code here: ! mpn.getUserprefs().putBoolean(PREF_USE_PROXY, useProxy.isSelected()); ! mpn.getUserprefs().put(PREF_PROXY_ADDR, proxyAddr.getText()); ! mpn.getUserprefs().put(PREF_PROXY_PORT, proxyPort.getText()); ! mpn.getUserprefs().putBoolean(PREF_USE_HTTPS_PROXY, useHttpsProxy.isSelected()); ! mpn.getUserprefs().put(PREF_HTTPS_PROXY_ADDR, httpsProxyAddr.getText()); ! mpn.getUserprefs().put(PREF_HTTPS_PROXY_PORT, httpsProxyPort.getText()); mpn.exit(); *************** *** 658,664 **** private void useProxyActionPerformed(java.awt.event.ItemEvent evt) { ! MrPostman.getMainInstance().userprefs.putBoolean("useProxy", useProxy.isSelected()); ! MrPostman.getMainInstance().userprefs.put("proxyAddr", proxyAddr.getText()); ! MrPostman.getMainInstance().userprefs.put("proxyPort", proxyPort.getText()); Properties systemProperties = System.getProperties(); if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { --- 696,702 ---- private void useProxyActionPerformed(java.awt.event.ItemEvent evt) { ! mpn.getUserprefs().putBoolean(PREF_USE_PROXY, useProxy.isSelected()); ! mpn.getUserprefs().put(PREF_PROXY_ADDR, proxyAddr.getText()); ! mpn.getUserprefs().put(PREF_PROXY_PORT, proxyPort.getText()); Properties systemProperties = System.getProperties(); if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { *************** *** 672,678 **** private void useHttpsProxyActionPerformed(java.awt.event.ItemEvent evt) { ! MrPostman.getMainInstance().userprefs.putBoolean("useHttpsProxy", useHttpsProxy.isSelected()); ! MrPostman.getMainInstance().userprefs.put("httpsProxyAddr", httpsProxyAddr.getText()); ! MrPostman.getMainInstance().userprefs.put("httpsProxyPort", httpsProxyPort.getText()); Properties systemProperties = System.getProperties(); if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { --- 710,716 ---- private void useHttpsProxyActionPerformed(java.awt.event.ItemEvent evt) { ! mpn.getUserprefs().putBoolean(PREF_USE_HTTPS_PROXY, useHttpsProxy.isSelected()); ! mpn.getUserprefs().put(PREF_HTTPS_PROXY_ADDR, httpsProxyAddr.getText()); ! mpn.getUserprefs().put(PREF_HTTPS_PROXY_PORT, httpsProxyPort.getText()); Properties systemProperties = System.getProperties(); if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { *************** *** 694,698 **** private void openLogCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_openLogCheckBoxActionPerformed // Add your handling code here: ! MrPostman.getMainInstance().userprefs.putBoolean("OpenLogStart", openLogCheckBox.isSelected()); } --- 732,736 ---- private void openLogCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_openLogCheckBoxActionPerformed // Add your handling code here: ! mpn.getUserprefs().putBoolean("OpenLogStart", openLogCheckBox.isSelected()); } *************** *** 700,704 **** private void runGuiCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_runGuiCheckBoxActionPerformed // Add your handling code here: ! MrPostman.getMainInstance().userprefs.putBoolean("RunGuiStart", runGuiCheckBox.isSelected()); } --- 738,742 ---- private void runGuiCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_runGuiCheckBoxActionPerformed // Add your handling code here: ! mpn.getUserprefs().putBoolean("RunGuiStart", runGuiCheckBox.isSelected()); } *************** *** 706,710 **** private void allowHostsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_allowHostsCheckBoxActionPerformed // Add your handling code here: ! MrPostman.getMainInstance().userprefs.putBoolean("AllowOtherHosts", allowHostsCheckBox.isSelected()); } --- 744,748 ---- private void allowHostsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_allowHostsCheckBoxActionPerformed // Add your handling code here: ! mpn.getUserprefs().putBoolean("AllowOtherHosts", allowHostsCheckBox.isSelected()); } *************** *** 714,726 **** portNumber = new Integer(jTextField1.getText()); } catch (Exception e) { ! portNumber = new Integer(MrPostman.getMainInstance().userprefs.getInt("ServerPort", MrPostman.DEFAULT_PORT)); } jTextField1.setText(portNumber.toString()); ! MrPostman.getMainInstance().userprefs.putInt("ServerPort", portNumber.intValue()); } private void portTextApplyActionPerformed(java.awt.event.ActionEvent evt) { portTextActionPerformed(evt); ! JOptionPane.showMessageDialog(this, MessageUtil.getMessage("message.serverport.restartrequired"), MessageUtil.getMessage("about.title"), JOptionPane.INFORMATION_MESSAGE); } --- 752,776 ---- portNumber = new Integer(jTextField1.getText()); } catch (Exception e) { ! portNumber = new Integer(mpn.getUserprefs().getInt("ServerPort", MrPostman.DEFAULT_PORT)); } jTextField1.setText(portNumber.toString()); ! mpn.getUserprefs().putInt("ServerPort", portNumber.intValue()); } + private void helpPortTextActionPerformed(java.awt.event.ActionEvent evt) { + Integer portNumber = null; + try { + portNumber = new Integer(helpPortField.getText()); + } catch (Exception e) { + portNumber = new Integer(mpn.getUserprefs().getInt(PREF_HELP_PORT, MrPostman.DEFAULT_HELP_PORT)); + } + helpPortField.setText(portNumber.toString()); + mpn.getUserprefs().putInt(PREF_HELP_PORT, portNumber.intValue()); + } + private void portTextApplyActionPerformed(java.awt.event.ActionEvent evt) { portTextActionPerformed(evt); ! helpPortTextActionPerformed(evt); ! JOptionPane.showMessageDialog(this, MessageUtil.getMessage("message.serverport.restartrequired"), MessageUtil.getMessage("about.title"), JOptionPane.INFORMATION_MESSAGE); } *************** *** 730,740 **** /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) { //GEN-FIRST:event_exitForm ! MrPostman.getMainInstance().userprefs.putBoolean("useProxy", useProxy.isSelected()); ! MrPostman.getMainInstance().userprefs.put("proxyAddr", proxyAddr.getText()); ! MrPostman.getMainInstance().userprefs.put("proxyPort", proxyPort.getText()); ! MrPostman.getMainInstance().userprefs.putBoolean("useHttpsProxy", useHttpsProxy.isSelected()); ! MrPostman.getMainInstance().userprefs.put("httpsProxyAddr", httpsProxyAddr.getText()); ! MrPostman.getMainInstance().userprefs.put("httpsProxyPort", httpsProxyPort.getText()); mpn.exit(); --- 780,790 ---- /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) { //GEN-FIRST:event_exitForm ! mpn.getUserprefs().putBoolean(PREF_USE_PROXY, useProxy.isSelected()); ! mpn.getUserprefs().put(PREF_PROXY_ADDR, proxyAddr.getText()); ! mpn.getUserprefs().put(PREF_PROXY_PORT, proxyPort.getText()); ! mpn.getUserprefs().putBoolean(PREF_USE_HTTPS_PROXY, useHttpsProxy.isSelected()); ! mpn.getUserprefs().put(PREF_HTTPS_PROXY_ADDR, httpsProxyAddr.getText()); ! mpn.getUserprefs().put(PREF_HTTPS_PROXY_PORT, httpsProxyPort.getText()); mpn.exit(); Index: messages_de.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages_de.properties,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** messages_de.properties 10 Dec 2003 00:35:11 -0000 1.4 --- messages_de.properties 15 Jan 2004 10:34:01 -0000 1.5 *************** *** 18,21 **** --- 18,22 ---- labels.serverport=Server-Port : + labels.helpport=Help Port : button.showlog=Protokoll anzeigen |
From: <chr...@us...> - 2004-01-15 10:33:38
|
Update of /cvsroot/mrpostman/mrpostman/src/com/sonalb/net/http In directory sc8-pr-cvs1:/tmp/cvs-serv13315/mrpostman/src/com/sonalb/net/http Modified Files: HTTPRedirectHandler.java Log Message: Fixed logger classname bug Index: HTTPRedirectHandler.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/com/sonalb/net/http/HTTPRedirectHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** HTTPRedirectHandler.java 12 Jan 2004 22:23:56 -0000 1.9 --- HTTPRedirectHandler.java 15 Jan 2004 10:33:35 -0000 1.10 *************** *** 73,77 **** InputStream is; ! private static Logger logger = Logger.getLogger("com.sonalb.net.http.httpredirecthandler"); /** --- 73,77 ---- InputStream is; ! private static Logger logger = Logger.getLogger("com.sonalb.net.http.HTTPRedirectHandler"); /** |
From: <chr...@us...> - 2004-01-12 22:34:03
|
Update of /cvsroot/mrpostman/mrpostman/tools In directory sc8-pr-cvs1:/tmp/cvs-serv11749/mrpostman/tools Added Files: junit.jar Log Message: --- NEW FILE: junit.jar --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom In directory sc8-pr-cvs1:/tmp/cvs-serv10610/mrpostman/src/org/mrbook/mrpostman/maildotcom Added Files: Attachment.java MailMessage.java PatternTest.java MailDotComMessageParser.java MailDotComMessageParserTest.java MailIdentifier.java Log Message: --- NEW FILE: Attachment.java --- /* * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java: * ex: set tabstop=4 expandtab: * * MrPostman - webmail <-> email gateway * Copyright (C) 2002-2003 MrPostman Development Group * Projectpage: http://mrbook.org/mrpostman/ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * In particular, this implies that users are responsible for * using MrPostman after reading the terms and conditions given * by their web-mail provider. * * You should have received a copy of the GNU General Public License * Named LICENSE in the base directory of this distribution, * if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.mrbook.mrpostman.maildotcom; import java.util.Collection; import java.util.LinkedHashMap; import java.util.ArrayList; import java.util.Iterator; /** * @author chris * Represents an Attachment in the MailDotComMessageParser */ public class Attachment { private String partId = null; private String filename = null; private String url = null; private LinkedHashMap headerLines = null; private ArrayList bodyLines; private String bodyDelimiter = null; /** * */ public Attachment() { super(); headerLines = new LinkedHashMap(); bodyLines = new ArrayList(); } /** * @return */ public String getFilename() { return filename; } /** * @return */ public String getPartId() { return partId; } /** * @param string */ public void setFilename(String string) { filename = string; } /** * @param string */ public void setPartId(String string) { partId = string; } /** * @return */ public String getUrl() { return url; } /** * @param string */ public void setUrl(String string) { url = string; } public void addHeaderLine(String headerKeyStr, String headerValueStr) { headerLines.put(headerKeyStr, headerValueStr); } public void addBodyLine(String line) { bodyLines.add(line); } public String toString() { StringBuffer buff = new StringBuffer(); if (!isEmbeddedAttachment()) { buff.append("Attachment URL: ").append(url); buff.append("\nFilename: ").append(filename); buff.append("\nPartId: ").append(partId); buff.append(headerLines.toString()).append("\n"); } else { buff.append("Inline Attachement\n"); buff.append(headerLines.toString()).append("\n"); for (Iterator it = bodyLines.iterator(); it.hasNext(); ) { buff.append((String)it.next()).append("\n"); } } return buff.toString(); } /** * @return */ public boolean isEmbeddedAttachment() { return bodyLines.size() > 0; } /** * @param string */ public void setBodyDelimiter(String string) { bodyDelimiter = string; } /** * @return */ public String getBodyDelimiter() { return bodyDelimiter; } public String getHeader(String key) { return (String)headerLines.get(key); } public Collection getBodyLines() { return bodyLines; } public LinkedHashMap getHeaders() { return headerLines; } } --- NEW FILE: MailMessage.java --- /* * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java: * ex: set tabstop=4 expandtab: * * MrPostman - webmail <-> email gateway * Copyright (C) 2002-2003 MrPostman Development Group * Projectpage: http://mrbook.org/mrpostman/ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * In particular, this implies that users are responsible for * using MrPostman after reading the terms and conditions given * by their web-mail provider. * * You should have received a copy of the GNU General Public License * Named LICENSE in the base directory of this distribution, * if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.mrbook.mrpostman.maildotcom; import java.util.Collection; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; /** * Helper class to represent a Message * @author chris * */ public class MailMessage { private LinkedHashMap headerLines = null; private ArrayList attachments = null; private ArrayList bodyLines; private String boundary; private int attachmentCount; private LinkedHashMap bodyHeaderLines = null; /** * Counter used when generating part numbers when constructing MIME encoded message... */ private int tmpPartCount = 0; public MailMessage() { headerLines = new LinkedHashMap(); bodyLines = new ArrayList(); bodyHeaderLines = new LinkedHashMap(); attachments = new ArrayList(); attachmentCount = -1; } public void addBodyLine(String line) { bodyLines.add(line); } public void addHeaderLine(String key, String value) { headerLines.put(key, value); } public String getHeader(String key) { return (String)headerLines.get(key); } public void addBodyHeaderLine(String key, String value) { bodyHeaderLines.put(key, value); } public String getBodyHeader(String key) { return (String)bodyHeaderLines.get(key); } public void addAttachment(Attachment attachment) { attachments.add(attachment); } public Attachment getCurrentAttachment() { return (Attachment) attachments.get(attachmentCount); } public String toString() { StringBuffer buff = new StringBuffer(); for(Iterator it = headerLines.keySet().iterator(); it.hasNext();) { String hdrKey = (String)it.next(); String value = (String)headerLines.get(hdrKey); buff.append(hdrKey + ": " + value).append("\n"); } buff.append("\n"); for(Iterator it = bodyHeaderLines.keySet().iterator(); it.hasNext();) { String hdrKey = (String)it.next(); String value = (String)bodyHeaderLines.get(hdrKey); buff.append(hdrKey + ": " + value).append("\n"); } buff.append("\n"); for(Iterator it = bodyLines.iterator(); it.hasNext();) { buff.append((String)it.next()).append("\n"); } buff.append(attachments); return buff.toString(); } /** * @return */ public int getAttachmentCount() { return attachmentCount; } /** * @param i */ public void setAttachmentCount(int i) { attachmentCount = i; } public void incrementAttachmentCount() { attachmentCount++; } public int getNumberAttachments() { return attachments.size(); } public Collection getBodyLines() { return bodyLines; } /** * Return the Attachment at specified index (starting from 0) * @throws IndexOutOfBoundsException if invalid index passed * @param index * @return */ public Attachment getAttachment(int index) throws IndexOutOfBoundsException { return (Attachment)attachments.get(index); } /** * @return */ public String getBoundary() { return boundary; } /** * @param string */ public void setBoundary(String string) { boundary = string; } /** * @return */ public int getTmpPartCount() { return tmpPartCount; } /** * @param i */ public void setTmpPartCount(int i) { tmpPartCount = i; } public LinkedHashMap getBodyHeaders() { return bodyHeaderLines; } public LinkedHashMap getHeaders() { return headerLines; } /** * Utility method to return a LinkedHasMap (as used in our Header lists) into * a flat list of encoded header lines i.e. "key: value" * @return Collection */ public static Collection getHeadersAsCollection(LinkedHashMap lhmap) { ArrayList list = new ArrayList(lhmap.keySet().size()); for(Iterator it = lhmap.keySet().iterator(); it.hasNext();) { String hdrKey = (String)it.next(); String value = (String)lhmap.get(hdrKey); list.add(hdrKey + ": " + value); } return list; } } --- NEW FILE: PatternTest.java --- /* * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java: * ex: set tabstop=4 expandtab: * * MrPostman - webmail <-> email gateway * Copyright (C) 2002-2003 MrPostman Development Group * Projectpage: http://mrbook.org/mrpostman/ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * In particular, this implies that users are responsible for * using MrPostman after reading the terms and conditions given * by their web-mail provider. * * You should have received a copy of the GNU General Public License * Named LICENSE in the base directory of this distribution, * if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.mrbook.mrpostman.maildotcom; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author chris * Simple class to test Patterns during development */ public class PatternTest { /** * */ public PatternTest() { super(); } public static void main(String[] args) { String line = "<A HREF=\"/getattach/attach1.zip?folder=INBOX&msg_uid=1073739904&filename=attach1.zip&partsno=3\" target=\"_blank\"><FONT COLOR=\"BLUE\">attach1.zip</FONT></A></STRONG><BR>"; Pattern attachPattern = Pattern.compile("^.*?<A HREF=\"(/getattach/(.*)\\?folder=INBOX&msg_uid=(.*)&filename=(.*)&partsno=(.*))\".*?>.*$"); Matcher match = attachPattern.matcher(line); if (match.find()) { System.out.println(match.group(1)); System.out.println(match.group(2)); System.out.println(match.group(3)); } else { System.out.println("No match"); } } } --- NEW FILE: MailDotComMessageParser.java --- /* * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java: * ex: set tabstop=4 expandtab: * * MrPostman - webmail <-> email gateway * Copyright (C) 2002-2003 MrPostman Development Group * Projectpage: http://mrbook.org/mrpostman/ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * In particular, this implies that users are responsible for * using MrPostman after reading the terms and conditions given * by their web-mail provider. * * You should have received a copy of the GNU General Public License * Named LICENSE in the base directory of this distribution, * if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.mrbook.mrpostman.maildotcom; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.logging.Logger; import java.io.BufferedReader; import java.io.IOException; /** * @author chris * * Parse the message data returned from Mail.com into an object representation suitable for encoding into a * MIME message */ public class MailDotComMessageParser { private static Logger logger = Logger.getLogger( "org.mrbook.mrpostman.maildotcom.MailDotComMessageParser"); //State settings private static final int START = 0; private static final int PROCESSING_HEADER = 1; private static final int FINDING_BODY = 2; private static final int PROCESSING_BODY = 3; private static final int FINDING_ATTACHMENT = 4; private static final int PROCESSING_ATTACHMENT = 5; private static final int PROCESSING_INLINE_ATTACHMENT = 6; private static final int STOPPED = 9; private static final int DONE = 10; /** * Represents the state of the parser. */ private int state = START; /** * Represents the delimeter used around the body of the message. Can be either * TEXT_BODY_DELIM or HTML_BODY_DELIM */ private String bodyDelimiter = null; private MailMessage message = null; //Message and attachment patterns... private Pattern bfieldpattern = Pattern.compile("<b>([^:]*):.*</b>"); private Pattern bbfieldpattern = Pattern.compile("<B>([^:]*):.*</B>\\s*(.*)\\s*<BR>"); private Pattern attachPattern = Pattern.compile("^.*?<A HREF=\"(/getattach/(.*)\\?folder=INBOX&msg_uid=(.*)&filename=(.*)&partsno=(\\d+))\".*?>.*$"); //Pattern.compile("<a target=\"_blank\" href=\"(.*)\">"); private Pattern attachStartPattern = Pattern.compile("^<HR SIZE=1>$"); private static final String TEXT_BODY_START_DELIM = "<PRE>"; private static final String TEXT_BODY_END_DELIM = "</PRE>"; private static final String HTML_BODY_START_DELIM = "<XHTML>"; private static final String HTML_BODY_END_DELIM = "</XHTML>"; /** * */ public MailDotComMessageParser() { super(); state = START; } /** * Process the message. * This method is called for each line in the received message * Returns the number of body lines processed. This is used to stop parsing if this is just a TOP command */ MailMessage processMessage(BufferedReader br, int numLines) throws IOException { //The message may be embedded between <PRE> </PRE> tags if sent in Text //or in <xhtml></xhtml> if sent in HTML //The same message may contain both if sent in both TEXT and HTM but the others will be as different //body parts boolean insidePre = false; boolean insideXHTML = false; int lineNo = 0; logger.finest("*** Starting message processing ***"); //Create our structure to store the parsed message content... message = new MailMessage(); String line = null; //We start by finding and processing the header... state = PROCESSING_HEADER; while ((line = br.readLine()) != null && state != DONE) { logger.finest("MailDotComMessageParser html: " + line); // TODO - I suspect this may happen - but am not sure so if you // see this in your log let me know! - CH if (line.indexOf("Your Mail.com session is sponsored by:") > -1) { logger.warning("*** SPONSOR PAGE ***"); } //Process the header... switch (state) { case PROCESSING_HEADER : processMessageHeader(br, line); break; case FINDING_BODY : processMessageFindStartOfBody(br, line); break; case PROCESSING_BODY : processMessageBody(br, line); break; case FINDING_ATTACHMENT : findingAttachments(br, line); break; case PROCESSING_ATTACHMENT : processAttachments(br, line); break; case PROCESSING_INLINE_ATTACHMENT : processInlineAttachmentBody(br, line); break; } //A TOP command can stop this processing prematurely... if (numLines > -1) { if (lineNo >= numLines) { state = STOPPED; break; } } } //end while logger.finest(message.toString()); logger.finest("*** Finished message processing ***"); return message; } /** * Process the message header. * * @param message * @param br * @param numLines * @param line * @return * @throws IOException */ void processMessageHeader( BufferedReader br, String line) throws IOException { String headerKeyStr = null; String headerValueStr = null; String line2 = null; boolean processedHeader = false; //There are two formats for header values, we'll handle them both.. Matcher match = bfieldpattern.matcher(line); if (match.find()) { /* In this case the header key is on one line, the value is on the next. e.g. <b>To:</b> MrPostman <mrp...@ma...><br> */ headerKeyStr = match.group(1); line2 = br.readLine(); headerValueStr = unescape(line2.substring(0, line2.length() - 4)); } else { match = bbfieldpattern.matcher(line); if (match.find()) { /* key and header on same line. e.g. <b>Return-Path:</b> <ch...@so...><br> */ headerKeyStr = match.group(1); headerValueStr = unescape(match.group(2)); } } //If we found a header line then process this information here... if (headerKeyStr != null) { message.addHeaderLine(headerKeyStr, headerValueStr); logger.fine( "Found header: " + headerKeyStr + " : " + headerValueStr); } else { //We may have processed all our header fields, we'll know this if they have sent //a </p> on its own if (line.equals("</p>")) { logger.fine("Finished processing header, </p> found."); state = FINDING_BODY; } } } /** * Process the message and wait for start of message body * * If we have processed the header, check for body part content-type lines * and the start of the body data (if present). e.g. * <b>Content-Type:</b> text/html; charset=us-ascii<br> * <b>Content-Transfer-Encoding:</b> 7bit<br> * <br> * <xhtml> * * or * * <PRE>hi this is the body text * </PRE> * * @param message * @param br * @param line * @return * @throws IOException */ void processMessageFindStartOfBody( BufferedReader br, String line) throws IOException { // For messages with a body type other than TEXT additional content-type lines // will be present... Matcher match = bbfieldpattern.matcher(line); if (match.find()) { /* key and header on same line. e.g. <b>Content-Type:</b> text/html; charset=us-ascii<br> */ String headerKeyStr = match.group(1); String headerValueStr = unescape(match.group(2)); logger.fine( "Found body part header: " + headerKeyStr + " : " + headerValueStr); message.addBodyHeaderLine(headerKeyStr, headerValueStr); } else if (line.toUpperCase().startsWith(TEXT_BODY_START_DELIM)) { bodyDelimiter = TEXT_BODY_START_DELIM; state = PROCESSING_BODY; logger.fine( "We have entered body - delimited by " + TEXT_BODY_START_DELIM); //we'll strip the pre tag message.addBodyLine(line.substring(TEXT_BODY_START_DELIM.length())); } else if (line.toUpperCase().startsWith(HTML_BODY_START_DELIM)) { bodyDelimiter = HTML_BODY_START_DELIM; state = PROCESSING_BODY; logger.fine( "We have entered body - delimited by " + HTML_BODY_START_DELIM); //we'll leave the xhtml tags complete message.addBodyLine(line); } } /** * Process the message body. * * @param message * @param br * @param line * @return * @throws IOException */ void processMessageBody( BufferedReader br, String line) throws IOException { boolean addLineToBody = false; if (bodyDelimiter.equals(TEXT_BODY_START_DELIM)) { // check if we have finished the body part... if (line.toUpperCase().startsWith(TEXT_BODY_END_DELIM)) { logger.fine( "We are have left body - delimited by " + TEXT_BODY_END_DELIM); bodyDelimiter = null; state = FINDING_ATTACHMENT; } else { //Add this line to our body content... addLineToBody = true; } } else if (bodyDelimiter.equals(HTML_BODY_START_DELIM)) { // check if we have finished the body part... if (line.toUpperCase().startsWith(HTML_BODY_END_DELIM)) { logger.fine( "We are have left body - delimited by " + HTML_BODY_END_DELIM); bodyDelimiter = null; state = FINDING_ATTACHMENT; // include the </xhtml> end tag in the body content... addLineToBody = true; } else { //Add this line to our body content... addLineToBody = true; } } if (addLineToBody) { message.addBodyLine(line); } } /** * Find any attachments in the message. * This method is called for each line in the received message after the main body has been processed. * * Attachments always start with: * <hr size="1"> */ private void findingAttachments(BufferedReader br, String line) { //Check for attachment start... Matcher match = attachStartPattern.matcher(line.toUpperCase()); if (match.find()) { Attachment attachment = new Attachment(); message.incrementAttachmentCount(); message.addAttachment(attachment); logger.fine("Found attachment start."); state = PROCESSING_ATTACHMENT; } } /** * Process any attachments in the message. * This method is called for each line in the received message after the main body has been processed. * * Attachments which are not inline will appear similar to this: * <hr size="1"> * <b>Content-Type:</b> application/zip; name="attach2.zip"<br> * <b>Content-Transfer-Encoding:</b> base64<br> * <b>Content-Disposition:</b> inline; filename="attach2.zip"<br> * <br> * <br><strong><a target="_blank" href="http://mail01.mail.com/getattach/attach2.zip?folder=INBOX&msg_uid=1073240058&filename=attach2.zip&partsno=2"><font color="BLUE">attach2.zip</font></a></strong><br> * */ private void processAttachments(BufferedReader br, String line) { // Attachments will have content type header lines... Matcher match = bbfieldpattern.matcher(line); if (match.find()) { /* key and header on same line. e.g. <b>Content-Type:</b> text/html; charset=us-ascii<br> */ String headerKeyStr = match.group(1); String headerValueStr = unescape(match.group(2)); logger.fine( "Found attachment header: " + headerKeyStr + " : " + headerValueStr); message.getCurrentAttachment().addHeaderLine(headerKeyStr, headerValueStr); } //Attachments can be inline for mime types which the browser can display or as links... //Check for attachment links... match = attachPattern.matcher(line); if (match.find()) { String attachmentUrl = match.group(1); String filename = match.group(4); String partno = match.group(5); message.getCurrentAttachment().setFilename(filename); message.getCurrentAttachment().setUrl(attachmentUrl); message.getCurrentAttachment().setPartId(partno); logger.fine("Found attachment: " + message.getCurrentAttachment().toString()); //finished this attachment... state = FINDING_ATTACHMENT; } //Check for inline attachments... if (line.toUpperCase().startsWith(TEXT_BODY_START_DELIM)) { message.getCurrentAttachment().setBodyDelimiter(TEXT_BODY_START_DELIM); state = PROCESSING_INLINE_ATTACHMENT; logger.fine("We have entered inline attachment body - delimited by " + TEXT_BODY_START_DELIM); //we'll strip the pre tag message.getCurrentAttachment().addBodyLine(line.substring(TEXT_BODY_START_DELIM.length())); } else if (line.toUpperCase().startsWith(HTML_BODY_START_DELIM)) { message.getCurrentAttachment().setBodyDelimiter(HTML_BODY_START_DELIM); state = PROCESSING_INLINE_ATTACHMENT; logger.fine("We have entered inline attachment body - delimited by " + HTML_BODY_START_DELIM); //we'll leave the xhtml tags complete message.getCurrentAttachment().addBodyLine(line); } } /** * Process the inline attachment body. * * @param message * @param br * @param line * @return * @throws IOException */ void processInlineAttachmentBody( BufferedReader br, String line) throws IOException { boolean addLineToBody = false; if (message.getCurrentAttachment().getBodyDelimiter().equals(TEXT_BODY_START_DELIM)) { // check if we have finished the body part... if (line.toUpperCase().startsWith(TEXT_BODY_END_DELIM)) { logger.fine( "We are have left body - delimited by " + TEXT_BODY_END_DELIM); state = FINDING_ATTACHMENT; } else { //Add this line to our body content... addLineToBody = true; } } else if (message.getCurrentAttachment().getBodyDelimiter().equals(HTML_BODY_START_DELIM)) { // check if we have finished the body part... if (line.toUpperCase().startsWith(HTML_BODY_END_DELIM)) { logger.fine( "We are have left body - delimited by " + HTML_BODY_END_DELIM); state = FINDING_ATTACHMENT; // include the </xhtml> end tag in the body content... addLineToBody = true; } else { //Add this line to our body content... addLineToBody = true; } } if (addLineToBody) { message.getCurrentAttachment().addBodyLine(line); } } private String unescape(String mystr) { String line = mystr.replaceAll("\\&", "\\&"); line = line.replaceAll("\\<", "<"); line = line.replaceAll("\\>", ">"); line = line.replaceAll("\\"", "\""); line = line.replaceAll("\\"", "\""); return line; } /** * @return */ public MailMessage getMessage() { return message; } } --- NEW FILE: MailDotComMessageParserTest.java --- /* * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java: * ex: set tabstop=4 expandtab: * * MrPostman - webmail <-> email gateway * Copyright (C) 2002-2003 MrPostman Development Group * Projectpage: http://mrbook.org/mrpostman/ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * In particular, this implies that users are responsible for * using MrPostman after reading the terms and conditions given * by their web-mail provider. * * You should have received a copy of the GNU General Public License * Named LICENSE in the base directory of this distribution, * if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.mrbook.mrpostman.maildotcom; import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import junit.framework.TestCase; //TODO - Add test case with two embedded attachments public class MailDotComMessageParserTest extends TestCase { //FILE1 = HTML with TXT attachment... public static final String MSG_FILE1 = "test/mesg1.mail.htm"; //FILE2 = HTML with ZIP attachment... public static final String MSG_FILE2 = "test/mesg2.mail.htm"; //FILE3 = TEXT body... public static final String MSG_FILE3 = "test/mesg3.mail.htm"; //FILE4 = HTML with HTML attachment... public static final String MSG_FILE4 = "test/mesg4.mail.htm"; //FILE5 - HTML with image attachment... public static final String MSG_FILE5 = "test/mesg5.mail.htm"; //FILE6 - HTML with 2 zip attachments... public static final String MSG_FILE6 = "test/mesg6.mail.htm"; //FILE7 - Multipart/alternative HTML and TEXT public static final String MSG_FILE7 = "test/mesg7.mail.htm"; public MailDotComMessageParserTest(String name) { super(name); } /** * This code will verify that the html message body code is working correctly * This code will also verify that the inline text attachment code is working correctly * @throws Exception */ public void testParserFile1() throws Exception { try { MailMessage msg = runParser(MSG_FILE1); // check headers... assertEquals(msg.getHeader("From"), "Chris Humphreys <ch...@so...>"); assertEquals(msg.getHeader("To"), "MrPostman <mrp...@ma...>"); assertEquals(msg.getHeader("Subject"), "test html with txt attachment"); assertEquals(msg.getHeader("Date"), "Sat, 10 Jan 2004 13:02:56 +0000"); // check msg body... assertEquals(msg.getBodyHeader("Content-Type"), "text/html; charset=us-ascii"); assertTrue(comparePartBodies(msg.getBodyLines(), createMsg1Body())); // check attachment... assertEquals(1, msg.getNumberAttachments()); assertTrue(msg.getAttachment(0).isEmbeddedAttachment()); assertEquals(msg.getAttachment(0).getHeader("Content-Type"), "text/plain; name=\"attach1.txt\""); assertEquals((String)msg.getAttachment(0).getBodyLines().iterator().next(), "text of attachment"); //correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } /** * This test will verify that the attachment link code is working correctly * @throws Exception */ public void testParserFile2() throws Exception { try { MailMessage msg = runParser(MSG_FILE2); // check headers... assertEquals(msg.getHeader("From"), "Chris Humphreys <ch...@so...>"); assertEquals(msg.getHeader("To"), "MrPostman <mrp...@ma...>"); assertEquals(msg.getHeader("Subject"), "test with zip attachment"); assertEquals(msg.getHeader("Date"), "Sun, 04 Jan 2004 18:14:06 +0000"); // we'll assume msg body works ok as it is similar to test1. // check attachment... assertEquals(1, msg.getNumberAttachments()); assertFalse(msg.getAttachment(0).isEmbeddedAttachment()); assertEquals(msg.getAttachment(0).getHeader("Content-Type"), "application/zip; name=\"attach2.zip\""); assertEquals(msg.getAttachment(0).getFilename(), "attach2.zip"); assertEquals(msg.getAttachment(0).getUrl(), "/getattach/attach2.zip?folder=INBOX&msg_uid=1073240058&filename=attach2.zip&partsno=2"); //correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } /** * This test verifies that the Header code and the TEXT body code works correctly. * @throws Exception */ public void testParserFile3() throws Exception { try { MailMessage msg = runParser(MSG_FILE3); // check headers... assertEquals(msg.getHeader("From"), "Chris Humphreys <ch...@so...>"); assertEquals(msg.getHeader("To"), "MrPostman <mrp...@ma...>"); assertEquals(msg.getHeader("Subject"), "single body text"); assertEquals(msg.getHeader("Date"), "Tue, 06 Jan 2004 21:36:38 +0000"); // check msg body... assertEquals(msg.getHeader("Content-Type"), "text/plain; charset=us-ascii; format=flowed"); assertEquals(msg.getHeader("Content-Transfer-Encoding"), "7bit"); assertEquals((String)msg.getBodyLines().iterator().next(),"hi this is the body text"); // check attachment... assertEquals(0, msg.getNumberAttachments()); // correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } /** * This test verifies the inline HTML attachment code works correctly * @throws Exception */ public void testParserFile4() throws Exception { try { MailMessage msg = runParser(MSG_FILE4); //we'll assume headers work correctly... //we'all assume html body works correctly... // check attachment... assertEquals(1, msg.getNumberAttachments()); assertTrue(msg.getAttachment(0).isEmbeddedAttachment()); assertEquals(msg.getAttachment(0).getHeader("Content-Type"), "text/html; name=\"attach3.html\""); assertTrue(comparePartBodies(msg.getAttachment(0).getBodyLines(), createMsg4AttachmentBody())); //correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } /** * This test verifies that image attachment code works correctly * This message has an blank html body and JPG attachment * @throws Exception */ public void testParserFile5() throws Exception { try { MailMessage msg = runParser(MSG_FILE5); // we'll assume headers work correctly... //we'all assume html body works correctly... // check attachment... assertEquals(1, msg.getNumberAttachments()); assertFalse(msg.getAttachment(0).isEmbeddedAttachment()); assertEquals(msg.getAttachment(0).getHeader("Content-Type"), "image/jpeg; name=\"gui-1.jpg\""); assertEquals(msg.getAttachment(0).getUrl(), "/getattach/gui-1.jpg?folder=INBOX&msg_uid=1073739625&filename=gui-1.jpg&partsno=2"); assertEquals(msg.getAttachment(0).getFilename(), "gui-1.jpg"); //correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } /** * This test verifies that multiple non-embedded attachment code * works correctly * @throws Exception */ public void testParserFile6() throws Exception { try { MailMessage msg = runParser(MSG_FILE6); //we'll assume headers work correctly... //we'all assume html body works correctly... // check attachment... assertEquals(2, msg.getNumberAttachments()); assertFalse(msg.getAttachment(0).isEmbeddedAttachment()); assertEquals(msg.getAttachment(0).getHeader("Content-Type"), "application/zip; name=\"attach2.zip\""); assertEquals(msg.getAttachment(0).getUrl(), "/getattach/attach2.zip?folder=INBOX&msg_uid=1073739904&filename=attach2.zip&partsno=2"); assertEquals(msg.getAttachment(0).getFilename(), "attach2.zip"); assertFalse(msg.getAttachment(1).isEmbeddedAttachment()); assertEquals(msg.getAttachment(1).getHeader("Content-Type"), "application/zip; name=\"attach1.zip\""); assertEquals(msg.getAttachment(1).getUrl(), "/getattach/attach1.zip?folder=INBOX&msg_uid=1073739904&filename=attach1.zip&partsno=3"); assertEquals(msg.getAttachment(1).getFilename(), "attach1.zip"); //correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } /** * This test verifies that the Header code and the TEXT body code works correctly. * Mail.com will infact just return the HTML version and ignore the TEXT version * @throws Exception */ public void testParserFile7() throws Exception { try { MailMessage msg = runParser(MSG_FILE7); // check headers... assertEquals(msg.getHeader("From"), "Chris Humphreys <ch...@so...>"); assertEquals(msg.getHeader("To"), "MrPostman <mrp...@ma...>"); assertEquals(msg.getHeader("Subject"), "multipart alternative"); assertEquals(msg.getHeader("Date"), "Sun, 11 Jan 2004 19:19:06 +0000"); // check msg body... assertEquals(msg.getBodyHeader("Content-Type"), "text/html; charset=us-ascii"); assertEquals(msg.getBodyHeader("Content-Transfer-Encoding"), "7bit"); assertTrue(comparePartBodies(msg.getBodyLines(), createMsg7Body())); // check attachment... assertEquals(0, msg.getNumberAttachments()); // correct! } catch (Exception e) { fail("Exception " + e.getMessage()); } } private MailMessage runParser(String fileName) throws Exception { BufferedReader br = new BufferedReader( new FileReader(fileName)); MailDotComMessageParser parser = new MailDotComMessageParser(); parser.processMessage(br, -1); MailMessage message = parser.getMessage(); return message; } private Collection createMsg1Body() { //see message1.eml //Note: it is given that mail.com will convert the file to xhtml ArrayList bodyLines = new ArrayList(); bodyLines.add("<xhtml>"); bodyLines.add("<head>"); bodyLines.add(" <xmeta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\">"); bodyLines.add(" <title></title>"); bodyLines.add("</head>"); bodyLines.add("<xbody text=\"#000000\" bgcolor=\"#ffffff\">"); bodyLines.add("hi there html body<br>"); bodyLines.add("</xbody>"); bodyLines.add("</xhtml>"); return bodyLines; } private Collection createMsg4AttachmentBody() { //see message4.eml //Note: it is given that mail.com will convert the file to xhtml ArrayList bodyLines = new ArrayList(); bodyLines.add("<xhtml>"); bodyLines.add("<xbody>"); bodyLines.add("attachment"); bodyLines.add("</xbody>"); bodyLines.add("</xhtml>"); return bodyLines; } private Collection createMsg7Body() { //see message7.eml //Note: it is given that mail.com will convert the file to xhtml ArrayList bodyLines = new ArrayList(); bodyLines.add("<xhtml>"); bodyLines.add("<head>"); bodyLines.add(" <xmeta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\">"); bodyLines.add(" <title></title>"); bodyLines.add("</head>"); bodyLines.add("<xbody text=\"#000000\" bgcolor=\"#ffffff\">"); bodyLines.add("There are two bodies on this message!<br>"); bodyLines.add("</xbody>"); bodyLines.add("</xhtml>"); return bodyLines; } private boolean comparePartBodies(Collection bodyALines, Collection bodyBLines) { Iterator itB = bodyBLines.iterator(); Iterator itA = bodyALines.iterator(); boolean equal = true; while (true) { if (itA.hasNext()) { if (!itB.hasNext()) { equal = false; break; } else { //we have two lines, lets compare them... String lineA = (String)itA.next(); if (!lineA.equals((String)itB.next())) { equal = false; break; } } } else { if (itB.hasNext()) { equal = false; break; } else { break; } } } return equal; } } --- NEW FILE: MailIdentifier.java --- /* * -*- mode: java; c-basic-indent: 4; indent-tabs-mode: nil -*- * :indentSize=4:noTabs=true:tabSize=4:indentOnTab=true:indentOnEnter=true:mode=java: * ex: set tabstop=4 expandtab: * * MrPostman - webmail <-> email gateway * Copyright (C) 2002-2003 MrPostman Development Group * Projectpage: http://mrbook.org/mrpostman/ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * In particular, this implies that users are responsible for * using MrPostman after reading the terms and conditions given * by their web-mail provider. * * You should have received a copy of the GNU General Public License * Named LICENSE in the base directory of this distribution, * if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.mrbook.mrpostman.maildotcom; /** * @author chris * * Represents a MailIdentifier */ public class MailIdentifier { String MailID = null; String author = null; String date = null; String subject = null; boolean unread = false; boolean flagged = false; int size; boolean retrieveSuccess = false; /** * */ public MailIdentifier() { super(); } public String toString() { return new String( "MailID=" + MailID + ", unread=" + unread + " flagged=" + flagged + " size=" + size); } } |
From: <chr...@us...> - 2004-01-12 22:26:12
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom In directory sc8-pr-cvs1:/tmp/cvs-serv10375/mrpostman/src/org/mrbook/mrpostman/maildotcom Modified Files: MailDotComMailSession.java Log Message: re-write to support new mail.com Index: MailDotComMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom/MailDotComMailSession.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** MailDotComMailSession.java 3 Dec 2003 12:08:35 -0000 1.27 --- MailDotComMailSession.java 12 Jan 2004 22:26:08 -0000 1.28 *************** *** 37,46 **** --- 37,49 ---- import org.mrbook.mrpostman.ModuleOption; import org.mrbook.mrpostman.WebMailSession; + import org.mrbook.mrpostman.another.Base64; import java.io.BufferedReader; import java.io.InputStreamReader; + import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.UnsupportedEncodingException; + import java.io.ByteArrayOutputStream; import java.net.HttpURLConnection; *************** *** 54,67 **** import java.util.regex.Matcher; import java.util.regex.Pattern; ! public class MailDotComMailSession extends WebMailSession { public static final String CVSID = "$Id$"; /** * Our hardcoded ModuleInfo data. */ ! private static final String[] AUTHORS = {"Hector Urtubia <ur...@mr...>", "Lucas Bruand <lb...@wa...>"}; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("mail.com", AUTHORS, "0.1", "http://mrpostman.sourceforge.net/updates/maildc", "/en/maildotcom/index.html", new ModuleOption[0]); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.maildotcom.MailDotComMailSession"); --- 57,84 ---- import java.util.regex.Matcher; import java.util.regex.Pattern; + import java.util.Iterator; + import java.util.Collection; ! //**TODO** Fix login. Fix HTML retrieve. Sort out advert page skips. Fix attachments Check it works when some are read / unread ! /* ! function seenAd(){ ! if(adShown == true){ ! self.location.href="http://mail01.mail.com/scripts/common/home.main?nu=%2Fscripts%2Fmail%2Fmailbox.mail%3F.ob%3D0523600a741e783f1dc9619fc0e0fb4f6eeaa62b%26folder%3DINBOX&.intr=1"; ! } ! } ! */ public class MailDotComMailSession extends WebMailSession { public static final String CVSID = "$Id$"; /** + * Generate summary information for all actions. If this is enabled, a maildrop summary will be output to the log. + */ + public static final boolean CREATE_SUMMARY_INFO = true; + + /** * Our hardcoded ModuleInfo data. */ ! private static final String[] AUTHORS = {"Hector Urtubia <ur...@mr...>", "Lucas Bruand <lb...@wa...>", "Chris Humphreys <ch...@so...>"}; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("mail.com", AUTHORS, "0.2", "http://mrpostman.sourceforge.net/updates/maildc", "/en/maildotcom/index.html", new ModuleOption[0]); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.maildotcom.MailDotComMailSession"); *************** *** 69,75 **** private static String httpInboxURL = "http://mail01.mail.com/scripts/mail/mailbox.mail"; private static String msgReadBaseURL = "http://mail01.mail.com/scripts/mail/mesg.mail?folder=INBOX&print=1&mhead=f&msg_uid="; ! private static String UserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20010914"; ! private static Pattern bfieldpattern = Pattern.compile("<b>(.*)</b>"); ! private static Pattern bbfieldpattern = Pattern.compile("<B>(.*)</B>(.*)<BR>"); private String baseUrl = null; private Vector messageIDS = null; --- 86,90 ---- private static String httpInboxURL = "http://mail01.mail.com/scripts/mail/mailbox.mail"; private static String msgReadBaseURL = "http://mail01.mail.com/scripts/mail/mesg.mail?folder=INBOX&print=1&mhead=f&msg_uid="; ! private static String userAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20010914"; private String baseUrl = null; private Vector messageIDS = null; *************** *** 84,100 **** private int limit_number_messages = 350; String username = null; ! private CookieJar cj = null; public int login(String username, String password, boolean secure) { this.username = new String(username); - String username2 = username.replaceAll("@.+\\Z", ""); - logger.fine("The username will be : " + username2); cj = new CookieJar(); ! String postRequest = createPostRequest(username, password); try { ! URL url = new URL(httpLoginURL + "?" + postRequest); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestProperty("User-Agent", UserAgent); conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Accept", "*/*"); --- 99,120 ---- private int limit_number_messages = 350; String username = null; ! private CookieJar cj = null; ! ! + + public int login(String username, String password, boolean secure) { this.username = new String(username); cj = new CookieJar(); ! //We'll perform a manual POST to perform a log in... ! //**TODO** rewrite this to use a general helper class to perform cookie POSTs ! //**TODO** doesn't correctly handle login failures ! String obStr = doPostLogin(username, password, cj); try { ! URL url = new URL("http://mail01.mail.com/scripts/mail/mailbox.mail?folder=INBOX&.ob=" + obStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestProperty("User-Agent", userAgent); conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Accept", "*/*"); *************** *** 102,105 **** --- 122,126 ---- conn.setInstanceFollowRedirects(false); HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); + hrh.setCookieJar(cj); hrh.connect(); *************** *** 128,131 **** --- 149,154 ---- rd.close(); + baseUrl = getBaseURL(conn.getURL()); + // Now, go to the INBOX and get the number of unread messages // *************** *** 135,142 **** } ! //baseUrl = getBaseURL(conn.getURL()); //System.err.println(baseUrl.toString()); } catch (Exception e) { ! logger.log(Level.SEVERE, "should not happen", e); } authenticated = true; --- 158,167 ---- } ! //System.err.println(baseUrl.toString()); } catch (Exception e) { ! logger.log(Level.SEVERE, "Exception during login() - " +e.getMessage(), e); ! logger.log(Level.INFO, "Login failed due to unexpected error. It is probably not due to your username/password"); ! return WebMailSession.WMS_LOGIN_FAILED; } authenticated = true; *************** *** 144,147 **** --- 169,239 ---- } + // This is currently a nasty hack to perform a manual POST login... + private String doPostLogin(String username, String password, CookieJar cj) { + try { + URL url = new URL("http://www.mail.com/scripts/common/proxy.main"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setRequestProperty("User-Agent", userAgent); + conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); + conn.setInstanceFollowRedirects(false); + conn.connect(); + java.io.OutputStreamWriter osw = new java.io.OutputStreamWriter(conn.getOutputStream()); + String data = "action=login&show_frame=Enter&mail_language=us&login="; + data += URLEncoder.encode(username, "UTF-8"); + data += "&password="; + data += URLEncoder.encode(password, "UTF-8"); + data += "&x=0&y=0"; + osw.write(data); + osw.flush(); + osw.close(); + + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + com.sonalb.net.http.cookie.Client client = new com.sonalb.net.http.cookie.Client(); + cj.addAll(client.getCookies(conn)); + + String line = null; + + while ((line = br.readLine()) != null) { + logger.log(Level.FINEST, line); + } + + conn.disconnect(); + + logger.log(Level.FINEST, cj.toString()); + + // The output redirects us via 302... + + url = new URL(conn.getHeaderField("location")); + System.out.println(url.toString()); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty("User-Agent", userAgent); + conn.setRequestProperty("Accept", "*/*"); + conn.setRequestProperty("Allowed", "GET HEAD PUT"); + conn.setInstanceFollowRedirects(false); + HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); + hrh.setCookieJar(cj); + hrh.connect(); + cj.addAll(hrh.getCookieJar()); + br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + Pattern obPattern = Pattern.compile("<frame src=\".*ob=([0-9a-f]*).*\" name=\"mailcomframe\".*?>"); + while ((line = br.readLine()) != null) { + Matcher obMatcher = obPattern.matcher(line); + if (obMatcher.find()) { + return obMatcher.group(1); + } + logger.log(Level.FINEST, line); + } + + conn.disconnect(); + } catch (java.io.IOException ioe) { + logger.log(Level.SEVERE, "Exception during manual login - " + ioe.getMessage()); + } + return null; + } + + private String createPostRequest(String username, String password) { String line = null; *************** *** 174,177 **** --- 266,271 ---- String inboxRequest = null; + logger.info("numMessages()"); + if (messageIDS != null) { return messageIDS.size(); *************** *** 192,197 **** Pattern sizePattern = Pattern.compile(".*<!--<<--> Size <!-->>--></b></font></A></td>.*"); /* <!--<<--> Size <!-->>--></b></font></A></td> */ ! Matcher sizeMatcher = null; ! Pattern messagePattern = Pattern.compile("<td align=\"center\">.*?</td>" // Important flag + "<td align=\"center\">.*?</td>" // Flag + "<td align=\"center\">.*?</td>" // Attachment --- 286,291 ---- Pattern sizePattern = Pattern.compile(".*<!--<<--> Size <!-->>--></b></font></A></td>.*"); /* <!--<<--> Size <!-->>--></b></font></A></td> */ ! Matcher sizeMatcher = null; ! /* String messagePatternStr = "<td align=\"center\">.*?</td>" // Important flag + "<td align=\"center\">.*?</td>" // Flag + "<td align=\"center\">.*?</td>" // Attachment *************** *** 201,207 **** + "<td><a class=\"hlink\" href=\"Javascript:readPopUpMail\\('http://mail01.mail.com/scripts/mail/mesg.mail\\?folder=INBOX(?:&order=.*?)?&mview=a&mstart=1&msg_uid=([0-9]+)&mprev=[0-9]*&mnext=[0-9]*'\\)\">(?:<font .*?>)?(?:<b>)?(.*?)(?:</b>)?(?:</font>)?</a></td>" // msguid = group 2, msgsubject = group 3 + "<td>(?:<font .*?>)?(.*?)(?:</font>)?</td>" // Date = group 4 ! + "<td align=\"center\">(?:<font .*?>)?([0-9]+)k(?:</font>)?</td>" // size = group 5 */ ! ); ! /* */ Matcher messageMatcher = null; --- 295,310 ---- + "<td><a class=\"hlink\" href=\"Javascript:readPopUpMail\\('http://mail01.mail.com/scripts/mail/mesg.mail\\?folder=INBOX(?:&order=.*?)?&mview=a&mstart=1&msg_uid=([0-9]+)&mprev=[0-9]*&mnext=[0-9]*'\\)\">(?:<font .*?>)?(?:<b>)?(.*?)(?:</b>)?(?:</font>)?</a></td>" // msguid = group 2, msgsubject = group 3 + "<td>(?:<font .*?>)?(.*?)(?:</font>)?</td>" // Date = group 4 ! + "<td align=\"center\">(?:<font .*?>)?([0-9]+)k(?:</font>)?</td>"; // size = group 5 ! */ ! String messagePatternStr = "<td align=\"center\">.*?</td><td align=\"center\">.*?</td><td align=\"center\">.*?</td><td align=\"center\">.*?</td>"; ! messagePatternStr +="<td align=\"center\">.*?</td><td>(?:<font .*?>)?(?:<B>)?(.*?)(?:</B>)?</td><td>"; ! messagePatternStr += "<a class=\"hlink\" href=\"/scripts/mail/mesg.mail\\?folder=INBOX(?:&order=.*?)?&mview=a&mstart=1&.popup=0&msg_uid=([0-9]+)&mprev=[0-9]*&mnext=[0-9]*\".*>"; ! messagePatternStr += "<font .*?><b>(.*)</b></font></a></td>"; ! messagePatternStr += "<td>(?:<font .*?>)?(.*?)(?:</font>)?</td><td align=\"center\">(?:<font .*?>)?([0-9]+)k(?:</font>)?</td>"; ! ! logger.fine("Using message pattern: " + messagePatternStr); ! Pattern messagePattern = Pattern.compile(messagePatternStr); ! ! Matcher messageMatcher = null; *************** *** 223,227 **** logger.log(Level.SEVERE, "should not happen", e); } ! conn.setRequestProperty("User-Agent", UserAgent); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Allowed", "GET HEAD PUT"); --- 326,330 ---- logger.log(Level.SEVERE, "should not happen", e); } ! conn.setRequestProperty("User-Agent", userAgent); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Allowed", "GET HEAD PUT"); *************** *** 248,252 **** numMessages = Integer.parseInt(unreadMessagesMatcher.group(1)); numNewMessages = Integer.parseInt(unreadMessagesMatcher.group(2)); ! logger.info("found line containing number of messages: " + numMessages + "messages and " + numNewMessages + " new"); break; --- 351,355 ---- numMessages = Integer.parseInt(unreadMessagesMatcher.group(1)); numNewMessages = Integer.parseInt(unreadMessagesMatcher.group(2)); ! logger.info("found line containing number of messages: " + numMessages + " messages and " + numNewMessages + " new"); break; *************** *** 334,343 **** messageIDS.add(muid); } else { ! logger.severe("We have a big problem... Message is NOT recognized!"); } } return messageIDS.size(); } catch (java.io.IOException e) { ! logger.log(Level.SEVERE, "should not happen", e); } return 0; --- 437,446 ---- messageIDS.add(muid); } else { ! logger.severe("We have a big problem... Message is NOT recognized! (messageMatcher did not match)"); } } return messageIDS.size(); } catch (java.io.IOException e) { ! logger.log(Level.SEVERE, "Exception in numMessages() - " + e.getMessage(), e); } return 0; *************** *** 349,390 **** /** ! * Retrieve and output the message. ! * If option is enabled, flag the message as read. ! * This is called by the RETR command. ! */ public void outputMessage(int num, PrintWriter pw) { ! retrieveMessage(num, pw, -1); } ! public String unescape(String mystr) { ! String line = mystr.replaceAll("\\&", "\\&"); ! line = line.replaceAll("\\<", "<"); ! line = line.replaceAll("\\>", ">"); ! line = line.replaceAll("\\"", "\""); ! return line; } ! /** ! * Retrieve the msg specified by the supplied msg number (indexed from 1!) ! * Strip the HTML tags and output the message (complete with header and attachments) to ! * the supplied PrintWriter ! * if numLines != -1 then limit the number of body lines to be this value (used for the TOP command) ! * Assumptions: the msg will be surrounded by 'PRE' and '/PRE' tags. ! */ ! private void retrieveMessage(int num, PrintWriter pw, int numLines) { ! logger.info("RETR Email #:" + num); ! if (num > numMessages()) { ! logger.warning("outputMessage() called with invalid message number " + num + " messageIDs size = " ! + messageIDS.size()); return; } try { ! URL url = new URL(msgReadBaseURL + ((MailIdentifier) messageIDS.elementAt(num - 1)).MailID); ! logger.fine("Read URL:\n" + url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestProperty("User-Agent", UserAgent); ! conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Allowed", "GET HEAD PUT"); conn.setInstanceFollowRedirects(false); --- 452,552 ---- /** ! * Retrieve and output the message. ! * If the option is enabled, move the message into the READ folder. ! * This is called by the RETR command. ! */ ! ! //public void outputMessage(int num, PrintWriter pw) throws MailSessionException{ public void outputMessage(int num, PrintWriter pw) { ! try { ! retrieveMessage(num, pw, -1); ! ! //flag message as retrieved... ! logger.fine("Flagging message as retrieved."); ! ((MailIdentifier) messageIDS.elementAt(num - 1)).retrieveSuccess = true; ! ! } catch (MailSessionException me) { ! logger.severe("outputMessage() Exception - " + me.getMessage()); ! } } ! /** ! * Retrieve the email header and numLines of the email body. ! * The message will not be marked as read. ! * This is called by the TOP command. ! */ ! public void outputLinesMessage(int num, PrintWriter pw, int numLines) { ! try { ! retrieveMessage(num, pw, numLines); ! ! } catch (MailSessionException me) { ! logger.severe("outputMessage() Exception - " + me.getMessage()); ! } } ! /** ! * Retrieve the msg specified by the supplied msg number (indexed from 1!) ! * This will use other methods to verify if the mail has attachements, retrieve the body text (always HTML) ! * and attachements. ! */ ! private void retrieveMessage(int num, PrintWriter pw, int numLines) ! throws MailSessionException { ! logger.fine("Retrieve Email #:" + num + ((numLines != -1) ? (" numlines=" + numLines) : " full")); ! if (num > numMessages) { ! logger.severe("outputMessage() called with invalid message number " + num + " number of messages = " ! + numMessages); return; } + //First parse the header and message body... + MailMessage message = requestAndParseMessage(num, numLines); + + //Output the message... + outputMessageHeader(message, pw); + outputMessageBody(message, pw); + + if (message.getNumberAttachments() > 0) { + for (int attachmentIndex = 0; attachmentIndex < message.getNumberAttachments(); attachmentIndex++) { + Attachment attachment = message.getAttachment(attachmentIndex); + logger.fine("Handling attachment (" + attachment.getPartId() + "," + attachment.getFilename()+ ")"); + if (attachment.isEmbeddedAttachment()) { + outputEmbeddedAttachment(message, attachment, pw); + } else { + outputLinkAttachment(message, attachment, pw); + } + } + + //Now we must output the closing boundary... + pw.print("--" + message.getBoundary() + "--"); + pw.print("\r\n"); + } + + pw.flush(); + } + + + /** + * Retrieve the msg specified by the supplied msg number (indexed from 1!) + * Strip the HTML tags and parse the message header. + * if numLines != -1 then limit the number of body lines to be this value (used for the TOP command) + * There is quite a lot of processing of the message. The message will be retrieved in the 'print' format with full headers + * This will allow us all the usual headers and the mime type for the message. If this is a simple HTML or TEXT only message + * this is sufficient. If this is a multipart message then we'll have to do more work. We'll have to process the body part + * and retrieve the MIME from this body part. We'll also need to process any attachments as they occur. The difficulty here is + * that some attachment types will be inline on the message (Text, HTML, Images) and others will be as a link. We'll need to + * support both, retrieve the data and reconstruct the MIME message envelope. + * + */ + private MailMessage requestAndParseMessage(int num, int numLines) + throws MailSessionException { + logger.fine("Retrieve Email Body #:" + num + ((numLines != -1) ? (" numlines=" + numLines) : " full")); + BufferedReader br = null; + try { ! URL url = new URL(msgReadBaseURL + ((MailIdentifier) messageIDS.elementAt(num - 1)).MailID); ! logger.fine("url: " + url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestMethod("GET"); conn.setRequestProperty("Allowed", "GET HEAD PUT"); conn.setInstanceFollowRedirects(false); *************** *** 393,469 **** hrh.connect(); cj.addAll(hrh.getCookieJar()); ! BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; - //Output everything between the <pre> tags... - boolean insidePre = false; - boolean insideBody = false; - int bodyLine = 0; ! while ((line = br.readLine()) != null) { ! logger.finest("html: " + line); ! //Strip/convert any html tags ! if (line.startsWith("</PRE>")) { ! logger.info("We are outside the PRE"); ! insidePre = false; ! continue; ! } ! if (line.startsWith("<PRE>")) { ! insidePre = true; ! logger.info("We are inside the PRE"); ! pw.print("\r\n"); ! line = line.substring(5); ! } ! if (line.startsWith("</html>")) { ! logger.fine("/html tag reached"); ! break; ! } - if (insidePre) { - //if(line.length()==0) insideBody=true; //first occurance signifies start of body text - line = unescape(line); - logger.fine("Included:" + line); - pw.print(line); - pw.print("\r\n"); //just incase the system we are running on has a different line terminator - } else { - Matcher match = bfieldpattern.matcher(line); ! if (match.find()) { ! ! pw.print(match.group(1)); ! line = br.readLine(); ! logger.finest("html: " + line); ! line = unescape(line.substring(0, line.length() - 4)); ! pw.print(line); ! pw.print("\r\n"); ! logger.fine("Found header: " + match.group(1) + " = " + line); ! } else { ! match = bbfieldpattern.matcher(line); ! if (match.find()) { ! ! pw.print(match.group(1)); ! pw.print(unescape(match.group(2))); ! logger.fine("found header group:" + match.group(1) + " " + unescape(match.group(2))); ! pw.print("\r\n"); ! } ! } } } ! logger.fine("Flush pw"); pw.flush(); ! } catch (Exception e) { ! logger.log(Level.SEVERE, "should not happen", e); } } ! // hook for POP. ! public void outputLinesMessage(int num, PrintWriter pw, int numLines) { ! retrieveMessage(num, pw, numLines); ! } // hook for UIDL. Optional. public String getUniqueMessageId(int num) throws MailSessionException { --- 555,764 ---- hrh.connect(); cj.addAll(hrh.getCookieJar()); ! br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; + + //We'll delegate responsibility for parsing the message to our parser... + MailDotComMessageParser parser = new MailDotComMessageParser(); + return parser.processMessage(br, numLines); + + } catch (Exception e) { + logger.log(Level.SEVERE, "Exception in parseMessageHeaderAndBody - " + e.getMessage(), e); + throw new MailSessionException("parseMessageHeaderAndBody(" + num + "," + numLines + ") failed : " + + e.getMessage()); + } finally { + try { + if (br != null) { + br.close(); + } + } catch (IOException ie) { + logger.log(Level.SEVERE, "should not happen", ie); + } + } + } ! ! /** ! * Output the email header ! */ ! private void outputMessageHeader(MailMessage message, PrintWriter pw) { ! ! if (message.getNumberAttachments() == 0) { ! //No attachments, single body message. ! //Depending on the message (multipart etc.) the correct content type headers ! //could be on the message header or on the body header. We'll merge the two using ! //the body headers as superior... ! message.getHeaders().putAll(message.getBodyHeaders()); ! for (Iterator it = MailMessage.getHeadersAsCollection(message.getHeaders()).iterator(); it.hasNext();) { ! pw.print((String)it.next()); ! pw.print("\r\n"); ! } ! pw.print("\r\n"); ! pw.print("\r\n"); //ouput the blank header-body separator line ! } else { ! //this is a multipart message. We'll strip and "Content-Type" headers from the message, ! //output all the others and then add our standard MIME headers... ! for (Iterator it = MailMessage.getHeadersAsCollection(message.getHeaders()).iterator(); it.hasNext(); ) { ! String hdr = (String)it.next(); ! if (!hdr.startsWith("Content-Type")) { ! pw.print(hdr); ! pw.print("\r\n"); ! } ! } ! ! //output our MIME header... ! pw.print("MIME-Version: 1.0"); ! pw.print("\r\n"); ! message.setBoundary(createUniqueBoundaryValue(message)); ! pw.print("Content-Type: multipart/mixed; boundary=\"" + message.getBoundary() + "\""); ! pw.print("\r\n"); ! pw.print("\r\n"); ! pw.print("This is a multi-part message in MIME format."); ! pw.print("\r\n"); ! pw.print("--" + message.getBoundary()); ! pw.print("\r\n"); ! //Now output body headers... ! for (Iterator it = MailMessage.getHeadersAsCollection(message.getBodyHeaders()).iterator(); it.hasNext(); ) { ! String hdr = (String)it.next(); ! pw.print(hdr); ! pw.print("\r\n"); ! } ! pw.print("\r\n"); //ouput the blank header-body separator line ! } ! } ! /** ! * Create a unique boundary string ! */ ! private String createUniqueBoundaryValue(MailMessage message) { ! StringBuffer sBuffer = new StringBuffer(); ! sBuffer.append("----=_Part_").append(message.getTmpPartCount()).append("_").append(sBuffer.hashCode()).append('.') ! .append(System.currentTimeMillis()); ! message.setBoundary(sBuffer.toString()); ! message.setTmpPartCount(message.getTmpPartCount() + 1); ! return message.getBoundary(); ! } ! /** ! * Output the email body ! */ ! private void outputMessageBody(MailMessage message, PrintWriter pw) { ! for (Iterator it = message.getBodyLines().iterator(); it.hasNext(); ) { ! pw.print((String)it.next()); ! pw.print("\r\n"); ! } ! } ! /** ! * Output an attachment which is not embedded in the page, i.e. one retrieved by ! * an href ! */ ! private void outputLinkAttachment(MailMessage message, Attachment attachment, PrintWriter pw) ! throws MailSessionException { ! logger.fine("outputLinkAttachment : " + attachment.getFilename()); ! //Retrieve the attachment... ! InputStream is = null; ! try { ! //read it and base64 encode it ! URL url = new URL(baseUrl + attachment.getUrl()); ! ! logger.fine("Attachment URL:\n" + url); ! HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestMethod("GET"); ! conn.setRequestProperty("Allowed", "GET HEAD PUT"); ! conn.setInstanceFollowRedirects(false); ! HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); ! hrh.setCookieJar(cj); ! hrh.connect(); ! cj.addAll(hrh.getCookieJar()); ! String contentType = conn.getContentType(); ! logger.fine("Content-type:" + contentType); ! is = conn.getInputStream(); ! int size = conn.getContentLength(); ! if (size <= 0) { ! //it is possible that the size is not set, we'll guess ! size = 1024; ! ! } ! ByteArrayOutputStream bos = new ByteArrayOutputStream(size); ! ! int numRead = -1; ! byte[] bytes = new byte[128]; ! ! while ((numRead = is.read(bytes)) > -1) { ! if (numRead > 0) { ! bos.write(bytes, 0, numRead); } } ! ! logger.fine("Attachment size: " + bos.toByteArray().length); ! //We have the raw attachment bytes. Output the header with the correct content type.... ! pw.print("--" + message.getBoundary()); ! pw.print("\r\n"); ! pw.print("Content-Type: " + contentType + "; name=\"" + attachment.getFilename() + "\""); ! pw.print("\r\n"); ! pw.print("Content-Transfer-Encoding: base64"); ! pw.print("\r\n"); ! pw.print("Content-Disposition: attachment; filename=\"" + attachment.getFilename() + "\""); ! pw.print("\r\n"); ! pw.print("\r\n"); //ouput the blank header-body separator line ! ! //Encode the bytes and output... ! pw.print(Base64.encodeBytes(bos.toByteArray(), true)); ! pw.print("\r\n"); pw.flush(); ! } catch (IOException ie) { ! throw new MailSessionException("outputAttachment(" + message + "," + attachment.getFilename() + ") failed : " ! + ie.getMessage()); ! } finally { ! try { ! if (is != null) { ! is.close(); ! } ! } catch (IOException ie) { ! logger.log(Level.SEVERE, "outputLinkAttachment: Exception -" + ie.getMessage(), ie); ! } } } ! /** ! * Output an attachment which is embedded in the page, i.e. one not retrieved by ! * an href ! */ ! private void outputEmbeddedAttachment(MailMessage message, Attachment attachment, PrintWriter pw) ! throws MailSessionException { ! logger.fine("outputEmbeddedAttachment"); ! ! pw.print("--" + message.getBoundary()); ! pw.print("\r\n"); ! //Output the attachment headers... ! for (Iterator it = MailMessage.getHeadersAsCollection(attachment.getHeaders()).iterator(); it.hasNext(); ) { ! pw.print((String)it.next()); ! pw.print("\r\n"); ! } ! pw.print("\r\n"); //ouput the blank header-body separator line + //Output the attachment body... + for(Iterator it = attachment.getBodyLines().iterator(); it.hasNext(); ) { + pw.print((String)it.next()); + pw.print("\r\n"); + } + pw.print("\r\n"); + pw.flush(); + } + + private byte[] getBodyLineCollectionAsBytes(Collection lines) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter pw = new PrintWriter(bos); + for(Iterator it = lines.iterator(); it.hasNext(); ) { + pw.print((String)it.next()); + pw.print("\r\n"); + } + return bos.toByteArray(); + } + // hook for UIDL. Optional. public String getUniqueMessageId(int num) throws MailSessionException { *************** *** 484,487 **** --- 779,788 ---- return false; } + + if(((MailIdentifier) messageIDS.elementAt(num - 1)).retrieveSuccess == false) { + logger.warning("Message was not successfully received. Ignoring DELE request. Message will remain on server."); + return false; + } + try { String delUrl = httpInboxURL + "?"; *************** *** 494,498 **** URL url = new URL(delUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestProperty("User-Agent", UserAgent); conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Accept", "*/*"); --- 795,799 ---- URL url = new URL(delUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); ! conn.setRequestProperty("User-Agent", userAgent); conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Accept", "*/*"); *************** *** 573,604 **** public static void main(String[] args) { ! if (args.length != 2) { ! System.err.println("Syntax MailDotComMailSession username password"); System.exit(1); } MailDotComMailSession mms = new MailDotComMailSession(); if (mms.login(args[0], args[1], true) == WebMailSession.WMS_LOGIN_OK) { System.out.println("Number of messages: " + mms.numMessages()); } else { System.out.println("ERROR"); } - } - } - - /** - * Helper class used to store message info. - */ - class MailIdentifier { - String MailID = null; - String author = null; - String date = null; - String subject = null; - boolean unread = false; - boolean flagged = false; - int size; - public String toString() { - return new String("MailID=" + MailID + ", unread=" + unread + " flagged=" + flagged + " size=" + size); } } --- 874,932 ---- public static void main(String[] args) { ! if (args.length != 3) { ! System.err.println("Syntax MailDotComMailSession username password msgno"); System.exit(1); } + + /* + //Message regex test - CH 30/12/03 + String msgStr = "<td align=\"center\"><img src=\"http://img1.us4.outblaze.com/common/inbox/ib_norm.gif\"></td><td align=\"center\"><img src=\"http://img1.us4.outblaze.com/common/inbox/ib_none.gif\"></td><td align=\"center\"><img src=\"http://img1.us4.outblaze.com/common/inbox/ib_none.gif\"></td><td align=\"center\"><img src=\"http://img1.us4.outblaze.com/common/inbox/ib_unread.gif\"></td><td align=\"center\"><input type=\"checkbox\" name=\"sel_1071861300\" value=\"ON\" onClick=\"checkAllMessages(this);\"></td>"; + msgStr += "<td><font size=\"-1\"><B> mail.com Member Services </B></td>"; + msgStr += "<td><a class=\"hlink\" href=\"/scripts/mail/mesg.mail?folder=INBOX&order=Newest&mview=a&mstart=1&.popup=0&msg_uid=1071861300&mprev=&mnext=\" onclick=\"return readPopUpMail(this.href)\">"; + msgStr += "<font size=\"-1\" color=\"000000\"><b>Welcome to mail.com</b></font></a></td>"; + msgStr += "<td><font size=\"-1\">19 Dec 2003</font></td><td align=\"center\"><font size=\"-1\">1k</font></td>"; + + String pStr = "<td align=\"center\">.*?</td><td align=\"center\">.*?</td><td align=\"center\">.*?</td><td align=\"center\">.*?</td>"; + pStr +="<td align=\"center\">.*?</td><td>(?:<font .*?>)?(?:<B>)?(.*?)(?:</B>)?</td><td>"; + pStr += "<a class=\"hlink\" href=\"/scripts/mail/mesg.mail\\?folder=INBOX(?:&order=.*?)?&mview=a&mstart=1&.popup=0&msg_uid=([0-9]+)&mprev=[0-9]*&mnext=[0-9]*\".*>"; + //pStr += "(?:<font .*?>)?(?:<b>)?(.*?)(?:</b>)?(?:</font>)?</a></td>"; + pStr += "<font .*?><b>(.*)</b></font></a></td>"; + + pStr += "<td>(?:<font .*?>)?(.*?)(?:</font>)?</td><td align=\"center\">(?:<font .*?>)?([0-9]+)k(?:</font>)?</td>"; + Pattern p = Pattern.compile(pStr); + Matcher messageMatcher = p.matcher(msgStr); + if (messageMatcher.find()) { + System.out.println(messageMatcher.group(1)); + System.out.println(messageMatcher.group(2)); + System.out.println(messageMatcher.group(3)); + System.out.println(messageMatcher.group(4)); + System.out.println(messageMatcher.group(5)); + } else { + System.out.println("No Match:"); + } + */ + + + //HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); + //hrh.setCookieJar(cj); + //hrh.connect(); + + MailDotComMailSession mms = new MailDotComMailSession(); if (mms.login(args[0], args[1], true) == WebMailSession.WMS_LOGIN_OK) { System.out.println("Number of messages: " + mms.numMessages()); + if (mms.numMessages() > 0 ) { + try { + System.out.println("***********************************"); + mms.retrieveMessage(Integer.parseInt(args[2]), new PrintWriter(System.out), -1); + } catch (MailSessionException mex) { + logger.severe("Exception - " + mex.getMessage()); + } + } } else { System.out.println("ERROR"); } } } |
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui In directory sc8-pr-cvs1:/tmp/cvs-serv10122/mrpostman/src/org/mrbook/mrpostman/gui Modified Files: HelpBrowser.java ModuleOptionGuiManager.java MrPostmanGui.java ModuleOptionPanel.java Log Message: Fixed compiler warnings Index: HelpBrowser.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/HelpBrowser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** HelpBrowser.java 21 Feb 2003 21:38:35 -0000 1.6 --- HelpBrowser.java 12 Jan 2004 22:25:15 -0000 1.7 *************** *** 200,205 **** } catch (MalformedURLException e) { logger.log(Level.SEVERE, "HelpBrowser MalformedURLException - " + e); - } catch (IOException e) { - logger.log(Level.SEVERE, "HelpBrowser IOException - " + e); } } --- 200,203 ---- Index: ModuleOptionGuiManager.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/ModuleOptionGuiManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModuleOptionGuiManager.java 9 Feb 2003 23:38:14 -0000 1.5 --- ModuleOptionGuiManager.java 12 Jan 2004 22:25:15 -0000 1.6 *************** *** 170,174 **** c = new javax.swing.JCheckBox(MessageUtil.getMessage(mo.getLabel())); c.setToolTipText(MessageUtil.getMessage(mo.getDesc())); ! gbc.gridwidth = gbc.REMAINDER; gbc.anchor = java.awt.GridBagConstraints.WEST; parent.add(c, gbc); --- 170,174 ---- c = new javax.swing.JCheckBox(MessageUtil.getMessage(mo.getLabel())); c.setToolTipText(MessageUtil.getMessage(mo.getDesc())); ! gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = java.awt.GridBagConstraints.WEST; parent.add(c, gbc); Index: MrPostmanGui.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/MrPostmanGui.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** MrPostmanGui.java 29 May 2003 10:54:35 -0000 1.21 --- MrPostmanGui.java 12 Jan 2004 22:25:15 -0000 1.22 *************** *** 662,666 **** MrPostman.getMainInstance().userprefs.put("proxyPort", proxyPort.getText()); Properties systemProperties = System.getProperties(); ! if (evt.getStateChange() == evt.SELECTED) { systemProperties.setProperty("http.proxyHost", proxyAddr.getText()); systemProperties.setProperty("http.proxyPort", proxyPort.getText()); --- 662,666 ---- MrPostman.getMainInstance().userprefs.put("proxyPort", proxyPort.getText()); Properties systemProperties = System.getProperties(); ! if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { systemProperties.setProperty("http.proxyHost", proxyAddr.getText()); systemProperties.setProperty("http.proxyPort", proxyPort.getText()); *************** *** 676,680 **** MrPostman.getMainInstance().userprefs.put("httpsProxyPort", httpsProxyPort.getText()); Properties systemProperties = System.getProperties(); ! if (evt.getStateChange() == evt.SELECTED) { systemProperties.setProperty("https.proxyHost", httpsProxyAddr.getText()); systemProperties.setProperty("https.proxyPort", httpsProxyPort.getText()); --- 676,680 ---- MrPostman.getMainInstance().userprefs.put("httpsProxyPort", httpsProxyPort.getText()); Properties systemProperties = System.getProperties(); ! if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { systemProperties.setProperty("https.proxyHost", httpsProxyAddr.getText()); systemProperties.setProperty("https.proxyPort", httpsProxyPort.getText()); Index: ModuleOptionPanel.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/ModuleOptionPanel.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ModuleOptionPanel.java 17 Feb 2003 22:39:05 -0000 1.8 --- ModuleOptionPanel.java 12 Jan 2004 22:25:15 -0000 1.9 *************** *** 107,112 **** gc = new java.awt.GridBagConstraints(); ! gc.fill = gc.BOTH; ! gc.gridwidth = gc.RELATIVE; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHEAST; --- 107,112 ---- gc = new java.awt.GridBagConstraints(); ! gc.fill = GridBagConstraints.BOTH; ! gc.gridwidth = GridBagConstraints.RELATIVE; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHEAST; *************** *** 115,120 **** version = new JLabel(info.getVersion()); gc = new java.awt.GridBagConstraints(); ! gc.fill = gc.BOTH; ! gc.gridwidth = gc.REMAINDER; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHWEST; --- 115,120 ---- version = new JLabel(info.getVersion()); gc = new java.awt.GridBagConstraints(); ! gc.fill = GridBagConstraints.BOTH; ! gc.gridwidth = GridBagConstraints.REMAINDER; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHWEST; *************** *** 122,127 **** gc = new java.awt.GridBagConstraints(); ! gc.fill = gc.BOTH; ! gc.gridwidth = gc.RELATIVE; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHEAST; --- 122,127 ---- gc = new java.awt.GridBagConstraints(); ! gc.fill = GridBagConstraints.BOTH; ! gc.gridwidth = GridBagConstraints.RELATIVE; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHEAST; *************** *** 130,135 **** authors = new JLabel(getAuthorsString(info.getAuthors())); gc = new java.awt.GridBagConstraints(); ! gc.fill = gc.BOTH; ! gc.gridwidth = gc.REMAINDER; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHWEST; --- 130,135 ---- authors = new JLabel(getAuthorsString(info.getAuthors())); gc = new java.awt.GridBagConstraints(); ! gc.fill = GridBagConstraints.BOTH; ! gc.gridwidth = GridBagConstraints.REMAINDER; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHWEST; *************** *** 149,156 **** gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = gc.RELATIVE; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHEAST; ! gc.fill = gc.BOTH; JLabel l = new JLabel(MessageUtil.getMessage("modules.info.options.label")); l.setVerticalTextPosition(SwingConstants.TOP); --- 149,156 ---- gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = GridBagConstraints.RELATIVE; gc.ipadx = CELL_PADDING; gc.anchor = java.awt.GridBagConstraints.NORTHEAST; ! gc.fill = GridBagConstraints.BOTH; JLabel l = new JLabel(MessageUtil.getMessage("modules.info.options.label")); l.setVerticalTextPosition(SwingConstants.TOP); *************** *** 158,164 **** gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = gc.REMAINDER; gc.ipadx = CELL_PADDING; ! gc.fill = gc.BOTH; gc.anchor = java.awt.GridBagConstraints.NORTHWEST; this.add(options, gc); --- 158,164 ---- gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = GridBagConstraints.REMAINDER; gc.ipadx = CELL_PADDING; ! gc.fill = GridBagConstraints.BOTH; gc.anchor = java.awt.GridBagConstraints.NORTHWEST; this.add(options, gc); *************** *** 168,172 **** JButton applyButton = new JButton(MessageUtil.getMessage("button.apply.label")); gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = gc.RELATIVE; this.add(applyButton, gc); --- 168,172 ---- JButton applyButton = new JButton(MessageUtil.getMessage("button.apply.label")); gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = GridBagConstraints.RELATIVE; this.add(applyButton, gc); *************** *** 181,185 **** JButton applyButton = new JButton(MessageUtil.getMessage("button.help.label")); gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = gc.REMAINDER; this.add(applyButton, gc); --- 181,185 ---- JButton applyButton = new JButton(MessageUtil.getMessage("button.help.label")); gc = new java.awt.GridBagConstraints(); ! gc.gridwidth = GridBagConstraints.REMAINDER; this.add(applyButton, gc); |
From: <chr...@us...> - 2004-01-12 22:23:59
|
Update of /cvsroot/mrpostman/mrpostman/src/com/sonalb/net/http In directory sc8-pr-cvs1:/tmp/cvs-serv9940/mrpostman/src/com/sonalb/net/http Modified Files: HTTPRedirectHandler.java Log Message: fixed compiler warnings Index: HTTPRedirectHandler.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/com/sonalb/net/http/HTTPRedirectHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HTTPRedirectHandler.java 17 Dec 2003 20:17:56 -0000 1.8 --- HTTPRedirectHandler.java 12 Jan 2004 22:23:56 -0000 1.9 *************** *** 43,47 **** import java.util.Iterator; import java.util.List; - import java.util.logging.Level; import java.util.logging.Logger; --- 43,46 ---- *************** *** 234,238 **** URL url; ! huc.setFollowRedirects(false); if (!cj.isEmpty()) { --- 233,237 ---- URL url; ! HttpURLConnection.setFollowRedirects(false); if (!cj.isEmpty()) { *************** *** 292,296 **** client.setCookies(huc, cj); ! huc.setFollowRedirects(false); huc.connect(); --- 291,295 ---- client.setCookies(huc, cj); ! HttpURLConnection.setFollowRedirects(false); huc.connect(); |
From: <chr...@us...> - 2004-01-12 22:09:20
|
Update of /cvsroot/mrpostman/mrpostman/test In directory sc8-pr-cvs1:/tmp/cvs-serv6673/mrpostman/test Log Message: Directory /cvsroot/mrpostman/mrpostman/test added to the repository |
From: <chr...@us...> - 2004-01-12 22:09:20
|
Update of /cvsroot/mrpostman/mrpostman/test/maildotcom In directory sc8-pr-cvs1:/tmp/cvs-serv6673/mrpostman/test/maildotcom Log Message: Directory /cvsroot/mrpostman/mrpostman/test/maildotcom added to the repository |
From: <chr...@us...> - 2003-12-17 20:17:59
|
Update of /cvsroot/mrpostman/mrpostman/src/com/sonalb/net/http In directory sc8-pr-cvs1:/tmp/cvs-serv4605 Modified Files: HTTPRedirectHandler.java Log Message: Relative redirect patch Index: HTTPRedirectHandler.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/com/sonalb/net/http/HTTPRedirectHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HTTPRedirectHandler.java 22 Feb 2003 09:17:19 -0000 1.7 --- HTTPRedirectHandler.java 17 Dec 2003 20:17:56 -0000 1.8 *************** *** 43,46 **** --- 43,49 ---- import java.util.Iterator; import java.util.List; + import java.util.logging.Level; + import java.util.logging.Logger; + /** *************** *** 71,74 **** --- 74,79 ---- InputStream is; + private static Logger logger = Logger.getLogger("com.sonalb.net.http.httpredirecthandler"); + /** *************** *** 248,252 **** is = null; ! url = new URL(huc.getHeaderField("location")); --- 253,269 ---- is = null; ! logger.finest("HRH redirect: " + huc.getHeaderField("location")); ! //Hotmail sometimes returns a location field which is a relative URL, we'll have to check for this and ! //add the previous protocol, server url and port.... ! String location = huc.getHeaderField("location"); ! String newLocation = location; ! if (location.charAt(0) == '/') { ! logger.warning("HTTP redirect with relative URL! : " + location); ! String oldUrlStr = huc.getURL().toString(); ! String oldServerUrl = oldUrlStr.substring(0, oldUrlStr.indexOf(huc.getURL().getPath())); ! newLocation = oldServerUrl + newLocation; ! logger.warning("Appending previous server path : " + newLocation); ! } ! url = new URL(newLocation); |
From: <chr...@us...> - 2003-12-16 13:34:46
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail In directory sc8-pr-cvs1:/tmp/cvs-serv26574 Modified Files: HotmailMailSession.java Log Message: Applied patch for msn bug - thanks Johnny Index: HotmailMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail/HotmailMailSession.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** HotmailMailSession.java 6 Dec 2003 11:50:37 -0000 1.33 --- HotmailMailSession.java 16 Dec 2003 13:34:43 -0000 1.34 *************** *** 146,150 **** private CookieJar cj = null; private boolean authenticated = false; ! /** * Flag to indicate whether this app will only retrieve the unread messages --- 146,150 ---- private CookieJar cj = null; private boolean authenticated = false; ! private String myCookie = ""; /** * Flag to indicate whether this app will only retrieve the unread messages *************** *** 537,540 **** --- 537,542 ---- if (inboxMatcher.find()) { inboxUrlStr = inboxMatcher.group(1); + myCookie=inboxUrlStr.substring(inboxUrlStr.indexOf('?')+1); + logger.info("myCookie URL: " + myCookie); logger.info("Found 'Original' Inbox url: " + inboxUrlStr); } *************** *** 547,550 **** --- 549,554 ---- if (inboxMatcher.find()) { inboxUrlStr = inboxMatcher.group(1); + myCookie=inboxUrlStr.substring(inboxUrlStr.indexOf('?')+1); + logger.info("myCookie URL: " + myCookie); logger.info("Found 'New' Inbox url: " + inboxUrlStr); } *************** *** 687,691 **** //The same as read but without the 'raw=1' option... URL url = new URL(baseUrl + msgReadBaseUrl + "msg=MSG" ! + ((MailIdentifier) messageIDS.elementAt(num - 1)).MailID); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", UserAgent); --- 691,696 ---- //The same as read but without the 'raw=1' option... URL url = new URL(baseUrl + msgReadBaseUrl + "msg=MSG" ! + ((MailIdentifier) messageIDS.elementAt(num - 1)).MailID ! + "&" + myCookie); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", UserAgent); *************** *** 744,750 **** try { URL url = new URL(baseUrl + msgReadBaseUrl + "msg=MSG" ! + ((MailIdentifier) messageIDS.elementAt(num - 1)).MailID + "&raw=1"); logger.fine("Read URL:\n" + url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", UserAgent); conn.setRequestProperty("Accept", "*/*"); --- 749,757 ---- try { URL url = new URL(baseUrl + msgReadBaseUrl + "msg=MSG" ! + ((MailIdentifier) messageIDS.elementAt(num - 1)).MailID + "&raw=1" + "&" + myCookie); logger.fine("Read URL:\n" + url); + logger.finest("About to open URL"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + logger.finest("Opened URL"); conn.setRequestProperty("User-Agent", UserAgent); conn.setRequestProperty("Accept", "*/*"); *************** *** 753,759 **** HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); hrh.setCookieJar(cj); hrh.connect(); cj.addAll(hrh.getCookieJar()); ! BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; --- 760,768 ---- HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); hrh.setCookieJar(cj); + logger.finest("About to HRH.connect"); hrh.connect(); + logger.finest("Done"); cj.addAll(hrh.getCookieJar()); ! BufferedReader br = new BufferedReader(new InputStreamReader(hrh.getInputStream())); String line = null; *************** *** 802,806 **** pw.flush(); } catch (Exception e) { ! logger.log(Level.SEVERE, "should not happen", e); } } --- 811,815 ---- pw.flush(); } catch (Exception e) { ! logger.log(Level.SEVERE, "Exception during retrieveMessage: " + e.getMessage(), e); } } |
From: <chr...@us...> - 2003-12-10 00:35:49
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/yahoo In directory sc8-pr-cvs1:/tmp/cvs-serv27390 Modified Files: YahooMailSession.java Log Message: Added unread TOP yahoo option Index: YahooMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/yahoo/YahooMailSession.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** YahooMailSession.java 22 Nov 2003 14:58:44 -0000 1.20 --- YahooMailSession.java 10 Dec 2003 00:35:46 -0000 1.21 *************** *** 64,70 **** private static final ModuleOption[] OPTIONS = { new ModuleOption("yahoo.https", "true"), ! new ModuleOption("yahoo.emptyTrash", "false") }; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("yahoo", AUTHORS, "0.6", "http://mrpostman.sourceforge.net/updates/yahoo", "/en/yahoo/index.html", OPTIONS); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.yahoo.YahooMailSession"); --- 64,71 ---- private static final ModuleOption[] OPTIONS = { new ModuleOption("yahoo.https", "true"), ! new ModuleOption("yahoo.emptyTrash", "false"), ! new ModuleOption("yahoo.unreadAfterTop", "false") }; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("yahoo", AUTHORS, "0.7", "http://mrpostman.sourceforge.net/updates/yahoo", "/en/yahoo/index.html", OPTIONS); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.yahoo.YahooMailSession"); *************** *** 79,82 **** --- 80,84 ---- private boolean useHttps = true; private boolean emptyTrash = false; //empty trash after collection option - CH 3/10/03 + private boolean leaveUnreadAfterTOP = false; //mark msg as unread after TOP command - CH 10/12/03 private String trashEmptyUrl = null; *************** *** 597,601 **** /* print the header first */ Pattern badHeader1 = Pattern.compile("\\AFrom\\s+"); ! try { URL url = new URL(baseUrl + bodyPart1 + ((MailIdentifier) (filtereMessageIDS.elementAt(num - 1))).MailID --- 599,603 ---- /* print the header first */ Pattern badHeader1 = Pattern.compile("\\AFrom\\s+"); ! try { URL url = new URL(baseUrl + bodyPart1 + ((MailIdentifier) (filtereMessageIDS.elementAt(num - 1))).MailID *************** *** 611,620 **** cj.addAll(hrh.getCookieJar()); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); ! String line = null; ! while ((line = br.readLine()) != null) { if (!badHeader1.matcher(line).find()) { pw.print(line + "\r\n"); ! } } /* now the text or body of the message */ --- 613,622 ---- cj.addAll(hrh.getCookieJar()); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); ! String line = null; ! while ((line = br.readLine()) != null) { if (!badHeader1.matcher(line).find()) { pw.print(line + "\r\n"); ! } } /* now the text or body of the message */ *************** *** 641,646 **** --- 643,711 ---- ; } + + //Depending on option value, we may be required to mark the message as unread after TOP command + //we won't do it by default as it is quite expensive... + if (leaveUnreadAfterTOP) { + markMessageAsUnread(num); + } } + protected void markMessageAsUnread(int num) { + if ((num > numMessages()) || (num < 1)) { + return; + } + logger.log(Level.INFO, "Marking letter as unread after TOP command: " + num); + String bodyPart1 = "/ym/ShowLetter?box=Inbox&MsgId="; + /* print the header first */ + Pattern markUnreadUrlPattern = Pattern.compile("<a href=\"(\\S+)\">Mark as Unread</a>"); + String unReadUrlStr = null; + try { + URL url = new URL(baseUrl + bodyPart1 + ((MailIdentifier) (filtereMessageIDS.elementAt(num - 1))).MailID); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty("User-Agent", UserAgent); + conn.setRequestProperty("Accept", "*/*"); + conn.setRequestProperty("Allowed", "GET HEAD PUT"); + conn.setInstanceFollowRedirects(false); + HTTPRedirectHandler hrh = new HTTPRedirectHandler(conn); + hrh.setCookieJar(cj); + hrh.connect(); + cj.addAll(hrh.getCookieJar()); + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line = null; + + Matcher unReadUrlMatcher = null; + + while ((line = br.readLine()) != null) { + unReadUrlMatcher = markUnreadUrlPattern.matcher(line); + if (unReadUrlMatcher.find()) { + unReadUrlStr = unReadUrlMatcher.group(1); + logger.log(Level.FINE, "Found Unread URL: " + unReadUrlStr); + } + } + + //mark the message as unread again... + url = new URL(baseUrl + unReadUrlStr); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty("User-Agent", UserAgent); + conn.setRequestProperty("Accept", "*/*"); + conn.setRequestProperty("Allowed", "GET HEAD PUT"); + conn.setInstanceFollowRedirects(false); + hrh = new HTTPRedirectHandler(conn); + hrh.setCookieJar(cj); + hrh.connect(); + cj.addAll(hrh.getCookieJar()); + br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + line = null; + + while ((line = br.readLine()) != null) { + //do nothing + } + + } catch (Exception e) { + logger.log(Level.SEVERE, "Exception in markMessageAsUnread", e); + ; + } + } + public String getUniqueMessageId(int num) throws MailSessionException { int numMsgs = numMessages(); *************** *** 744,748 **** useHttps = "true".equalsIgnoreCase(value); } else if ("yahoo.emptyTrash".equals(optionName)) { ! emptyTrash = "true".equalsIgnoreCase(value); } } --- 809,815 ---- useHttps = "true".equalsIgnoreCase(value); } else if ("yahoo.emptyTrash".equals(optionName)) { ! emptyTrash = "true".equalsIgnoreCase(value); ! } else if ("yahoo.unreadAfterTop".equals(optionName)) { ! leaveUnreadAfterTOP = "true".equalsIgnoreCase(value); } } |
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui In directory sc8-pr-cvs1:/tmp/cvs-serv27303 Modified Files: messages.properties messages_de.properties messages_es.properties messages_fr.properties moduleoptiongui.xml Log Message: Added unread TOP yahoo option Index: messages.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages.properties,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** messages.properties 3 Oct 2003 13:53:17 -0000 1.10 --- messages.properties 10 Dec 2003 00:35:11 -0000 1.11 *************** *** 66,68 **** modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection \ No newline at end of file --- 66,71 ---- modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection ! ! modules.yahoo.option.unreadAfterTop.label=Unread after TOP ! modules.yahoo.option.unreadAfterTop.desc=Mark message as Unread after TOP command (advanced only) \ No newline at end of file Index: messages_de.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages_de.properties,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** messages_de.properties 3 Oct 2003 13:53:17 -0000 1.3 --- messages_de.properties 10 Dec 2003 00:35:11 -0000 1.4 *************** *** 129,131 **** modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection \ No newline at end of file --- 129,134 ---- modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection ! ! modules.yahoo.option.unreadAfterTop.label=Unread after TOP ! modules.yahoo.option.unreadAfterTop.desc=Mark message as Unread after TOP command (advanced only) \ No newline at end of file Index: messages_es.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages_es.properties,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** messages_es.properties 3 Oct 2003 13:53:17 -0000 1.9 --- messages_es.properties 10 Dec 2003 00:35:11 -0000 1.10 *************** *** 67,69 **** modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection \ No newline at end of file --- 67,72 ---- modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection ! ! modules.yahoo.option.unreadAfterTop.label=Unread after TOP ! modules.yahoo.option.unreadAfterTop.desc=Mark message as Unread after TOP command (advanced only) \ No newline at end of file Index: messages_fr.properties =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/messages_fr.properties,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** messages_fr.properties 3 Oct 2003 13:53:17 -0000 1.15 --- messages_fr.properties 10 Dec 2003 00:35:11 -0000 1.16 *************** *** 132,134 **** modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection \ No newline at end of file --- 132,137 ---- modules.yahoo.option.emptyTrash.label=Empty Trash ! modules.yahoo.option.emptyTrash.desc=Empty Trash after successful mail collection ! ! modules.yahoo.option.unreadAfterTop.label=Unread after TOP ! modules.yahoo.option.unreadAfterTop.desc=Mark message as Unread after TOP command (advanced only) \ No newline at end of file Index: moduleoptiongui.xml =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/gui/moduleoptiongui.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** moduleoptiongui.xml 3 Oct 2003 13:53:17 -0000 1.4 --- moduleoptiongui.xml 10 Dec 2003 00:35:11 -0000 1.5 *************** *** 56,59 **** --- 56,64 ---- <input type="checkbox" /> </module-option> + <module-option id="yahoo.unreadAfterTop"> + <label>modules.yahoo.option.unreadAfterTop.label</label> + <desc>modules.yahoo.option.unreadAfterTop.desc</desc> + <input type="checkbox" /> + </module-option> </module> |
From: <chr...@us...> - 2003-12-08 12:17:35
|
Update of /cvsroot/mrpostman/mrpostman/install/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv22273 Modified Files: install.xml Log Message: Changed url Index: install.xml =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/install/win32/install.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** install.xml 7 Mar 2003 21:37:21 -0000 1.4 --- install.xml 8 Dec 2003 12:17:32 -0000 1.5 *************** *** 25,29 **** <author name="Thomas O'Dowd" email="to...@no..."/> </authors> ! <url>http://mrbook.org/mrpostman/</url> <javaversion>1.4</javaversion> </info> --- 25,29 ---- <author name="Thomas O'Dowd" email="to...@no..."/> </authors> ! <url>http://mrpostman.sourceforge.net/</url> <javaversion>1.4</javaversion> </info> |
From: <chr...@us...> - 2003-12-06 11:50:40
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail In directory sc8-pr-cvs1:/tmp/cvs-serv22547 Modified Files: HotmailMailSession.java Log Message: Added old-style Nav support. Fixed circular bug Index: HotmailMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail/HotmailMailSession.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** HotmailMailSession.java 4 Dec 2003 00:43:26 -0000 1.32 --- HotmailMailSession.java 6 Dec 2003 11:50:37 -0000 1.33 *************** *** 42,46 **** /* ! Hotmail module (v0.9) for MyPostman. Supports retrieval of unread Inbox messages complete with attachements. --- 42,46 ---- /* ! Hotmail module (v0.10) for MyPostman. Supports retrieval of unread Inbox messages complete with attachements. *************** *** 91,95 **** new ModuleOption("hotmail.onlyunread", "true"), new ModuleOption("hotmail.markasread", "true") }; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("hotmail", AUTHORS, "0.9", "http://mrpostman.sourceforge.net/updates/hotmail", "/en/hotmail/index.html", OPTIONS); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.hotmail.HotmailMailSession"); --- 91,95 ---- new ModuleOption("hotmail.onlyunread", "true"), new ModuleOption("hotmail.markasread", "true") }; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("hotmail", AUTHORS, "0.10", "http://mrpostman.sourceforge.net/updates/hotmail", "/en/hotmail/index.html", OPTIONS); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.hotmail.HotmailMailSession"); *************** *** 99,108 **** /** ! * Locales to work with account in other languages but English. */ ! public static final java.util.HashMap local = new java.util.HashMap(); ! static { ! /* Old language specific new message count regex... local.put("EN", new String[] {"Inbox", "(\\d+)\\s\\((\\d+).*new\\)"}); local.put("FR", new String[] {"Boîte de réception", "(\\d+)\\s\\((\\d+).*nouveaux\\)"}); --- 99,109 ---- /** ! * Hashmap to store locale dependant details. Used to support the various languages that Hotmail may ! * use for its UI. */ ! public static final java.util.HashMap locale = new java.util.HashMap(); ! static { ! /* Old language specific new message count regex. Not needed anymore - CH local.put("EN", new String[] {"Inbox", "(\\d+)\\s\\((\\d+).*new\\)"}); local.put("FR", new String[] {"Boîte de réception", "(\\d+)\\s\\((\\d+).*nouveaux\\)"}); *************** *** 112,134 **** local.put("JA", new String[] {"\u53d7\u4fe1\u30c8\u30ec\u30a4", "(\\d+)\\s+\\((\\d+).*\u901a\u304c\u65b0\u7740\\)"}); ! */ - // New as of 7 May 03 - local.put("EN", new String[] {"Inbox", "(\\d+)\\s<b>\\((\\d+)\\)"}); - local.put("FR", new String[] {"Boîte de réception", "(\\d+)\\s<b>\\((\\d+)\\)"}); - local.put("ES", new String[] {"Bandeja de entrada", "(\\d+)\\s<b>\\((\\d+)\\)"}); - local.put("IT", new String[] {"Posta in arrivo", "(\\d+).*<b>\\((\\d+)\\)"}); - local.put("DE", new String[] {"Posteingang", "(\\d+)\\s<b>\\((\\d+)\\)"}); - local.put("JA", new String[] {"\u53d7\u4fe1\u30c8\u30ec\u30a4", "(\\d+)\\s<b>\\((\\d+)\\)"}); - local.put("NL", new String[] {"Postvak IN", "(\\d+)\\s<b>\\((\\d+)\\)"}); ! // New as of 2 Dec 03 ! local.put("EN", new String[] {"Mail", "New mail from my contacts:"}); ! local.put("FR", new String[] {"Courrier", "Nouveaux messages de mes contacts :"}); ! local.put("ES", new String[] {"Correo", "Correo nuevo de mis contactos:"}); ! local.put("IT", new String[] {"Posta", "Nuovi messaggi provenienti dai tuoi contatti:"}); ! local.put("DE", new String[] {"Posteingang", "Neue E-Mails von meinen Kontakten:"}); ! local.put("JA", new String[] {"\u30e1\u30fc\u30eb", "\u77e5\u4eba\u304b\u3089\u306e\u65b0\u7740\u30e1\u30fc\u30eb :"}); ! local.put("NL", new String[] {"Post", "Nieuwe e-mail van mijn contactpersonen:"}); // **TODO** add other languages here! } --- 113,139 ---- local.put("JA", new String[] {"\u53d7\u4fe1\u30c8\u30ec\u30a4", "(\\d+)\\s+\\((\\d+).*\u901a\u304c\u65b0\u7740\\)"}); ! ! // Original Hotmail Navigation (as of 7 May 03) - CH ! //originalLocale.put("EN", new String[] {"Inbox", "(\\d+)\\s<b>\\((\\d+)\\)"}); ! //originalLocale.put("FR", new String[] {"Boîte de réception", "(\\d+)\\s<b>\\((\\d+)\\)"}); ! //originalLocale.put("ES", new String[] {"Bandeja de entrada", "(\\d+)\\s<b>\\((\\d+)\\)"}); ! //originalLocale.put("IT", new String[] {"Posta in arrivo", "(\\d+).*<b>\\((\\d+)\\)"}); ! //originalLocale.put("DE", new String[] {"Posteingang", "(\\d+)\\s<b>\\((\\d+)\\)"}); ! //originalLocale.put("JA", new String[] {"\u53d7\u4fe1\u30c8\u30ec\u30a4", "(\\d+)\\s<b>\\((\\d+)\\)"}); ! //originalLocale.put("NL", new String[] {"Postvak IN", "(\\d+)\\s<b>\\((\\d+)\\)"}); */ ! // New as of 2 Dec 03 ! // Each entry represents: ! // The new style tab string for the 'Mail' (inbox) link ! // The new style string indicating how many new messages are in the inbox. ! // The old style tab string for the 'Inbox' link. This is still accessible if the user chooses the 'Hotmail Navigation' option in the options screen. ! locale.put("EN", new String[] {"Mail", "New mail from my contacts:", "Inbox"}); ! locale.put("FR", new String[] {"Courrier", "Nouveaux messages de mes contacts :", "Boîte de réception"}); ! locale.put("ES", new String[] {"Correo", "Correo nuevo de mis contactos:", "Bandeja de entrada"}); ! locale.put("IT", new String[] {"Posta", "Nuovi messaggi provenienti dai tuoi contatti:", "Posta in arrivo"}); ! locale.put("DE", new String[] {"Posteingang", "Neue E-Mails von meinen Kontakten:", "Posteingang"}); ! locale.put("JA", new String[] {"\u30e1\u30fc\u30eb", "\u77e5\u4eba\u304b\u3089\u306e\u65b0\u7740\u30e1\u30fc\u30eb :", "\u53d7\u4fe1\u30c8\u30ec\u30a4"}); ! locale.put("NL", new String[] {"Post", "Nieuwe e-mail van mijn contactpersonen:", "Postvak IN"}); // **TODO** add other languages here! } *************** *** 140,145 **** private String msgDeleteBaseUrl = null; private CookieJar cj = null; - private int numMessages = -1; - private int numNewMessages = -1; private boolean authenticated = false; --- 145,148 ---- *************** *** 340,345 **** hrh.setCookieJar(cj); conn.setRequestProperty("User-Agent", UserAgent); //conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - //FRIG - The cookie handling code doesn't handle this one well at all! //conn.setRequestProperty("Cookie", "BrowserTest=Success?"); --- 343,349 ---- hrh.setCookieJar(cj); conn.setRequestProperty("User-Agent", UserAgent); + // The following 'hacks' aren't needed, but are useful when debugging Hotmail's login process + //should they change it again. So I've left it in. - CH //conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); //FRIG - The cookie handling code doesn't handle this one well at all! //conn.setRequestProperty("Cookie", "BrowserTest=Success?"); *************** *** 355,359 **** /* ! // Do manually... HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); --- 359,365 ---- /* ! // The following 'hacks' aren't needed, but are useful when debugging Hotmail's login process ! //should they change it again. So I've left it in. - CH ! // Manually read page (in case there is a problem with our cookie code)... HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); *************** *** 396,399 **** --- 402,407 ---- } + // The following 'hacks' aren't needed, but are useful when debugging Hotmail's login process + //should they change it again. So I've left it in. - CH //frig - clear the cookie jar here! //cj.clear(); *************** *** 433,445 **** // user/pass problem instead of actually doing the post. Pattern signInFailure = Pattern.compile("uilogin.srf"); ! Matcher inboxMatcher = null; ! Matcher langMatcher = null; ! Pattern langPattern = Pattern.compile("<link rel=\"stylesheet\" href=\"/cgi-bin/dasp/([A-Z][A-Z])"); ! Pattern inboxUrlPattern = null; ! Pattern messageCountPattern = null; ! Matcher msgCountMatcher = null; ! String lang = null; ! numMessages = -1; ! numNewMessages = -1; //verify page does not contain password error text. For debugging we'll retrieve the msg summary info too... --- 441,448 ---- // user/pass problem instead of actually doing the post. Pattern signInFailure = Pattern.compile("uilogin.srf"); ! LanguageSettings languageSettings = new LanguageSettings(); ! ! // Set the pattern used to locate the language setting for this page... ! languageSettings.langPattern = Pattern.compile("<link rel=\"stylesheet\" href=\"/cgi-bin/dasp/([A-Z][A-Z])"); //verify page does not contain password error text. For debugging we'll retrieve the msg summary info too... *************** *** 452,532 **** } ! if (lang == null) { ! langMatcher = langPattern.matcher(line); ! ! if (langMatcher.find()) { ! lang = langMatcher.group(1); ! logger.info(" Language found for this page: " + lang); ! ! try { ! String[] arr = (String[]) local.get(lang); ! // CH - New login structure 2/12/03 ! //inboxUrlPattern = Pattern.compile("<a href=\"(\\S+)\"><font class=\".*\">" + arr[0] ! // + "\\s*:\\s" + arr[1] + "</b>"); ! inboxUrlPattern = Pattern.compile("<a href=\"(\\S+)\" tabindex=121 class=\"E\">" + arr[0] + "</a>"); ! logger.fine(" Using inboxUrlPattern :" + inboxUrlPattern.pattern()); ! //messageCountPattern = Pattern.compile("<td.*><font.*>" + arr[1] + "</font></td>"); ! messageCountPattern = Pattern.compile("<td.*><font.*>" + arr[1] + "</font><td.*><font.*> (\\d+)</font></td>"); ! logger.fine("Using message count pattern: " + messageCountPattern); ! //logger.fine(" Using inboxUrlPattern :" + messageCountPattern.pattern()); ! } catch (Exception e) { ! logger.log(Level.SEVERE, "Language determination error ", e); ! } ! } ! continue; ! } ! inboxMatcher = inboxUrlPattern.matcher(line); ! ! if (inboxMatcher.find()) { ! inboxUrlStr = inboxMatcher.group(1); ! logger.info("Found Inbox url: " + inboxUrlStr); ! //changed again - 2/12/03 - CH ! // new structure has this on the same line: ! //numMessages = Integer.parseInt(inboxMatcher.group(2)); ! //numNewMessages = Integer.parseInt(inboxMatcher.group(3)); ! //logger.info("Number of messages in inbox: " + numMessages); ! //logger.info("Number new: " + numNewMessages); ! } ! //changed again - 2/12/03 - CH ! msgCountMatcher = messageCountPattern.matcher(line); ! /* //changed as of 7 May 03 ! //The msg count should be on the next line... ! if ((line = rd.readLine()) != null) { ! logger.finest("html: " + line); ! msgCountMatcher = messageCountPattern.matcher(line); ! */ ! if (msgCountMatcher.find()) { ! logger.info("Line containing the number of new messages found!"); ! //numMessages = Integer.parseInt(msgCountMatcher.group(1)); ! numNewMessages = Integer.parseInt(msgCountMatcher.group(1)); ! //logger.info("Number of messages in inbox: " + numMessages); ! logger.info("Number new: " + numNewMessages); ! ! } ! ! } ! if (lang == null) { ! logger.severe("The language hasn't been found!!!"); } if (inboxUrlStr == null) { ! logger.severe("The inbox url hasn't been found!!!"); } rd.close(); baseUrl = getBaseURL(conn.getURL()); logger.fine("url: " + baseUrl.toString()); } catch (Exception e) { ! logger.log(Level.SEVERE, "should not happen", e); } if (inboxUrlStr != null) { ! logger.info("Inbox URL: " + inboxUrlStr); ! ! //verify we were able to determine the correct number of messages... ! //if (numMessages > -1) { ! authenticated = true; ! return WebMailSession.WMS_LOGIN_OK; ! //} } --- 455,487 ---- } ! //If we haven't found the language for this page yet, check for it now... ! if (!languageSettings.isLanguageSet()) { ! determineLanguageSettings(languageSettings, line); ! } else { ! findInboxURL(languageSettings, line); ! } ! } // end while ! if (!languageSettings.isLanguageSet()) { ! logger.severe("The language hasn't been found - Hotmail changed WebSite structure or using an unsupported language setting"); } if (inboxUrlStr == null) { ! logger.severe("The inbox url hasn't been found - Hotmail changed WebSite structure?"); } rd.close(); baseUrl = getBaseURL(conn.getURL()); logger.fine("url: " + baseUrl.toString()); + + } catch (LanguageNotSupportedException le) { + logger.log(Level.SEVERE, le.getMessage()); } catch (Exception e) { ! logger.log(Level.SEVERE, "Unexpected Exception thrown whilst processing language and inbox page.", e); } if (inboxUrlStr != null) { ! logger.info("Inbox URL: " + inboxUrlStr); ! authenticated = true; ! return WebMailSession.WMS_LOGIN_OK; } *************** *** 536,539 **** --- 491,566 ---- /** + * Determine the language used and calculate language dependant variables. + * Broke this out from login() to improve clarity + */ + private void determineLanguageSettings(LanguageSettings langSettings, String line) throws LanguageNotSupportedException { + String[] langStrs = null; + //Check if language is set on this line... + Matcher langMatcher = langSettings.langPattern.matcher(line); + + if (langMatcher.find()) { + langSettings.lang = langMatcher.group(1); + logger.info("Language found for this page: " + langSettings.lang); + + //We have found the language, use this to construct the language dependant values... + try { + //Construct the regex's for the old and new style inbox links... + langStrs = (String[]) locale.get(langSettings.lang); + langSettings.newInboxUrlPatternStr = "<a href=\"(\\S+)\" tabindex=121 class=\"E\">" + langStrs[0] + "</a>"; + logger.fine("Using 'new' inboxUrlPattern :" + langSettings.newInboxUrlPatternStr); + langSettings.originalInboxUrlPatternStr = "<a href=\"(\\S+)\" tabindex=121 class=\"E\">" + langStrs[2] + "</a>"; + logger.fine("Using 'Original Hotmail Navigation' inboxUrlPattern :" + langSettings.originalInboxUrlPatternStr); + //The message count link will always be new style.. + langSettings.newMessageCountPatternStr = "<td.*><font.*>" + langStrs[1] + "</font><td.*><font.*> (\\d+)</font></td>"; + logger.fine("Using 'new' message count pattern: " + langSettings.newMessageCountPatternStr); + } catch (Exception e) { + String msg = "Language error, language '" + langSettings.lang + "' not supported"; + throw new LanguageNotSupportedException(msg); + } + } + } + + /** + * Helper function to test for the Inbox URL based on language settings. + * Supports new and original navigation styles + * Updates class attribute inboxUrlStr + */ + private void findInboxURL(LanguageSettings langSettings, String line) { + Matcher inboxMatcher, msgCountMatcher = null; + + //Attempt to find 'original' inbox URL... + if (langSettings.originalInboxUrlPattern == null) { + langSettings.originalInboxUrlPattern = Pattern.compile(langSettings.originalInboxUrlPatternStr); + } + inboxMatcher = langSettings.originalInboxUrlPattern.matcher(line); + + if (inboxMatcher.find()) { + inboxUrlStr = inboxMatcher.group(1); + logger.info("Found 'Original' Inbox url: " + inboxUrlStr); + } + + //Attempt to find 'new' inbox URL... + if (langSettings.newInboxUrlPattern == null) { + langSettings.newInboxUrlPattern = Pattern.compile(langSettings.newInboxUrlPatternStr); + } + inboxMatcher = langSettings.newInboxUrlPattern.matcher(line); + if (inboxMatcher.find()) { + inboxUrlStr = inboxMatcher.group(1); + logger.info("Found 'New' Inbox url: " + inboxUrlStr); + } + + if(langSettings.newMessageCountPattern == null) { + langSettings.newMessageCountPattern = Pattern.compile(langSettings.newMessageCountPatternStr); + } + + msgCountMatcher = langSettings.newMessageCountPattern.matcher(line); + if (msgCountMatcher.find()) { + logger.info("Line containing the number of new messages found!"); + int numNewMessages = Integer.parseInt(msgCountMatcher.group(1)); + logger.info("Number new: " + numNewMessages); + } + } + + /** * Strip the base context url from the request url for use in later gets */ *************** *** 602,607 **** } ! // Fixed bug: the .\d* part is optional for MSN system messages ! Pattern messagePattern = Pattern.compile("<a href=\"javascript:G\\('(\\S+)msg=MSG(\\d+(\\.\\d*)?)[\\&|\"]"); Pattern sizePattern = Pattern.compile("\\&start=\\d+\\&len=(\\d+)"); --- 629,634 ---- } ! // Fixed bug: the .\d* part is optional for MSN system messages ! Pattern messagePattern = Pattern.compile("<a href=\"javascript:G\\('(\\S+)msg=MSG(\\d+(\\.\\d*)?)[\\&|']"); Pattern sizePattern = Pattern.compile("\\&start=\\d+\\&len=(\\d+)"); *************** *** 856,902 **** } ! /** ! * Return hotmail's UIDL for this message. We can get this by parsing the msg header ! * returned from TOP. ! * This is only valid for 'real' emails i.e. not Hotmail circulars ! * We'll have to calculate our our UIDL for the circular messages :( ! */ ! /* ! // Removed this pending further investigations, Message-IDs do not always ! //appear and are not always unique. Replaced with the MD5 function below. - CH 28/7/03 ! public String getUniqueMessageId(int num) throws MailSessionException { ! try { ! ByteArrayOutputStream bos = new ByteArrayOutputStream(); ! PrintWriter pw = new PrintWriter(bos, true); ! retrieveMessage(num, pw, 1); ! bos.flush(); ! String header = bos.toString(); ! Pattern uidlPattern = Pattern.compile("Message-ID:\\s+<(\\S+)>"); ! Matcher matcher = uidlPattern.matcher(header); ! ! if (matcher.find()) { ! return matcher.group(1); ! } else { ! //The message did not have an UIDL header field - must be a hotmail circular ! //we'll create our own hash from the header contents! ! logger.finest("Message with on UIDL, is it a hotmail circular? - returning a hashcode of header: " ! + header); ! String encStr = org.mrbook.mrpostman.another.Base64.encodeString(header); ! logger.finest("Encoded header: " + encStr); ! ! if (encStr.length() > 70) { ! //we'll have to truncate it - lets hope this is really good enough! ! logger.fine("Truncating generated UIDL hashcode (this could cause it to become non-unique)"); ! return encStr.substring(0, 69); ! } ! return Integer.toString(header.hashCode()); ! } ! } catch (IOException i) { ! logger.log(Level.SEVERE, "should not happen", i); ! throw new MailSessionException("IOException whilst attempting to read UIDL for message" + num); ! } ! } ! */ ! /** * Return hotmail's UIDL for this message. We can get this by generating the MD5 hash of the message --- 883,887 ---- } ! /** * Return hotmail's UIDL for this message. We can get this by generating the MD5 hash of the message *************** *** 986,989 **** --- 971,999 ---- public String toString() { return new String("MailID=" + MailID + ", unread=" + unread + " flagged=" + flagged + " size=" + size); + } + } + + /** + * Helper class to store dependant variable values + */ + class LanguageSettings { + //These Pattern objects exist for efficiency so we don't have to re-calculate every input line... + public Pattern langPattern = null; + public Pattern originalInboxUrlPattern = null; + public Pattern newInboxUrlPattern = null; + public Pattern newMessageCountPattern = null; + + //Language dependant attributes... + public String lang = null; + public String originalInboxUrlPatternStr = null; + public String newInboxUrlPatternStr = null; + public String newMessageCountPatternStr = null; + + public boolean isLanguageSet() { return lang != null; } + } + + class LanguageNotSupportedException extends Exception { + public LanguageNotSupportedException(String msg) { + super(msg); } } |
From: <tp...@us...> - 2003-12-04 00:43:29
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail In directory sc8-pr-cvs1:/tmp/cvs-serv11493 Modified Files: HotmailMailSession.java Log Message: Re-added support for previously supported languages other than English to the hotmail module. Index: HotmailMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail/HotmailMailSession.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** HotmailMailSession.java 2 Dec 2003 11:03:53 -0000 1.31 --- HotmailMailSession.java 4 Dec 2003 00:43:26 -0000 1.32 *************** *** 125,128 **** --- 125,134 ---- // New as of 2 Dec 03 local.put("EN", new String[] {"Mail", "New mail from my contacts:"}); + local.put("FR", new String[] {"Courrier", "Nouveaux messages de mes contacts :"}); + local.put("ES", new String[] {"Correo", "Correo nuevo de mis contactos:"}); + local.put("IT", new String[] {"Posta", "Nuovi messaggi provenienti dai tuoi contatti:"}); + local.put("DE", new String[] {"Posteingang", "Neue E-Mails von meinen Kontakten:"}); + local.put("JA", new String[] {"\u30e1\u30fc\u30eb", "\u77e5\u4eba\u304b\u3089\u306e\u65b0\u7740\u30e1\u30fc\u30eb :"}); + local.put("NL", new String[] {"Post", "Nieuwe e-mail van mijn contactpersonen:"}); // **TODO** add other languages here! } |
From: <chr...@us...> - 2003-12-03 12:08:38
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom In directory sc8-pr-cvs1:/tmp/cvs-serv12785 Modified Files: MailDotComMailSession.java Log Message: Added extensions Index: MailDotComMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/maildotcom/MailDotComMailSession.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** MailDotComMailSession.java 11 May 2003 14:27:58 -0000 1.26 --- MailDotComMailSession.java 3 Dec 2003 12:08:35 -0000 1.27 *************** *** 552,556 **** "@publicist.com", "@realtyagent.com", "@registerednurses.com", "@repairman.com", "@representative.com", "@rescueteam.com", "@scientist.com", "@sociologist.com", ! "@teacher.com", "@techie.com", "@umpire.com", "@innocent.com" }; return extensions; --- 552,557 ---- "@publicist.com", "@realtyagent.com", "@registerednurses.com", "@repairman.com", "@representative.com", "@rescueteam.com", "@scientist.com", "@sociologist.com", ! "@teacher.com", "@techie.com", "@umpire.com", "@innocent.com", ! "@cyberdude.com", "@cybergal.com", "@technologist.com", "@unforgettable.com" }; return extensions; |
From: <chr...@us...> - 2003-12-02 11:04:01
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail In directory sc8-pr-cvs1:/tmp/cvs-serv21532 Modified Files: HotmailMailSession.java Log Message: Updated version number Index: HotmailMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail/HotmailMailSession.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** HotmailMailSession.java 2 Dec 2003 11:01:04 -0000 1.30 --- HotmailMailSession.java 2 Dec 2003 11:03:53 -0000 1.31 *************** *** 42,46 **** /* ! Hotmail module (v0.8) for MyPostman. Supports retrieval of unread Inbox messages complete with attachements. --- 42,46 ---- /* ! Hotmail module (v0.9) for MyPostman. Supports retrieval of unread Inbox messages complete with attachements. *************** *** 91,95 **** new ModuleOption("hotmail.onlyunread", "true"), new ModuleOption("hotmail.markasread", "true") }; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("hotmail", AUTHORS, "0.8", "http://mrpostman.sourceforge.net/updates/hotmail", "/en/hotmail/index.html", OPTIONS); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.hotmail.HotmailMailSession"); --- 91,95 ---- new ModuleOption("hotmail.onlyunread", "true"), new ModuleOption("hotmail.markasread", "true") }; ! private static final ModuleInfo MODULE_INFO = new ModuleInfo("hotmail", AUTHORS, "0.9", "http://mrpostman.sourceforge.net/updates/hotmail", "/en/hotmail/index.html", OPTIONS); private static Logger logger = Logger.getLogger("org.mrbook.mrpostman.hotmail.HotmailMailSession"); |
From: <chr...@us...> - 2003-12-02 11:01:15
|
Update of /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail In directory sc8-pr-cvs1:/tmp/cvs-serv21049 Modified Files: HotmailMailSession.java Log Message: Updated for new hotmail interface Index: HotmailMailSession.java =================================================================== RCS file: /cvsroot/mrpostman/mrpostman/src/org/mrbook/mrpostman/hotmail/HotmailMailSession.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** HotmailMailSession.java 6 Oct 2003 14:30:11 -0000 1.29 --- HotmailMailSession.java 2 Dec 2003 11:01:04 -0000 1.30 *************** *** 42,46 **** /* ! Hotmail module (v0.7) for MyPostman. Supports retrieval of unread Inbox messages complete with attachements. --- 42,46 ---- /* ! Hotmail module (v0.8) for MyPostman. Supports retrieval of unread Inbox messages complete with attachements. *************** *** 122,125 **** --- 122,129 ---- local.put("JA", new String[] {"\u53d7\u4fe1\u30c8\u30ec\u30a4", "(\\d+)\\s<b>\\((\\d+)\\)"}); local.put("NL", new String[] {"Postvak IN", "(\\d+)\\s<b>\\((\\d+)\\)"}); + + // New as of 2 Dec 03 + local.put("EN", new String[] {"Mail", "New mail from my contacts:"}); + // **TODO** add other languages here! } *************** *** 451,458 **** try { String[] arr = (String[]) local.get(lang); ! inboxUrlPattern = Pattern.compile("<a href=\"(\\S+)\"><font class=\".*\">" + arr[0] ! + "\\s*:\\s" + arr[1] + "</b>"); logger.fine(" Using inboxUrlPattern :" + inboxUrlPattern.pattern()); //messageCountPattern = Pattern.compile("<td.*><font.*>" + arr[1] + "</font></td>"); //logger.fine(" Using inboxUrlPattern :" + messageCountPattern.pattern()); } catch (Exception e) { --- 455,466 ---- try { String[] arr = (String[]) local.get(lang); ! // CH - New login structure 2/12/03 ! //inboxUrlPattern = Pattern.compile("<a href=\"(\\S+)\"><font class=\".*\">" + arr[0] ! // + "\\s*:\\s" + arr[1] + "</b>"); ! inboxUrlPattern = Pattern.compile("<a href=\"(\\S+)\" tabindex=121 class=\"E\">" + arr[0] + "</a>"); logger.fine(" Using inboxUrlPattern :" + inboxUrlPattern.pattern()); //messageCountPattern = Pattern.compile("<td.*><font.*>" + arr[1] + "</font></td>"); + messageCountPattern = Pattern.compile("<td.*><font.*>" + arr[1] + "</font><td.*><font.*> (\\d+)</font></td>"); + logger.fine("Using message count pattern: " + messageCountPattern); //logger.fine(" Using inboxUrlPattern :" + messageCountPattern.pattern()); } catch (Exception e) { *************** *** 466,475 **** if (inboxMatcher.find()) { inboxUrlStr = inboxMatcher.group(1); // new structure has this on the same line: ! numMessages = Integer.parseInt(inboxMatcher.group(2)); ! numNewMessages = Integer.parseInt(inboxMatcher.group(3)); ! logger.info("Number of messages in inbox: " + numMessages); ! logger.info("Number new: " + numNewMessages); ! /* //changed as of 7 May 03 //The msg count should be on the next line... --- 474,487 ---- if (inboxMatcher.find()) { inboxUrlStr = inboxMatcher.group(1); + logger.info("Found Inbox url: " + inboxUrlStr); + //changed again - 2/12/03 - CH // new structure has this on the same line: ! //numMessages = Integer.parseInt(inboxMatcher.group(2)); ! //numNewMessages = Integer.parseInt(inboxMatcher.group(3)); ! //logger.info("Number of messages in inbox: " + numMessages); ! //logger.info("Number new: " + numNewMessages); ! } ! //changed again - 2/12/03 - CH ! msgCountMatcher = messageCountPattern.matcher(line); /* //changed as of 7 May 03 //The msg count should be on the next line... *************** *** 477,492 **** logger.finest("html: " + line); msgCountMatcher = messageCountPattern.matcher(line); - - if (msgCountMatcher.find()) { - logger.info("Line containing the number of messages found!"); - numMessages = Integer.parseInt(msgCountMatcher.group(1)); - numNewMessages = Integer.parseInt(msgCountMatcher.group(2)); - logger.info("Number of messages in inbox: " + numMessages); - logger.info("Number new: " + numNewMessages); - } - } */ ! ! } } --- 489,502 ---- logger.finest("html: " + line); msgCountMatcher = messageCountPattern.matcher(line); */ ! if (msgCountMatcher.find()) { ! logger.info("Line containing the number of new messages found!"); ! //numMessages = Integer.parseInt(msgCountMatcher.group(1)); ! numNewMessages = Integer.parseInt(msgCountMatcher.group(1)); ! //logger.info("Number of messages in inbox: " + numMessages); ! logger.info("Number new: " + numNewMessages); ! ! } ! } *************** *** 509,516 **** //verify we were able to determine the correct number of messages... ! if (numMessages > -1) { authenticated = true; return WebMailSession.WMS_LOGIN_OK; ! } } --- 519,526 ---- //verify we were able to determine the correct number of messages... ! //if (numMessages > -1) { authenticated = true; return WebMailSession.WMS_LOGIN_OK; ! //} } *************** *** 587,591 **** // Fixed bug: the .\d* part is optional for MSN system messages ! Pattern messagePattern = Pattern.compile("<a href=\"(\\S+)msg=MSG(\\d+(\\.\\d*)?)[\\&|\"]"); Pattern sizePattern = Pattern.compile("\\&start=\\d+\\&len=(\\d+)"); --- 597,601 ---- // Fixed bug: the .\d* part is optional for MSN system messages ! Pattern messagePattern = Pattern.compile("<a href=\"javascript:G\\('(\\S+)msg=MSG(\\d+(\\.\\d*)?)[\\&|\"]"); Pattern sizePattern = Pattern.compile("\\&start=\\d+\\&len=(\\d+)"); *************** *** 598,601 **** --- 608,612 ---- if (matcher.find()) { msgReadBaseUrl = matcher.group(1); + logger.finest("msgReadBaseUrl: " + msgReadBaseUrl); MailIdentifier mi = new MailIdentifier(); mi.MailID = matcher.group(2); *************** *** 694,697 **** --- 705,712 ---- } + logger.finest("retrieveMessage " + num +" , " + numLines); + logger.finest("messageIDS.size() = " + messageIDS.size()); + logger.finest(baseUrl); + logger.finest(msgReadBaseUrl); try { URL url = new URL(baseUrl + msgReadBaseUrl + "msg=MSG" |