From alexlehm at freenetproject.org Thu Jan 3 21:28:32 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Thu, 3 Jan 2008 21:28:32 +0000 (UTC) Subject: [Freemail] r16864 - trunk/apps/Freemail/src/freemail Message-ID: <20080103212832.8B87247BC70@freenetproject.org> Author: alexlehm Date: 2008-01-03 21:28:31 +0000 (Thu, 03 Jan 2008) New Revision: 16864 Modified: trunk/apps/Freemail/src/freemail/SlotManager.java Log: fix for https://bugs.freenetproject.org/view.php?id=1946 "out of sequence rts keys confuse freemail" Modified: trunk/apps/Freemail/src/freemail/SlotManager.java =================================================================== --- trunk/apps/Freemail/src/freemail/SlotManager.java 2008-01-03 21:26:57 UTC (rev 16863) +++ trunk/apps/Freemail/src/freemail/SlotManager.java 2008-01-03 21:28:31 UTC (rev 16864) @@ -92,21 +92,30 @@ } else { // add all the slots before the used one that aren't already // in the list + // note that this also modifies the previously last slot with a timestamp int i; Slot s = (Slot)this.slots.lastElement(); + s.time_added = System.currentTimeMillis(); + Slot s_new = new Slot(); + s_new.slot = s.slot; int slots_start_size = this.slots.size(); for (i = slots_start_size; i < this.nextSlotNum - 1; i++) { - s.slot = this.incSlot(s.slot); - s.time_added = System.currentTimeMillis(); - this.slots.add(s); + s_new.slot = this.incSlot(s_new.slot); + // copy slot to a new object, otherwise we have an identical copy of the last slot n times + Slot s_copy=new Slot(); + s_copy.slot = s_new.slot; + s_copy.time_added = System.currentTimeMillis(); + this.slots.add(s_copy); } // increment to get the used slot... - s.slot = this.incSlot(s.slot); + s_new.slot = this.incSlot(s_new.slot); // and again to get the one that nextSlotNum is pointing at - s.slot = this.incSlot(s.slot); - // ...and add that - s.time_added = System.currentTimeMillis(); - this.slots.add(s); + s_new.slot = this.incSlot(s_new.slot); + // ...and add that one without time limit + s_new.time_added = -1; + this.slots.add(s_new); + // decrease nextSlotNum since we just have removed one slot + this.nextSlotNum--; } this.saveSlots(); } From tastre at gmail.com Mon Jan 7 17:15:27 2008 From: tastre at gmail.com (thomas) Date: Mon, 07 Jan 2008 18:15:27 +0100 Subject: [Freemail] Bad Number 1,7,11, reported as asked In-Reply-To: <20080103212832.8B87247BC70@freenetproject.org> References: <20080103212832.8B87247BC70@freenetproject.org> Message-ID: <47825E2F.9000503@gmail.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there, When I check for new email (that I sent from me to me through freemail), with Thunderbird, I got this error popup : "The current command did not succeed. The mail server responded: Bad Number 1,7,11. Please report this error!." I log the output of java -jar Freemail but no error are reported when this popup appears. I can only see insert and requests. I manage to retrieve and send few freemails before this error happened but now it does it each time I check for new messages. It looks like I can send freemails. I guess this report is useless as there as nothing show up in the logs. Maybe someone here can give me more information about this error. Or is there a way to increase verbosity level of Freemail ? Thanks, -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHgl4vMtFcs4F/JvARAp7uAJ0bMXIZiioFqcXhaM7GFwT5wxDfEwCgp4ti kvqoswFwj2SqssmE8VkdJoY= =3T/A -----END PGP SIGNATURE----- From dbkr at freenetproject.org Tue Jan 8 09:17:07 2008 From: dbkr at freenetproject.org (Dave Baker) Date: Tue, 8 Jan 2008 09:17:07 +0000 Subject: [Freemail] Bad Number 1,7,11, reported as asked In-Reply-To: <47825E2F.9000503@gmail.com> References: <20080103212832.8B87247BC70@freenetproject.org> <47825E2F.9000503@gmail.com> Message-ID: <200801080917.07995.dbkr@freenetproject.org> On Monday 07 January 2008 17:15:27 thomas wrote: > Hi there, > > When I check for new email (that I sent from me to me through freemail), > with Thunderbird, I got this error popup : > > "The current command did not succeed. The mail server responded: Bad > Number 1,7,11. > Please report this error!." > > I log the output of java -jar Freemail but no error are reported when > this popup appears. I can only see insert and requests. > > I manage to retrieve and send few freemails before this error happened > but now it does it each time I check for new messages. It looks like I > can send freemails. > > I guess this report is useless as there as nothing show up in the logs. > > Maybe someone here can give me more information about this error. > > Or is there a way to increase verbosity level of Freemail ? There's no extra verbosity available (or to be more precise, there's no way to turn it down) but it's okay - I think I know what's happenned here. If it's happenning while you're checking email it will presumably be Thunderbird specifying comma separated numbers in a fetch command and Freemail not liking it. In fact, there's a bug for it, to which I've attached this message: https://bugs.freenetproject.org/view.php?id=1090 Thanks for reporting this. Dave From tastre at gmail.com Tue Jan 8 18:10:53 2008 From: tastre at gmail.com (thomas) Date: Tue, 08 Jan 2008 19:10:53 +0100 Subject: [Freemail] Bad Number 1,7,11, reported as asked In-Reply-To: <200801080917.07995.dbkr@freenetproject.org> References: <20080103212832.8B87247BC70@freenetproject.org> <47825E2F.9000503@gmail.com> <200801080917.07995.dbkr@freenetproject.org> Message-ID: <4783BCAD.5050705@gmail.com> Dave Baker wrote: > On Monday 07 January 2008 17:15:27 thomas wrote: >> Hi there, >> >> When I check for new email (that I sent from me to me through freemail), >> with Thunderbird, I got this error popup : >> >> "The current command did not succeed. The mail server responded: Bad >> Number 1,7,11. >> Please report this error!." >> >> I log the output of java -jar Freemail but no error are reported when >> this popup appears. I can only see insert and requests. >> >> I manage to retrieve and send few freemails before this error happened >> but now it does it each time I check for new messages. It looks like I >> can send freemails. >> >> I guess this report is useless as there as nothing show up in the logs. >> >> Maybe someone here can give me more information about this error. >> >> Or is there a way to increase verbosity level of Freemail ? > > There's no extra verbosity available (or to be more precise, there's no way to > turn it down) but it's okay - I think I know what's happenned here. If it's > happenning while you're checking email it will presumably be Thunderbird > specifying comma separated numbers in a fetch command and Freemail not liking > it. In fact, there's a bug for it, to which I've attached this message: > https://bugs.freenetproject.org/view.php?id=1090 > > Thanks for reporting this. > > > > Dave > > I checked out svn version but I still have this issue. No Thunderbird with freemail yet... ok for me. Thanks for replying and pointing to the bug. From alexlehm at freenetproject.org Thu Jan 10 15:06:44 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Thu, 10 Jan 2008 15:06:44 +0000 (UTC) Subject: [Freemail] r16992 - trunk/apps/Freemail/src/freemail/imap Message-ID: <20080110150644.7308D3A0B99@freenetproject.org> Author: alexlehm Date: 2008-01-10 15:06:43 +0000 (Thu, 10 Jan 2008) New Revision: 16992 Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java Log: fix for issue 0001090: Accessing Freemail with Thunderbird gives error Bad Number (https://bugs.freenetproject.org/view.php?id=1090) parse ranges of the form n1:n2,n3:n4 or n1,n2 etc. correctly. This is done by using a TreeSet (SortedSet). Worked for me for a few weeks now, however there is another issue with enumerating message UIDs wrt. sorting. Also included is two protocol errors in the case where a parsing error happens and the trailing newline is missing. Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java =================================================================== --- trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-10 00:49:27 UTC (rev 16991) +++ trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-10 15:06:43 UTC (rev 16992) @@ -27,7 +27,9 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; +import java.util.Iterator; import java.util.SortedMap; +import java.util.TreeSet; import java.lang.NumberFormatException; import java.text.SimpleDateFormat; import java.util.Date; @@ -406,67 +408,65 @@ } return; } + + // build a set from the uid ranges, first separated by , then by : + TreeSet ts=new TreeSet(); + String[] rangeparts = msg.args[1].split(","); - String[] parts = msg.args[1].split(":"); - try { - from = Integer.parseInt(parts[0]); - } catch (NumberFormatException nfe) { - this.reply(msg, "BAD Bad number: "+parts[0]+". Please report this error!"); - return; - } - if (parts.length < 2) { - to = from; - } else if (parts[1].equals("*")) { - Integer tmp = (Integer)msgs.lastKey(); - to = tmp.intValue(); - } else { - try { - to = Integer.parseInt(parts[1]); - } catch (NumberFormatException nfe) { - this.reply(msg, "BAD Bad number: "+parts[0]+". Please report this error!"); - return; + for(int i=0;i 0) { - Integer curuid = (Integer)msgs.firstKey(); - if (curuid.intValue() > to) { - break; - } + + Iterator it=ts.iterator(); + + while(it.hasNext()) { + Integer curuid = (Integer)it.next(); + + MailMessage mm=(MailMessage)msgs.get(curuid); - if (!this.fetch_single((MailMessage)msgs.get(msgs.firstKey()), msgnum, msg.args, 2, true)) { - this.reply(msg, "BAD Unknown attribute in list or unterminated list"); - return; + if(mm!=null) { + if (!this.fetch_single((MailMessage)msgs.get(curuid), msgnum, msg.args, 2, true)) { + this.reply(msg, "BAD Unknown attribute in list or unterminated list"); + return; + } + msgnum++; } - - msgs = msgs.tailMap(new Integer(curuid.intValue()+1)); - msgnum++; } this.reply(msg, "OK Fetch completed"); } else if (msg.args[0].equalsIgnoreCase("store")) { - int oldsize = msgs.size(); - msgs = msgs.tailMap(new Integer(from)); - int firstmsg = oldsize - msgs.size(); - msgs = msgs.headMap(new Integer(to + 1)); - - MailMessage[] targetmsgs = new MailMessage[msgs.size()]; - - for (int i = 0; i < targetmsgs.length; i++) { - targetmsgs[i] = (MailMessage)msgs.values().toArray()[i]; + MailMessage[] targetmsgs = new MailMessage[ts.size()]; + + Iterator it=ts.iterator(); + + int i=0; + while(it.hasNext()) { + Integer curuid = (Integer)it.next(); + targetmsgs[i] = (MailMessage)msgs.get(curuid); + i++; } - - this.do_store(msg.args, 2, targetmsgs, msg, firstmsg, true); - + // FIXME: firstmessage==0 is probably not right + this.do_store(msg.args, 2, targetmsgs, msg, 0, true); + this.reply(msg, "OK Store completed"); } else if (msg.args[0].equalsIgnoreCase("copy")) { - msgs = msgs.tailMap(new Integer(from)); - + if (msg.args.length < 3) { this.reply(msg, "BAD Not enough arguments"); return; @@ -479,22 +479,18 @@ } int copied = 0; - - while (msgs.size() > 0) { - Integer curuid = (Integer)msgs.firstKey(); - if (curuid.intValue() > to) { - break; - } + + Iterator it=ts.iterator(); + + while(it.hasNext()) { + Integer curuid = (Integer)it.next(); + + MailMessage srcmsg = (MailMessage)msgs.get(curuid); - MailMessage srcmsg = (MailMessage)msgs.get(msgs.firstKey()); - MailMessage copymsg = target.createMessage(); srcmsg.copyTo(copymsg); copied++; - - msgs = msgs.tailMap(new Integer(curuid.intValue()+1)); - msgnum++; } if (copied > 0) @@ -514,9 +510,12 @@ if (!imap_args[firstarg].startsWith("(")) { // It's a loner this.ps.flush(); - if (!this.send_attr(msg, imap_args[firstarg])) + if (!this.send_attr(msg, imap_args[firstarg])){ + // send fake end delimiter, so we do not break the protocol + this.ps.print(")\r\n"); + this.ps.flush(); return false; - + } if (send_uid_too && !imap_args[firstarg].equalsIgnoreCase("uid")) { this.ps.print(" UID "+msg.getUID()); } @@ -543,8 +542,12 @@ //this.ps.print(attr+" "); this.ps.flush(); - if (!this.send_attr(msg, attr)) + if (!this.send_attr(msg, attr)) { + // send fake end delimiter, so we do not break the protocol + this.ps.print(")\r\n"); + this.ps.flush(); return false; + } if (attr.equalsIgnoreCase("uid")) { send_uid_too = false; From alexlehm at freenetproject.org Thu Jan 10 17:03:10 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Thu, 10 Jan 2008 17:03:10 +0000 (UTC) Subject: [Freemail] r16994 - in trunk/apps/Freemail/src/freemail: . imap Message-ID: <20080110170310.C4A1847B72E@freenetproject.org> Author: alexlehm Date: 2008-01-10 17:03:10 +0000 (Thu, 10 Jan 2008) New Revision: 16994 Modified: trunk/apps/Freemail/src/freemail/MailMessage.java trunk/apps/Freemail/src/freemail/Postman.java trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java Log: a few typos in comments, one method in imap/IMAPHandler.java changed to private (no functional changes) Modified: trunk/apps/Freemail/src/freemail/MailMessage.java =================================================================== --- trunk/apps/Freemail/src/freemail/MailMessage.java 2008-01-10 16:40:27 UTC (rev 16993) +++ trunk/apps/Freemail/src/freemail/MailMessage.java 2008-01-10 17:03:10 UTC (rev 16994) @@ -46,7 +46,7 @@ this.file = f; this.headers = new Vector(); - // initalise flags from filename + // initialize flags from filename String[] parts = f.getName().split(","); if (parts.length < 2 && !f.getName().endsWith(",")) { // treat it as a new message @@ -181,7 +181,7 @@ public void commit() { try { this.os.close(); - // also potentally move from a temp dir to real inbox + // also potentially move from a temp dir to real inbox // to do safer inbox access } catch (IOException ioe) { @@ -215,7 +215,7 @@ parts = null; break; } else if (line.startsWith(" ") || line.startsWith("\t")) { - // contination of previous line + // continuation of previous line if (parts == null || parts[1] == null) continue; parts[1] += " "+line.trim(); Modified: trunk/apps/Freemail/src/freemail/Postman.java =================================================================== --- trunk/apps/Freemail/src/freemail/Postman.java 2008-01-10 16:40:27 UTC (rev 16993) +++ trunk/apps/Freemail/src/freemail/Postman.java 2008-01-10 17:03:10 UTC (rev 16994) @@ -41,7 +41,7 @@ /** * - * @throws ConnectionTerminatedException If the Freenet connection was terminated whilst trying to validate the address + * @throws ConnectionTerminatedException if the Freenet connection was terminated whilst trying to validate the address */ protected void storeMessage(BufferedReader brdr, MessageBank mb) throws IOException, ConnectionTerminatedException { MailMessage newmsg = mb.createMessage(); @@ -51,7 +51,7 @@ newmsg.readHeaders(brdr); // add our own headers - // recieved and date + // received and date newmsg.addHeader("Received", "(Freemail); "+sdf.format(new Date())); // validate the from header - or headers. There could be several. Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java =================================================================== --- trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-10 16:40:27 UTC (rev 16993) +++ trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-10 17:03:10 UTC (rev 16994) @@ -704,7 +704,7 @@ return false; } - public void handle_store(IMAPMessage msg) { + private void handle_store(IMAPMessage msg) { if (msg.args == null || msg.args.length < 2) { this.reply(msg, "BAD Not enough arguments"); return; From alexlehm at freenetproject.org Thu Jan 10 17:44:24 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Thu, 10 Jan 2008 17:44:24 +0000 (UTC) Subject: [Freemail] r16995 - trunk/apps/Freemail/src/freemail Message-ID: <20080110174424.E47B447AEAE@freenetproject.org> Author: alexlehm Date: 2008-01-10 17:44:24 +0000 (Thu, 10 Jan 2008) New Revision: 16995 Modified: trunk/apps/Freemail/src/freemail/MessageBank.java Log: 0001980: mailbox uid list is sorted alphabetically (https://bugs.freenetproject.org/view.php?id=1980) sort the mail messages by number instead of alphabetically (i.e. 1,..,9,10,... instead of 1,10,2,...) to avoid confusing Thunderbird this also filters out filenames that do not match the format number,XXX or number Modified: trunk/apps/Freemail/src/freemail/MessageBank.java =================================================================== --- trunk/apps/Freemail/src/freemail/MessageBank.java 2008-01-10 17:03:10 UTC (rev 16994) +++ trunk/apps/Freemail/src/freemail/MessageBank.java 2008-01-10 17:44:24 UTC (rev 16995) @@ -32,6 +32,8 @@ import java.util.SortedMap; import java.util.Vector; import java.util.Enumeration; +import java.util.Comparator; +import java.util.Arrays; public class MessageBank { private static final String MESSAGES_DIR = "inbox"; @@ -129,6 +131,8 @@ public MailMessage[] listMessagesArray() { File[] files = this.dir.listFiles(new MessageFileNameFilter()); + + Arrays.sort(files, new UIDComparator()); MailMessage[] msgs = new MailMessage[files.length]; @@ -243,7 +247,20 @@ private class MessageFileNameFilter implements FilenameFilter { public boolean accept(File dir, String name) { if (name.startsWith(".")) return false; + if (!name.matches("[0-9]+(,.*)?")) return false; return true; } } + + // compare to filenames by number leading up to "," + private class UIDComparator implements Comparator { + public final int compare ( Object a, Object b ) { + int ia=Integer.parseInt(((File)a).getName().split(",",2)[0]); + int ib=Integer.parseInt(((File)b).getName().split(",",2)[0]); + + return( ia-ib ); + } + } + + } From alexlehm at freenetproject.org Fri Jan 11 15:28:37 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Fri, 11 Jan 2008 15:28:37 +0000 (UTC) Subject: [Freemail] r17010 - trunk/apps/Freemail/src/freemail Message-ID: <20080111152837.D2A4B47B2C1@freenetproject.org> Author: alexlehm Date: 2008-01-11 15:28:37 +0000 (Fri, 11 Jan 2008) New Revision: 17010 Modified: trunk/apps/Freemail/src/freemail/AccountManager.java trunk/apps/Freemail/src/freemail/FreemailCli.java trunk/apps/Freemail/src/freemail/FreemailPlugin.java trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java Log: 1745: freemail accepts "@" as short address char (https://bugs.freenetproject.org/view.php?id=1745) and 1843: @-character allowed in account name -> Thunderbird/Evolution won't connect (https://bugs.freenetproject.org/view.php?id=1843) validate username and short address agains list of invalid chars (still rather lenient, but it should catch common errors) Modified: trunk/apps/Freemail/src/freemail/AccountManager.java =================================================================== --- trunk/apps/Freemail/src/freemail/AccountManager.java 2008-01-11 14:10:33 UTC (rev 17009) +++ trunk/apps/Freemail/src/freemail/AccountManager.java 2008-01-11 15:28:37 UTC (rev 17010) @@ -64,10 +64,34 @@ public static final String MAILSITE_SUFFIX = "mailsite"; public static final String MAILSITE_VERSION = "-1"; + + // avoid invalid chars in username or address + // returns the first invalid char to give user a hint + private static String validateChars(String username, String invalid) { + for(int i=0;i=0) { + return invalid.substring(i,i+1); + } + } + return ""; + } + + // @ plus chars that may be invalid as filenames + public static String validateUsername(String username) { + return validateChars(username, "@\'\"\\/ :"); + } + + // @, space and other email meta chars + public static String validateShortAddress(String username) { + return validateChars(username, "@\'\"\\/,:%()+ "); + } - - public static void Create(String username) throws IOException { + public static void Create(String username) throws IOException,IllegalArgumentException { File datadir = new File(DATADIR); + String invalid=validateUsername(username); + if(!invalid.isEmpty()) { + throw new IllegalArgumentException("The username may not contain the character '"+invalid+"'"); + } if (!datadir.exists()) { if (!datadir.mkdir()) throw new IOException("Failed to create data directory"); } @@ -241,6 +265,11 @@ if (!accountdir.exists()) { throw new Exception("No such account - "+username+"."); } + + String invalid=validateShortAddress(alias); + if(!invalid.isEmpty()) { + throw new IllegalArgumentException("The short address may not contain the character '"+invalid+"'"); + } PropsFile accfile = getAccountFile(accountdir); Modified: trunk/apps/Freemail/src/freemail/FreemailCli.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailCli.java 2008-01-11 14:10:33 UTC (rev 17009) +++ trunk/apps/Freemail/src/freemail/FreemailCli.java 2008-01-11 15:28:37 UTC (rev 17010) @@ -109,6 +109,8 @@ //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()); + } catch (IllegalArgumentException iae) { + System.out.println("Couldn't create account. Error: "+iae.getMessage()); } return; } else if (action.equals("--passwd")) { @@ -123,6 +125,9 @@ } else if (action.equals("--shortaddress")) { try { AccountManager.addShortAddress(account, alias); + } catch (IllegalArgumentException iae) { + System.out.println("Couldn't add short address for "+account+". Error: "+iae.getMessage()); + return; } catch (Exception e) { System.out.println("Couldn't add short address for "+account+". "+e.getMessage()); e.printStackTrace(); @@ -161,6 +166,10 @@ continue; if (!files[i].isDirectory()) continue; + if(!AccountManager.validateUsername(files[i].getName()).isEmpty()) { + System.out.println("Account name "+files[i].getName()+" contains invalid chars, you may get problems accessing the account."); + } + Thread t = new Thread(new SingleAccountWatcher(files[i]), "Account Watcher for "+files[i].getName()); t.setDaemon(true); t.start(); Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-11 14:10:33 UTC (rev 17009) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-11 15:28:37 UTC (rev 17010) @@ -101,6 +101,11 @@ if (files[i].getName().equals(".") || files[i].getName().equals("..")) continue; if (!files[i].isDirectory()) continue; + + String invalid=AccountManager.validateUsername(files[i].getName()); + if(!invalid.isEmpty()) { + Logger.error(this,"Account name "+files[i].getName()+" contains invalid chars (\""+invalid+"\"), you may get problems accessing the account."); + } SingleAccountWatcher saw = new SingleAccountWatcher(files[i]); singleAccountWatcherList.add(saw); Modified: trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java =================================================================== --- trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2008-01-11 14:10:33 UTC (rev 17009) +++ trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2008-01-11 15:28:37 UTC (rev 17010) @@ -86,6 +86,11 @@ String shortdomain = AccountManager.getKSKFreemailDomain(accdir); if (shortdomain != null) { Logger.normal(this,"Short Freemail address (*probably* secure): @"+shortdomain); + + String invalid=AccountManager.validateUsername(shortdomain); + if(!invalid.isEmpty()) { + Logger.normal(this,"Your short Freemail address contains invalid characters (\""+invalid+"\"), others may have problems sending you mail"); + } } else { Logger.normal(this,"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 Fri Jan 11 16:21:09 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Fri, 11 Jan 2008 16:21:09 +0000 (UTC) Subject: [Freemail] r17011 - trunk/apps/Freemail/src/freemail Message-ID: <20080111162109.7CB3847A17D@freenetproject.org> Author: alexlehm Date: 2008-01-11 16:21:09 +0000 (Fri, 11 Jan 2008) New Revision: 17011 Modified: trunk/apps/Freemail/src/freemail/AccountManager.java trunk/apps/Freemail/src/freemail/FreemailCli.java trunk/apps/Freemail/src/freemail/FreemailPlugin.java trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java Log: used a java6 method in last commited fix Modified: trunk/apps/Freemail/src/freemail/AccountManager.java =================================================================== --- trunk/apps/Freemail/src/freemail/AccountManager.java 2008-01-11 15:28:37 UTC (rev 17010) +++ trunk/apps/Freemail/src/freemail/AccountManager.java 2008-01-11 16:21:09 UTC (rev 17011) @@ -89,7 +89,7 @@ public static void Create(String username) throws IOException,IllegalArgumentException { File datadir = new File(DATADIR); String invalid=validateUsername(username); - if(!invalid.isEmpty()) { + if(!invalid.equals("")) { throw new IllegalArgumentException("The username may not contain the character '"+invalid+"'"); } if (!datadir.exists()) { @@ -267,7 +267,7 @@ } String invalid=validateShortAddress(alias); - if(!invalid.isEmpty()) { + if(!invalid.equals("")) { throw new IllegalArgumentException("The short address may not contain the character '"+invalid+"'"); } Modified: trunk/apps/Freemail/src/freemail/FreemailCli.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailCli.java 2008-01-11 15:28:37 UTC (rev 17010) +++ trunk/apps/Freemail/src/freemail/FreemailCli.java 2008-01-11 16:21:09 UTC (rev 17011) @@ -166,7 +166,7 @@ continue; if (!files[i].isDirectory()) continue; - if(!AccountManager.validateUsername(files[i].getName()).isEmpty()) { + if(!AccountManager.validateUsername(files[i].getName()).equals("")) { System.out.println("Account name "+files[i].getName()+" contains invalid chars, you may get problems accessing the account."); } Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-11 15:28:37 UTC (rev 17010) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-11 16:21:09 UTC (rev 17011) @@ -103,7 +103,7 @@ if (!files[i].isDirectory()) continue; String invalid=AccountManager.validateUsername(files[i].getName()); - if(!invalid.isEmpty()) { + if(!invalid.equals("")) { Logger.error(this,"Account name "+files[i].getName()+" contains invalid chars (\""+invalid+"\"), you may get problems accessing the account."); } Modified: trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java =================================================================== --- trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2008-01-11 15:28:37 UTC (rev 17010) +++ trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2008-01-11 16:21:09 UTC (rev 17011) @@ -88,7 +88,7 @@ Logger.normal(this,"Short Freemail address (*probably* secure): @"+shortdomain); String invalid=AccountManager.validateUsername(shortdomain); - if(!invalid.isEmpty()) { + if(!invalid.equals("")) { Logger.normal(this,"Your short Freemail address contains invalid characters (\""+invalid+"\"), others may have problems sending you mail"); } } else { From alexlehm at freenetproject.org Fri Jan 11 23:22:03 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Fri, 11 Jan 2008 23:22:03 +0000 (UTC) Subject: [Freemail] r17023 - trunk/apps/Freemail/src/freemail/utils Message-ID: <20080111232203.7ADE33A114C@freenetproject.org> Author: alexlehm Date: 2008-01-11 23:22:03 +0000 (Fri, 11 Jan 2008) New Revision: 17023 Modified: trunk/apps/Freemail/src/freemail/utils/EmailAddress.java Log: 1871: Multi subdomain addresses (https://bugs.freenetproject.org/view.php?id=1871) return full domain if it includes dots (e.g. @foo.bar.freemail) Modified: trunk/apps/Freemail/src/freemail/utils/EmailAddress.java =================================================================== --- trunk/apps/Freemail/src/freemail/utils/EmailAddress.java 2008-01-11 23:17:25 UTC (rev 17022) +++ trunk/apps/Freemail/src/freemail/utils/EmailAddress.java 2008-01-11 23:22:03 UTC (rev 17023) @@ -118,12 +118,14 @@ } // get the part of the domain before the '.freemail' + // note that the domain may contain additional dots, so we cannot use split public String getSubDomain() { - String[] domparts = this.domain.split("\\.", 2); - - if (domparts.length < 2) return null; - - return domparts[0]; + int index=this.domain.lastIndexOf('.'); + if(index<0) { + return null; + } else { + return this.domain.substring(0,index); + } } public String getMailpageKey() { From ebaschiera at gmail.com Fri Jan 11 23:26:11 2008 From: ebaschiera at gmail.com (Ermanno Baschiera) Date: Sat, 12 Jan 2008 00:26:11 +0100 Subject: [Freemail] Freemail plugin not loading/unloading Message-ID: Hi all, I loaded the Freemail plugin into Freenet (just to learn something about it), but I'm having some issues... I got Freemail listed in the plugin list, but if I "visit" it, it tells "Plugin not found!". Then I tried to Unload it, but the operation never gets completed (the browser still loads the page, but it goes timeout). Additionally, in my logs there's plenty of this: "Jan 10, 2008 22:10:06:808 (freemail.fcp.HighLevelFCPClient, Scheduled job: freenet.pluginmanager.PluginHandler$PluginStarter at 16e4ff1, ERROR): Warning - no connection to node. Waiting..." It seems that every 5 seconds, that error happens. I tried also to rm Freemail.jar.url from /plugins, but it gets redownloaded. Can anyone help me please? Thanks a lot. -ermanno baschiera From martin.nyhus at sensewave.com Sat Jan 12 13:53:49 2008 From: martin.nyhus at sensewave.com (Martin Nyhus) Date: Sat, 12 Jan 2008 14:53:49 +0100 Subject: [Freemail] Patch for Freemail/IMAPHandler Message-ID: <200801121453.49612.martin.nyhus@sensewave.com> I'm not sure where to send this, so hopefully this will work :) Anyway, the append command can be used with two or more arguments, and should return bad, not no, when there are less than two (as I interpret the RFC). Would someone mind checking the patch and committing it if you think it's ok? Nogaso -------------- next part -------------- A non-text attachment was scrubbed... Name: patch Type: text/x-diff Size: 1401 bytes Desc: not available Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20080112/a1ce8551/attachment.diff From alexlehm at myrealbox.com Sun Jan 13 18:05:54 2008 From: alexlehm at myrealbox.com (Alexander Lehmann) Date: Sun, 13 Jan 2008 19:05:54 +0100 Subject: [Freemail] Patch for Freemail/IMAPHandler In-Reply-To: References: Message-ID: <478A5302.1090303@myrealbox.com> I have opened a bug: https://bugs.freenetproject.org/view.php?id=1988 freemail-request at freenetproject.org wrote: > Message: 1 > Date: Sat, 12 Jan 2008 14:53:49 +0100 > From: Martin Nyhus > Subject: [Freemail] Patch for Freemail/IMAPHandler > To: freemail at emu.freenetproject.org > Message-ID: <200801121453.49612.martin.nyhus at sensewave.com> > Content-Type: text/plain; charset="utf-8" > > I'm not sure where to send this, so hopefully this will work :) > > Anyway, the append command can be used with two or more arguments, and should > return bad, not no, when there are less than two (as I interpret the RFC). > Would someone mind checking the patch and committing it if you think it's ok? > > Nogaso > > > From dbkr at freenetproject.org Mon Jan 14 09:02:25 2008 From: dbkr at freenetproject.org (Dave Baker) Date: Mon, 14 Jan 2008 09:02:25 +0000 Subject: [Freemail] Freemail plugin not loading/unloading In-Reply-To: References: Message-ID: <200801140902.26360.dbkr@freenetproject.org> On Friday 11 January 2008 23:26:11 Ermanno Baschiera wrote: > Hi all, > I loaded the Freemail plugin into Freenet (just to learn something > about it), but I'm having some issues... > I got Freemail listed in the plugin list, but if I "visit" it, it > tells "Plugin not found!". Then I tried to Unload it, but the > operation never gets completed (the browser still loads the page, but > it goes timeout). > Additionally, in my logs there's plenty of this: > "Jan 10, 2008 22:10:06:808 (freemail.fcp.HighLevelFCPClient, Scheduled > job: freenet.pluginmanager.PluginHandler$PluginStarter at 16e4ff1, > ERROR): Warning - no connection to node. Waiting..." > It seems that every 5 seconds, that error happens. > > I tried also to rm Freemail.jar.url from /plugins, but it gets > redownloaded. Have you changed your FCP port by any chance? The plugin isn't clever enough to read what port you're using from the config, so if you're using a different one, you'll have to manually edit the Freemail config file. That might be what's causing your error message above. To remove the plugin though, you'll want to shut down freenet & remove it from freenet.ini. Dave From alexlehm at freenetproject.org Mon Jan 14 16:14:16 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Mon, 14 Jan 2008 16:14:16 +0000 (UTC) Subject: [Freemail] r17037 - trunk/apps/Freemail/src/freemail/imap Message-ID: <20080114161416.9B63C47B309@freenetproject.org> Author: alexlehm Date: 2008-01-14 16:14:16 +0000 (Mon, 14 Jan 2008) New Revision: 17037 Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java Log: 1988: Patch for Freemail/IMAPHandler (https://bugs.freenetproject.org/view.php?id=1988) handle append commands that do not include flags (e.g. Kmail) (reported by Martin Nyhus) Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java =================================================================== --- trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-13 00:03:11 UTC (rev 17036) +++ trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-14 16:14:16 UTC (rev 17037) @@ -1075,18 +1075,27 @@ } private void handle_append(IMAPMessage msg) { - if (msg.args == null || msg.args.length < 3) { - this.reply(msg, "NO Not enough arguments"); + if (msg.args == null || msg.args.length < 2) { + this.reply(msg, "BAD Not enough arguments"); return; } + //args[0] is always the mailbox String mbname = trimQuotes(msg.args[0]); - String sflags = msg.args[1]; - if (sflags.startsWith("(")) sflags = sflags.substring(1); - if (sflags.endsWith(")")) sflags = sflags.substring(0, sflags.length() - 1); - String sdatalen = msg.args[2]; - if (sdatalen.startsWith("{")) sdatalen = sdatalen.substring(1); - if (sdatalen.endsWith("}")) sdatalen = sdatalen.substring(0, sdatalen.length() - 1); + + String sdatalen = ""; + String sflags = ""; + + for (int i = 1; i < msg.args.length; i++) { + if (msg.args[i].startsWith("(")) { + //List of flags + sflags = msg.args[i].substring(1, msg.args[i].length() - 1); + } else if (msg.args[i].startsWith("{")) { + //Data length + sdatalen = msg.args[i].substring(1, msg.args[i].length() -1); + } + } + int datalen; try { datalen = Integer.parseInt(sdatalen); From alexlehm at freenetproject.org Mon Jan 14 17:18:29 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Mon, 14 Jan 2008 17:18:29 +0000 (UTC) Subject: [Freemail] r17039 - in trunk/apps/Freemail/src/freemail: . imap Message-ID: <20080114171829.A56B347A0E3@freenetproject.org> Author: alexlehm Date: 2008-01-14 17:18:29 +0000 (Mon, 14 Jan 2008) New Revision: 17039 Modified: trunk/apps/Freemail/src/freemail/MailMessage.java trunk/apps/Freemail/src/freemail/MessageBank.java trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java Log: 1987: various issues with mail index numbers (https://bugs.freenetproject.org/view.php?id=1987) message sequence numbers were not counted correctly, as replies to the uid command, they always counted from 1. This is probably the cause of the other message related bugs 1160: Messages are not set to read, 1766: Mail disappears from folders, 1779: expunge response breaks Thunderbird, 1986: deleted mail reappears Modified: trunk/apps/Freemail/src/freemail/MailMessage.java =================================================================== --- trunk/apps/Freemail/src/freemail/MailMessage.java 2008-01-14 16:46:46 UTC (rev 17038) +++ trunk/apps/Freemail/src/freemail/MailMessage.java 2008-01-14 17:18:29 UTC (rev 17039) @@ -40,11 +40,13 @@ private PrintStream ps; private final Vector headers; private BufferedReader brdr; + private int msg_seqnum=0; public IMAPMessageFlags flags; - MailMessage(File f) { + MailMessage(File f, int msg_seqnum) { this.file = f; this.headers = new Vector(); + this.msg_seqnum=msg_seqnum; // initialize flags from filename String[] parts = f.getName().split(","); @@ -240,6 +242,10 @@ return Integer.parseInt(parts[0]); } + + public int getSeqNum() { + return msg_seqnum; + } public long getSize() throws IOException { // this is quite arduous since we have to send the message Modified: trunk/apps/Freemail/src/freemail/MessageBank.java =================================================================== --- trunk/apps/Freemail/src/freemail/MessageBank.java 2008-01-14 16:46:46 UTC (rev 17038) +++ trunk/apps/Freemail/src/freemail/MessageBank.java 2008-01-14 17:18:29 UTC (rev 17039) @@ -105,7 +105,7 @@ this.writeNextId(newid); if (newfile != null) { - MailMessage newmsg = new MailMessage(newfile); + MailMessage newmsg = new MailMessage(newfile,0); return newmsg; } @@ -113,15 +113,17 @@ } public SortedMap listMessages() { - File[] files = this.dir.listFiles(); - + File[] files = this.dir.listFiles(new MessageFileNameFilter()); + + Arrays.sort(files, new UIDComparator()); + TreeMap msgs = new TreeMap(); - + + int seq=1; for (int i = 0; i < files.length; i++) { - if (files[i].getName().startsWith(".")) continue; if (files[i].isDirectory()) continue; - MailMessage msg = new MailMessage(files[i]); + MailMessage msg = new MailMessage(files[i],seq++); msgs.put(new Integer(msg.getUID()), msg); } @@ -139,7 +141,7 @@ for (int i = 0; i < files.length; i++) { //if (files[i].getName().startsWith(".")) continue; - MailMessage msg = new MailMessage(files[i]); + MailMessage msg = new MailMessage(files[i],i+1); msgs[i] = msg; } Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java =================================================================== --- trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-14 16:46:46 UTC (rev 17038) +++ trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-14 17:18:29 UTC (rev 17039) @@ -202,7 +202,7 @@ // '*' needs to be '.*' mbname = mbname.replaceAll("\\*", ".*"); - // and % is a wildcard not inclusing the hierarchy delimiter + // and % is a wildcard not including the hierarchy delimiter mbname = mbname.replaceAll("%", "[^\\.]*"); @@ -368,7 +368,7 @@ } if (i > to) break; - if (!this.fetch_single((MailMessage)msgs.get(msgs.firstKey()), i, msg.args, 1, false)) { + if (!this.fetch_single((MailMessage)msgs.get(msgs.firstKey()), msg.args, 1, false)) { this.reply(msg, "BAD Unknown attribute in list or unterminated list"); return; } @@ -441,7 +441,7 @@ MailMessage mm=(MailMessage)msgs.get(curuid); if(mm!=null) { - if (!this.fetch_single((MailMessage)msgs.get(curuid), msgnum, msg.args, 2, true)) { + if (!this.fetch_single((MailMessage)msgs.get(curuid), msg.args, 2, true)) { this.reply(msg, "BAD Unknown attribute in list or unterminated list"); return; } @@ -461,8 +461,7 @@ targetmsgs[i] = (MailMessage)msgs.get(curuid); i++; } - // FIXME: firstmessage==0 is probably not right - this.do_store(msg.args, 2, targetmsgs, msg, 0, true); + this.do_store(msg.args, 2, targetmsgs, msg, true); this.reply(msg, "OK Store completed"); } else if (msg.args[0].equalsIgnoreCase("copy")) { @@ -502,9 +501,9 @@ } } - private boolean fetch_single(MailMessage msg, int id, String[] args, int firstarg, boolean send_uid_too) { + private boolean fetch_single(MailMessage msg, String[] args, int firstarg, boolean send_uid_too) { String[] imap_args = (String[]) args.clone(); - this.ps.print("* "+id+" FETCH ("); + this.ps.print("* "+msg.getSeqNum()+" FETCH ("); // do the first attribute, if it's a loner. if (!imap_args[firstarg].startsWith("(")) { @@ -528,7 +527,7 @@ imap_args[firstarg] = imap_args[firstarg].substring(1); } - // go through the parenthesised list + // go through the parenthesized list for (int i = firstarg; i < imap_args.length; i++) { String attr; boolean finish = false; @@ -760,12 +759,12 @@ msgs[i - from] = (MailMessage) allmsgs[i]; } - do_store(msg.args, 1, msgs, msg, from + 1, false); + do_store(msg.args, 1, msgs, msg, false); this.reply(msg, "OK Store completed"); } - private void do_store(String[] args, int offset, MailMessage[] mmsgs, IMAPMessage msg, int firstmsgnum, boolean senduid) { + private void do_store(String[] args, int offset, MailMessage[] mmsgs, IMAPMessage msg, boolean senduid) { if (args[offset].toLowerCase().indexOf("flags") < 0) { // IMAP4Rev1 can only store flags, so you're // trying something crazy @@ -805,7 +804,7 @@ for (int i = 0; i < mmsgs.length; i++) { StringBuffer buf = new StringBuffer(""); - buf.append((i+firstmsgnum)); + buf.append(mmsgs[i].getSeqNum()); if (senduid) { buf.append(" FETCH (UID "); buf.append(mmsgs[i].getUID()); @@ -849,10 +848,13 @@ private void expunge(boolean verbose) { MailMessage[] mmsgs = this.mb.listMessagesArray(); + int count_correction=0; for (int i = 0; i < mmsgs.length; i++) { - if (mmsgs[i].flags.get("\\Deleted")) + if (mmsgs[i].flags.get("\\Deleted")) { mmsgs[i].delete(); - if (verbose) this.sendState(i+" EXPUNGE"); + if (verbose) this.sendState((i+1-count_correction)+" EXPUNGE"); + count_correction++; + } } } From ebaschiera at gmail.com Tue Jan 15 21:56:30 2008 From: ebaschiera at gmail.com (Ermanno Baschiera) Date: Tue, 15 Jan 2008 22:56:30 +0100 Subject: [Freemail] Freemail plugin not loading/unloading In-Reply-To: <200801140902.26360.dbkr@freenetproject.org> References: <200801140902.26360.dbkr@freenetproject.org> Message-ID: Thank you Dave. That was actually my mistake about which IP address to bind with FCP. Also I expected to find some kind of webclient, that I suppose it doesn't exist (yet..?). -ermanno 2008/1/14, Dave Baker : > On Friday 11 January 2008 23:26:11 Ermanno Baschiera wrote: > > Hi all, > > I loaded the Freemail plugin into Freenet (just to learn something > > about it), but I'm having some issues... > > I got Freemail listed in the plugin list, but if I "visit" it, it > > tells "Plugin not found!". Then I tried to Unload it, but the > > operation never gets completed (the browser still loads the page, but > > it goes timeout). > > Additionally, in my logs there's plenty of this: > > "Jan 10, 2008 22:10:06:808 (freemail.fcp.HighLevelFCPClient, Scheduled > > job: freenet.pluginmanager.PluginHandler$PluginStarter at 16e4ff1, > > ERROR): Warning - no connection to node. Waiting..." > > It seems that every 5 seconds, that error happens. > > > > I tried also to rm Freemail.jar.url from /plugins, but it gets > > redownloaded. > > Have you changed your FCP port by any chance? The plugin isn't clever enough > to read what port you're using from the config, so if you're using a > different one, you'll have to manually edit the Freemail config file. That > might be what's causing your error message above. > > To remove the plugin though, you'll want to shut down freenet & remove it from > freenet.ini. > > > Dave > > > _______________________________________________ > Freemail mailing list > Freemail at freenetproject.org > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail > From martin.nyhus at sensewave.com Tue Jan 15 22:07:05 2008 From: martin.nyhus at sensewave.com (Martin Nyhus) Date: Tue, 15 Jan 2008 23:07:05 +0100 Subject: [Freemail] Freemail plugin not loading/unloading In-Reply-To: References: <200801140902.26360.dbkr@freenetproject.org> Message-ID: <200801152307.13219.martin.nyhus@sensewave.com> On Tuesday 15. January 2008 22:56:30 Ermanno Baschiera wrote: > Also I expected to find some kind of webclient, that I suppose it > doesn't exist (yet..?). At the moment Freemail is only a server, so you need to use a mail client to connect. The web interface is only used to get a Freemail-address at the moment. Nogaso -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part. Url : http://emu.freenetproject.org/pipermail/freemail/attachments/20080115/cd2e59e7/attachment.pgp From alexlehm at freenetproject.org Tue Jan 22 21:55:20 2008 From: alexlehm at freenetproject.org (alexlehm at freenetproject.org) Date: Tue, 22 Jan 2008 21:55:20 +0000 (UTC) Subject: [Freemail] r17194 - trunk/apps/Freemail/src/freemail/imap Message-ID: <20080122215520.644D93908D6@freenetproject.org> Author: alexlehm Date: 2008-01-22 21:55:18 +0000 (Tue, 22 Jan 2008) New Revision: 17194 Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java Log: 1770: Thunderbird cannot access attachments received by Freemail (https://bugs.freenetproject.org/view.php?id=1770) 1993: Freemail's IMAP-server is not compatible with MacOS's Mail.app (https://bugs.freenetproject.org/view.php?id=1993) implement BODYSTRUCTURE (preliminary) and byte ranges (should be correct) to get Thunderbird to load large emails with attachment. I hope this will fix the problem with Mail.app as well. Note that the reply to BODYSTRUCTURE is fake, but it should be sufficient for now. Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java =================================================================== --- trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-22 19:19:45 UTC (rev 17193) +++ trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2008-01-22 21:55:18 UTC (rev 17194) @@ -590,7 +590,13 @@ this.ps.flush(); a = a.substring("body.peek".length()); return this.sendBody(mmsg, a); + } else if (attr.startsWith("bodystructure")) { + // TODO: we blatantly lie about the message structure + this.ps.print(a.substring(0, "bodystructure".length())); + this.ps.print(" (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"ISO-8859-1\") NIL NIL \"8BIT\" 1024 10)"); + return true; } else if (attr.startsWith("body")) { + // TODO: this is not quite right since it will match bodyanything mmsg.flags.set("\\Seen", true); this.ps.print(a.substring(0, "body".length())); @@ -626,18 +632,80 @@ private boolean sendBody(MailMessage mmsg, String attr) { if (attr.length() < 1) return false; + // handle byte ranges (e.g. body.peek[]<0.10240> + + int range_start=-1; + int range_len=-1; + + if(attr.matches(".*<\\d+\\.\\d+>$")) { + String range=attr.substring(attr.indexOf("<")+1,attr.length()-1); + attr=attr.substring(0, attr.indexOf("<")); + + String r_start=range.substring(0,range.indexOf(".")); + String r_end=range.substring(range.indexOf(".")+1); + try { + range_start=Integer.parseInt(r_start); + range_len=Integer.parseInt(r_end); + } catch(NumberFormatException nfe) { + // just ignore the range, this may problems though + range_start=-1; + range_len=-1; + } + } + if (attr.charAt(0) == '[') attr = attr.substring(1); if (attr.charAt(attr.length() - 1) == ']') attr = attr.substring(0, attr.length() - 1); if (attr.trim().length() == 0) { try { - this.ps.print("[] "); - this.ps.print("{"+mmsg.getSize()+"}\r\n"); + this.ps.print("[]"); + if(range_start!=-1) { + this.ps.print("<"+range_start+">"); + } + this.ps.print(" "); + + long partsize=0; + if(range_start==-1) { + partsize=mmsg.getSize(); + } else { + partsize=range_len; + if(mmsg.getSize()-range_start0) { + if(range_start>=line.length()) { + range_start-=line.length(); + line=""; + } else { + line=line.substring(range_start); + range_start=0; + } + } + if(range_start==0 || range_start==-1) { + if(range_len==-1) { + this.ps.print(line); + } else { + if(range_len>0) { + if(range_len Author: dbkr Date: 2008-01-24 19:17:31 +0000 (Thu, 24 Jan 2008) New Revision: 17241 Added: trunk/apps/Freemail/src/freemail/support/ Removed: trunk/apps/Freemail/src/freenet/support/ Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java trunk/apps/Freemail/src/freemail/support/io/LineReader.java trunk/apps/Freemail/src/freemail/support/io/LineReadingInputStream.java trunk/apps/Freemail/src/freemail/support/io/TooLongException.java Log: Move the freenet LineReader classes to freemail.support.io. Keeping copies is too error-prone so this is our best option in the absence of a freenet-common.jar. Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java =================================================================== --- trunk/apps/Freemail/src/freemail/RTSFetcher.java 2008-01-24 19:11:59 UTC (rev 17240) +++ trunk/apps/Freemail/src/freemail/RTSFetcher.java 2008-01-24 19:17:31 UTC (rev 17241) @@ -52,8 +52,8 @@ import org.bouncycastle.crypto.modes.CBCBlockCipher; import org.bouncycastle.crypto.DataLengthException; -import freenet.support.io.LineReadingInputStream; -import freenet.support.io.TooLongException; +import freemail.support.io.LineReadingInputStream; +import freemail.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 2008-01-24 19:11:59 UTC (rev 17240) +++ trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2008-01-24 19:17:31 UTC (rev 17241) @@ -32,8 +32,8 @@ import freemail.Freemail; -import freenet.support.io.LineReader; -import freenet.support.io.LineReadingInputStream; +import freemail.support.io.LineReader; +import freemail.support.io.LineReadingInputStream; public class FCPMessage { private String messagetype; Copied: trunk/apps/Freemail/src/freemail/support (from rev 17237, trunk/apps/Freemail/src/freenet/support) Modified: trunk/apps/Freemail/src/freemail/support/io/LineReader.java =================================================================== --- trunk/apps/Freemail/src/freenet/support/io/LineReader.java 2008-01-24 18:44:28 UTC (rev 17237) +++ trunk/apps/Freemail/src/freemail/support/io/LineReader.java 2008-01-24 19:17:31 UTC (rev 17241) @@ -1,5 +1,9 @@ -package freenet.support.io; +package freemail.support.io; +/* + * This file originates from the main Freenet distribution, originally in freenet.support.io + */ + import java.io.IOException; public interface LineReader { Modified: trunk/apps/Freemail/src/freemail/support/io/LineReadingInputStream.java =================================================================== --- trunk/apps/Freemail/src/freenet/support/io/LineReadingInputStream.java 2008-01-24 18:44:28 UTC (rev 17237) +++ trunk/apps/Freemail/src/freemail/support/io/LineReadingInputStream.java 2008-01-24 19:17:31 UTC (rev 17241) @@ -1,5 +1,9 @@ -package freenet.support.io; +package freemail.support.io; +/* + * This file originates from the main Freenet distribution, originally in freenet.support.io + */ + import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; Modified: trunk/apps/Freemail/src/freemail/support/io/TooLongException.java =================================================================== --- trunk/apps/Freemail/src/freenet/support/io/TooLongException.java 2008-01-24 18:44:28 UTC (rev 17237) +++ trunk/apps/Freemail/src/freemail/support/io/TooLongException.java 2008-01-24 19:17:31 UTC (rev 17241) @@ -1,5 +1,9 @@ -package freenet.support.io; +package freemail.support.io; +/* + * This file originates from the main Freenet distribution, originally in freenet.support.io + */ + import java.io.IOException; /** Exception thrown by a LineReadingInputStream when a line is too long. */ From dbkr at freenetproject.org Thu Jan 24 20:13:15 2008 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 24 Jan 2008 20:13:15 +0000 (UTC) Subject: [Freemail] r17246 - in trunk/apps/Freemail/src/freemail: . utils Message-ID: <20080124201315.E596F479EBB@freenetproject.org> Author: dbkr Date: 2008-01-24 20:13:15 +0000 (Thu, 24 Jan 2008) New Revision: 17246 Modified: trunk/apps/Freemail/src/freemail/FreemailCli.java trunk/apps/Freemail/src/freemail/utils/Logger.java Log: Add config file interface to Logger to set log level. Modified: trunk/apps/Freemail/src/freemail/FreemailCli.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailCli.java 2008-01-24 19:43:26 UTC (rev 17245) +++ trunk/apps/Freemail/src/freemail/FreemailCli.java 2008-01-24 20:13:15 UTC (rev 17246) @@ -31,6 +31,7 @@ import freemail.fcp.FCPConnection; import freemail.imap.IMAPListener; import freemail.smtp.SMTPListener; +import freemail.utils.Logger; import freemail.config.Configurator; //import freemail.config.ConfigClient; @@ -90,6 +91,8 @@ Configurator cfg = new Configurator(new File(cfgfile)); + cfg.register("loglevel", new Logger(), "normal|error"); + FCPContext fcpctx = new FCPContext(); cfg.register("fcp_host", fcpctx, "localhost"); Modified: trunk/apps/Freemail/src/freemail/utils/Logger.java =================================================================== --- trunk/apps/Freemail/src/freemail/utils/Logger.java 2008-01-24 19:43:26 UTC (rev 17245) +++ trunk/apps/Freemail/src/freemail/utils/Logger.java 2008-01-24 20:13:15 UTC (rev 17246) @@ -11,8 +11,10 @@ import java.lang.NoClassDefFoundError; -public class Logger { +import freemail.config.ConfigClient; +public class Logger implements ConfigClient { + static final private int INTERNAL=1; static final private int DEBUG=2; static final private int MINOR=4; @@ -24,7 +26,29 @@ //static final private int loglevel=INTERNAL|DEBUG|MINOR|NORMAL|ERROR; // everything //static final private int loglevel=DEBUG|NORMAL|ERROR; - static final private int loglevel=NORMAL|ERROR; // should be ok for normal users + static private int loglevel=NORMAL|ERROR; // should be ok for normal users + + public void setConfigProp(String key, String val) { + if (key.equals("loglevel")) { + String[] levels = val.split("\\s*\\|\\s*"); + + loglevel = 0; + + for (int i = 0; i < levels.length; i++) { + if (levels[i].equalsIgnoreCase("internal")) { + loglevel |= INTERNAL; + } else if (levels[i].equalsIgnoreCase("debug")) { + loglevel |= DEBUG; + } else if (levels[i].equalsIgnoreCase("minor")) { + loglevel |= MINOR; + } else if (levels[i].equalsIgnoreCase("normal")){ + loglevel |= NORMAL; + } else if (levels[i].equalsIgnoreCase("error")){ + loglevel |= ERROR; + } + } + } + } static private boolean useFreenetLogger() { From dbkr at freenetproject.org Thu Jan 24 22:43:42 2008 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 24 Jan 2008 22:43:42 +0000 (UTC) Subject: [Freemail] r17252 - trunk/apps/Freemail/src/freemail Message-ID: <20080124224342.E0C3B3A0DD2@freenetproject.org> Author: dbkr Date: 2008-01-24 22:43:42 +0000 (Thu, 24 Jan 2008) New Revision: 17252 Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java Log: Register the logger config entry in FreemailPlugin too :/ Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-24 22:32:05 UTC (rev 17251) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-24 22:43:42 UTC (rev 17252) @@ -67,6 +67,8 @@ String cfgfile = CFGFILE; Configurator cfg = new Configurator(new File(cfgfile)); FCPContext fcpctx = new FCPContext(); + + cfg.register("loglevel", new Logger(), "normal|error"); cfg.register("fcp_host", fcpctx, "localhost"); cfg.register("fcp_port", fcpctx, "9481"); From dbkr at freenetproject.org Thu Jan 24 22:50:29 2008 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Thu, 24 Jan 2008 22:50:29 +0000 (UTC) Subject: [Freemail] r17253 - trunk/apps/Freemail/src/freemail Message-ID: <20080124225029.44240390061@freenetproject.org> Author: dbkr Date: 2008-01-24 22:50:29 +0000 (Thu, 24 Jan 2008) New Revision: 17253 Modified: trunk/apps/Freemail/src/freemail/Freemail.java Log: I think we're about due for a version bump. Champagne, anyone? Modified: trunk/apps/Freemail/src/freemail/Freemail.java =================================================================== --- trunk/apps/Freemail/src/freemail/Freemail.java 2008-01-24 22:43:42 UTC (rev 17252) +++ trunk/apps/Freemail/src/freemail/Freemail.java 2008-01-24 22:50:29 UTC (rev 17253) @@ -28,7 +28,7 @@ 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 int BUILD_NO = 9; public static final String VERSION_TAG = "Pet Shop"; protected static final String TEMPDIRNAME = "temp"; From dbkr at freenetproject.org Fri Jan 25 00:43:20 2008 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Fri, 25 Jan 2008 00:43:20 +0000 (UTC) Subject: [Freemail] r17255 - trunk/apps/Freemail/src/freemail Message-ID: <20080125004320.9E389390A87@freenetproject.org> Author: dbkr Date: 2008-01-25 00:43:20 +0000 (Fri, 25 Jan 2008) New Revision: 17255 Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java Log: Log the version number in the plugin Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java =================================================================== --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-24 22:55:38 UTC (rev 17254) +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2008-01-25 00:43:20 UTC (rev 17255) @@ -69,6 +69,8 @@ FCPContext fcpctx = new FCPContext(); cfg.register("loglevel", new Logger(), "normal|error"); + + Logger.normal(this, "This is the Freemail plugin version "+VER_MAJOR+"."+VER_MINOR+" build #"+BUILD_NO+" ("+VERSION_TAG+")"); cfg.register("fcp_host", fcpctx, "localhost"); cfg.register("fcp_port", fcpctx, "9481"); From dbkr at freenetproject.org Fri Jan 25 15:15:56 2008 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Fri, 25 Jan 2008 15:15:56 +0000 (UTC) Subject: [Freemail] r17276 - trunk/apps/Freemail/src/freemail Message-ID: <20080125151556.9E91047B7A2@freenetproject.org> Author: dbkr Date: 2008-01-25 15:15:56 +0000 (Fri, 25 Jan 2008) New Revision: 17276 Modified: trunk/apps/Freemail/src/freemail/ServerListener.java Log: sock can be null if it failed to bind Modified: trunk/apps/Freemail/src/freemail/ServerListener.java =================================================================== --- trunk/apps/Freemail/src/freemail/ServerListener.java 2008-01-25 15:14:55 UTC (rev 17275) +++ trunk/apps/Freemail/src/freemail/ServerListener.java 2008-01-25 15:15:56 UTC (rev 17276) @@ -20,7 +20,7 @@ */ public void kill() { try { - sock.close(); + if (sock != null) sock.close(); } catch (IOException ioe) { } From dbkr at freenetproject.org Mon Jan 28 09:31:08 2008 From: dbkr at freenetproject.org (dbkr at freenetproject.org) Date: Mon, 28 Jan 2008 09:31:08 +0000 (UTC) Subject: [Freemail] r17342 - trunk/apps/Freemail/src/freemail/fcp Message-ID: <20080128093108.63158390919@freenetproject.org> Author: dbkr Date: 2008-01-28 09:31:08 +0000 (Mon, 28 Jan 2008) New Revision: 17342 Modified: trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java Log: Another NPE dodger. Modified: trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java =================================================================== --- trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java 2008-01-28 01:15:27 UTC (rev 17341) +++ trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java 2008-01-28 09:31:08 UTC (rev 17342) @@ -120,7 +120,7 @@ stopping = true; try { // we can safely close the socket from this thread: any read operations other threads are in will throw a SocketException - conn.close(); + if (conn != null) conn.close(); } catch (IOException ioe) { // ignore }