Commit cd4f99df authored by akwizgran's avatar akwizgran

Initial commit with new directory structure.

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="ui"/>
<classpathentry kind="src" path="i18n"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="api"/>
<classpathentry kind="src" path="components"/>
<classpathentry kind="src" path="util"/>
<classpathentry kind="src" path="installer"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="lib" path="lib/h2small-1.3.154.jar"/>
<classpathentry kind="lib" path="lib/guice-3.0-no_aop.jar"/>
<classpathentry kind="lib" path="lib/javax.inject-1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/windows-jre
/Briar
/bin
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>briar-prototype</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Wed Apr 13 15:01:36 BST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
<project name='api' default='compile'>
<import file='../build-common.xml'/>
</project>
package net.sf.briar.api.crypto;
public interface Password {
char[] getPassword();
}
package net.sf.briar.api.db;
import java.util.Set;
import net.sf.briar.api.protocol.AuthorId;
import net.sf.briar.api.protocol.Bundle;
import net.sf.briar.api.protocol.GroupId;
import net.sf.briar.api.protocol.Message;
public interface DatabaseComponent {
static final long MEGABYTES = 1024L * 1024L;
static final long GIGABYTES = 1024L * MEGABYTES;
static final long MAX_DB_SIZE = 2L * GIGABYTES;
static final long MIN_FREE_SPACE = 300L * MEGABYTES;
static final long CRITICAL_FREE_SPACE = 100L * MEGABYTES;
static final long MAX_BYTES_BETWEEN_SPACE_CHECKS = 5L * MEGABYTES;
static final long MAX_MS_BETWEEN_SPACE_CHECKS = 60L * 1000L; // 1 min
static final long BYTES_PER_SWEEP = 5L * MEGABYTES;
static final int CLEANER_SLEEP_MS = 1000; // 1 sec
static final int RETRANSMIT_THRESHOLD = 3;
void close() throws DbException;
void addLocallyGeneratedMessage(Message m) throws DbException;
void addNeighbour(NeighbourId n) throws DbException;
void generateBundle(NeighbourId n, Bundle b) throws DbException;
Rating getRating(AuthorId a) throws DbException;
Set<GroupId> getSubscriptions() throws DbException;
void receiveBundle(NeighbourId n, Bundle b) throws DbException;
void setRating(AuthorId a, Rating r) throws DbException;
void subscribe(GroupId g) throws DbException;
void unsubscribe(GroupId g) throws DbException;
}
package net.sf.briar.api.db;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import com.google.inject.BindingAnnotation;
@BindingAnnotation
@Target({ PARAMETER })
@Retention(RUNTIME)
public @interface DatabasePassword {}
package net.sf.briar.api.db;
public class DbException extends Exception {
private static final long serialVersionUID = 3706581789209939441L;
public DbException(Throwable t) {
super(t);
}
}
package net.sf.briar.api.db;
public class NeighbourId {
private final int id;
public NeighbourId(int id) {
this.id = id;
}
public int getInt() {
return id;
}
@Override
public boolean equals(Object o) {
if(o instanceof NeighbourId) return id == ((NeighbourId) o).id;
return false;
}
@Override
public int hashCode() {
return id;
}
@Override
public String toString() {
return String.valueOf(id);
}
}
package net.sf.briar.api.db;
public enum Rating {
BAD, UNRATED, GOOD
}
package net.sf.briar.api.db;
public enum Status {
NEW, SENT, SEEN
}
package net.sf.briar.api.i18n;
import java.awt.Font;
import java.io.IOException;
import java.util.Locale;
public interface FontManager {
void initialize(Locale locale) throws IOException;
String[] getBundledFontFilenames();
Font getFontForLanguage(String language);
Font getUiFont();
void setUiFontForLanguage(String language);
}
\ No newline at end of file
package net.sf.briar.api.i18n;
import java.awt.ComponentOrientation;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
public interface I18n {
String tr(String name);
Locale getLocale();
void setLocale(Locale locale);
void loadLocale() throws IOException;
void saveLocale() throws IOException;
void saveLocale(File dir) throws IOException;
ComponentOrientation getComponentOrientation();
void addListener(Listener l);
void removeListener(Listener l);
public interface Listener {
void localeChanged(Font uiFont);
}
}
\ No newline at end of file
package net.sf.briar.api.i18n;
public class Stri18ng {
private static final String HTML_OPEN_LEFT = "<html><body align='left'>";
private static final String HTML_OPEN_RIGHT = "<html><body align='right'>";
private static final String HTML_CLOSE = "</body></html>";
private static final String PARAGRAPH = "<p><p>"; // Yes, two of them
private final String name;
private final I18n i18n;
public Stri18ng(String name, I18n i18n) {
this.name = name;
this.i18n = i18n;
}
public String tr() {
return i18n.tr(name);
}
public String html() {
if(i18n.getComponentOrientation().isLeftToRight())
return HTML_OPEN_LEFT + i18n.tr(name) + HTML_CLOSE;
else return HTML_OPEN_RIGHT + i18n.tr(name) + HTML_CLOSE;
}
public String html(String... paras) {
StringBuilder s = new StringBuilder();
if(i18n.getComponentOrientation().isLeftToRight())
s.append(HTML_OPEN_LEFT);
else s.append(HTML_OPEN_RIGHT);
s.append(tr());
for(String para : paras) {
s.append(PARAGRAPH);
s.append(para);
}
s.append(HTML_CLOSE);
return s.toString();
}
}
package net.sf.briar.api.invitation;
import java.io.File;
import java.util.List;
public interface InvitationCallback {
boolean isCancelled();
void copyingFile(File f);
void encryptingFile(File f);
void created(List<File> files);
void error(String message);
void notFound(File f);
void notDirectory(File f);
void notAllowed(File f);
}
package net.sf.briar.api.invitation;
import java.io.File;
public interface InvitationParameters {
boolean shouldCreateExe();
boolean shouldCreateJar();
char[] getPassword();
File getChosenLocation();
String[] getBundledFontFilenames();
}
package net.sf.briar.api.invitation;
public interface InvitationWorkerFactory {
Runnable createWorker(InvitationCallback callback,
InvitationParameters parameters);
}
package net.sf.briar.api.protocol;
import java.util.Arrays;
public class AuthorId {
public static final int LENGTH = 32;
public static final AuthorId SELF = new AuthorId(new byte[] {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
});
private final byte[] id;
public AuthorId(byte[] id) {
assert id.length == LENGTH;
this.id = id;
}
public byte[] getBytes() {
return id;
}
@Override
public boolean equals(Object o) {
if(o instanceof AuthorId)
return Arrays.equals(id, ((AuthorId) o).id);
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(id);
}
}
package net.sf.briar.api.protocol;
public interface Batch {
public static final long CAPACITY = 1024L * 1024L;
public void seal();
BatchId getId();
long getSize();
Iterable<Message> getMessages();
void addMessage(Message m);
}
\ No newline at end of file
package net.sf.briar.api.protocol;
import java.util.Arrays;
public class BatchId {
public static final int LENGTH = 32;
private final byte[] id;
public BatchId(byte[] id) {
assert id.length == LENGTH;
this.id = id;
}
public byte[] getBytes() {
return id;
}
@Override
public boolean equals(Object o) {
if(o instanceof BatchId)
return Arrays.equals(id, ((BatchId) o).id);
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(id);
}
}
package net.sf.briar.api.protocol;
public interface Bundle {
public void seal();
BundleId getId();
long getCapacity();
long getSize();
Iterable<BatchId> getAcks();
void addAck(BatchId b);
Iterable<GroupId> getSubscriptions();
void addSubscription(GroupId g);
Iterable<Batch> getBatches();
void addBatch(Batch b);
}
package net.sf.briar.api.protocol;
import java.util.Arrays;
public class BundleId {
public static final BundleId NONE = new BundleId(new byte[] {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
});
public static final int LENGTH = 32;
private final byte[] id;
public BundleId(byte[] id) {
assert id.length == LENGTH;
this.id = id;
}
public byte[] getBytes() {
return id;
}
@Override
public boolean equals(Object o) {
if(o instanceof BundleId)
return Arrays.equals(id, ((BundleId) o).id);
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(id);
}
}
package net.sf.briar.api.protocol;
import java.util.Arrays;
public class GroupId {
public static final int LENGTH = 32;
private final byte[] id;
public GroupId(byte[] id) {
assert id.length == LENGTH;
this.id = id;
}
public byte[] getBytes() {
return id;
}
@Override
public boolean equals(Object o) {
if(o instanceof GroupId)
return Arrays.equals(id, ((GroupId) o).id);
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(id);
}
}
package net.sf.briar.api.protocol;
public interface Message {
MessageId getId();
MessageId getParent();
GroupId getGroup();
AuthorId getAuthor();
long getTimestamp();
int getSize();
byte[] getBody();
}
\ No newline at end of file
package net.sf.briar.api.protocol;
public interface MessageFactory {
Message createMessage(MessageId id, MessageId parent, GroupId group,
AuthorId author, long timestamp, byte[] body);
}
package net.sf.briar.api.protocol;
import java.util.Arrays;
public class MessageId {
public static final MessageId NONE = new MessageId(new byte[] {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
});
public static final int LENGTH = 32;
private final byte[] id;
public MessageId(byte[] id) {
assert id.length == LENGTH;
this.id = id;
}
public byte[] getBytes() {
return id;
}
@Override
public boolean equals(Object o) {
if(o instanceof MessageId)
return Arrays.equals(id, ((MessageId) o).id);
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(id);
}
}
package net.sf.briar.api.setup;
import java.io.File;
public interface SetupCallback {
boolean isCancelled();
void extractingFile(File f);
void copyingFile(File f);
void installed(File f);
void error(String message);
void notFound(File f);
void notDirectory(File f);
void notAllowed(File f);
}
package net.sf.briar.api.setup;
import java.io.File;
public interface SetupParameters {
File getChosenLocation();
String[] getBundledFontFilenames();
}
package net.sf.briar.api.setup;
public interface SetupWorkerFactory {
Runnable createWorker(SetupCallback callback, SetupParameters parameters);
}
<project name='build-common' default='compile'>
<import file='dependencies.xml'/>
<property name='build' location='build'/>
<dirname property='build-common.root' file='${ant.file.build-common}'/>
<fileset id='third-party-jars' dir='${build-common.root}/lib'>
<include name='*.jar'/>
</fileset>
<path id='api-classes'>
<pathelement location='${build-common.root}/api/build'/>
</path>
<path id='component-classes'>
<pathelement location='${build-common.root}/components/build'/>
</path>
<path id='util-classes'>
<pathelement location='${build-common.root}/util/build'/>
</path>
<target name='clean'>
<delete dir='${build}'/>
</target>
<target name='compile'>
<mkdir dir='${build}'/>
<javac srcdir='net/sf/briar' destdir='${build}'
includeantruntime='false'>
<classpath>
<fileset refid='third-party-jars'/>
<path refid='api-classes'/>
<path refid='component-classes'/>
<path refid='util-classes'/>
</classpath>
</javac>
</target>
<target name='depend'>
<antcall target='depend.${ant.project.name}'/>
</target>
<target name='depend-clean'>
<antcall target='depend-clean.${ant.project.name}'/>
</target>
</project>
<project name='all' default='compile'>
<import file='build-common.xml'/>
</project>