Added gmail plugin containing both imap and smtp, with unit test

This commit is contained in:
Daryl
2012-08-30 18:48:25 +08:00
parent 36dade1092
commit 617c65dd48
12 changed files with 597 additions and 31 deletions

View File

@@ -0,0 +1,43 @@
package net.sf.briar.plugins.email;
import java.io.IOException;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.io.StreamConnection;
import net.sf.briar.api.plugins.simplex.SimplexTransportWriter;
public class GmailTransportConnectionWriter implements SimplexTransportWriter {
private static final Logger LOG = Logger.getLogger(GmailTransportConnectionWriter.class.getName());
private final StreamConnection stream;
private final long capacity = 25 * 1000 * 1000;
public GmailTransportConnectionWriter(StreamConnection stream) {
this.stream = stream;
}
public long getCapacity() {
return capacity;
}
public OutputStream getOutputStream() throws IOException {
return stream.openOutputStream();
}
public boolean shouldFlush() {
return false;
}
public void dispose(boolean exception) {
try {
stream.close();
} catch(IOException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
}
}