Author: dbkr
Date: 2006-08-30 17:59:35 +0000 (Wed, 30 Aug 2006)
New Revision: 10300
Modified:
trunk/apps/Freemail/src/freemail/MessageSender.java
trunk/apps/Freemail/src/freemail/OutboundContact.java
trunk/apps/Freemail/src/freemail/RTSFetcher.java
Log:
Don't use colons in file names - Windows can't do that. Also some other fixes:
catch more exceptions whilst decrypting RTS messages and fix in tracking when
messages are sent.
Modified: trunk/apps/Freemail/src/freemail/MessageSender.java
===================================================================
--- trunk/apps/Freemail/src/freemail/MessageSender.java 2006-08-30 12:44:52 UTC
(rev 10299)
+++ trunk/apps/Freemail/src/freemail/MessageSender.java 2006-08-30 17:59:35 UTC
(rev 10300)
@@ -18,6 +18,7 @@
private static final int MAX_TRIES = 10;
private final File datadir;
private Thread senderthread;
+ private static final String ATTR_SEP_CHAR = "_";
public MessageSender(File d) {
this.datadir = d;
@@ -59,7 +60,7 @@
int prefix = 1;
synchronized (this.senderthread) {
do {
- String filename = prefix + ":" + tries + ":" +
to;
+ String filename = prefix + ATTR_SEP_CHAR +
tries + ATTR_SEP_CHAR + to;
destfile = new File(outbox, filename);
prefix++;
} while (destfile.exists());
@@ -109,7 +110,7 @@
}
private void sendSingle(File accdir, File msg) {
- String parts[] = msg.getName().split(":", 3);
+ String parts[] = msg.getName().split(ATTR_SEP_CHAR, 3);
EmailAddress addr;
int tries;
if (parts.length < 3) {
Modified: trunk/apps/Freemail/src/freemail/OutboundContact.java
===================================================================
--- trunk/apps/Freemail/src/freemail/OutboundContact.java 2006-08-30
12:44:52 UTC (rev 10299)
+++ trunk/apps/Freemail/src/freemail/OutboundContact.java 2006-08-30
17:59:35 UTC (rev 10300)
@@ -602,7 +602,8 @@
}
if (err == null) {
System.out.println("Successfully inserted
"+key);
- msgs[i].first_send_time =
System.currentTimeMillis();
+ if (msgs[i].first_send_time < 0)
+ msgs[i].first_send_time =
System.currentTimeMillis();
msgs[i].last_send_time =
System.currentTimeMillis();
msgs[i].saveProps();
} else if (msgs[i].added_time + FAIL_DELAY <
System.currentTimeMillis()) {
Modified: trunk/apps/Freemail/src/freemail/RTSFetcher.java
===================================================================
--- trunk/apps/Freemail/src/freemail/RTSFetcher.java 2006-08-30 12:44:52 UTC
(rev 10299)
+++ trunk/apps/Freemail/src/freemail/RTSFetcher.java 2006-08-30 17:59:35 UTC
(rev 10300)
@@ -27,6 +27,7 @@
import org.bouncycastle.crypto.paddings.PKCS7Padding;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
+import org.bouncycastle.crypto.DataLengthException;
import freenet.support.io.LineReadingInputStream;
import freenet.support.io.TooLongException;
@@ -405,7 +406,11 @@
KeyParameter kp = new KeyParameter(aes_iv_and_key,
aescipher.getBlockSize(), aes_iv_and_key.length - aescipher.getBlockSize());
ParametersWithIV kpiv = new ParametersWithIV(kp,
aes_iv_and_key, 0, aescipher.getBlockSize());
- aescipher.init(false, kpiv);
+ try {
+ aescipher.init(false, kpiv);
+ } catch (IllegalArgumentException iae) {
+ throw new InvalidCipherTextException(iae.getMessage());
+ }
byte[] plaintext = new
byte[aescipher.getOutputSize((int)rtsmessage.length() - read)];
@@ -420,7 +425,11 @@
fis.close();
- aescipher.doFinal(plaintext, ptbytes);
+ try {
+ aescipher.doFinal(plaintext, ptbytes);
+ } catch (DataLengthException dle) {
+ throw new InvalidCipherTextException(dle.getMessage());
+ }
return plaintext;
}