From 5281113f24e75089518fd4ee0085a6d416df09f1 Mon Sep 17 00:00:00 2001 From: akwizgran <akwizgran@users.sourceforge.net> Date: Mon, 27 Jun 2011 13:01:31 +0100 Subject: [PATCH] Javadocs and unit tests, God help me. --- api/net/sf/briar/api/crypto/Password.java | 8 ++++++ .../sf/briar/api/db/DatabaseComponent.java | 24 ++++++++++++++++++ api/net/sf/briar/api/db/DatabasePassword.java | 4 +++ api/net/sf/briar/api/db/NeighbourId.java | 1 + api/net/sf/briar/api/db/Rating.java | 1 + api/net/sf/briar/api/db/Status.java | 14 ++++++++++- api/net/sf/briar/api/i18n/FontManager.java | 6 +++-- api/net/sf/briar/api/i18n/I18n.java | 17 +++++++++++++ api/net/sf/briar/api/i18n/Stri18ng.java | 8 ++++++ .../api/invitation/InvitationCallback.java | 2 ++ .../api/invitation/InvitationParameters.java | 3 ++- api/net/sf/briar/api/protocol/AuthorId.java | 3 +++ api/net/sf/briar/api/protocol/Batch.java | 13 +++++++++- api/net/sf/briar/api/protocol/BatchId.java | 1 + api/net/sf/briar/api/protocol/Bundle.java | 25 ++++++++++++++++++- api/net/sf/briar/api/protocol/GroupId.java | 1 + api/net/sf/briar/api/protocol/Message.java | 17 ++++++++++++- api/net/sf/briar/api/protocol/MessageId.java | 2 ++ api/net/sf/briar/api/setup/SetupCallback.java | 2 ++ .../sf/briar/api/setup/SetupParameters.java | 3 +-- .../net/sf/briar/i18n/FontManagerImpl.java | 7 ------ .../sf/briar/invitation/InvitationWorker.java | 3 +-- .../net/sf/briar/ui/setup/SetupMain.java | 3 +-- test/net/sf/briar/TestUtils.java | 10 ++++++++ test/net/sf/briar/setup/SetupWorkerTest.java | 2 +- test/net/sf/briar/util/FileUtilsTest.java | 2 +- test/net/sf/briar/util/ZipUtilsTest.java | 2 +- .../invitation/InvitationParametersImpl.java | 13 +++------- .../sf/briar/ui/invitation/LocationPanel.java | 3 --- .../ui/invitation/OperatingSystemPanel.java | 3 --- .../sf/briar/ui/invitation/PasswordPanel.java | 3 --- .../ui/invitation/UiInvitationModule.java | 5 ++-- .../briar/ui/setup/SetupParametersImpl.java | 9 +------ ui/net/sf/briar/ui/setup/UiSetupModule.java | 3 +-- 34 files changed, 169 insertions(+), 54 deletions(-) diff --git a/api/net/sf/briar/api/crypto/Password.java b/api/net/sf/briar/api/crypto/Password.java index be576f3281..f26b68ef34 100644 --- a/api/net/sf/briar/api/crypto/Password.java +++ b/api/net/sf/briar/api/crypto/Password.java @@ -1,6 +1,14 @@ package net.sf.briar.api.crypto; +/** + * Encapsulates a password. Implementations may keep the password encrypted in + * memory to reduce the chances of writing it to the swapfile in plaintext. + */ public interface Password { + /** + * Returns the password as a character array, which should be filled with + * zeroes as soon as it has been used. + */ char[] getPassword(); } diff --git a/api/net/sf/briar/api/db/DatabaseComponent.java b/api/net/sf/briar/api/db/DatabaseComponent.java index 8f5cd228e8..8be61c5cd0 100644 --- a/api/net/sf/briar/api/db/DatabaseComponent.java +++ b/api/net/sf/briar/api/db/DatabaseComponent.java @@ -7,11 +7,16 @@ import net.sf.briar.api.protocol.Bundle; import net.sf.briar.api.protocol.GroupId; import net.sf.briar.api.protocol.Message; +/** + * Encapsulates the database implementation and exposes high-level operations + * to other components. + */ public interface DatabaseComponent { static final long MEGABYTES = 1024L * 1024L; static final long GIGABYTES = 1024L * MEGABYTES; + // FIXME: Some of these should be configurable static final long MAX_DB_SIZE = 2L * GIGABYTES; static final long MIN_FREE_SPACE = 300L * MEGABYTES; static final long CRITICAL_FREE_SPACE = 100L * MEGABYTES; @@ -21,23 +26,42 @@ public interface DatabaseComponent { static final int CLEANER_SLEEP_MS = 1000; // 1 sec static final int RETRANSMIT_THRESHOLD = 3; + /** Waits for any open transactions to finish and closes the database. */ void close() throws DbException; + /** Adds a locally generated message to the database. */ void addLocallyGeneratedMessage(Message m) throws DbException; + /** Adds a new neighbour to the database. */ void addNeighbour(NeighbourId n) throws DbException; + /** Generates a bundle of messages for the given neighbour. */ void generateBundle(NeighbourId n, Bundle b) throws DbException; + /** + * Returns the rating assigned to the given author, which may be + * Rating.UNRATED if no rating has been assigned. + */ Rating getRating(AuthorId a) throws DbException; + /** Returns the set of groups to which we subscribe. */ Set<GroupId> getSubscriptions() throws DbException; + /** + * Processes a bundle of messages received from the given neighbour. Some + * or all of the messages in the bundle may be stored. + */ void receiveBundle(NeighbourId n, Bundle b) throws DbException; + /** Stores a rating for the given author. */ void setRating(AuthorId a, Rating r) throws DbException; + /** Subscribes to the given group. */ void subscribe(GroupId g) throws DbException; + /** + * Unsubscribes from the given group. Any messages belonging to the group + * will be deleted from the database. + */ void unsubscribe(GroupId g) throws DbException; } diff --git a/api/net/sf/briar/api/db/DatabasePassword.java b/api/net/sf/briar/api/db/DatabasePassword.java index 06f5e4fb26..d24a4a30c9 100644 --- a/api/net/sf/briar/api/db/DatabasePassword.java +++ b/api/net/sf/briar/api/db/DatabasePassword.java @@ -8,6 +8,10 @@ import java.lang.annotation.Target; import com.google.inject.BindingAnnotation; +/** + * Annotation for injecting the password from which the database encryption + * key is derived. + */ @BindingAnnotation @Target({ PARAMETER }) @Retention(RUNTIME) diff --git a/api/net/sf/briar/api/db/NeighbourId.java b/api/net/sf/briar/api/db/NeighbourId.java index b35a92680d..943db44f1a 100644 --- a/api/net/sf/briar/api/db/NeighbourId.java +++ b/api/net/sf/briar/api/db/NeighbourId.java @@ -1,5 +1,6 @@ package net.sf.briar.api.db; +/** Uniquely identifies a neighbour. */ public class NeighbourId { private final int id; diff --git a/api/net/sf/briar/api/db/Rating.java b/api/net/sf/briar/api/db/Rating.java index b8b4a07f81..2a61dbfde2 100644 --- a/api/net/sf/briar/api/db/Rating.java +++ b/api/net/sf/briar/api/db/Rating.java @@ -1,5 +1,6 @@ package net.sf.briar.api.db; +/** The ratings that may be applied to an author in peer moderation. */ public enum Rating { BAD, UNRATED, GOOD } diff --git a/api/net/sf/briar/api/db/Status.java b/api/net/sf/briar/api/db/Status.java index ed5bba15ff..0f80ba176b 100644 --- a/api/net/sf/briar/api/db/Status.java +++ b/api/net/sf/briar/api/db/Status.java @@ -1,5 +1,17 @@ package net.sf.briar.api.db; +/** The status of a message with respect to a neighbour. */ public enum Status { - NEW, SENT, SEEN + /** + * The message has not been sent to, received from, or acked by the + * neighbour. + */ + NEW, + /** + * The message has been sent to, but not received from or acked by, the + * neighbour. + */ + SENT, + /** The message has been received from or acked by the neighbour. */ + SEEN } diff --git a/api/net/sf/briar/api/i18n/FontManager.java b/api/net/sf/briar/api/i18n/FontManager.java index 87053fa5b0..df6be33d5b 100644 --- a/api/net/sf/briar/api/i18n/FontManager.java +++ b/api/net/sf/briar/api/i18n/FontManager.java @@ -6,13 +6,15 @@ import java.util.Locale; public interface FontManager { + /** Initializes the FontManager for the given locale. */ void initialize(Locale locale) throws IOException; - String[] getBundledFontFilenames(); - + /** Returns the appropriate font for the given language. */ Font getFontForLanguage(String language); + /** Returns the current user interface font. */ Font getUiFont(); + /** Sets the user interface font appropriately for the given language. */ void setUiFontForLanguage(String language); } \ No newline at end of file diff --git a/api/net/sf/briar/api/i18n/I18n.java b/api/net/sf/briar/api/i18n/I18n.java index 2e93804ef8..c1930e5678 100644 --- a/api/net/sf/briar/api/i18n/I18n.java +++ b/api/net/sf/briar/api/i18n/I18n.java @@ -8,26 +8,43 @@ import java.util.Locale; public interface I18n { + /** Returns the named string, translated for the current i18n locale. */ String tr(String name); + /** Returns the i18n locale. This may not match the system locale. */ Locale getLocale(); + /** Sets the i18n locale. */ void setLocale(Locale locale); + /** Loads the i18n locale from Briar/Data/locale.cfg. */ void loadLocale() throws IOException; + /** Saves the i18n locale to Briar/Data/locale.cfg. */ void saveLocale() throws IOException; + /** Saves the i18n locale to the given file. */ void saveLocale(File dir) throws IOException; + /** Returns the ComponentOrientation of the current i18n locale. */ ComponentOrientation getComponentOrientation(); + /** Registers a listener for changes to the i18n locale. */ void addListener(Listener l); + /** Unregisters a listener for changes to the i18n locale. */ void removeListener(Listener l); + /** + * Implemented by classes that wish to be informed of changes to the i18n + * locale. + */ public interface Listener { + /** + * Called whenever the i18n locale changes. + * @param uiFont The user interface font for the new locale. + */ void localeChanged(Font uiFont); } } \ No newline at end of file diff --git a/api/net/sf/briar/api/i18n/Stri18ng.java b/api/net/sf/briar/api/i18n/Stri18ng.java index 250752b0e1..a15305b317 100644 --- a/api/net/sf/briar/api/i18n/Stri18ng.java +++ b/api/net/sf/briar/api/i18n/Stri18ng.java @@ -1,5 +1,6 @@ package net.sf.briar.api.i18n; +/** A named translatable string. */ public class Stri18ng { private static final String HTML_OPEN_LEFT = "<html><body align='left'>"; @@ -15,16 +16,23 @@ public class Stri18ng { this.i18n = i18n; } + /** Returns the string translated for the current i18n locale. */ public String tr() { return i18n.tr(name); } + /** Returns the string, translated for the current i18n locale, as HTML. */ 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; } + /** + * Returns the string, translated for the current locale, as HTML. + * @param paras Additional (pre-translated) paragraphs that should be + * appended to the HTML. + */ public String html(String... paras) { StringBuilder s = new StringBuilder(); if(i18n.getComponentOrientation().isLeftToRight()) diff --git a/api/net/sf/briar/api/invitation/InvitationCallback.java b/api/net/sf/briar/api/invitation/InvitationCallback.java index 01d9fc3a6d..793cb79939 100644 --- a/api/net/sf/briar/api/invitation/InvitationCallback.java +++ b/api/net/sf/briar/api/invitation/InvitationCallback.java @@ -3,8 +3,10 @@ package net.sf.briar.api.invitation; import java.io.File; import java.util.List; +/** A progress callback for creating an invitation. */ public interface InvitationCallback { + /** Returns true if the process has been cancelled by the user. */ boolean isCancelled(); void copyingFile(File f); diff --git a/api/net/sf/briar/api/invitation/InvitationParameters.java b/api/net/sf/briar/api/invitation/InvitationParameters.java index 550e78fda8..ff53a21bba 100644 --- a/api/net/sf/briar/api/invitation/InvitationParameters.java +++ b/api/net/sf/briar/api/invitation/InvitationParameters.java @@ -2,6 +2,7 @@ package net.sf.briar.api.invitation; import java.io.File; +/** Provides the parameters for creating an invitation. */ public interface InvitationParameters { boolean shouldCreateExe(); @@ -12,5 +13,5 @@ public interface InvitationParameters { File getChosenLocation(); - String[] getBundledFontFilenames(); + File getSetupDat(); } diff --git a/api/net/sf/briar/api/protocol/AuthorId.java b/api/net/sf/briar/api/protocol/AuthorId.java index 08b9f69766..5f5ab3b133 100644 --- a/api/net/sf/briar/api/protocol/AuthorId.java +++ b/api/net/sf/briar/api/protocol/AuthorId.java @@ -2,10 +2,13 @@ package net.sf.briar.api.protocol; import java.util.Arrays; +/** Uniquely identifies a pseudonymous author. */ public class AuthorId { public static final int LENGTH = 32; + // FIXME: Replace this with an isSelf() method that compares an AuthorId + // to any and all local AuthorIds. 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 diff --git a/api/net/sf/briar/api/protocol/Batch.java b/api/net/sf/briar/api/protocol/Batch.java index b7503e7720..82c86222cc 100644 --- a/api/net/sf/briar/api/protocol/Batch.java +++ b/api/net/sf/briar/api/protocol/Batch.java @@ -1,13 +1,24 @@ package net.sf.briar.api.protocol; - +/** A batch of messages up to CAPACITY bytes in total size. */ public interface Batch { public static final long CAPACITY = 1024L * 1024L; + /** Prepares the batch for transmission and generates its identifier. */ public void seal(); + + /** + * Returns the batch's unique identifier. Cannot be called before seal(). + */ BatchId getId(); + + /** Returns the size of the batch in bytes. */ long getSize(); + + /** Returns the messages contained in the batch. */ Iterable<Message> getMessages(); + + /** Adds a message to the batch. Cannot be called after seal(). */ void addMessage(Message m); } \ No newline at end of file diff --git a/api/net/sf/briar/api/protocol/BatchId.java b/api/net/sf/briar/api/protocol/BatchId.java index 1125c47aff..9aad9c0e2d 100644 --- a/api/net/sf/briar/api/protocol/BatchId.java +++ b/api/net/sf/briar/api/protocol/BatchId.java @@ -2,6 +2,7 @@ package net.sf.briar.api.protocol; import java.util.Arrays; +/** Uniquely identifies a batch of messages. */ public class BatchId { public static final int LENGTH = 32; diff --git a/api/net/sf/briar/api/protocol/Bundle.java b/api/net/sf/briar/api/protocol/Bundle.java index 5bb55e455e..e027825fba 100644 --- a/api/net/sf/briar/api/protocol/Bundle.java +++ b/api/net/sf/briar/api/protocol/Bundle.java @@ -1,16 +1,39 @@ package net.sf.briar.api.protocol; - +/** A bundle of acknowledgements, subscriptions, and batches of messages. */ public interface Bundle { + /** Prepares the bundle for transmission and generates its identifier. */ public void seal(); + + /** + * Returns the bundle's unique identifier. Cannot be called before seal(). + */ BundleId getId(); + + /** Returns the bundle's capacity in bytes. */ long getCapacity(); + + /** Returns the bundle's size in bytes. */ long getSize(); + + /** Returns the acknowledgements contained in the bundle. */ Iterable<BatchId> getAcks(); + + /** Adds an acknowledgement to the bundle. Cannot be called after seal(). */ void addAck(BatchId b); + + /** Returns the subscriptions contained in the bundle. */ Iterable<GroupId> getSubscriptions(); + + /** Adds a subscription to the bundle. Cannot be called after seal(). */ void addSubscription(GroupId g); + + /** Returns the batches of messages contained in the bundle. */ Iterable<Batch> getBatches(); + + /** + * Adds a batch of messages to the bundle. Cannot be called after seal(). + */ void addBatch(Batch b); } diff --git a/api/net/sf/briar/api/protocol/GroupId.java b/api/net/sf/briar/api/protocol/GroupId.java index 1ac038bbfb..75a12c8a3f 100644 --- a/api/net/sf/briar/api/protocol/GroupId.java +++ b/api/net/sf/briar/api/protocol/GroupId.java @@ -2,6 +2,7 @@ package net.sf.briar.api.protocol; import java.util.Arrays; +/** Uniquely identifies a group to which a user may subscribe. */ public class GroupId { public static final int LENGTH = 32; diff --git a/api/net/sf/briar/api/protocol/Message.java b/api/net/sf/briar/api/protocol/Message.java index 31458e4928..8ed42d12d2 100644 --- a/api/net/sf/briar/api/protocol/Message.java +++ b/api/net/sf/briar/api/protocol/Message.java @@ -1,13 +1,28 @@ package net.sf.briar.api.protocol; - public interface Message { + /** Returns the message's unique identifier. */ MessageId getId(); + + /** + * Returns the message's parent, or MessageId.NONE if this is the first + * message in a thread. + */ MessageId getParent(); + + /** Returns the group to which the message belongs. */ GroupId getGroup(); + + /** Returns the message's author. */ AuthorId getAuthor(); + + /** Returns the timestamp created by the message's author. */ long getTimestamp(); + + /** Returns the size of the message in bytes. */ int getSize(); + + /** Returns the message in wire format. */ byte[] getBody(); } \ No newline at end of file diff --git a/api/net/sf/briar/api/protocol/MessageId.java b/api/net/sf/briar/api/protocol/MessageId.java index 7fb042a298..ad25c171d6 100644 --- a/api/net/sf/briar/api/protocol/MessageId.java +++ b/api/net/sf/briar/api/protocol/MessageId.java @@ -2,8 +2,10 @@ package net.sf.briar.api.protocol; import java.util.Arrays; +/** Uniquely identifies a message. */ public class MessageId { + /** Used to indicate that the first message in a thread has no parent. */ 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 diff --git a/api/net/sf/briar/api/setup/SetupCallback.java b/api/net/sf/briar/api/setup/SetupCallback.java index 1c3767c00d..490612ecfa 100644 --- a/api/net/sf/briar/api/setup/SetupCallback.java +++ b/api/net/sf/briar/api/setup/SetupCallback.java @@ -2,8 +2,10 @@ package net.sf.briar.api.setup; import java.io.File; +/** A progress callback for the installation process. */ public interface SetupCallback { + /** Returns true if the process has been cancelled by the user. */ boolean isCancelled(); void extractingFile(File f); diff --git a/api/net/sf/briar/api/setup/SetupParameters.java b/api/net/sf/briar/api/setup/SetupParameters.java index be90063496..f9876305b9 100644 --- a/api/net/sf/briar/api/setup/SetupParameters.java +++ b/api/net/sf/briar/api/setup/SetupParameters.java @@ -2,11 +2,10 @@ package net.sf.briar.api.setup; import java.io.File; +/** Provides the parameters for the installation process. */ public interface SetupParameters { File getChosenLocation(); - String[] getBundledFontFilenames(); - long getExeHeaderSize(); } diff --git a/components/net/sf/briar/i18n/FontManagerImpl.java b/components/net/sf/briar/i18n/FontManagerImpl.java index 8b5f9623fe..378cd354c2 100644 --- a/components/net/sf/briar/i18n/FontManagerImpl.java +++ b/components/net/sf/briar/i18n/FontManagerImpl.java @@ -58,13 +58,6 @@ public class FontManagerImpl implements FontManager { return Font.getFont(attr); } - public String[] getBundledFontFilenames() { - String[] names = new String[BUNDLED_FONTS.length]; - for(int i = 0; i < BUNDLED_FONTS.length; i++) - names[i] = BUNDLED_FONTS[i].filename; - return names; - } - public Font getFontForLanguage(String language) { assert defaultFont != null; Font font = fonts.get(language); diff --git a/components/net/sf/briar/invitation/InvitationWorker.java b/components/net/sf/briar/invitation/InvitationWorker.java index 4c8f94e55f..ce3c5751cc 100644 --- a/components/net/sf/briar/invitation/InvitationWorker.java +++ b/components/net/sf/briar/invitation/InvitationWorker.java @@ -94,8 +94,7 @@ class InvitationWorker implements Runnable { } private void copyInstaller(File dest) throws IOException { - File root = FileUtils.getBriarDirectory(); - File src = new File(root, "Data/setup.dat"); + File src = parameters.getSetupDat(); if(!src.exists() || !src.isFile()) throw new IOException("File not found: " + src.getPath()); callback.copyingFile(dest); diff --git a/installer/net/sf/briar/ui/setup/SetupMain.java b/installer/net/sf/briar/ui/setup/SetupMain.java index db25a705b7..5529703e57 100644 --- a/installer/net/sf/briar/ui/setup/SetupMain.java +++ b/installer/net/sf/briar/ui/setup/SetupMain.java @@ -27,8 +27,7 @@ public class SetupMain { new AlreadyInstalledPanel(wizard, i18n); new InstructionsPanel(wizard, i18n); LocationPanel locationPanel = new LocationPanel(wizard, i18n); - SetupParameters parameters = - new SetupParametersImpl(locationPanel, fontManager); + SetupParameters parameters = new SetupParametersImpl(locationPanel); new SetupWorkerPanel(wizard, workerFactory, parameters, i18n); fontManager.initialize(Locale.getDefault()); diff --git a/test/net/sf/briar/TestUtils.java b/test/net/sf/briar/TestUtils.java index 8e3e8daf30..86fb377099 100644 --- a/test/net/sf/briar/TestUtils.java +++ b/test/net/sf/briar/TestUtils.java @@ -4,9 +4,13 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.util.concurrent.atomic.AtomicInteger; public class TestUtils { + private static final AtomicInteger nextTestDir = + new AtomicInteger((int) (Math.random() * 1000 * 1000)); + public static void delete(File f) throws IOException { if(f.isDirectory()) for(File child : f.listFiles()) delete(child); f.delete(); @@ -19,4 +23,10 @@ public class TestUtils { out.flush(); out.close(); } + + public static File getTestDirectory() { + int name = nextTestDir.getAndIncrement(); + File testDir = new File("test.tmp/" + name); + return testDir; + } } diff --git a/test/net/sf/briar/setup/SetupWorkerTest.java b/test/net/sf/briar/setup/SetupWorkerTest.java index bcaeb2ba12..cf164a9591 100644 --- a/test/net/sf/briar/setup/SetupWorkerTest.java +++ b/test/net/sf/briar/setup/SetupWorkerTest.java @@ -22,7 +22,7 @@ public class SetupWorkerTest extends TestCase { private static final int HEADER_SIZE = 1234; - private final File testDir = new File("test.tmp"); + private final File testDir = TestUtils.getTestDirectory(); private final File jar = new File(testDir, "test.jar"); @Before diff --git a/test/net/sf/briar/util/FileUtilsTest.java b/test/net/sf/briar/util/FileUtilsTest.java index 0f303d56c1..8dbbe0f367 100644 --- a/test/net/sf/briar/util/FileUtilsTest.java +++ b/test/net/sf/briar/util/FileUtilsTest.java @@ -18,7 +18,7 @@ import org.junit.Test; public class FileUtilsTest extends TestCase { - private final File testDir = new File("test.tmp"); + private final File testDir = TestUtils.getTestDirectory(); @Before public void setUp() { diff --git a/test/net/sf/briar/util/ZipUtilsTest.java b/test/net/sf/briar/util/ZipUtilsTest.java index 4e95a437fa..c2ad772aef 100644 --- a/test/net/sf/briar/util/ZipUtilsTest.java +++ b/test/net/sf/briar/util/ZipUtilsTest.java @@ -24,7 +24,7 @@ import org.junit.Test; public class ZipUtilsTest extends TestCase { - private final File testDir = new File("test.tmp"); + private final File testDir = TestUtils.getTestDirectory(); private final File f1 = new File(testDir, "abc/def/1"); private final File f2 = new File(testDir, "abc/def/2"); diff --git a/ui/net/sf/briar/ui/invitation/InvitationParametersImpl.java b/ui/net/sf/briar/ui/invitation/InvitationParametersImpl.java index d6933ce566..b2eae75adb 100644 --- a/ui/net/sf/briar/ui/invitation/InvitationParametersImpl.java +++ b/ui/net/sf/briar/ui/invitation/InvitationParametersImpl.java @@ -2,10 +2,8 @@ package net.sf.briar.ui.invitation; import java.io.File; -import net.sf.briar.api.i18n.FontManager; import net.sf.briar.api.invitation.InvitationParameters; - -import com.google.inject.Inject; +import net.sf.briar.util.FileUtils; class InvitationParametersImpl implements InvitationParameters { @@ -13,17 +11,14 @@ class InvitationParametersImpl implements InvitationParameters { private final OperatingSystemPanel osPanel; private final PasswordPanel passwordPanel; private final LocationPanel locationPanel; - private final FontManager fontManager; - @Inject InvitationParametersImpl(ExistingUserPanel existingUserPanel, OperatingSystemPanel osPanel, PasswordPanel passwordPanel, - LocationPanel locationPanel, FontManager fontManager) { + LocationPanel locationPanel) { this.existingUserPanel = existingUserPanel; this.osPanel = osPanel; this.passwordPanel = passwordPanel; this.locationPanel = locationPanel; - this.fontManager = fontManager; } public boolean shouldCreateExe() { @@ -44,7 +39,7 @@ class InvitationParametersImpl implements InvitationParameters { return locationPanel.getChosenDirectory(); } - public String[] getBundledFontFilenames() { - return fontManager.getBundledFontFilenames(); + public File getSetupDat() { + return FileUtils.getBriarDirectory(); } } diff --git a/ui/net/sf/briar/ui/invitation/LocationPanel.java b/ui/net/sf/briar/ui/invitation/LocationPanel.java index b3f52b3df1..a949113d56 100644 --- a/ui/net/sf/briar/ui/invitation/LocationPanel.java +++ b/ui/net/sf/briar/ui/invitation/LocationPanel.java @@ -5,13 +5,10 @@ import net.sf.briar.api.i18n.Stri18ng; import net.sf.briar.ui.wizard.DirectoryChooserPanel; import net.sf.briar.ui.wizard.Wizard; -import com.google.inject.Inject; - class LocationPanel extends DirectoryChooserPanel { private static final long serialVersionUID = 3788640725729516888L; - @Inject LocationPanel(Wizard wizard, I18n i18n) { super(wizard, "Location", "Password", "InvitationWorker", new Stri18ng("INVITATION_LOCATION_TITLE", i18n), diff --git a/ui/net/sf/briar/ui/invitation/OperatingSystemPanel.java b/ui/net/sf/briar/ui/invitation/OperatingSystemPanel.java index 777bc5b571..80f0116a9b 100644 --- a/ui/net/sf/briar/ui/invitation/OperatingSystemPanel.java +++ b/ui/net/sf/briar/ui/invitation/OperatingSystemPanel.java @@ -15,8 +15,6 @@ import net.sf.briar.api.i18n.Stri18ng; import net.sf.briar.ui.wizard.Wizard; import net.sf.briar.ui.wizard.WizardPanel; -import com.google.inject.Inject; - class OperatingSystemPanel extends WizardPanel { private static final long serialVersionUID = -8370132633634629466L; @@ -26,7 +24,6 @@ class OperatingSystemPanel extends WizardPanel { private final JRadioButton windowsButton, macButton, linuxButton; private final JRadioButton unknownButton; - @Inject OperatingSystemPanel(Wizard wizard, I18n i18n) { super(wizard, "OperatingSystem"); question = new Stri18ng("INVITATION_OPERATING_SYSTEM", i18n); diff --git a/ui/net/sf/briar/ui/invitation/PasswordPanel.java b/ui/net/sf/briar/ui/invitation/PasswordPanel.java index 343ee0a96e..273768c097 100644 --- a/ui/net/sf/briar/ui/invitation/PasswordPanel.java +++ b/ui/net/sf/briar/ui/invitation/PasswordPanel.java @@ -17,8 +17,6 @@ import net.sf.briar.api.i18n.Stri18ng; import net.sf.briar.ui.wizard.Wizard; import net.sf.briar.ui.wizard.WizardPanel; -import com.google.inject.Inject; - public class PasswordPanel extends WizardPanel { private static final long serialVersionUID = -1012132977732308293L; @@ -28,7 +26,6 @@ public class PasswordPanel extends WizardPanel { private final JLabel introLabel, enterPasswordLabel, confirmPasswordLabel; private final JPasswordField password1, password2; - @Inject PasswordPanel(Wizard wizard, ExistingUserPanel existingUserPanel, I18n i18n) { super(wizard, "Password"); diff --git a/ui/net/sf/briar/ui/invitation/UiInvitationModule.java b/ui/net/sf/briar/ui/invitation/UiInvitationModule.java index 742efd4fd3..82b78640f0 100644 --- a/ui/net/sf/briar/ui/invitation/UiInvitationModule.java +++ b/ui/net/sf/briar/ui/invitation/UiInvitationModule.java @@ -1,6 +1,5 @@ package net.sf.briar.ui.invitation; -import net.sf.briar.api.i18n.FontManager; import net.sf.briar.api.i18n.I18n; import net.sf.briar.api.invitation.InvitationParameters; import net.sf.briar.api.invitation.InvitationWorkerFactory; @@ -15,7 +14,7 @@ public class UiInvitationModule extends AbstractModule { protected void configure() {} @Provides @Singleton - InvitationWizard getInvitationWizard(I18n i18n, FontManager fontManager, + InvitationWizard getInvitationWizard(I18n i18n, InvitationWorkerFactory workerFactory) { InvitationWizard wizard = new InvitationWizard(i18n); new IntroPanel(wizard, i18n); @@ -25,7 +24,7 @@ public class UiInvitationModule extends AbstractModule { new PasswordPanel(wizard, userPanel, i18n); LocationPanel locationPanel = new LocationPanel(wizard, i18n); InvitationParameters parameters = new InvitationParametersImpl( - userPanel, osPanel, passwordPanel, locationPanel, fontManager); + userPanel, osPanel, passwordPanel, locationPanel); new InvitationWorkerPanel(wizard, workerFactory, parameters, i18n); return wizard; } diff --git a/ui/net/sf/briar/ui/setup/SetupParametersImpl.java b/ui/net/sf/briar/ui/setup/SetupParametersImpl.java index 0fb1b72a48..1545ad085f 100644 --- a/ui/net/sf/briar/ui/setup/SetupParametersImpl.java +++ b/ui/net/sf/briar/ui/setup/SetupParametersImpl.java @@ -2,7 +2,6 @@ package net.sf.briar.ui.setup; import java.io.File; -import net.sf.briar.api.i18n.FontManager; import net.sf.briar.api.setup.SetupParameters; class SetupParametersImpl implements SetupParameters { @@ -10,21 +9,15 @@ class SetupParametersImpl implements SetupParameters { private static final int EXE_HEADER_SIZE = 62976; private final LocationPanel locationPanel; - private final FontManager fontManager; - SetupParametersImpl(LocationPanel locationPanel, FontManager fontManager) { + SetupParametersImpl(LocationPanel locationPanel) { this.locationPanel = locationPanel; - this.fontManager = fontManager; } public File getChosenLocation() { return locationPanel.getChosenDirectory(); } - public String[] getBundledFontFilenames() { - return fontManager.getBundledFontFilenames(); - } - public long getExeHeaderSize() { return EXE_HEADER_SIZE; } diff --git a/ui/net/sf/briar/ui/setup/UiSetupModule.java b/ui/net/sf/briar/ui/setup/UiSetupModule.java index 26b8df46d8..3a6a96452c 100644 --- a/ui/net/sf/briar/ui/setup/UiSetupModule.java +++ b/ui/net/sf/briar/ui/setup/UiSetupModule.java @@ -22,8 +22,7 @@ public class UiSetupModule extends AbstractModule { new AlreadyInstalledPanel(wizard, i18n); new InstructionsPanel(wizard, i18n); LocationPanel locationPanel = new LocationPanel(wizard, i18n); - SetupParameters parameters = - new SetupParametersImpl(locationPanel, fontManager); + SetupParameters parameters = new SetupParametersImpl(locationPanel); new SetupWorkerPanel(wizard, workerFactory, parameters, i18n); return wizard; } -- GitLab