From dbkr at freenetproject.org Fri Nov 2 00:48:17 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Fri, 2 Nov 2007 00:48:17 +0000 (UTC) Subject: [Freemail] r15656 - trunk/apps/Freemail/src/freemail Message-ID: <20071102004817.48A1047919B@freenetproject.org> Author: dbkr Date: 2007-11-02 00:48:16 +0000 (Fri, 02 Nov 2007) New Revision: 15656 Added: trunk/apps/Freemail/src/freemail/FreemailCli.java trunk/apps/Freemail/src/freemail/FreemailPlugin.java Modified: trunk/apps/Freemail/src/freemail/Freemail.java Log: Separate plugin & command line interface, so we can run the CLI interface without needing the freenet jar. Modified: trunk/apps/Freemail/src/freemail/Freemail.java =================================================================== --- trunk/apps/Freemail/src/freemail/Freemail.java 2007-10-31 17:12:22 UTC (rev 15655) +++ trunk/apps/Freemail/src/freemail/Freemail.java 2007-11-02 00:48:16 UTC (rev 15656) @@ -22,216 +22,41 @@ package freemail; import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import freemail.fcp.FCPContext; import freemail.fcp.FCPConnection; -import freemail.imap.IMAPListener; -import freemail.smtp.SMTPListener; -import freemail.config.Configurator; import freemail.config.ConfigClient; -import freenet.pluginmanager.FredPlugin; -import freenet.pluginmanager.FredPluginHTTP; -import freenet.pluginmanager.FredPluginHTTPAdvanced; -import freenet.pluginmanager.FredPluginThreadless; -import freenet.pluginmanager.PluginHTTPException; -import freenet.pluginmanager.PluginRespirator; -import freenet.support.HTMLNode; -import freenet.support.api.HTTPRequest; -public class Freemail implements ConfigClient, FredPlugin, FredPluginHTTP, FredPluginHTTPAdvanced, FredPluginThreadless { - // version info +public class Freemail implements ConfigClient { public static final int VER_MAJOR = 0; public static final int VER_MINOR = 1; public static final int BUILD_NO = 8; public static final String VERSION_TAG = "Pet Shop"; - private static final String TEMPDIRNAME = "temp"; - private static final String DATADIR = "data"; - private static final String GLOBALDATADIR = "globaldata"; - private static final String ACKDIR = "delayedacks"; - private static final String CFGFILE = "globalconfig"; + protected static final String TEMPDIRNAME = "temp"; + protected static final String DATADIR = "data"; + protected static final String GLOBALDATADIR = "globaldata"; + protected static final String ACKDIR = "delayedacks"; + protected static final String CFGFILE = "globalconfig"; private static File datadir; private static File globaldatadir; private static File tempdir; - private static FCPConnection fcpconn; + protected static FCPConnection fcpconn = null; - - //Plugin - private static PluginRespirator pr; - private ArrayList singleAccountWatcherList = new ArrayList(); - private MessageSender sender; - private SMTPListener smtpl; - private AckProcrastinator ackinserter; - private IMAPListener imapl; - public static File getTempDir() { return Freemail.tempdir; } + protected static File getGlobalDataDir() { + return globaldatadir; + } + + public static File getDataDir() { + return datadir; + } + public static FCPConnection getFCPConnection() { return Freemail.fcpconn; } - public static void main(String[] args) { - String cfgfile = CFGFILE; - - String action = ""; - String account = null; - String newpasswd = null; - String alias = null; - - System.out.println("This is Freemail version "+VER_MAJOR+"."+VER_MINOR+" build #"+BUILD_NO+" ("+VERSION_TAG+")"); - System.out.println("Freemail is released under the terms of the GNU Lesser General Public License. Freemail is provided WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see the LICENSE file included with this distribution."); - System.out.println(""); - - for (int i = 0; i < args.length; i++) { - if (args[i].equals("--newaccount")) { - action = args[i]; - i++; - if (args.length - 1 < i) { - System.out.println("Usage: --newaccount "); - return; - } - - account = args[i]; - } else if (args[i].equals("--passwd") || args[i].equals("--password")) { - action = "--passwd"; - i = i + 2; - if (args.length - 1 < i) { - System.out.println("Usage: --passwd "); - return; - } - account = args[i - 1]; - newpasswd = args[i]; - } else if (args[i].equals("--shortaddress")) { - action = args[i]; - i = i + 2; - if (args.length - 1 < i) { - System.out.println("Usage: --shortaddress "); - return; - } - account = args[i - 1]; - alias = args[i]; - } else if (args[i].equals("-c")) { - i++; - if (args.length - 1 < i) { - System.out.println("No config file supplied, using default"); - continue; - } - cfgfile = args[i]; - } else { - System.out.println("Unknown option: '"+args[i]+"'"); - return; - } - } - - Configurator cfg = new Configurator(new File(cfgfile)); - - FCPContext fcpctx = new FCPContext(); - - cfg.register("fcp_host", fcpctx, "localhost"); - cfg.register("fcp_port", fcpctx, "9481"); - - Freemail.fcpconn = new FCPConnection(fcpctx); - Thread fcpthread = new Thread(fcpconn); - fcpthread.setDaemon(true); - fcpthread.start(); - - if (action.equals("--newaccount")) { - try { - AccountManager.Create(account); - // by default, we'll not setup NIM now real mode works - //AccountManager.setupNIM(account); - System.out.println("Account created for "+account+". You may now set a password with --passwd "); - //System.out.println("For the time being, you address is "+account+"@nim.freemail"); - } catch (IOException ioe) { - System.out.println("Couldn't create account. Please check write access to Freemail's working directory. If you want to overwrite your account, delete the appropriate directory manually in 'data' first. Freemail will intentionally not overwrite it. Error: "+ioe.getMessage()); - } - return; - } else if (action.equals("--passwd")) { - try { - AccountManager.ChangePassword(account, newpasswd); - System.out.println("Password changed."); - } catch (Exception e) { - System.out.println("Couldn't change password for "+account+". "+e.getMessage()); - e.printStackTrace(); - } - return; - } else if (action.equals("--shortaddress")) { - try { - AccountManager.addShortAddress(account, alias); - } catch (Exception e) { - System.out.println("Couldn't add short address for "+account+". "+e.getMessage()); - e.printStackTrace(); - return; - } - System.out.println("Your short Freemail address is: 'anything@"+alias+".freemail'. Your long address will continue to work."); - return; - } - - cfg.register("globaldatadir", new Freemail(), GLOBALDATADIR); - if (!globaldatadir.exists()) { - globaldatadir.mkdir(); - } - - // start a SingleAccountWatcher for each account - cfg.register("datadir", new Freemail(), Freemail.DATADIR); - if (!Freemail.datadir.exists()) { - System.out.println("Starting Freemail for the first time."); - System.out.println("You will probably want to add an account by running Freemail with arguments --newaccount "); - if (!Freemail.datadir.mkdir()) { - System.out.println("Couldn't create data directory. Please ensure that the user you are running Freemail as has write access to its working directory"); - System.exit(1); - } - } - cfg.register("tempdir", new Freemail(), Freemail.TEMPDIRNAME); - if (!Freemail.tempdir.exists()) { - if (!Freemail.tempdir.mkdir()) { - System.out.println("Couldn't create temporary directory. Please ensure that the user you are running Freemail as has write access to its working directory"); - System.exit(1); - } - } - - File[] files = Freemail.datadir.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].getName().equals(".") || files[i].getName().equals("..")) - continue; - if (!files[i].isDirectory()) continue; - - Thread t = new Thread(new SingleAccountWatcher(files[i]), "Account Watcher for "+files[i].getName()); - t.setDaemon(true); - t.start(); - } - - // and a sender thread - MessageSender sender = new MessageSender(Freemail.datadir); - Thread senderthread = new Thread(sender, "Message sender"); - senderthread.setDaemon(true); - senderthread.start(); - - // start the SMTP Listener - SMTPListener smtpl = new SMTPListener(sender, cfg); - Thread smtpthread = new Thread(smtpl, "SMTP Listener"); - smtpthread.setDaemon(true); - smtpthread.start(); - - // start the delayed ACK inserter - File ackdir = new File(globaldatadir, ACKDIR); - AckProcrastinator.setAckDir(ackdir); - AckProcrastinator ackinserter = new AckProcrastinator(); - Thread ackinsthread = new Thread(ackinserter, "Delayed ACK Inserter"); - ackinsthread.setDaemon(true); - ackinsthread.start(); - - - // start the IMAP listener - IMAPListener imapl = new IMAPListener(cfg); - imapl.run(); - } - public void setConfigProp(String key, String val) { if (key.equalsIgnoreCase("datadir")) { Freemail.datadir = new File(val); @@ -241,156 +66,4 @@ Freemail.globaldatadir = new File(val); } } - - // Plugin - public void runPlugin(PluginRespirator pr) { - Freemail.pr = pr; - String cfgfile = CFGFILE; - Configurator cfg = new Configurator(new File(cfgfile)); - FCPContext fcpctx = new FCPContext(); - - cfg.register("fcp_host", fcpctx, "localhost"); - cfg.register("fcp_port", fcpctx, "9481"); - - Freemail.fcpconn = new FCPConnection(fcpctx); - Thread fcpthread = new Thread(fcpconn, "Freemail FCP Connection"); - fcpthread.setDaemon(true); - fcpthread.start(); - cfg.register("globaldatadir", new Freemail(), GLOBALDATADIR); - if (!globaldatadir.exists()) { - if(!globaldatadir.mkdir()) { - System.out.println("Freemail plugin: Couldn't create global data directory. Please ensure that the user you are running Freemail as has write access to its working directory"); - return; - } - } - cfg.register("datadir", new Freemail(), Freemail.DATADIR); - if (!Freemail.datadir.exists()) { - if (!Freemail.datadir.mkdir()) { - System.out.println("Freemail plugin: Couldn't create data directory. Please ensure that the user you are running Freemail as has write access to its working directory"); - return; - } - } - cfg.register("tempdir", new Freemail(), Freemail.TEMPDIRNAME); - if (!Freemail.tempdir.exists()) { - if (!Freemail.tempdir.mkdir()) { - System.out.println("Freemail plugin: Couldn't create temporary directory. Please ensure that the user you are running Freemail as has write access to its working directory"); - return; - } - } - File[] files = Freemail.datadir.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].getName().equals(".") || files[i].getName().equals("..")) - continue; - if (!files[i].isDirectory()) continue; - - SingleAccountWatcher saw = new SingleAccountWatcher(files[i]); - singleAccountWatcherList.add(saw); - Thread t = new Thread(saw, "Freemail Account Watcher for "+files[i].getName()); - t.setDaemon(true); - t.start(); - } - - // and a sender thread - sender = new MessageSender(Freemail.datadir); - Thread senderthread = new Thread(sender, "Freemail Message sender"); - senderthread.setDaemon(true); - senderthread.start(); - - // start the SMTP Listener - smtpl = new SMTPListener(sender, cfg); - Thread smtpthread = new Thread(smtpl, "Freemail SMTP Listener"); - smtpthread.setDaemon(true); - smtpthread.start(); - - // start the delayed ACK inserter - File ackdir = new File(globaldatadir, ACKDIR); - AckProcrastinator.setAckDir(ackdir); - ackinserter = new AckProcrastinator(); - Thread ackinsthread = new Thread(ackinserter, "Freemail Delayed ACK Inserter"); - ackinsthread.setDaemon(true); - ackinsthread.start(); - - // start the IMAP listener - imapl = new IMAPListener(cfg); - Thread imaplthread = new Thread(imapl, "Freemail IMAP Listener"); - imaplthread.setDaemon(true); - imaplthread.start(); - } - - public void terminate() { - Iterator it = singleAccountWatcherList.iterator(); - while(it.hasNext()) { - ((SingleAccountWatcher)it.next()).kill(); - it.remove(); - } - sender.kill(); - ackinserter.kill(); - smtpl.kill(); - imapl.kill(); - fcpconn.kill(); - return; - } - - public String handleHTTPGet(HTTPRequest request) throws PluginHTTPException { - HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail plugin", false, null); - HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); - - if(request.getParam("add").equals("Add account")) { - if(!(request.getParam("name").equals("") || request.getParam("password").equals(""))) { - try { - AccountManager.Create(request.getParam("name")); - AccountManager.ChangePassword(request.getParam("name"), request.getParam("password")); - if(!request.getParam("domain").equals("")) { - AccountManager.addShortAddress(request.getParam("name"), request.getParam("domain")); - } - Thread t = new Thread(new SingleAccountWatcher(new File(DATADIR, request.getParam("name"))), "Account Watcher for "+request.getParam("name")); - t.setDaemon(true); - t.start(); - HTMLNode addedBox = contentNode.addChild("div", "class", "infobox"); - addedBox.addChild("div", "class", "infobox-header", "Added account"); - addedBox.addChild("div", "class", "infobox-content", "Account for " + request.getParam("name") + " is created"); - - } catch (IOException ioe) { - HTMLNode errorBox = contentNode.addChild("div", "class", "infobox infobox-error"); - errorBox.addChild("div", "class", "infobox-header", "IO Error"); - errorBox.addChild("div", "class", "infobox-content", "Couldn't create account. Please check write access to Freemail's working directory. If you want to overwrite your account, delete the appropriate directory manually in 'data' first. Freemail will intentionally not overwrite it. Error: "+ioe.getMessage()); - } catch (Exception e) { - HTMLNode errorBox = contentNode.addChild("div", "class", "infobox-error"); - errorBox.addChild("div", "class", "infobox-header", "Error"); - errorBox.addChild("div", "class", "infobox-content", "Couldn't change password for "+request.getParam("name")+". "+e.getMessage()); - } - } else { - HTMLNode errorBox = contentNode.addChild("div", "class", "infobox infobox-error"); - errorBox.addChild("div", "class", "infobox-header", "Error"); - errorBox.addChild("div", "class", "infobox-content", "Couldn't create account, name or password is missing"); - } - } - - HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); - addBox.addChild("div", "class", "infobox-header", "Add account"); - HTMLNode table = addBox.addChild("div", "class", "infobox-content").addChild("form").addChild("table", "class", "plugintable"); - HTMLNode tableRowName = table.addChild("tr"); - tableRowName.addChild("td", "Name"); - tableRowName.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "name", "", "30" }); - HTMLNode tableRowPassword = table.addChild("tr"); - tableRowPassword.addChild("td", "Password"); - tableRowPassword.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "password", "password", "", "30" }); - HTMLNode tableRowDomain = table.addChild("tr"); - tableRowDomain.addChild("td", "Domain"); - tableRowDomain.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "domain", "", "30" }); - HTMLNode tableRowSubmit = table.addChild("tr"); - tableRowSubmit.addChild("td"); - tableRowSubmit.addChild("td").addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add account"}); - - return pageNode.generate(); - } - - public String handleHTTPPost(HTTPRequest request) throws PluginHTTPException { - return null; - } - - public String handleHTTPPut(HTTPRequest request) throws PluginHTTPException { - return null; - } - } Added: trunk/apps/Freemail/src/freemail/FreemailCli.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailCli.java (rev 0) +++ trunk/apps/Freemail/src/freemail/FreemailCli.java 2007-11-02 00:48:16 UTC (rev 15656) @@ -0,0 +1,194 @@ +/* + * FreemailCli.java + * This file is part of Freemail, copyright (C) 2006 Dave Baker + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + */ + +package freemail; + +import java.io.File; +import java.io.IOException; +//import java.util.ArrayList; +//import java.util.Iterator; + +import freemail.Freemail; +import freemail.fcp.FCPContext; +import freemail.fcp.FCPConnection; +import freemail.imap.IMAPListener; +import freemail.smtp.SMTPListener; +import freemail.config.Configurator; +//import freemail.config.ConfigClient; + +public abstract class FreemailCli extends Freemail { + public static void main(String[] args) { + String cfgfile = CFGFILE; + + String action = ""; + String account = null; + String newpasswd = null; + String alias = null; + + System.out.println("This is Freemail version "+VER_MAJOR+"."+VER_MINOR+" build #"+BUILD_NO+" ("+VERSION_TAG+")"); + System.out.println("Freemail is released under the terms of the GNU Lesser General Public License. Freemail is provided WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see the LICENSE file included with this distribution."); + System.out.println(""); + + for (int i = 0; i < args.length; i++) { + if (args[i].equals("--newaccount")) { + action = args[i]; + i++; + if (args.length - 1 < i) { + System.out.println("Usage: --newaccount "); + return; + } + + account = args[i]; + } else if (args[i].equals("--passwd") || args[i].equals("--password")) { + action = "--passwd"; + i = i + 2; + if (args.length - 1 < i) { + System.out.println("Usage: --passwd "); + return; + } + account = args[i - 1]; + newpasswd = args[i]; + } else if (args[i].equals("--shortaddress")) { + action = args[i]; + i = i + 2; + if (args.length - 1 < i) { + System.out.println("Usage: --shortaddress "); + return; + } + account = args[i - 1]; + alias = args[i]; + } else if (args[i].equals("-c")) { + i++; + if (args.length - 1 < i) { + System.out.println("No config file supplied, using default"); + continue; + } + cfgfile = args[i]; + } else { + System.out.println("Unknown option: '"+args[i]+"'"); + return; + } + } + + Configurator cfg = new Configurator(new File(cfgfile)); + + FCPContext fcpctx = new FCPContext(); + + cfg.register("fcp_host", fcpctx, "localhost"); + cfg.register("fcp_port", fcpctx, "9481"); + + Freemail.fcpconn = new FCPConnection(fcpctx); + Thread fcpthread = new Thread(fcpconn); + fcpthread.setDaemon(true); + fcpthread.start(); + + if (action.equals("--newaccount")) { + try { + AccountManager.Create(account); + // by default, we'll not setup NIM now real mode works + //AccountManager.setupNIM(account); + System.out.println("Account created for "+account+". You may now set a password with --passwd "); + //System.out.println("For the time being, you address is "+account+"@nim.freemail"); + } catch (IOException ioe) { + System.out.println("Couldn't create account. Please check write access to Freemail's working directory. If you want to overwrite your account, delete the appropriate directory manually in 'data' first. Freemail will intentionally not overwrite it. Error: "+ioe.getMessage()); + } + return; + } else if (action.equals("--passwd")) { + try { + AccountManager.ChangePassword(account, newpasswd); + System.out.println("Password changed."); + } catch (Exception e) { + System.out.println("Couldn't change password for "+account+". "+e.getMessage()); + e.printStackTrace(); + } + return; + } else if (action.equals("--shortaddress")) { + try { + AccountManager.addShortAddress(account, alias); + } catch (Exception e) { + System.out.println("Couldn't add short address for "+account+". "+e.getMessage()); + e.printStackTrace(); + return; + } + System.out.println("Your short Freemail address is: 'anything@"+alias+".freemail'. Your long address will continue to work."); + return; + } + + cfg.register("globaldatadir", new Freemail(), GLOBALDATADIR); + if (!getGlobalDataDir().exists()) { + getGlobalDataDir().mkdir(); + } + + // start a SingleAccountWatcher for each account + cfg.register("datadir", new Freemail(), Freemail.DATADIR); + if (!getDataDir().exists()) { + System.out.println("Starting Freemail for the first time."); + System.out.println("You will probably want to add an account by running Freemail with arguments --newaccount "); + if (!getDataDir().mkdir()) { + System.out.println("Couldn't create data directory. Please ensure that the user you are running Freemail as has write access to its working directory"); + System.exit(1); + } + } + cfg.register("tempdir", new Freemail(), Freemail.TEMPDIRNAME); + if (!getTempDir().exists()) { + if (!getTempDir().mkdir()) { + System.out.println("Couldn't create temporary directory. Please ensure that the user you are running Freemail as has write access to its working directory"); + System.exit(1); + } + } + + File[] files = getDataDir().listFiles(); + for (int i = 0; i < files.length; i++) { + if (files[i].getName().equals(".") || files[i].getName().equals("..")) + continue; + if (!files[i].isDirectory()) continue; + + Thread t = new Thread(new SingleAccountWatcher(files[i]), "Account Watcher for "+files[i].getName()); + t.setDaemon(true); + t.start(); + } + + // and a sender thread + MessageSender sender = new MessageSender(getDataDir()); + Thread senderthread = new Thread(sender, "Message sender"); + senderthread.setDaemon(true); + senderthread.start(); + + // start the SMTP Listener + SMTPListener smtpl = new SMTPListener(sender, cfg); + Thread smtpthread = new Thread(smtpl, "SMTP Listener"); + smtpthread.setDaemon(true); + smtpthread.start(); + + // start the delayed ACK inserter + File ackdir = new File(getGlobalDataDir(), ACKDIR); + AckProcrastinator.setAckDir(ackdir); + AckProcrastinator ackinserter = new AckProcrastinator(); + Thread ackinsthread = new Thread(ackinserter, "Delayed ACK Inserter"); + ackinsthread.setDaemon(true); + ackinsthread.start(); + + + // start the IMAP listener + IMAPListener imapl = new IMAPListener(cfg); + imapl.run(); + } +} Added: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java (rev 0) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-02 00:48:16 UTC (rev 15656) @@ -0,0 +1,206 @@ +/* + * FreemailPlugin.java + * This file is part of Freemail, copyright (C) 2006 Dave Baker + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + */ + +package freemail; + + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; + + +import freemail.Freemail; +import freemail.fcp.FCPContext; +import freemail.fcp.FCPConnection; +import freemail.imap.IMAPListener; +import freemail.smtp.SMTPListener; +import freemail.config.Configurator; + +import freenet.pluginmanager.FredPlugin; +import freenet.pluginmanager.FredPluginHTTP; +import freenet.pluginmanager.FredPluginHTTPAdvanced; +import freenet.pluginmanager.FredPluginThreadless; +import freenet.pluginmanager.PluginHTTPException; +import freenet.pluginmanager.PluginRespirator; +import freenet.support.HTMLNode; +import freenet.support.api.HTTPRequest; + +public class FreemailPlugin extends Freemail implements FredPlugin, FredPluginHTTP, + FredPluginHTTPAdvanced, FredPluginThreadless { + private static PluginRespirator pr; + private ArrayList singleAccountWatcherList = new ArrayList(); + private MessageSender sender; + private SMTPListener smtpl; + private AckProcrastinator ackinserter; + private IMAPListener imapl; + + public void runPlugin(PluginRespirator pr) { + FreemailPlugin.pr = pr; + String cfgfile = CFGFILE; + Configurator cfg = new Configurator(new File(cfgfile)); + FCPContext fcpctx = new FCPContext(); + + cfg.register("fcp_host", fcpctx, "localhost"); + cfg.register("fcp_port", fcpctx, "9481"); + + Freemail.fcpconn = new FCPConnection(fcpctx); + Thread fcpthread = new Thread(fcpconn, "Freemail FCP Connection"); + fcpthread.setDaemon(true); + fcpthread.start(); + cfg.register("globaldatadir", new Freemail(), GLOBALDATADIR); + if (!getGlobalDataDir().exists()) { + if(!getGlobalDataDir().mkdir()) { + System.out.println("Freemail plugin: Couldn't create global data directory. Please ensure that the user you are running Freemail as has write access to its working directory"); + return; + } + } + cfg.register("datadir", new Freemail(), Freemail.DATADIR); + if (!getDataDir().exists()) { + if (!getDataDir().mkdir()) { + System.out.println("Freemail plugin: Couldn't create data directory. Please ensure that the user you are running Freemail as has write access to its working directory"); + return; + } + } + cfg.register("tempdir", new Freemail(), Freemail.TEMPDIRNAME); + if (!getTempDir().exists()) { + if (!Freemail.getTempDir().mkdir()) { + System.out.println("Freemail plugin: Couldn't create temporary directory. Please ensure that the user you are running Freemail as has write access to its working directory"); + return; + } + } + File[] files = getDataDir().listFiles(); + for (int i = 0; i < files.length; i++) { + if (files[i].getName().equals(".") || files[i].getName().equals("..")) + continue; + if (!files[i].isDirectory()) continue; + + SingleAccountWatcher saw = new SingleAccountWatcher(files[i]); + singleAccountWatcherList.add(saw); + Thread t = new Thread(saw, "Freemail Account Watcher for "+files[i].getName()); + t.setDaemon(true); + t.start(); + } + + // and a sender thread + sender = new MessageSender(getDataDir()); + Thread senderthread = new Thread(sender, "Freemail Message sender"); + senderthread.setDaemon(true); + senderthread.start(); + + // start the SMTP Listener + smtpl = new SMTPListener(sender, cfg); + Thread smtpthread = new Thread(smtpl, "Freemail SMTP Listener"); + smtpthread.setDaemon(true); + smtpthread.start(); + + // start the delayed ACK inserter + File ackdir = new File(getGlobalDataDir(), ACKDIR); + AckProcrastinator.setAckDir(ackdir); + ackinserter = new AckProcrastinator(); + Thread ackinsthread = new Thread(ackinserter, "Freemail Delayed ACK Inserter"); + ackinsthread.setDaemon(true); + ackinsthread.start(); + + // start the IMAP listener + imapl = new IMAPListener(cfg); + Thread imaplthread = new Thread(imapl, "Freemail IMAP Listener"); + imaplthread.setDaemon(true); + imaplthread.start(); + } + + public void terminate() { + Iterator it = singleAccountWatcherList.iterator(); + while(it.hasNext()) { + ((SingleAccountWatcher)it.next()).kill(); + it.remove(); + } + sender.kill(); + ackinserter.kill(); + smtpl.kill(); + imapl.kill(); + fcpconn.kill(); + return; + } + + public String handleHTTPGet(HTTPRequest request) throws PluginHTTPException { + HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail plugin", false, null); + HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); + + if(request.getParam("add").equals("Add account")) { + if(!(request.getParam("name").equals("") || request.getParam("password").equals(""))) { + try { + AccountManager.Create(request.getParam("name")); + AccountManager.ChangePassword(request.getParam("name"), request.getParam("password")); + if(!request.getParam("domain").equals("")) { + AccountManager.addShortAddress(request.getParam("name"), request.getParam("domain")); + } + Thread t = new Thread(new SingleAccountWatcher(new File(DATADIR, request.getParam("name"))), "Account Watcher for "+request.getParam("name")); + t.setDaemon(true); + t.start(); + HTMLNode addedBox = contentNode.addChild("div", "class", "infobox"); + addedBox.addChild("div", "class", "infobox-header", "Added account"); + addedBox.addChild("div", "class", "infobox-content", "Account for " + request.getParam("name") + " is created"); + + } catch (IOException ioe) { + HTMLNode errorBox = contentNode.addChild("div", "class", "infobox infobox-error"); + errorBox.addChild("div", "class", "infobox-header", "IO Error"); + errorBox.addChild("div", "class", "infobox-content", "Couldn't create account. Please check write access to Freemail's working directory. If you want to overwrite your account, delete the appropriate directory manually in 'data' first. Freemail will intentionally not overwrite it. Error: "+ioe.getMessage()); + } catch (Exception e) { + HTMLNode errorBox = contentNode.addChild("div", "class", "infobox-error"); + errorBox.addChild("div", "class", "infobox-header", "Error"); + errorBox.addChild("div", "class", "infobox-content", "Couldn't change password for "+request.getParam("name")+". "+e.getMessage()); + } + } else { + HTMLNode errorBox = contentNode.addChild("div", "class", "infobox infobox-error"); + errorBox.addChild("div", "class", "infobox-header", "Error"); + errorBox.addChild("div", "class", "infobox-content", "Couldn't create account, name or password is missing"); + } + } + + HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); + addBox.addChild("div", "class", "infobox-header", "Add account"); + HTMLNode table = addBox.addChild("div", "class", "infobox-content").addChild("form").addChild("table", "class", "plugintable"); + HTMLNode tableRowName = table.addChild("tr"); + tableRowName.addChild("td", "Name"); + tableRowName.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "name", "", "30" }); + HTMLNode tableRowPassword = table.addChild("tr"); + tableRowPassword.addChild("td", "Password"); + tableRowPassword.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "password", "password", "", "30" }); + HTMLNode tableRowDomain = table.addChild("tr"); + tableRowDomain.addChild("td", "Domain"); + tableRowDomain.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "domain", "", "30" }); + HTMLNode tableRowSubmit = table.addChild("tr"); + tableRowSubmit.addChild("td"); + tableRowSubmit.addChild("td").addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add account"}); + + return pageNode.generate(); + } + + public String handleHTTPPost(HTTPRequest request) throws PluginHTTPException { + return null; + } + + public String handleHTTPPut(HTTPRequest request) throws PluginHTTPException { + return null; + } + +} From nextgens at freenetproject.org Fri Nov 2 01:04:46 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Fri, 2 Nov 2007 01:04:46 +0000 (UTC) Subject: [Freemail] r15657 - trunk/apps/Freemail Message-ID: <20071102010446.270E547B2B3@freenetproject.org> Author: nextgens Date: 2007-11-02 01:04:43 +0000 (Fri, 02 Nov 2007) New Revision: 15657 Modified: trunk/apps/Freemail/build.xml Log: Freemail: apply dbkr's patch to build.xml Modified: trunk/apps/Freemail/build.xml =================================================================== --- trunk/apps/Freemail/build.xml 2007-11-02 00:48:16 UTC (rev 15656) +++ trunk/apps/Freemail/build.xml 2007-11-02 01:04:43 UTC (rev 15657) @@ -3,7 +3,6 @@ - @@ -52,11 +51,10 @@ - - + - - + +
From nextgens at freenetproject.org Fri Nov 2 10:02:42 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Fri, 2 Nov 2007 10:02:42 +0000 (UTC) Subject: [Freemail] r15661 - trunk/apps/Freemail Message-ID: <20071102100242.44C6F47B311@freenetproject.org> Author: nextgens Date: 2007-11-02 10:02:41 +0000 (Fri, 02 Nov 2007) New Revision: 15661 Modified: trunk/apps/Freemail/build.xml Log: Freemail: patch to build.xml from dbkr Modified: trunk/apps/Freemail/build.xml =================================================================== --- trunk/apps/Freemail/build.xml 2007-11-02 03:10:17 UTC (rev 15660) +++ trunk/apps/Freemail/build.xml 2007-11-02 10:02:41 UTC (rev 15661) @@ -3,6 +3,7 @@ + @@ -51,7 +52,8 @@ - + + From dbkr at freenetproject.org Sun Nov 4 23:31:28 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Sun, 4 Nov 2007 23:31:28 +0000 (UTC) Subject: [Freemail] r15689 - trunk/apps/Freemail/src/freemailgui Message-ID: <20071104233128.99B9547AA9D@freenetproject.org> Author: dbkr Date: 2007-11-04 23:31:27 +0000 (Sun, 04 Nov 2007) New Revision: 15689 Modified: trunk/apps/Freemail/src/freemailgui/WizardAskGenKeys.java Log: Fix a couple of warnings Modified: trunk/apps/Freemail/src/freemailgui/WizardAskGenKeys.java =================================================================== --- trunk/apps/Freemail/src/freemailgui/WizardAskGenKeys.java 2007-11-04 22:58:52 UTC (rev 15688) +++ trunk/apps/Freemail/src/freemailgui/WizardAskGenKeys.java 2007-11-04 23:31:27 UTC (rev 15689) @@ -25,7 +25,6 @@ import javax.swing.JLabel; import javax.swing.SwingConstants; import javax.swing.Box; -import javax.swing.BoxLayout; import javax.swing.JTextField; import java.awt.Dimension; import java.awt.GridBagLayout; @@ -35,6 +34,7 @@ import java.util.ResourceBundle; public class WizardAskGenKeys extends JPanel { + private static final long serialVersionUID = -1; private final JTextField fcphosttext; private final JTextField fcpporttext; From dbkr at freenetproject.org Sun Nov 4 23:35:39 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Sun, 4 Nov 2007 23:35:39 +0000 (UTC) Subject: [Freemail] r15690 - trunk/apps/Freemail Message-ID: <20071104233539.5C3E447B343@freenetproject.org> Author: dbkr Date: 2007-11-04 23:35:39 +0000 (Sun, 04 Nov 2007) New Revision: 15690 Removed: trunk/apps/Freemail/.classpath Log: This won't work now we need the freenet plugin classes on the classpath, and I'm not inclined to fix it because I'm not too keen on having settings files for the IDE-de-jour cluttering up the source. Deleted: trunk/apps/Freemail/.classpath =================================================================== --- trunk/apps/Freemail/.classpath 2007-11-04 23:31:27 UTC (rev 15689) +++ trunk/apps/Freemail/.classpath 2007-11-04 23:35:39 UTC (rev 15690) @@ -1,7 +0,0 @@ - - - - - - - From dbkr at freenetproject.org Sun Nov 4 23:37:31 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Sun, 4 Nov 2007 23:37:31 +0000 (UTC) Subject: [Freemail] r15691 - trunk/apps/Freemail Message-ID: <20071104233731.EF8E247B343@freenetproject.org> Author: dbkr Date: 2007-11-04 23:37:31 +0000 (Sun, 04 Nov 2007) New Revision: 15691 Removed: trunk/apps/Freemail/.project Log: Ditto 15690. Deleted: trunk/apps/Freemail/.project =================================================================== --- trunk/apps/Freemail/.project 2007-11-04 23:35:39 UTC (rev 15690) +++ trunk/apps/Freemail/.project 2007-11-04 23:37:31 UTC (rev 15691) @@ -1,17 +0,0 @@ - - - Freemail - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - From dbkr at freenetproject.org Mon Nov 5 21:41:52 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Mon, 5 Nov 2007 21:41:52 +0000 (UTC) Subject: [Freemail] r15695 - trunk/apps/Freemail/src/freemail Message-ID: <20071105214152.902894798A1@freenetproject.org> Author: dbkr Date: 2007-11-05 21:41:52 +0000 (Mon, 05 Nov 2007) New Revision: 15695 Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java Log: Revert unintentional commit. Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 14:09:24 UTC (rev 15694) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 21:41:52 UTC (rev 15695) @@ -191,7 +191,7 @@ } public String handleHTTPGet(HTTPRequest request) throws PluginHTTPException { - HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail plugin", true, null); + HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail plugin", false, null); HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); if(request.getParam("add").equals("Add account")) { From dbkr at freenetproject.org Mon Nov 5 23:59:35 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Mon, 5 Nov 2007 23:59:35 +0000 (UTC) Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail Message-ID: <20071105235935.93EB43908DD@freenetproject.org> Author: dbkr Date: 2007-11-05 23:59:35 +0000 (Mon, 05 Nov 2007) New Revision: 15698 Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java Log: Use post for the add account form. Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 23:41:48 UTC (rev 15697) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 23:59:35 UTC (rev 15698) @@ -194,21 +194,62 @@ HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail plugin", false, null); HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); - if(request.getParam("add").equals("Add account")) { - if(!(request.getParam("name").equals("") || request.getParam("password").equals(""))) { + HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); + addBox.addChild("div", "class", "infobox-header", "Add account"); + + HTMLNode boxContent = addBox.addChild("div", "class", "infobox-content"); + HTMLNode form = pr.addFormChild(boxContent, "", "addAccountForm"); + + HTMLNode table = form.addChild("table", "class", "plugintable"); + HTMLNode tableRowName = table.addChild("tr"); + tableRowName.addChild("td", "Name"); + tableRowName.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "name", "", "30" }); + HTMLNode tableRowPassword = table.addChild("tr"); + tableRowPassword.addChild("td", "Password"); + tableRowPassword.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "password", "password", "", "30" }); + HTMLNode tableRowDomain = table.addChild("tr"); + tableRowDomain.addChild("td", "Domain"); + tableRowDomain.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "domain", "", "30" }); + HTMLNode tableRowSubmit = table.addChild("tr"); + tableRowSubmit.addChild("td"); + tableRowSubmit.addChild("td").addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add account"}); + + return pageNode.generate(); + } + + public String handleHTTPPost(HTTPRequest request) throws PluginHTTPException { + HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail plugin", false, null); + HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); + + String add = request.getPartAsString("add", 100); + String name = request.getPartAsString("name", 100); + String password = request.getPartAsString("password", 100); + String domain = request.getPartAsString("domain", 100); + + if(add.equals("Add account")) { + if(!(name.equals("") || password.equals(""))) { try { - AccountManager.Create(request.getParam("name")); - AccountManager.ChangePassword(request.getParam("name"), request.getParam("password")); - if(!request.getParam("domain").equals("")) { - AccountManager.addShortAddress(request.getParam("name"), request.getParam("domain")); + AccountManager.Create(name); + AccountManager.ChangePassword(name, password); + if(!domain.equals("")) { + AccountManager.addShortAddress(name, domain); } - Thread t = new Thread(new SingleAccountWatcher(new File(DATADIR, request.getParam("name"))), "Account Watcher for "+request.getParam("name")); + Thread t = new Thread(new SingleAccountWatcher(new File(DATADIR, name)), "Account Watcher for "+name); t.setDaemon(true); t.start(); - HTMLNode addedBox = contentNode.addChild("div", "class", "infobox"); - addedBox.addChild("div", "class", "infobox-header", "Added account"); - addedBox.addChild("div", "class", "infobox-content", "Account for " + request.getParam("name") + " is created"); - + + HTMLNode successBox = contentNode.addChild("div", "class", "infobox infobox-success"); + successBox.addChild("div", "class", "infobox-header", "Account Created"); + // TODO: This is not the world's best into message, but it's only temporary (hopefully...) + HTMLNode text = successBox.addChild("div", "class", "infobox-content"); + text.addChild("#", "The account "); + text.addChild("i", name); + text.addChild("#", " was created successfully."); + text.addChild("br"); + text.addChild("br"); + text.addChild("#", "You now need to configure your email client to send and receive email through " + + "Freemail using IMAP and SMTP. Freemail uses ports 3143 and 3025 for these " + + "respectively by default."); } catch (IOException ioe) { HTMLNode errorBox = contentNode.addChild("div", "class", "infobox infobox-error"); errorBox.addChild("div", "class", "infobox-header", "IO Error"); @@ -216,38 +257,23 @@ } catch (Exception e) { HTMLNode errorBox = contentNode.addChild("div", "class", "infobox-error"); errorBox.addChild("div", "class", "infobox-header", "Error"); - errorBox.addChild("div", "class", "infobox-content", "Couldn't change password for "+request.getParam("name")+". "+e.getMessage()); + errorBox.addChild("div", "class", "infobox-content", "Couldn't change password for "+name+". "+e.getMessage()); } + + // XXX: There doesn't seem to be a way to get (or set) our root in the web interface, + // so we'll just have to assume it's this and won't change + contentNode.addChild("a", "href", "/plugins/freemail.FreemailPlugin", + "Freemail Home"); } else { HTMLNode errorBox = contentNode.addChild("div", "class", "infobox infobox-error"); errorBox.addChild("div", "class", "infobox-header", "Error"); errorBox.addChild("div", "class", "infobox-content", "Couldn't create account, name or password is missing"); } } - - HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); - addBox.addChild("div", "class", "infobox-header", "Add account"); - HTMLNode table = addBox.addChild("div", "class", "infobox-content").addChild("form").addChild("table", "class", "plugintable"); - HTMLNode tableRowName = table.addChild("tr"); - tableRowName.addChild("td", "Name"); - tableRowName.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "name", "", "30" }); - HTMLNode tableRowPassword = table.addChild("tr"); - tableRowPassword.addChild("td", "Password"); - tableRowPassword.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "password", "password", "", "30" }); - HTMLNode tableRowDomain = table.addChild("tr"); - tableRowDomain.addChild("td", "Domain"); - tableRowDomain.addChild("td").addChild("input", new String[] { "type", "name", "value", "size" }, new String[] { "text", "domain", "", "30" }); - HTMLNode tableRowSubmit = table.addChild("tr"); - tableRowSubmit.addChild("td"); - tableRowSubmit.addChild("td").addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add account"}); return pageNode.generate(); } - public String handleHTTPPost(HTTPRequest request) throws PluginHTTPException { - return null; - } - public String handleHTTPPut(HTTPRequest request) throws PluginHTTPException { return null; } From dbkr at freenetproject.org Tue Nov 6 00:30:54 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Tue, 6 Nov 2007 00:30:54 +0000 (UTC) Subject: [Freemail] r15699 - trunk/apps/Freemail/src/freemail Message-ID: <20071106003054.933F347B748@freenetproject.org> Author: dbkr Date: 2007-11-06 00:30:54 +0000 (Tue, 06 Nov 2007) New Revision: 15699 Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java Log: Add an explanatory note about how a plugin with several threads comes to implement FredPluginThreadless. Also don't implement FredPluginHTTPAdvanced, which seems to do precisely sweet FA. Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 23:59:35 UTC (rev 15698) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-06 00:30:54 UTC (rev 15699) @@ -44,8 +44,10 @@ import freenet.support.HTMLNode; import freenet.support.api.HTTPRequest; +// although we have threads, we still 'implement' FredPluginThreadless because our runPlugin method +// returns rather than just continuing to run for the lifetime of the plugin. public class FreemailPlugin extends Freemail implements FredPlugin, FredPluginHTTP, - FredPluginHTTPAdvanced, FredPluginThreadless { + FredPluginThreadless { private static PluginRespirator pr; private ArrayList singleAccountWatcherList = new ArrayList(); private MessageSender sender; From alexlehm at freenetproject.org Tue Nov 6 23:52:15 2007 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Tue, 6 Nov 2007 23:52:15 +0000 (UTC) Subject: [Freemail] r15701 - trunk/apps/Freemail/src/freemail Message-ID: <20071106235215.121BD47B750@freenetproject.org> Author: alexlehm Date: 2007-11-06 23:52:14 +0000 (Tue, 06 Nov 2007) New Revision: 15701 Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java Log: fix sdf format to use proper locale and gmt timezone, this fixes the following bugs: https://bugs.freenetproject.org/view.php?id=1762 (rewriting the date header to gmt doesn't work) https://bugs.freenetproject.org/view.php?id=1505 (Exception: "couldn't parse date" when sending mail) Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java =================================================================== --- trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-06 01:04:49 UTC (rev 15700) +++ trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-06 23:52:14 UTC (rev 15701) @@ -32,8 +32,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; -import java.util.Calendar; import java.text.ParseException; +import java.util.Locale; class MailHeaderFilter { private final BufferedReader reader; @@ -41,12 +41,14 @@ private boolean foundEnd; private static final SimpleDateFormat sdf; private static final TimeZone gmt; - private static final Calendar cal; + // TODO: according to javadoc, SimpleDateFormat objects are not synchronized, + // should this be taken into account? + static { - sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); + sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US); gmt = TimeZone.getTimeZone("GMT"); - cal = Calendar.getInstance(gmt); + sdf.setTimeZone(gmt); } public MailHeaderFilter(BufferedReader rdr) { @@ -125,9 +127,7 @@ System.out.println("Warning: couldn't parse date: "+val+" (got null)"); return null; } - cal.setTime(d); - cal.setTimeZone(gmt); - return sdf.format(cal.getTime()); + return sdf.format(d); } else if (name.equalsIgnoreCase("User-Agent")) { // might as well hide this return null; From lists at privaterra.info Wed Nov 7 04:41:19 2007 From: lists at privaterra.info (Robert Guerra) Date: Tue, 6 Nov 2007 23:41:19 -0500 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <20071105235935.93EB43908DD@freenetproject.org> References: <20071105235935.93EB43908DD@freenetproject.org> Message-ID: <5B381F94-6DE8-4AA9-BD5C-158F8E657689@privaterra.info> Does this version mean that Freemail can now be used as a plugin? If so, would you be so kind as to describe the steps needed to add the plugin to freenet. thanks regards, Robert --- Robert Guerra Managing Director, Privaterra Tel +1 416 893 0377 On 5-Nov-07, at 6:59 PM, dbkr at freenetproject.org wrote: > Author: dbkr > Date: 2007-11-05 23:59:35 +0000 (Mon, 05 Nov 2007) > New Revision: 15698 > > Modified: > trunk/apps/Freemail/src/freemail/FreemailPlugin.java > Log: > Use post for the add account form. > > > Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java > =================================================================== > --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 > 23:41:48 UTC (rev 15697) > +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 > 23:59:35 UTC (rev 15698) > @@ -194,21 +194,62 @@ > HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail > plugin", false, null); > HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); > > - if(request.getParam("add").equals("Add account")) { > - if(!(request.getParam("name").equals("") || > request.getParam("password").equals(""))) { > + HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); > + addBox.addChild("div", "class", "infobox-header", "Add account"); > + > + HTMLNode boxContent = addBox.addChild("div", "class", "infobox- > content"); > + HTMLNode form = pr.addFormChild(boxContent, "", "addAccountForm"); > + > + HTMLNode table = form.addChild("table", "class", "plugintable"); > + HTMLNode tableRowName = table.addChild("tr"); > + tableRowName.addChild("td", "Name"); > + tableRowName.addChild("td").addChild("input", new String[] > { "type", "name", "value", "size" }, new String[] { "text", "name", > "", "30" }); > + HTMLNode tableRowPassword = table.addChild("tr"); > + tableRowPassword.addChild("td", "Password"); > + tableRowPassword.addChild("td").addChild("input", new String[] > { "type", "name", "value", "size" }, new String[] { "password", > "password", "", "30" }); > + HTMLNode tableRowDomain = table.addChild("tr"); > + tableRowDomain.addChild("td", "Domain"); > + tableRowDomain.addChild("td").addChild("input", new String[] > { "type", "name", "value", "size" }, new String[] { "text", > "domain", "", "30" }); > + HTMLNode tableRowSubmit = table.addChild("tr"); > + tableRowSubmit.addChild("td"); > + tableRowSubmit.addChild("td").addChild("input", new String[] > { "type", "name", "value" }, new String[] { "submit", "add", "Add > account"}); > + > + return pageNode.generate(); > + } > + > + public String handleHTTPPost(HTTPRequest request) throws > PluginHTTPException { > + HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail > plugin", false, null); > + HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); > + > + String add = request.getPartAsString("add", 100); > + String name = request.getPartAsString("name", 100); > + String password = request.getPartAsString("password", 100); > + String domain = request.getPartAsString("domain", 100); > + > + if(add.equals("Add account")) { > + if(!(name.equals("") || password.equals(""))) { > try { > - AccountManager.Create(request.getParam("name")); > - AccountManager.ChangePassword(request.getParam("name"), > request.getParam("password")); > - if(!request.getParam("domain").equals("")) { > - AccountManager.addShortAddress(request.getParam("name"), > request.getParam("domain")); > + AccountManager.Create(name); > + AccountManager.ChangePassword(name, password); > + if(!domain.equals("")) { > + AccountManager.addShortAddress(name, domain); > } > - Thread t = new Thread(new SingleAccountWatcher(new > File(DATADIR, request.getParam("name"))), "Account Watcher for > "+request.getParam("name")); > + Thread t = new Thread(new SingleAccountWatcher(new > File(DATADIR, name)), "Account Watcher for "+name); > t.setDaemon(true); > t.start(); > - HTMLNode addedBox = contentNode.addChild("div", "class", > "infobox"); > - addedBox.addChild("div", "class", "infobox-header", "Added > account"); > - addedBox.addChild("div", "class", "infobox-content", "Account > for " + request.getParam("name") + " is created"); > - > + > + HTMLNode successBox = contentNode.addChild("div", "class", > "infobox infobox-success"); > + successBox.addChild("div", "class", "infobox-header", "Account > Created"); > + // TODO: This is not the world's best into message, but it's > only temporary (hopefully...) > + HTMLNode text = successBox.addChild("div", "class", "infobox- > content"); > + text.addChild("#", "The account "); > + text.addChild("i", name); > + text.addChild("#", " was created successfully."); > + text.addChild("br"); > + text.addChild("br"); > + text.addChild("#", "You now need to configure your email > client to send and receive email through " > + + "Freemail using IMAP and SMTP. Freemail uses ports 3143 > and 3025 for these " > + + "respectively by default."); > } catch (IOException ioe) { > HTMLNode errorBox = contentNode.addChild("div", "class", > "infobox infobox-error"); > errorBox.addChild("div", "class", "infobox-header", "IO Error"); > @@ -216,38 +257,23 @@ > } catch (Exception e) { > HTMLNode errorBox = contentNode.addChild("div", "class", > "infobox-error"); > errorBox.addChild("div", "class", "infobox-header", "Error"); > - errorBox.addChild("div", "class", "infobox-content", "Couldn't > change password for "+request.getParam("name")+". "+e.getMessage()); > + errorBox.addChild("div", "class", "infobox-content", "Couldn't > change password for "+name+". "+e.getMessage()); > } > + > + // XXX: There doesn't seem to be a way to get (or set) our root > in the web interface, > + // so we'll just have to assume it's this and won't change > + contentNode.addChild("a", "href", "/plugins/ > freemail.FreemailPlugin", > + "Freemail Home"); > } else { > HTMLNode errorBox = contentNode.addChild("div", "class", > "infobox infobox-error"); > errorBox.addChild("div", "class", "infobox-header", "Error"); > errorBox.addChild("div", "class", "infobox-content", "Couldn't > create account, name or password is missing"); > } > } > - > - HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); > - addBox.addChild("div", "class", "infobox-header", "Add account"); > - HTMLNode table = addBox.addChild("div", "class", "infobox- > content").addChild("form").addChild("table", "class", "plugintable"); > - HTMLNode tableRowName = table.addChild("tr"); > - tableRowName.addChild("td", "Name"); > - tableRowName.addChild("td").addChild("input", new String[] > { "type", "name", "value", "size" }, new String[] { "text", "name", > "", "30" }); > - HTMLNode tableRowPassword = table.addChild("tr"); > - tableRowPassword.addChild("td", "Password"); > - tableRowPassword.addChild("td").addChild("input", new String[] > { "type", "name", "value", "size" }, new String[] { "password", > "password", "", "30" }); > - HTMLNode tableRowDomain = table.addChild("tr"); > - tableRowDomain.addChild("td", "Domain"); > - tableRowDomain.addChild("td").addChild("input", new String[] > { "type", "name", "value", "size" }, new String[] { "text", > "domain", "", "30" }); > - HTMLNode tableRowSubmit = table.addChild("tr"); > - tableRowSubmit.addChild("td"); > - tableRowSubmit.addChild("td").addChild("input", new String[] > { "type", "name", "value" }, new String[] { "submit", "add", "Add > account"}); > > return pageNode.generate(); > } > > - public String handleHTTPPost(HTTPRequest request) throws > PluginHTTPException { > - return null; > - } > - > public String handleHTTPPut(HTTPRequest request) throws > PluginHTTPException { > return null; > } > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail From dbkr at freenetproject.org Wed Nov 7 09:42:24 2007 From: dbkr at freenetproject.org (Dave Baker) Date: Wed, 7 Nov 2007 09:42:24 +0000 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <5B381F94-6DE8-4AA9-BD5C-158F8E657689@privaterra.info> References: <20071105235935.93EB43908DD@freenetproject.org> <5B381F94-6DE8-4AA9-BD5C-158F8E657689@privaterra.info> Message-ID: <200711070942.25650.dbkr@freenetproject.org> On Wednesday 07 November 2007 04:41:19 Robert Guerra wrote: > Does this version mean that Freemail can now be used as a plugin? If > so, would you be so kind as to describe the steps needed to add the > plugin to freenet. It depends what you consider 'usable'! There has been a plugin that runs Freemail for a while now, although there was no documentation provided on how to run it as such. There is still functionality missing - the only thing you can do from the web interface is add accounts. To get it running, I'm not sure what the current stable version of Freenet does plugin-wise, but I think it's a question of putting the url to the Freemail plugin in the box (pick the latest from http://downloads.freenetproject.org/alpha/plugins/Freemail/, or the path with file:// in front of it to use one on your local machine) and pressing the button. On Freenet trunk, you can just select 'Freemail' from the list and press the button. After that, you can go to the plugin's web interface to add an account, and set up your mail client as before. If you want to copy settings over, copy everything from your Freemail directory to your node dir. Bear in mind that Freemail as a plugin is very alpha. By all means report bugs, but if it breaks, you get to keep all the pieces! Dave > > thanks > > regards, > > Robert > --- > Robert Guerra > Managing Director, Privaterra > Tel +1 416 893 0377 > > On 5-Nov-07, at 6:59 PM, dbkr at freenetproject.org wrote: > > Author: dbkr > > Date: 2007-11-05 23:59:35 +0000 (Mon, 05 Nov 2007) > > New Revision: 15698 > > > > Modified: > > trunk/apps/Freemail/src/freemail/FreemailPlugin.java > > Log: > > Use post for the add account form. > > > > > > Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java > > =================================================================== > > --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 > > 23:41:48 UTC (rev 15697) > > +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 > > 23:59:35 UTC (rev 15698) > > @@ -194,21 +194,62 @@ > > HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail > > plugin", false, null); > > HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); > > > > - if(request.getParam("add").equals("Add account")) { > > - if(!(request.getParam("name").equals("") || > > request.getParam("password").equals(""))) { > > + HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); > > + addBox.addChild("div", "class", "infobox-header", "Add account"); > > + > > + HTMLNode boxContent = addBox.addChild("div", "class", "infobox- > > content"); > > + HTMLNode form = pr.addFormChild(boxContent, "", "addAccountForm"); > > + > > + HTMLNode table = form.addChild("table", "class", "plugintable"); > > + HTMLNode tableRowName = table.addChild("tr"); > > + tableRowName.addChild("td", "Name"); > > + tableRowName.addChild("td").addChild("input", new String[] > > { "type", "name", "value", "size" }, new String[] { "text", "name", > > "", "30" }); > > + HTMLNode tableRowPassword = table.addChild("tr"); > > + tableRowPassword.addChild("td", "Password"); > > + tableRowPassword.addChild("td").addChild("input", new String[] > > { "type", "name", "value", "size" }, new String[] { "password", > > "password", "", "30" }); > > + HTMLNode tableRowDomain = table.addChild("tr"); > > + tableRowDomain.addChild("td", "Domain"); > > + tableRowDomain.addChild("td").addChild("input", new String[] > > { "type", "name", "value", "size" }, new String[] { "text", > > "domain", "", "30" }); > > + HTMLNode tableRowSubmit = table.addChild("tr"); > > + tableRowSubmit.addChild("td"); > > + tableRowSubmit.addChild("td").addChild("input", new String[] > > { "type", "name", "value" }, new String[] { "submit", "add", "Add > > account"}); > > + > > + return pageNode.generate(); > > + } > > + > > + public String handleHTTPPost(HTTPRequest request) throws > > PluginHTTPException { > > + HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail > > plugin", false, null); > > + HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); > > + > > + String add = request.getPartAsString("add", 100); > > + String name = request.getPartAsString("name", 100); > > + String password = request.getPartAsString("password", 100); > > + String domain = request.getPartAsString("domain", 100); > > + > > + if(add.equals("Add account")) { > > + if(!(name.equals("") || password.equals(""))) { > > try { > > - AccountManager.Create(request.getParam("name")); > > - AccountManager.ChangePassword(request.getParam("name"), > > request.getParam("password")); > > - if(!request.getParam("domain").equals("")) { > > - AccountManager.addShortAddress(request.getParam("name"), > > request.getParam("domain")); > > + AccountManager.Create(name); > > + AccountManager.ChangePassword(name, password); > > + if(!domain.equals("")) { > > + AccountManager.addShortAddress(name, domain); > > } > > - Thread t = new Thread(new SingleAccountWatcher(new > > File(DATADIR, request.getParam("name"))), "Account Watcher for > > "+request.getParam("name")); > > + Thread t = new Thread(new SingleAccountWatcher(new > > File(DATADIR, name)), "Account Watcher for "+name); > > t.setDaemon(true); > > t.start(); > > - HTMLNode addedBox = contentNode.addChild("div", "class", > > "infobox"); > > - addedBox.addChild("div", "class", "infobox-header", "Added > > account"); > > - addedBox.addChild("div", "class", "infobox-content", "Account > > for " + request.getParam("name") + " is created"); > > - > > + > > + HTMLNode successBox = contentNode.addChild("div", "class", > > "infobox infobox-success"); > > + successBox.addChild("div", "class", "infobox-header", "Account > > Created"); > > + // TODO: This is not the world's best into message, but it's > > only temporary (hopefully...) > > + HTMLNode text = successBox.addChild("div", "class", "infobox- > > content"); > > + text.addChild("#", "The account "); > > + text.addChild("i", name); > > + text.addChild("#", " was created successfully."); > > + text.addChild("br"); > > + text.addChild("br"); > > + text.addChild("#", "You now need to configure your email > > client to send and receive email through " > > + + "Freemail using IMAP and SMTP. Freemail uses ports 3143 > > and 3025 for these " > > + + "respectively by default."); > > } catch (IOException ioe) { > > HTMLNode errorBox = contentNode.addChild("div", "class", > > "infobox infobox-error"); > > errorBox.addChild("div", "class", "infobox-header", "IO Error"); > > @@ -216,38 +257,23 @@ > > } catch (Exception e) { > > HTMLNode errorBox = contentNode.addChild("div", "class", > > "infobox-error"); > > errorBox.addChild("div", "class", "infobox-header", "Error"); > > - errorBox.addChild("div", "class", "infobox-content", "Couldn't > > change password for "+request.getParam("name")+". "+e.getMessage()); > > + errorBox.addChild("div", "class", "infobox-content", "Couldn't > > change password for "+name+". "+e.getMessage()); > > } > > + > > + // XXX: There doesn't seem to be a way to get (or set) our root > > in the web interface, > > + // so we'll just have to assume it's this and won't change > > + contentNode.addChild("a", "href", "/plugins/ > > freemail.FreemailPlugin", > > + "Freemail Home"); > > } else { > > HTMLNode errorBox = contentNode.addChild("div", "class", > > "infobox infobox-error"); > > errorBox.addChild("div", "class", "infobox-header", "Error"); > > errorBox.addChild("div", "class", "infobox-content", "Couldn't > > create account, name or password is missing"); > > } > > } > > - > > - HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); > > - addBox.addChild("div", "class", "infobox-header", "Add account"); > > - HTMLNode table = addBox.addChild("div", "class", "infobox- > > content").addChild("form").addChild("table", "class", "plugintable"); > > - HTMLNode tableRowName = table.addChild("tr"); > > - tableRowName.addChild("td", "Name"); > > - tableRowName.addChild("td").addChild("input", new String[] > > { "type", "name", "value", "size" }, new String[] { "text", "name", > > "", "30" }); > > - HTMLNode tableRowPassword = table.addChild("tr"); > > - tableRowPassword.addChild("td", "Password"); > > - tableRowPassword.addChild("td").addChild("input", new String[] > > { "type", "name", "value", "size" }, new String[] { "password", > > "password", "", "30" }); > > - HTMLNode tableRowDomain = table.addChild("tr"); > > - tableRowDomain.addChild("td", "Domain"); > > - tableRowDomain.addChild("td").addChild("input", new String[] > > { "type", "name", "value", "size" }, new String[] { "text", > > "domain", "", "30" }); > > - HTMLNode tableRowSubmit = table.addChild("tr"); > > - tableRowSubmit.addChild("td"); > > - tableRowSubmit.addChild("td").addChild("input", new String[] > > { "type", "name", "value" }, new String[] { "submit", "add", "Add > > account"}); > > > > return pageNode.generate(); > > } > > > > - public String handleHTTPPost(HTTPRequest request) throws > > PluginHTTPException { > > - return null; > > - } > > - > > public String handleHTTPPut(HTTPRequest request) throws > > PluginHTTPException { > > return null; > > } > > > > _______________________________________________ > > Freemail mailing list > > Freemail at freenetproject.org > > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail From nextgens at freenetproject.org Wed Nov 7 15:40:34 2007 From: nextgens at freenetproject.org (Florent =?iso-8859-1?Q?Daigni=E8re?=) Date: Wed, 7 Nov 2007 16:40:34 +0100 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <200711070942.25650.dbkr@freenetproject.org> References: <20071105235935.93EB43908DD@freenetproject.org> <5B381F94-6DE8-4AA9-BD5C-158F8E657689@privaterra.info> <200711070942.25650.dbkr@freenetproject.org> Message-ID: <20071107154033.GA4248@freenetproject.org> * Dave Baker [2007-11-07 09:42:24]: > On Wednesday 07 November 2007 04:41:19 Robert Guerra wrote: > > Does this version mean that Freemail can now be used as a plugin? If > > so, would you be so kind as to describe the steps needed to add the > > plugin to freenet. > > It depends what you consider 'usable'! There has been a plugin that runs > Freemail for a while now, although there was no documentation provided on how > to run it as such. There is still functionality missing - the only thing you > can do from the web interface is add accounts. > > To get it running, I'm not sure what the current stable version of Freenet > does plugin-wise, but I think it's a question of putting the url to the > Freemail plugin in the box (pick the latest from > http://downloads.freenetproject.org/alpha/plugins/Freemail/, or the path with > file:// in front of it to use one on your local machine) and pressing the > button. On Freenet trunk, you can just select 'Freemail' from the list and > press the button. > > After that, you can go to the plugin's web interface to add an account, and > set up your mail client as before. > > If you want to copy settings over, copy everything from your Freemail > directory to your node dir. > > Bear in mind that Freemail as a plugin is very alpha. By all means report > bugs, but if it breaks, you get to keep all the pieces! > Dave All the proceedure to load/unload plugins will be much simpler in 1071... thanks to Bombe. Grab the trunk if you want a preview ;) NextGen$ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071107/eb97a294/attachment.pgp From dbkr at freenetproject.org Thu Nov 8 09:30:17 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 8 Nov 2007 09:30:17 +0000 (UTC) Subject: [Freemail] r15703 - trunk/apps/Freemail/src/freemail Message-ID: <20071108093017.3462647B31B@freenetproject.org> Author: dbkr Date: 2007-11-08 09:30:16 +0000 (Thu, 08 Nov 2007) New Revision: 15703 Modified: trunk/apps/Freemail/src/freemail/OutboundContact.java Log: Typo in bounce message. Modified: trunk/apps/Freemail/src/freemail/OutboundContact.java =================================================================== --- trunk/apps/Freemail/src/freemail/OutboundContact.java 2007-11-08 06:01:33 UTC (rev 15702) +++ trunk/apps/Freemail/src/freemail/OutboundContact.java 2007-11-08 09:30:16 UTC (rev 15703) @@ -686,7 +686,7 @@ // give up and bounce the message File m = msgs[i].getMessageFile(); - Postman.bounceMessage(m, new MessageBank(this.accdir.getName()), "Freemail has been trying for too long to deliver this message, and has received no acknowledgement. It is possivle that the recipient has not run Freemail since you sent the message. If you believe this is likely, try resending the message.", true); + Postman.bounceMessage(m, new MessageBank(this.accdir.getName()), "Freemail has been trying for too long to deliver this message, and has received no acknowledgement. It is possible that the recipient has not run Freemail since you sent the message. If you believe this is likely, try resending the message.", true); System.out.println("Giving up on message - been trying for too long."); msgs[i].delete(); } else if (System.currentTimeMillis() > msgs[i].last_send_time + RETRANSMIT_DELAY) { From alexlehm at freenetproject.org Thu Nov 8 21:34:23 2007 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Thu, 8 Nov 2007 21:34:23 +0000 (UTC) Subject: [Freemail] r15716 - trunk/apps/Freemail/src/freemail Message-ID: <20071108213423.63F473A053A@freenetproject.org> Author: alexlehm Date: 2007-11-08 21:34:23 +0000 (Thu, 08 Nov 2007) New Revision: 15716 Modified: trunk/apps/Freemail/src/freemail/AccountManager.java Log: missing space in the welcome message makes emu url not clickable, one typo in the same line Modified: trunk/apps/Freemail/src/freemail/AccountManager.java =================================================================== --- trunk/apps/Freemail/src/freemail/AccountManager.java 2007-11-08 17:45:03 UTC (rev 15715) +++ trunk/apps/Freemail/src/freemail/AccountManager.java 2007-11-08 21:34:23 UTC (rev 15716) @@ -343,7 +343,7 @@ ps.println(""); ps.println("Try to pick something unique - Freemail will tell you if somebody has already taken the address you want. These short addresses are *probably* secure, but not absolutely. If you want to be sure, use the long address."); ps.println(""); - ps.println("If you find a bug, or would like something changed in Freemail, visit our bug tracker at https://bugs.freenetproject.org/(and select 'Freemail' in the top right). You can also drop into #freemail on irc.freenode.net to discuss, or sign up tp the mailing list at http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail."); + ps.println("If you find a bug, or would like something changed in Freemail, visit our bug tracker at https://bugs.freenetproject.org/ (and select 'Freemail' in the top right). You can also drop into #freemail on irc.freenode.net to discuss, or sign up to the mailing list at http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail."); ps.println(""); ps.println("Happy Freemailing!"); ps.println(""); From alexlehm at myrealbox.com Fri Nov 9 18:32:35 2007 From: alexlehm at myrealbox.com (Alexander Lehmann) Date: Fri, 09 Nov 2007 19:32:35 +0100 Subject: [Freemail] Fwd: r15716 - trunk/apps/Freemail/src/freemail In-Reply-To: References: Message-ID: <4734A7C3.4060408@myrealbox.com> sorry, I got confused when writing the message, the bugs-url wasn't working. > Author: alexlehm > Date: 2007-11-08 21:34:23 +0000 (Thu, 08 Nov 2007) > New Revision: 15716 > > Modified: > trunk/apps/Freemail/src/freemail/AccountManager.java > Log: > missing space in the welcome message makes emu url not clickable, one typo in the same line > > From alexlehm at freenetproject.org Fri Nov 9 21:52:31 2007 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Fri, 9 Nov 2007 21:52:31 +0000 (UTC) Subject: [Freemail] r15729 - trunk/apps/Freemail/src/freemail Message-ID: <20071109215231.121D847A0B6@freenetproject.org> Author: alexlehm Date: 2007-11-09 21:52:30 +0000 (Fri, 09 Nov 2007) New Revision: 15729 Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java Log: https://bugs.freenetproject.org/view.php?id=1761 freemail rewrites mail headers wrong if continuation lines are used add a space in front of a continuation line Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java =================================================================== --- trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-09 18:06:06 UTC (rev 15728) +++ trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-09 21:52:30 UTC (rev 15729) @@ -77,7 +77,7 @@ retval = this.flush(); } else if (line.startsWith(" ") || line.startsWith("\t")) { // continuation of the previous header - this.buffer.append("\r\n"+line.trim()); + this.buffer.append("\r\n "+line.trim()); } else { retval = this.flush(); this.buffer.append(line); From alexlehm at freenetproject.org Fri Nov 9 22:16:46 2007 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Fri, 9 Nov 2007 22:16:46 +0000 (UTC) Subject: [Freemail] r15730 - trunk/apps/Freemail/src/freemail Message-ID: <20071109221646.C8DAB47992A@freenetproject.org> Author: alexlehm Date: 2007-11-09 22:16:46 +0000 (Fri, 09 Nov 2007) New Revision: 15730 Modified: trunk/apps/Freemail/src/freemail/OutboundContact.java Log: a few typos (most are comments though) Modified: trunk/apps/Freemail/src/freemail/OutboundContact.java =================================================================== --- trunk/apps/Freemail/src/freemail/OutboundContact.java 2007-11-09 21:52:30 UTC (rev 15729) +++ trunk/apps/Freemail/src/freemail/OutboundContact.java 2007-11-09 22:16:46 UTC (rev 15730) @@ -65,7 +65,7 @@ private final File ctoutbox; private final EmailAddress address; // how long to wait for a CTS before sending the message again - // slightly over 24 hours since some people are likley to fire Freemail + // slightly over 24 hours since some people are likely to fire Freemail // up and roughly the same time every day private static final long CTS_WAIT_TIME = 26 * 60 * 60 * 1000; private static final String PROPSFILE_NAME = "props"; @@ -172,7 +172,7 @@ System.out.println("Sucessfully received CTS for "+this.address.getSubDomain()); cts.delete(); this.contactfile.put("status", "cts-received"); - // delete inital slot for forward secrecy + // delete initial slot for forward secrecy this.contactfile.remove("initialslot"); } } else { @@ -193,7 +193,7 @@ this.contactfile.put("commssk.privkey", ssk.privkey); this.contactfile.put("commssk.pubkey", ssk.pubkey); - // we've just generated a new SSK, so the other party definately doesn't know about it + // we've just generated a new SSK, so the other party definitely doesn't know about it this.contactfile.put("status", "notsent"); } @@ -312,7 +312,7 @@ rtsmessage.append("messagetype=rts\r\n"); - // must include who this RTS is to, otherwise we're vulnerable to surruptitious forwarding + // must include who this RTS is to, otherwise we're vulnerable to surreptitious forwarding rtsmessage.append("to="+this.address.getSubDomain()+"\r\n"); // get our mailsite URI @@ -403,7 +403,7 @@ this.contactfile.put("status", "rts-sent"); // and remember when we sent it! this.contactfile.put("rts-sent-at", Long.toString(System.currentTimeMillis())); - // and since that's been sucessfully inserted to that key, we can + // and since that's been successfully inserted to that key, we can // throw away the symmetric key this.contactfile.remove("aesparams"); return true; @@ -469,8 +469,8 @@ if (rtsksk == null || keymod_str == null || keyexp_str == null) { // TODO: More failure mechanisms - this is fatal. - System.out.println("Mailsite for "+this.address+" does not contain all necessary iformation!"); - throw new OutboundContactFatalException("Mailsite for "+this.address+" does not contain all necessary iformation!"); + System.out.println("Mailsite for "+this.address+" does not contain all necessary information!"); + throw new OutboundContactFatalException("Mailsite for "+this.address+" does not contain all necessary information!"); } // add this to a new outbound contact file @@ -678,7 +678,7 @@ msgs[i].delete(); // treat the ACK as a CTS too this.contactfile.put("status", "cts-received"); - // delete inital slot for forward secrecy + // delete initial slot for forward secrecy this.contactfile.remove("initialslot"); } else { System.out.println("Failed to receive ack on "+key); From alexlehm at freenetproject.org Fri Nov 9 22:19:49 2007 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Fri, 9 Nov 2007 22:19:49 +0000 (UTC) Subject: [Freemail] r15731 - trunk/apps/Freemail/src/freemail Message-ID: <20071109221949.29CBA47992A@freenetproject.org> Author: alexlehm Date: 2007-11-09 22:19:48 +0000 (Fri, 09 Nov 2007) New Revision: 15731 Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java Log: fix for https://bugs.freenetproject.org/view.php?id=1765 Freemail doesn't strip out Received lines Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java =================================================================== --- trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-09 22:16:46 UTC (rev 15730) +++ trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-09 22:19:48 UTC (rev 15731) @@ -131,6 +131,9 @@ } else if (name.equalsIgnoreCase("User-Agent")) { // might as well hide this return null; + } else if (name.equalsIgnoreCase("Received")) { + // may give away local address + return null; } else { return val; } From dbkr at freenetproject.org Thu Nov 15 19:35:24 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 15 Nov 2007 19:35:24 +0000 (UTC) Subject: [Freemail] r15791 - trunk/apps/Freemail/src/freemail Message-ID: <20071115193524.4548747B786@freenetproject.org> Author: dbkr Date: 2007-11-15 19:35:23 +0000 (Thu, 15 Nov 2007) New Revision: 15791 Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java Log: Unused import Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-15 00:11:33 UTC (rev 15790) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-15 19:35:23 UTC (rev 15791) @@ -37,7 +37,6 @@ import freenet.pluginmanager.FredPlugin; import freenet.pluginmanager.FredPluginHTTP; -import freenet.pluginmanager.FredPluginHTTPAdvanced; import freenet.pluginmanager.FredPluginThreadless; import freenet.pluginmanager.PluginHTTPException; import freenet.pluginmanager.PluginRespirator; From dbkr at freenetproject.org Thu Nov 15 19:36:38 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 15 Nov 2007 19:36:38 +0000 (UTC) Subject: [Freemail] r15792 - in trunk/apps/Freemail/src/freemail: . fcp Message-ID: <20071115193638.7CFCF47B783@freenetproject.org> Author: dbkr Date: 2007-11-15 19:36:38 +0000 (Thu, 15 Nov 2007) New Revision: 15792 Removed: trunk/apps/Freemail/src/freemail/support/ Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java Log: Remove unnecessary duplicates created in the plugin patch. Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java =================================================================== --- trunk/apps/Freemail/src/freemail/RTSFetcher.java 2007-11-15 19:35:23 UTC (rev 15791) +++ trunk/apps/Freemail/src/freemail/RTSFetcher.java 2007-11-15 19:36:38 UTC (rev 15792) @@ -23,8 +23,6 @@ import freemail.fcp.HighLevelFCPClient; import freemail.fcp.ConnectionTerminatedException; -import freemail.support.io.LineReadingInputStream; -import freemail.support.io.TooLongException; import freemail.utils.DateStringFactory; import freemail.utils.PropsFile; @@ -53,6 +51,8 @@ import org.bouncycastle.crypto.modes.CBCBlockCipher; import org.bouncycastle.crypto.DataLengthException; +import freenet.support.io.LineReadingInputStream; +import freenet.support.io.TooLongException; import org.archive.util.Base32; Modified: trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java =================================================================== --- trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2007-11-15 19:35:23 UTC (rev 15791) +++ trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2007-11-15 19:36:38 UTC (rev 15792) @@ -31,9 +31,9 @@ import java.util.Collections; import freemail.Freemail; -import freemail.support.io.LineReader; -import freemail.support.io.LineReadingInputStream; +import freenet.support.io.LineReader; +import freenet.support.io.LineReadingInputStream; public class FCPMessage { private String messagetype; From dbkr at freenetproject.org Thu Nov 15 19:37:23 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 15 Nov 2007 19:37:23 +0000 (UTC) Subject: [Freemail] r15793 - trunk/apps/Freemail Message-ID: <20071115193723.70ADF47B783@freenetproject.org> Author: dbkr Date: 2007-11-15 19:37:23 +0000 (Thu, 15 Nov 2007) New Revision: 15793 Added: trunk/apps/Freemail/build.properties Log: Prepare for automatic freenet jar fetching in ant. Added: trunk/apps/Freemail/build.properties =================================================================== --- trunk/apps/Freemail/build.properties (rev 0) +++ trunk/apps/Freemail/build.properties 2007-11-15 19:37:23 UTC (rev 15793) @@ -0,0 +1 @@ +freenetjar.url=http://downloads.freenetproject.org/alpha/freenet-r15787-snapshot.jar From dbkr at freenetproject.org Thu Nov 15 22:06:34 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 15 Nov 2007 22:06:34 +0000 (UTC) Subject: [Freemail] r15794 - trunk/apps/Freemail Message-ID: <20071115220634.D9FC53920C2@freenetproject.org> Author: dbkr Date: 2007-11-15 22:06:34 +0000 (Thu, 15 Nov 2007) New Revision: 15794 Removed: trunk/apps/Freemail/build.properties Log: Never mind - that won't work. Deleted: trunk/apps/Freemail/build.properties =================================================================== --- trunk/apps/Freemail/build.properties 2007-11-15 19:37:23 UTC (rev 15793) +++ trunk/apps/Freemail/build.properties 2007-11-15 22:06:34 UTC (rev 15794) @@ -1 +0,0 @@ -freenetjar.url=http://downloads.freenetproject.org/alpha/freenet-r15787-snapshot.jar From toad at amphibian.dyndns.org Fri Nov 16 12:30:14 2007 From: toad at amphibian.dyndns.org (Matthew Toseland) Date: Fri, 16 Nov 2007 12:30:14 +0000 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <20071105235935.93EB43908DD@freenetproject.org> References: <20071105235935.93EB43908DD@freenetproject.org> Message-ID: <200711161230.19740.toad@amphibian.dyndns.org> On Monday 05 November 2007 23:59, dbkr at freenetproject.org wrote: > + text.addChild("#", "You now need to configure your email client to send and receive email through " > + + "Freemail using IMAP and SMTP. Freemail uses ports 3143 and 3025 for these " > + + "respectively by default."); Shouldn't it show the current values of the port numbers rather than the defaults? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071116/5fb01ff6/attachment.pgp From toad at amphibian.dyndns.org Fri Nov 16 12:32:11 2007 From: toad at amphibian.dyndns.org (Matthew Toseland) Date: Fri, 16 Nov 2007 12:32:11 +0000 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <200711070942.25650.dbkr@freenetproject.org> References: <20071105235935.93EB43908DD@freenetproject.org> <5B381F94-6DE8-4AA9-BD5C-158F8E657689@privaterra.info> <200711070942.25650.dbkr@freenetproject.org> Message-ID: <200711161232.11674.toad@amphibian.dyndns.org> Obvious current issues: - Freemail uses the current working directory to store everything, not a Freemail/ subdir. - Even as a plugin it still uses FCP, instead of HighLevelSimpleClient etc. - It logs to stderr/stdout. - As he says below, you can't add shortnames from the web interface. On Wednesday 07 November 2007 09:42, Dave Baker wrote: > On Wednesday 07 November 2007 04:41:19 Robert Guerra wrote: > > Does this version mean that Freemail can now be used as a plugin? If > > so, would you be so kind as to describe the steps needed to add the > > plugin to freenet. > > It depends what you consider 'usable'! There has been a plugin that runs > Freemail for a while now, although there was no documentation provided on how > to run it as such. There is still functionality missing - the only thing you > can do from the web interface is add accounts. > > To get it running, I'm not sure what the current stable version of Freenet > does plugin-wise, but I think it's a question of putting the url to the > Freemail plugin in the box (pick the latest from > http://downloads.freenetproject.org/alpha/plugins/Freemail/, or the path with > file:// in front of it to use one on your local machine) and pressing the > button. On Freenet trunk, you can just select 'Freemail' from the list and > press the button. > > After that, you can go to the plugin's web interface to add an account, and > set up your mail client as before. > > If you want to copy settings over, copy everything from your Freemail > directory to your node dir. > > Bear in mind that Freemail as a plugin is very alpha. By all means report > bugs, but if it breaks, you get to keep all the pieces! > > > Dave > > > > > > thanks > > > > regards, > > > > Robert > > --- > > Robert Guerra > > Managing Director, Privaterra > > Tel +1 416 893 0377 > > > > On 5-Nov-07, at 6:59 PM, dbkr at freenetproject.org wrote: > > > Author: dbkr > > > Date: 2007-11-05 23:59:35 +0000 (Mon, 05 Nov 2007) > > > New Revision: 15698 > > > > > > Modified: > > > trunk/apps/Freemail/src/freemail/FreemailPlugin.java > > > Log: > > > Use post for the add account form. > > > > > > > > > Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java > > > =================================================================== > > > --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 > > > 23:41:48 UTC (rev 15697) > > > +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-05 > > > 23:59:35 UTC (rev 15698) > > > @@ -194,21 +194,62 @@ > > > HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail > > > plugin", false, null); > > > HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); > > > > > > - if(request.getParam("add").equals("Add account")) { > > > - if(!(request.getParam("name").equals("") || > > > request.getParam("password").equals(""))) { > > > + HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); > > > + addBox.addChild("div", "class", "infobox-header", "Add account"); > > > + > > > + HTMLNode boxContent = addBox.addChild("div", "class", "infobox- > > > content"); > > > + HTMLNode form = pr.addFormChild(boxContent, "", "addAccountForm"); > > > + > > > + HTMLNode table = form.addChild("table", "class", "plugintable"); > > > + HTMLNode tableRowName = table.addChild("tr"); > > > + tableRowName.addChild("td", "Name"); > > > + tableRowName.addChild("td").addChild("input", new String[] > > > { "type", "name", "value", "size" }, new String[] { "text", "name", > > > "", "30" }); > > > + HTMLNode tableRowPassword = table.addChild("tr"); > > > + tableRowPassword.addChild("td", "Password"); > > > + tableRowPassword.addChild("td").addChild("input", new String[] > > > { "type", "name", "value", "size" }, new String[] { "password", > > > "password", "", "30" }); > > > + HTMLNode tableRowDomain = table.addChild("tr"); > > > + tableRowDomain.addChild("td", "Domain"); > > > + tableRowDomain.addChild("td").addChild("input", new String[] > > > { "type", "name", "value", "size" }, new String[] { "text", > > > "domain", "", "30" }); > > > + HTMLNode tableRowSubmit = table.addChild("tr"); > > > + tableRowSubmit.addChild("td"); > > > + tableRowSubmit.addChild("td").addChild("input", new String[] > > > { "type", "name", "value" }, new String[] { "submit", "add", "Add > > > account"}); > > > + > > > + return pageNode.generate(); > > > + } > > > + > > > + public String handleHTTPPost(HTTPRequest request) throws > > > PluginHTTPException { > > > + HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail > > > plugin", false, null); > > > + HTMLNode contentNode = pr.getPageMaker().getContentNode(pageNode); > > > + > > > + String add = request.getPartAsString("add", 100); > > > + String name = request.getPartAsString("name", 100); > > > + String password = request.getPartAsString("password", 100); > > > + String domain = request.getPartAsString("domain", 100); > > > + > > > + if(add.equals("Add account")) { > > > + if(!(name.equals("") || password.equals(""))) { > > > try { > > > - AccountManager.Create(request.getParam("name")); > > > - AccountManager.ChangePassword(request.getParam("name"), > > > request.getParam("password")); > > > - if(!request.getParam("domain").equals("")) { > > > - AccountManager.addShortAddress(request.getParam("name"), > > > request.getParam("domain")); > > > + AccountManager.Create(name); > > > + AccountManager.ChangePassword(name, password); > > > + if(!domain.equals("")) { > > > + AccountManager.addShortAddress(name, domain); > > > } > > > - Thread t = new Thread(new SingleAccountWatcher(new > > > File(DATADIR, request.getParam("name"))), "Account Watcher for > > > "+request.getParam("name")); > > > + Thread t = new Thread(new SingleAccountWatcher(new > > > File(DATADIR, name)), "Account Watcher for "+name); > > > t.setDaemon(true); > > > t.start(); > > > - HTMLNode addedBox = contentNode.addChild("div", "class", > > > "infobox"); > > > - addedBox.addChild("div", "class", "infobox-header", "Added > > > account"); > > > - addedBox.addChild("div", "class", "infobox-content", "Account > > > for " + request.getParam("name") + " is created"); > > > - > > > + > > > + HTMLNode successBox = contentNode.addChild("div", "class", > > > "infobox infobox-success"); > > > + successBox.addChild("div", "class", "infobox-header", "Account > > > Created"); > > > + // TODO: This is not the world's best into message, but it's > > > only temporary (hopefully...) > > > + HTMLNode text = successBox.addChild("div", "class", "infobox- > > > content"); > > > + text.addChild("#", "The account "); > > > + text.addChild("i", name); > > > + text.addChild("#", " was created successfully."); > > > + text.addChild("br"); > > > + text.addChild("br"); > > > + text.addChild("#", "You now need to configure your email > > > client to send and receive email through " > > > + + "Freemail using IMAP and SMTP. Freemail uses ports 3143 > > > and 3025 for these " > > > + + "respectively by default."); > > > } catch (IOException ioe) { > > > HTMLNode errorBox = contentNode.addChild("div", "class", > > > "infobox infobox-error"); > > > errorBox.addChild("div", "class", "infobox-header", "IO Error"); > > > @@ -216,38 +257,23 @@ > > > } catch (Exception e) { > > > HTMLNode errorBox = contentNode.addChild("div", "class", > > > "infobox-error"); > > > errorBox.addChild("div", "class", "infobox-header", "Error"); > > > - errorBox.addChild("div", "class", "infobox-content", "Couldn't > > > change password for "+request.getParam("name")+". "+e.getMessage()); > > > + errorBox.addChild("div", "class", "infobox-content", "Couldn't > > > change password for "+name+". "+e.getMessage()); > > > } > > > + > > > + // XXX: There doesn't seem to be a way to get (or set) our root > > > in the web interface, > > > + // so we'll just have to assume it's this and won't change > > > + contentNode.addChild("a", "href", "/plugins/ > > > freemail.FreemailPlugin", > > > + "Freemail Home"); > > > } else { > > > HTMLNode errorBox = contentNode.addChild("div", "class", > > > "infobox infobox-error"); > > > errorBox.addChild("div", "class", "infobox-header", "Error"); > > > errorBox.addChild("div", "class", "infobox-content", "Couldn't > > > create account, name or password is missing"); > > > } > > > } > > > - > > > - HTMLNode addBox = contentNode.addChild("div", "class", "infobox"); > > > - addBox.addChild("div", "class", "infobox-header", "Add account"); > > > - HTMLNode table = addBox.addChild("div", "class", "infobox- > > > content").addChild("form").addChild("table", "class", "plugintable"); > > > - HTMLNode tableRowName = table.addChild("tr"); > > > - tableRowName.addChild("td", "Name"); > > > - tableRowName.addChild("td").addChild("input", new String[] > > > { "type", "name", "value", "size" }, new String[] { "text", "name", > > > "", "30" }); > > > - HTMLNode tableRowPassword = table.addChild("tr"); > > > - tableRowPassword.addChild("td", "Password"); > > > - tableRowPassword.addChild("td").addChild("input", new String[] > > > { "type", "name", "value", "size" }, new String[] { "password", > > > "password", "", "30" }); > > > - HTMLNode tableRowDomain = table.addChild("tr"); > > > - tableRowDomain.addChild("td", "Domain"); > > > - tableRowDomain.addChild("td").addChild("input", new String[] > > > { "type", "name", "value", "size" }, new String[] { "text", > > > "domain", "", "30" }); > > > - HTMLNode tableRowSubmit = table.addChild("tr"); > > > - tableRowSubmit.addChild("td"); > > > - tableRowSubmit.addChild("td").addChild("input", new String[] > > > { "type", "name", "value" }, new String[] { "submit", "add", "Add > > > account"}); > > > > > > return pageNode.generate(); > > > } > > > > > > - public String handleHTTPPost(HTTPRequest request) throws > > > PluginHTTPException { > > > - return null; > > > - } > > > - > > > public String handleHTTPPut(HTTPRequest request) throws > > > PluginHTTPException { > > > return null; > > > } > > > > > > _______________________________________________ > > > Freemail mailing list > > > Freemail at freenetproject.org > > > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > > > _______________________________________________ > > Freemail mailing list > > Freemail at freenetproject.org > > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071116/236b9144/attachment.pgp From toad at amphibian.dyndns.org Fri Nov 16 12:35:33 2007 From: toad at amphibian.dyndns.org (Matthew Toseland) Date: Fri, 16 Nov 2007 12:35:33 +0000 Subject: [Freemail] r15731 - trunk/apps/Freemail/src/freemail In-Reply-To: <20071109221949.29CBA47992A@freenetproject.org> References: <20071109221949.29CBA47992A@freenetproject.org> Message-ID: <200711161235.33869.toad@amphibian.dyndns.org> Would it be better to whitelist headers? On Friday 09 November 2007 22:19, alexlehm at freenetproject.org wrote: > Author: alexlehm > Date: 2007-11-09 22:19:48 +0000 (Fri, 09 Nov 2007) > New Revision: 15731 > > Modified: > trunk/apps/Freemail/src/freemail/MailHeaderFilter.java > Log: > fix for https://bugs.freenetproject.org/view.php?id=1765 Freemail doesn't strip out Received lines > > > Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java > =================================================================== > --- trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-09 22:16:46 UTC (rev 15730) > +++ trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-09 22:19:48 UTC (rev 15731) > @@ -131,6 +131,9 @@ > } else if (name.equalsIgnoreCase("User-Agent")) { > // might as well hide this > return null; > + } else if (name.equalsIgnoreCase("Received")) { > + // may give away local address > + return null; > } else { > return val; > } > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071116/15aa721f/attachment.pgp From nextgens at freenetproject.org Fri Nov 16 12:45:23 2007 From: nextgens at freenetproject.org (Florent =?iso-8859-1?Q?Daigni=E8re?=) Date: Fri, 16 Nov 2007 13:45:23 +0100 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <200711161232.11674.toad@amphibian.dyndns.org> References: <20071105235935.93EB43908DD@freenetproject.org> <5B381F94-6DE8-4AA9-BD5C-158F8E657689@privaterra.info> <200711070942.25650.dbkr@freenetproject.org> <200711161232.11674.toad@amphibian.dyndns.org> Message-ID: <20071116124523.GC4272@freenetproject.org> * Matthew Toseland [2007-11-16 12:32:11]: > Obvious current issues: > - Freemail uses the current working directory to store everything, not a > Freemail/ subdir. > - Even as a plugin it still uses FCP, instead of HighLevelSimpleClient etc. > - It logs to stderr/stdout. > - As he says below, you can't add shortnames from the web interface. Imho the node and the plugin system should handle file creation/management. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071116/747ec92b/attachment.pgp From dbkr at freenetproject.org Mon Nov 19 11:04:57 2007 From: dbkr at freenetproject.org (Dave Baker) Date: Mon, 19 Nov 2007 11:04:57 +0000 Subject: [Freemail] r15698 - trunk/apps/Freemail/src/freemail In-Reply-To: <200711161230.19740.toad@amphibian.dyndns.org> References: <20071105235935.93EB43908DD@freenetproject.org> <200711161230.19740.toad@amphibian.dyndns.org> Message-ID: <200711191104.58049.dbkr@freenetproject.org> On Friday 16 November 2007 12:30:14 Matthew Toseland wrote: > On Monday 05 November 2007 23:59, dbkr at freenetproject.org wrote: > > + text.addChild("#", "You now need to configure your email client to > send and receive email through " > > + + "Freemail using IMAP and SMTP. Freemail uses ports 3143 and 3025 > for these " > > + + "respectively by default."); > > Shouldn't it show the current values of the port numbers rather than the > defaults? > Yes - it should, hence the comment. :) Dave From alexlehm at myrealbox.com Mon Nov 19 14:25:56 2007 From: alexlehm at myrealbox.com (Alexander Lehmann) Date: Mon, 19 Nov 2007 15:25:56 +0100 Subject: [Freemail] r15731 - trunk/apps/Freemail/src/freemail In-Reply-To: References: Message-ID: <47419CF4.6060702@myrealbox.com> probably yes, I think we need to classify headers as either safe to copy, to filter and to throw away (anything else). freemail-request at freenetproject.org wrote: > Message: 3 > Date: Fri, 16 Nov 2007 12:35:33 +0000 > From: Matthew Toseland > Subject: Re: [Freemail] r15731 - trunk/apps/Freemail/src/freemail > To: freemail at freenetproject.org > Message-ID: <200711161235.33869.toad at amphibian.dyndns.org> > Content-Type: text/plain; charset="iso-8859-1" > > Would it be better to whitelist headers? > > From nextgens at freenetproject.org Tue Nov 20 15:43:26 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Tue, 20 Nov 2007 15:43:26 +0000 (UTC) Subject: [Freemail] r15874 - trunk/apps/Freemail Message-ID: <20071120154326.3451F478928@freenetproject.org> Author: nextgens Date: 2007-11-20 15:43:25 +0000 (Tue, 20 Nov 2007) New Revision: 15874 Modified: trunk/apps/Freemail/build.xml Log: Freemail: patch to build.xml from dbkr Modified: trunk/apps/Freemail/build.xml =================================================================== --- trunk/apps/Freemail/build.xml 2007-11-20 02:24:42 UTC (rev 15873) +++ trunk/apps/Freemail/build.xml 2007-11-20 15:43:25 UTC (rev 15874) @@ -7,6 +7,35 @@ + + + + + + + + + + + + Attempting to fetch Freenet main jar - ant cannot do this reliably, so if it fails, delete ${deps}/${freenetjar} and ${freenetjarurl.localpath} and run ant again. + + + + + + + @@ -30,7 +59,7 @@ - + @@ -39,7 +68,7 @@ It makes it much easier to run --> - + @@ -76,11 +105,15 @@ - + + + + + From toad at amphibian.dyndns.org Tue Nov 20 17:02:26 2007 From: toad at amphibian.dyndns.org (Matthew Toseland) Date: Tue, 20 Nov 2007 17:02:26 +0000 Subject: [Freemail] r15874 - trunk/apps/Freemail In-Reply-To: <20071120154326.3451F478928@freenetproject.org> References: <20071120154326.3451F478928@freenetproject.org> Message-ID: <200711201702.31054.toad@amphibian.dyndns.org> No, we could just specify what directory the freenet tree needs to be in relative to this one (e.g. ../Freenet), like we did with contrib in 0.5. On Tuesday 20 November 2007 15:43, nextgens at freenetproject.org wrote: > Author: nextgens > Date: 2007-11-20 15:43:25 +0000 (Tue, 20 Nov 2007) > New Revision: 15874 > > Modified: > trunk/apps/Freemail/build.xml > Log: > Freemail: patch to build.xml from dbkr > > Modified: trunk/apps/Freemail/build.xml > =================================================================== > --- trunk/apps/Freemail/build.xml 2007-11-20 02:24:42 UTC (rev 15873) > +++ trunk/apps/Freemail/build.xml 2007-11-20 15:43:25 UTC (rev 15874) > @@ -7,6 +7,35 @@ > > > > + > + > + > + > + > + > + > + > + > + > + > + Attempting to fetch Freenet main jar - ant cannot do this reliably, so if it fails, delete ${deps}/${freenetjar} and ${freenetjarurl.localpath} and run ant again. > + > + > + > + + dest="${freenetjarurl.localpath}" /> > + + srcFile="${freenetjarurl.localpath}" /> > + + dest="${deps}/${freenetjar}" > + verbose="true" /> > + > > > > @@ -30,7 +59,7 @@ > > > > - > + > > > > @@ -39,7 +68,7 @@ > It makes it much easier to run --> > > > - > + > > > > @@ -76,11 +105,15 @@ > > > > - > + > > > > > + > + > + > + > > > > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071120/777071f4/attachment.pgp From nextgens at freenetproject.org Tue Nov 20 17:07:41 2007 From: nextgens at freenetproject.org (Florent =?iso-8859-1?Q?Daigni=E8re?=) Date: Tue, 20 Nov 2007 18:07:41 +0100 Subject: [Freemail] r15874 - trunk/apps/Freemail In-Reply-To: <200711201702.31054.toad@amphibian.dyndns.org> References: <20071120154326.3451F478928@freenetproject.org> <200711201702.31054.toad@amphibian.dyndns.org> Message-ID: <20071120170740.GE4323@freenetproject.org> * Matthew Toseland [2007-11-20 17:02:26]: > No, we could just specify what directory the freenet tree needs to be in > relative to this one (e.g. ../Freenet), like we did with contrib in 0.5. > Well, tell dbkr, not me :) > On Tuesday 20 November 2007 15:43, nextgens at freenetproject.org wrote: > > Author: nextgens > > Date: 2007-11-20 15:43:25 +0000 (Tue, 20 Nov 2007) > > New Revision: 15874 > > > > Modified: > > trunk/apps/Freemail/build.xml > > Log: > > Freemail: patch to build.xml from dbkr > > > > Modified: trunk/apps/Freemail/build.xml > > =================================================================== > > --- trunk/apps/Freemail/build.xml 2007-11-20 02:24:42 UTC (rev 15873) > > +++ trunk/apps/Freemail/build.xml 2007-11-20 15:43:25 UTC (rev 15874) > > @@ -7,6 +7,35 @@ > > > > > > > > + value="http://downloads.freenetproject.org/alpha/freenet-testing-latest.jar.url"/> > > + value="${deps}/freenet-testing-latest.jar.url"/> > > + > > + > > + > > + > > + > > + > > + > > + unless="freenetjar.present"> > > + > > + Attempting to fetch Freenet main jar - ant cannot do this reliably, so > if it fails, delete ${deps}/${freenetjar} and ${freenetjarurl.localpath} and > run ant again. > > + > > + > > + > > + > + dest="${freenetjarurl.localpath}" /> > > + > + srcFile="${freenetjarurl.localpath}" /> > > + > + dest="${deps}/${freenetjar}" > > + verbose="true" /> > > + > > > > > > property="bouncycastle-dist.present" /> > > @@ -30,7 +59,7 @@ > > > > > > > > - > > + > > > > > > > > @@ -39,7 +68,7 @@ > > It makes it much easier to run --> > > source="1.4"> > > > > - > > + > > > > > > > > @@ -76,11 +105,15 @@ > > > > > > > > - > > + > > > > > > > > > > + > > + > > + > > + > > > > > > > > > > _______________________________________________ > > Freemail mailing list > > Freemail at freenetproject.org > > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > > > > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20071120/3a9426ba/attachment.pgp From dbkr at freenetproject.org Wed Nov 21 16:32:23 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Wed, 21 Nov 2007 16:32:23 +0000 (UTC) Subject: [Freemail] r15907 - in trunk/apps/Freemail/src: freemail freemail/fcp freenet/support/io Message-ID: <20071121163223.127643909EB@freenetproject.org> Author: dbkr Date: 2007-11-21 16:32:22 +0000 (Wed, 21 Nov 2007) New Revision: 15907 Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java trunk/apps/Freemail/src/freenet/support/io/LineReader.java trunk/apps/Freemail/src/freenet/support/io/LineReadingInputStream.java Log: Pull in r9105 from freenet on the support/io code and update Freemail to be compatible. Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java =================================================================== --- trunk/apps/Freemail/src/freemail/RTSFetcher.java 2007-11-21 15:53:52 UTC (rev 15906) +++ trunk/apps/Freemail/src/freemail/RTSFetcher.java 2007-11-21 16:32:22 UTC (rev 15907) @@ -216,7 +216,7 @@ String line; while (true) { try { - line = lis.readLine(200, 200); + line = lis.readLine(200, 200, false); } catch (TooLongException tle) { System.out.println("RTS message has lines that are too long. Discarding."); rtsfile.delete(); Modified: trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java =================================================================== --- trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2007-11-21 15:53:52 UTC (rev 15906) +++ trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2007-11-21 16:32:22 UTC (rev 15907) @@ -59,7 +59,7 @@ LineReader r = new LineReadingInputStream(is); String line; - while ( (line = r.readLine(200, 200)) != null) { + while ( (line = r.readLine(200, 200, false)) != null) { /***************************************/ //System.out.println(line); if (this.messagetype == null) { Modified: trunk/apps/Freemail/src/freenet/support/io/LineReader.java =================================================================== --- trunk/apps/Freemail/src/freenet/support/io/LineReader.java 2007-11-21 15:53:52 UTC (rev 15906) +++ trunk/apps/Freemail/src/freenet/support/io/LineReader.java 2007-11-21 16:32:22 UTC (rev 15907) @@ -4,6 +4,9 @@ public interface LineReader { - public String readLine(int maxLength, int bufferSize) throws IOException; + /** + * Read a \n or \r\n terminated line of UTF-8 or ISO-8859-1. + */ + public String readLine(int maxLength, int bufferSize, boolean utf) throws IOException; } Modified: trunk/apps/Freemail/src/freenet/support/io/LineReadingInputStream.java =================================================================== --- trunk/apps/Freemail/src/freenet/support/io/LineReadingInputStream.java 2007-11-21 15:53:52 UTC (rev 15906) +++ trunk/apps/Freemail/src/freenet/support/io/LineReadingInputStream.java 2007-11-21 16:32:22 UTC (rev 15907) @@ -14,30 +14,36 @@ super(in); } + private byte[] buf; + /** - * Read a line of US-ASCII. Used for e.g. HTTP. @return Null if end of file. + * Read a \n or \r\n terminated line of UTF-8 or ISO-8859-1. */ - public String readLine(int maxLength, int bufferSize) throws IOException { - StringBuffer sb = new StringBuffer(bufferSize); + public String readLine(int maxLength, int bufferSize, boolean utf) throws IOException { + if(buf == null) + buf = new byte[Math.max(128, Math.min(1024, bufferSize))]; + int ctr = 0; this.lastBytesRead = 0; while(true) { int x = read(); this.lastBytesRead++; if(x == -1) { - if(sb.length() == 0) return null; - return sb.toString(); + if(ctr == 0) return null; + return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1"); } - char c = (char) x; - if(c == '\n') { - if(sb.length() > 0) { - if(sb.charAt(sb.length()-1) == '\r') - sb.setLength(sb.length()-1); - } - return sb.toString(); + // REDFLAG this is definitely safe with the above charsets, it may not be safe with some wierd ones. + if(x == (int)'\n') { + if(ctr == 0) return ""; + if(buf[ctr-1] == '\r') ctr--; + return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1"); } - sb.append(c); - if(sb.length() >= maxLength) - throw new TooLongException(); + if(ctr >= buf.length) { + if(buf.length == bufferSize) throw new TooLongException(); + byte[] newBuf = new byte[Math.min(buf.length * 2, bufferSize)]; + System.arraycopy(buf, 0, newBuf, 0, buf.length); + buf = newBuf; + } + buf[ctr++] = (byte)x; } } From dbkr at freenetproject.org Thu Nov 22 17:49:13 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 22 Nov 2007 17:49:13 +0000 (UTC) Subject: [Freemail] r15926 - trunk/apps/Freemail/src/freemail/utils Message-ID: <20071122174913.8E01B47AE85@freenetproject.org> Author: dbkr Date: 2007-11-22 17:49:13 +0000 (Thu, 22 Nov 2007) New Revision: 15926 Modified: trunk/apps/Freemail/src/freemail/utils/EmailAddress.java Log: Make all EmailAddresses lowercase. Modified: trunk/apps/Freemail/src/freemail/utils/EmailAddress.java =================================================================== --- trunk/apps/Freemail/src/freemail/utils/EmailAddress.java 2007-11-22 16:23:14 UTC (rev 15925) +++ trunk/apps/Freemail/src/freemail/utils/EmailAddress.java 2007-11-22 17:49:13 UTC (rev 15926) @@ -33,7 +33,8 @@ public String user; public String domain; - public EmailAddress(String address) { + public EmailAddress(String rawAddress) { + String address = rawAddress.toLowerCase(); this.realname = null; this.user = null; this.domain = null; From dbkr at freenetproject.org Thu Nov 22 18:31:06 2007 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 22 Nov 2007 18:31:06 +0000 (UTC) Subject: [Freemail] r15927 - trunk/apps/Freemail/src/freemail Message-ID: <20071122183106.C203F390989@freenetproject.org> Author: dbkr Date: 2007-11-22 18:31:06 +0000 (Thu, 22 Nov 2007) New Revision: 15927 Modified: trunk/apps/Freemail/src/freemail/AccountManager.java trunk/apps/Freemail/src/freemail/FreemailCli.java trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java Log: Get rid of the anything@.freemail messages that were confusing people. Modified: trunk/apps/Freemail/src/freemail/AccountManager.java =================================================================== --- trunk/apps/Freemail/src/freemail/AccountManager.java 2007-11-22 17:49:13 UTC (rev 15926) +++ trunk/apps/Freemail/src/freemail/AccountManager.java 2007-11-22 18:31:06 UTC (rev 15927) @@ -74,7 +74,7 @@ File accountdir = new File(DATADIR, username); if (!accountdir.mkdir()) throw new IOException("Failed to create directory "+username+" in "+DATADIR); - putWelcomeMessage(username, getFreemailAddress(accountdir)); + putWelcomeMessage(username, new EmailAddress(username+"@"+getFreemailDomain(accountdir))); } public static void setupNIM(String username) throws IOException { @@ -126,13 +126,13 @@ return accfile; } - public static EmailAddress getFreemailAddress(File accdir) { + public static String getFreemailDomain(File accdir) { PropsFile accfile = getAccountFile(accdir); - return getFreemailAddress(accfile); + return getFreemailDomain(accfile); } - public static EmailAddress getFreemailAddress(PropsFile accfile) { + public static String getFreemailDomain(PropsFile accfile) { FreenetURI mailsite; try { mailsite = new FreenetURI(accfile.get("mailsite.pubkey")); @@ -141,17 +141,17 @@ return null; } - return new EmailAddress("anything@"+Base32.encode(mailsite.getKeyBody().getBytes())+".freemail"); + return Base32.encode(mailsite.getKeyBody().getBytes())+".freemail"; } - public static EmailAddress getKSKFreemailAddress(File accdir) { + public static String getKSKFreemailDomain(File accdir) { PropsFile accfile = getAccountFile(accdir); String alias = accfile.get("domain_alias"); if (alias == null) return null; - return new EmailAddress("anything@"+alias+".freemail"); + return alias+".freemail"; } public static RSAKeyParameters getPrivateKey(File accdir) { @@ -209,7 +209,7 @@ } System.out.println("Mailsite keys generated."); - System.out.println("Your Freemail address is: "+getFreemailAddress(accfile)); + System.out.println("Your Freemail address is any username followed by '@"+getFreemailDomain(accfile)+"'"); } catch (IOException ioe) { System.out.println("Couldn't create mailsite key file! "+ioe.getMessage()); } @@ -251,7 +251,7 @@ accfile.put("domain_alias", alias); SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z"); - EmailAddress to = getKSKFreemailAddress(accountdir); + EmailAddress to = new EmailAddress(username+"@"+getKSKFreemailDomain(accountdir)); MessageBank mb = new MessageBank(username); Modified: trunk/apps/Freemail/src/freemail/FreemailCli.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailCli.java 2007-11-22 17:49:13 UTC (rev 15926) +++ trunk/apps/Freemail/src/freemail/FreemailCli.java 2007-11-22 18:31:06 UTC (rev 15927) @@ -128,7 +128,7 @@ e.printStackTrace(); return; } - System.out.println("Your short Freemail address is: 'anything@"+alias+".freemail'. Your long address will continue to work."); + System.out.println("You now have all Freemail addresses ending: '@"+alias+".freemail'. Your long address will continue to work."); return; } Modified: trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java =================================================================== --- trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2007-11-22 17:49:13 UTC (rev 15926) +++ trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2007-11-22 18:31:06 UTC (rev 15927) @@ -25,7 +25,6 @@ import java.lang.InterruptedException; import freemail.utils.PropsFile; -import freemail.utils.EmailAddress; import freemail.fcp.ConnectionTerminatedException; public class SingleAccountWatcher implements Runnable { @@ -80,13 +79,13 @@ //this.mf = new MailFetcher(this.mb, inbound_dir, Freemail.getFCPConnection()); // temporary info message until there's a nicer UI :) - System.out.println("Secure Freemail address: "+AccountManager.getFreemailAddress(accdir)); + System.out.println("Secure Freemail address: @"+AccountManager.getFreemailDomain(accdir)); - EmailAddress shortaddr = AccountManager.getKSKFreemailAddress(accdir); - if (shortaddr != null) { - System.out.println("Short Freemail address (*probably* secure): "+shortaddr); + String shortdomain = AccountManager.getKSKFreemailDomain(accdir); + if (shortdomain != null) { + System.out.println("Short Freemail address (*probably* secure): @"+shortdomain); } else { - System.out.println("You don't have a short Freemail address. You could get one by running Freemail with the --shortaddress option, followed by your account name and the name you'd like. For example, 'java -jar freemail.jar --shortaddress bob bob' will give you the address 'anything at bob.freemail'. Try to pick something unique!"); + System.out.println("You don't have a short Freemail address. You could get one by running Freemail with the --shortaddress option, followed by your account name and the name you'd like. For example, 'java -jar freemail.jar --shortaddress bob bob' will give you all addresses ending '@bob.freemail'. Try to pick something unique!"); } } From alexlehm at freenetproject.org Thu Nov 22 20:24:44 2007 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Thu, 22 Nov 2007 20:24:44 +0000 (UTC) Subject: [Freemail] r1592