ENH: Replaces transport config with namespaced settings

This commit is contained in:
Santiago Torres
2016-01-17 15:42:45 -05:00
parent 2b02db3023
commit 190bb12964
27 changed files with 206 additions and 238 deletions

View File

@@ -17,5 +17,6 @@
<item>org.briarproject.sync.SyncModule</item> <item>org.briarproject.sync.SyncModule</item>
<item>org.briarproject.system.AndroidSystemModule</item> <item>org.briarproject.system.AndroidSystemModule</item>
<item>org.briarproject.transport.TransportModule</item> <item>org.briarproject.transport.TransportModule</item>
<item>org.briarproject.settings.SettingsModule</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -93,7 +93,7 @@ EventListener {
dbExecutor.execute(new Runnable() { dbExecutor.execute(new Runnable() {
public void run() { public void run() {
try { try {
settings = db.getSettings(); settings = db.getSettings("settings-activity");
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e); LOG.log(WARNING, e.toString(), e);

View File

@@ -23,7 +23,7 @@ import org.briarproject.android.util.HorizontalBorder;
import org.briarproject.android.util.LayoutUtils; import org.briarproject.android.util.LayoutUtils;
import org.briarproject.android.util.ListLoadingProgressBar; import org.briarproject.android.util.ListLoadingProgressBar;
import org.briarproject.api.Settings; import org.briarproject.api.Settings;
import org.briarproject.api.TransportConfig; import org.briarproject.api.settings.SettingsManager;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.db.DatabaseComponent; import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.db.DbException; import org.briarproject.api.db.DbException;
@@ -77,6 +77,7 @@ OnClickListener {
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject private volatile DatabaseComponent db; @Inject private volatile DatabaseComponent db;
@Inject private volatile SettingsManager settingsManager;
@Inject private volatile EventBus eventBus; @Inject private volatile EventBus eventBus;
private volatile Settings settings; private volatile Settings settings;
private volatile boolean bluetoothSetting = true, torSetting = false; private volatile boolean bluetoothSetting = true, torSetting = false;
@@ -262,14 +263,15 @@ OnClickListener {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
public void run() { public void run() {
try { try {
settings = settingsManager.getSettings("settings-activity");
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TransportConfig c = db.getConfig(new TransportId("bt")); Settings btSettings = settingsManager.getSettings("bt");
settings = db.getSettings(); Settings torSettings = settingsManager.getSettings("tor");
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
LOG.info("Loading settings took " + duration + " ms"); LOG.info("Loading settings took " + duration + " ms");
bluetoothSetting = c.getBoolean("enable", false); bluetoothSetting = btSettings.getBoolean("enable", false);
torSetting = settings.getBoolean("torOverWifi", false); torSetting = torSettings.getBoolean("torOverWifi", false);
displaySettings(); displaySettings();
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
@@ -338,6 +340,7 @@ OnClickListener {
} else if (view == torOverWifi || view == torOverWifiHint) { } else if (view == torOverWifi || view == torOverWifiHint) {
torSetting = !torSetting; torSetting = !torSetting;
storeTorSettings(); storeTorSettings();
displaySettings();
} else if (view == notifyPrivateMessages) { } else if (view == notifyPrivateMessages) {
Settings s = new Settings(); Settings s = new Settings();
s.putBoolean("notifyPrivateMessages", s.putBoolean("notifyPrivateMessages",
@@ -378,11 +381,8 @@ OnClickListener {
try { try {
Settings s = new Settings(); Settings s = new Settings();
s.putBoolean("torOverWifi", torSetting); s.putBoolean("torOverWifi", torSetting);
TransportConfig c = new TransportConfig();
c.putBoolean("torOverWifi", torSetting);
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
db.mergeSettings(s); settingsManager.mergeSettings(s, "tor");
db.mergeConfig(new TransportId("tor"), c);
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
LOG.info("Merging config took " + duration + " ms"); LOG.info("Merging config took " + duration + " ms");
@@ -398,10 +398,10 @@ OnClickListener {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
public void run() { public void run() {
try { try {
TransportConfig c = new TransportConfig(); Settings s = new Settings();
c.putBoolean("enable", bluetoothSetting); s.putBoolean("enable", bluetoothSetting);
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
db.mergeConfig(new TransportId("bt"), c); settingsManager.mergeSettings(s, "bt");
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
LOG.info("Merging config took " + duration + " ms"); LOG.info("Merging config took " + duration + " ms");
@@ -418,7 +418,7 @@ OnClickListener {
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
db.mergeSettings(settings); settingsManager.mergeSettings(settings, "settings-activity");
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
LOG.info("Merging settings took " + duration + " ms"); LOG.info("Merging settings took " + duration + " ms");

View File

@@ -8,7 +8,7 @@ import android.widget.Toast;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
import org.briarproject.android.util.AndroidUtils; import org.briarproject.android.util.AndroidUtils;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.android.ReferenceManager; import org.briarproject.api.android.ReferenceManager;
import org.briarproject.api.crypto.CryptoComponent; import org.briarproject.api.crypto.CryptoComponent;
@@ -170,12 +170,12 @@ implements InvitationListener {
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TransportConfig c = db.getConfig(new TransportId("bt")); Settings s = db.getSettings("bt");
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
LOG.info("Loading setting took " + duration + " ms"); LOG.info("Loading setting took " + duration + " ms");
leaveBluetoothEnabled = bluetoothWasEnabled leaveBluetoothEnabled = bluetoothWasEnabled
|| c.getBoolean("enable", false); || s.getBoolean("enable", false);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e); LOG.log(WARNING, e.toString(), e);

View File

@@ -137,7 +137,7 @@ class DroidtoothPlugin implements DuplexPlugin {
bind(); bind();
} else { } else {
wasDisabled = true; wasDisabled = true;
if (callback.getConfig().getBoolean("enable", false)) { if (callback.getSettings().getBoolean("enable", false)) {
if (adapter.enable()) LOG.info("Enabling Bluetooth"); if (adapter.enable()) LOG.info("Enabling Bluetooth");
else LOG.info("Could not enable Bluetooth"); else LOG.info("Could not enable Bluetooth");
} else { } else {

View File

@@ -11,7 +11,7 @@ import android.os.FileObserver;
import net.freehaven.tor.control.EventHandler; import net.freehaven.tor.control.EventHandler;
import net.freehaven.tor.control.TorControlConnection; import net.freehaven.tor.control.TorControlConnection;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
@@ -23,6 +23,7 @@ import org.briarproject.api.plugins.duplex.DuplexPlugin;
import org.briarproject.api.plugins.duplex.DuplexPluginCallback; import org.briarproject.api.plugins.duplex.DuplexPluginCallback;
import org.briarproject.api.plugins.duplex.DuplexTransportConnection; import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
import org.briarproject.api.system.LocationUtils; import org.briarproject.api.system.LocationUtils;
import org.briarproject.api.settings.SettingsManager;
import org.briarproject.util.StringUtils; import org.briarproject.util.StringUtils;
import java.io.EOFException; import java.io.EOFException;
@@ -349,7 +350,7 @@ class TorPlugin implements DuplexPlugin, EventHandler,
ioExecutor.execute(new Runnable() { ioExecutor.execute(new Runnable() {
public void run() { public void run() {
// If there's already a port number stored in config, reuse it // If there's already a port number stored in config, reuse it
String portString = callback.getConfig().get("port"); String portString = callback.getSettings().get("port");
int port; int port;
if (StringUtils.isNullOrEmpty(portString)) port = 0; if (StringUtils.isNullOrEmpty(portString)) port = 0;
else port = Integer.parseInt(portString); else port = Integer.parseInt(portString);
@@ -371,9 +372,9 @@ class TorPlugin implements DuplexPlugin, EventHandler,
socket = ss; socket = ss;
// Store the port number // Store the port number
final String localPort = String.valueOf(ss.getLocalPort()); final String localPort = String.valueOf(ss.getLocalPort());
TransportConfig c = new TransportConfig(); Settings s = new Settings();
c.put("port", localPort); s.put("port", localPort);
callback.mergeConfig(c); callback.mergeSettings(s);
// Create a hidden service if necessary // Create a hidden service if necessary
ioExecutor.execute(new Runnable() { ioExecutor.execute(new Runnable() {
public void run() { public void run() {
@@ -614,8 +615,8 @@ class TorPlugin implements DuplexPlugin, EventHandler,
} }
boolean blocked = TorNetworkMetadata.isTorProbablyBlocked( boolean blocked = TorNetworkMetadata.isTorProbablyBlocked(
country); country);
TransportConfig c = callback.getConfig(); Settings s = callback.getSettings();
boolean wifiOnly = c.getBoolean("torOverWifi", false); boolean wifiOnly = s.getBoolean("torOverWifi", false);
try { try {
if (!online) { if (!online) {

View File

@@ -1,16 +0,0 @@
package org.briarproject.api;
import java.util.Map;
public class TransportConfig extends StringMap {
private static final long serialVersionUID = 2330384620787778596L;
public TransportConfig(Map<String, String> m) {
super(m);
}
public TransportConfig() {
super();
}
}

View File

@@ -1,7 +1,6 @@
package org.briarproject.api.db; package org.briarproject.api.db;
import org.briarproject.api.Settings; import org.briarproject.api.Settings;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
@@ -139,9 +138,6 @@ public interface DatabaseComponent {
/** Returns all groups to which the user could subscribe. */ /** Returns all groups to which the user could subscribe. */
Collection<Group> getAvailableGroups() throws DbException; Collection<Group> getAvailableGroups() throws DbException;
/** Returns the configuration for the given transport. */
TransportConfig getConfig(TransportId t) throws DbException;
/** Returns the contact with the given ID. */ /** Returns the contact with the given ID. */
Contact getContact(ContactId c) throws DbException; Contact getContact(ContactId c) throws DbException;
@@ -194,8 +190,8 @@ public interface DatabaseComponent {
Map<ContactId, TransportProperties> getRemoteProperties(TransportId t) Map<ContactId, TransportProperties> getRemoteProperties(TransportId t)
throws DbException; throws DbException;
/** Returns all settings. */ /** Returns all settings for a given namespace. */
Settings getSettings() throws DbException; Settings getSettings(String namespace) throws DbException;
/** Returns all contacts who subscribe to the given group. */ /** Returns all contacts who subscribe to the given group. */
Collection<Contact> getSubscribers(GroupId g) throws DbException; Collection<Contact> getSubscribers(GroupId g) throws DbException;
@@ -220,12 +216,6 @@ public interface DatabaseComponent {
void incrementStreamCounter(ContactId c, TransportId t, long rotationPeriod) void incrementStreamCounter(ContactId c, TransportId t, long rotationPeriod)
throws DbException; throws DbException;
/**
* Merges the given configuration with existing configuration for the
* given transport.
*/
void mergeConfig(TransportId t, TransportConfig c) throws DbException;
/** /**
* Merges the given properties with the existing local properties for the * Merges the given properties with the existing local properties for the
* given transport. * given transport.
@@ -234,7 +224,7 @@ public interface DatabaseComponent {
throws DbException; throws DbException;
/** Merges the given settings with the existing settings. */ /** Merges the given settings with the existing settings. */
void mergeSettings(Settings s) throws DbException; void mergeSettings(Settings s, String namespace) throws DbException;
/** Processes an ack from the given contact. */ /** Processes an ack from the given contact. */
void receiveAck(ContactId c, Ack a) throws DbException; void receiveAck(ContactId c, Ack a) throws DbException;

View File

@@ -1,8 +1,8 @@
package org.briarproject.api.plugins; package org.briarproject.api.plugins;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.Settings;
import java.util.Map; import java.util.Map;
@@ -12,8 +12,8 @@ import java.util.Map;
*/ */
public interface PluginCallback { public interface PluginCallback {
/** Returns the plugin's configuration. */ /** Returns the plugin's settings */
TransportConfig getConfig(); Settings getSettings();
/** Returns the plugin's local transport properties. */ /** Returns the plugin's local transport properties. */
TransportProperties getLocalProperties(); TransportProperties getLocalProperties();
@@ -21,8 +21,8 @@ public interface PluginCallback {
/** Returns the plugin's remote transport properties. */ /** Returns the plugin's remote transport properties. */
Map<ContactId, TransportProperties> getRemoteProperties(); Map<ContactId, TransportProperties> getRemoteProperties();
/** Merges the given configuration with the plugin's configuration. */ /** Merges the given settings with the namespaced settings */
void mergeConfig(TransportConfig c); void mergeSettings(Settings s);
/** /**
* Merges the given properties with the plugin's local transport properties. * Merges the given properties with the plugin's local transport properties.

View File

@@ -0,0 +1,20 @@
package org.briarproject.api.settings;
import org.briarproject.api.db.DbException;
import org.briarproject.api.Settings;
public interface SettingsManager {
/**
* Returns the settings object identified by the provided namespace
* string
*/
Settings getSettings(String namespace) throws DbException;
/**
* Merges (read syncs) the provided settings identified by the provided namespace
* string
*/
void mergeSettings(Settings s, String namespace) throws DbException;
}

View File

@@ -1,7 +1,6 @@
package org.briarproject.db; package org.briarproject.db;
import org.briarproject.api.Settings; import org.briarproject.api.Settings;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
@@ -223,13 +222,6 @@ interface Database<T> {
*/ */
Collection<Group> getAvailableGroups(T txn) throws DbException; Collection<Group> getAvailableGroups(T txn) throws DbException;
/**
* Returns the configuration for the given transport.
* <p>
* Locking: read.
*/
TransportConfig getConfig(T txn, TransportId t) throws DbException;
/** /**
* Returns the contact with the given ID. * Returns the contact with the given ID.
* <p> * <p>
@@ -419,11 +411,11 @@ interface Database<T> {
int maxLength) throws DbException; int maxLength) throws DbException;
/** /**
* Returns all settings. * Returns all settings that belong to a namespace.
* <p> * <p>
* Locking: read. * Locking: read.
*/ */
Settings getSettings(T txn) throws DbException; Settings getSettings(T txn, String namespace) throws DbException;
/** /**
* Returns all contacts who subscribe to the given group. * Returns all contacts who subscribe to the given group.
@@ -524,15 +516,6 @@ interface Database<T> {
void lowerRequestedFlag(T txn, ContactId c, Collection<MessageId> requested) void lowerRequestedFlag(T txn, ContactId c, Collection<MessageId> requested)
throws DbException; throws DbException;
/**
* Merges the given configuration with the existing configuration for the
* given transport.
* <p>
* Locking: write.
*/
void mergeConfig(T txn, TransportId t, TransportConfig config)
throws DbException;
/** /**
* Merges the given properties with the existing local properties for the * Merges the given properties with the existing local properties for the
* given transport. * given transport.
@@ -547,7 +530,7 @@ interface Database<T> {
* <p> * <p>
* Locking: write. * Locking: write.
*/ */
void mergeSettings(T txn, Settings s) throws DbException; void mergeSettings(T txn, Settings s, String Namespace) throws DbException;
/** /**
* Marks a message as needing to be acknowledged to the given contact. * Marks a message as needing to be acknowledged to the given contact.

View File

@@ -1,7 +1,6 @@
package org.briarproject.db; package org.briarproject.db;
import org.briarproject.api.Settings; import org.briarproject.api.Settings;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
@@ -524,25 +523,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
} }
} }
public TransportConfig getConfig(TransportId t) throws DbException {
lock.readLock().lock();
try {
T txn = db.startTransaction();
try {
if (!db.containsTransport(txn, t))
throw new NoSuchTransportException();
TransportConfig config = db.getConfig(txn, t);
db.commitTransaction(txn);
return config;
} catch (DbException e) {
db.abortTransaction(txn);
throw e;
}
} finally {
lock.readLock().unlock();
}
}
public Contact getContact(ContactId c) throws DbException { public Contact getContact(ContactId c) throws DbException {
lock.readLock().lock(); lock.readLock().lock();
try { try {
@@ -808,12 +788,12 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
} }
} }
public Settings getSettings() throws DbException { public Settings getSettings(String namespace) throws DbException {
lock.readLock().lock(); lock.readLock().lock();
try { try {
T txn = db.startTransaction(); T txn = db.startTransaction();
try { try {
Settings s = db.getSettings(txn); Settings s = db.getSettings(txn, namespace);
db.commitTransaction(txn); db.commitTransaction(txn);
return s; return s;
} catch (DbException e) { } catch (DbException e) {
@@ -939,25 +919,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
} }
} }
public void mergeConfig(TransportId t, TransportConfig c)
throws DbException {
lock.writeLock().lock();
try {
T txn = db.startTransaction();
try {
if (!db.containsTransport(txn, t))
throw new NoSuchTransportException();
db.mergeConfig(txn, t, c);
db.commitTransaction(txn);
} catch (DbException e) {
db.abortTransaction(txn);
throw e;
}
} finally {
lock.writeLock().unlock();
}
}
public void mergeLocalProperties(TransportId t, TransportProperties p) public void mergeLocalProperties(TransportId t, TransportProperties p)
throws DbException { throws DbException {
boolean changed = false; boolean changed = false;
@@ -982,14 +943,14 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
if (changed) eventBus.broadcast(new LocalTransportsUpdatedEvent()); if (changed) eventBus.broadcast(new LocalTransportsUpdatedEvent());
} }
public void mergeSettings(Settings s) throws DbException { public void mergeSettings(Settings s, String namespace) throws DbException {
boolean changed = false; boolean changed = false;
lock.writeLock().lock(); lock.writeLock().lock();
try { try {
T txn = db.startTransaction(); T txn = db.startTransaction();
try { try {
if (!s.equals(db.getSettings(txn))) { if (!s.equals(db.getSettings(txn, namespace))) {
db.mergeSettings(txn, s); db.mergeSettings(txn, s, namespace);
changed = true; changed = true;
} }
db.commitTransaction(txn); db.commitTransaction(txn);

View File

@@ -1,7 +1,6 @@
package org.briarproject.db; package org.briarproject.db;
import org.briarproject.api.Settings; import org.briarproject.api.Settings;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
@@ -64,14 +63,15 @@ import static org.briarproject.db.ExponentialBackoff.calculateExpiry;
*/ */
abstract class JdbcDatabase implements Database<Connection> { abstract class JdbcDatabase implements Database<Connection> {
private static final int SCHEMA_VERSION = 11; private static final int SCHEMA_VERSION = 12;
private static final int MIN_SCHEMA_VERSION = 10; private static final int MIN_SCHEMA_VERSION = 12;
private static final String CREATE_SETTINGS = private static final String CREATE_SETTINGS =
"CREATE TABLE settings" "CREATE TABLE settings"
+ " (key VARCHAR NOT NULL," + " (key VARCHAR NOT NULL,"
+ " value VARCHAR NOT NULL," + " value VARCHAR NOT NULL,"
+ " PRIMARY KEY (key))"; + " namespace VARCHAR NOT NULL,"
+ " PRIMARY KEY (key, namespace))";
private static final String CREATE_LOCAL_AUTHORS = private static final String CREATE_LOCAL_AUTHORS =
"CREATE TABLE localAuthors" "CREATE TABLE localAuthors"
@@ -343,7 +343,7 @@ abstract class JdbcDatabase implements Database<Connection> {
Settings s = new Settings(); Settings s = new Settings();
s.put("schemaVersion", String.valueOf(SCHEMA_VERSION)); s.put("schemaVersion", String.valueOf(SCHEMA_VERSION));
s.put("minSchemaVersion", String.valueOf(MIN_SCHEMA_VERSION)); s.put("minSchemaVersion", String.valueOf(MIN_SCHEMA_VERSION));
mergeSettings(txn, s); mergeSettings(txn, s, "db");
} }
commitTransaction(txn); commitTransaction(txn);
} catch (DbException e) { } catch (DbException e) {
@@ -354,7 +354,7 @@ abstract class JdbcDatabase implements Database<Connection> {
private boolean checkSchemaVersion(Connection txn) throws DbException { private boolean checkSchemaVersion(Connection txn) throws DbException {
try { try {
Settings s = getSettings(txn); Settings s = getSettings(txn, "db");
int schemaVersion = Integer.valueOf(s.get("schemaVersion")); int schemaVersion = Integer.valueOf(s.get("schemaVersion"));
if (schemaVersion == SCHEMA_VERSION) return true; if (schemaVersion == SCHEMA_VERSION) return true;
if (schemaVersion < MIN_SCHEMA_VERSION) return false; if (schemaVersion < MIN_SCHEMA_VERSION) return false;
@@ -1179,28 +1179,6 @@ abstract class JdbcDatabase implements Database<Connection> {
} }
} }
public TransportConfig getConfig(Connection txn, TransportId t)
throws DbException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = "SELECT key, value FROM transportConfigs"
+ " WHERE transportId = ?";
ps = txn.prepareStatement(sql);
ps.setString(1, t.getString());
rs = ps.executeQuery();
TransportConfig c = new TransportConfig();
while (rs.next()) c.put(rs.getString(1), rs.getString(2));
rs.close();
ps.close();
return c;
} catch (SQLException e) {
tryToClose(rs);
tryToClose(ps);
throw new DbException(e);
}
}
public Contact getContact(Connection txn, ContactId c) throws DbException { public Contact getContact(Connection txn, ContactId c) throws DbException {
PreparedStatement ps = null; PreparedStatement ps = null;
ResultSet rs = null; ResultSet rs = null;
@@ -1921,12 +1899,13 @@ abstract class JdbcDatabase implements Database<Connection> {
} }
} }
public Settings getSettings(Connection txn) throws DbException { public Settings getSettings(Connection txn, String namespace) throws DbException {
PreparedStatement ps = null; PreparedStatement ps = null;
ResultSet rs = null; ResultSet rs = null;
try { try {
String sql = "SELECT key, value FROM settings"; String sql = "SELECT key, value FROM settings WHERE namespace = ?";
ps = txn.prepareStatement(sql); ps = txn.prepareStatement(sql);
ps.setString(1, namespace);
rs = ps.executeQuery(); rs = ps.executeQuery();
Settings s = new Settings(); Settings s = new Settings();
while (rs.next()) s.put(rs.getString(1), rs.getString(2)); while (rs.next()) s.put(rs.getString(1), rs.getString(2));
@@ -2373,12 +2352,6 @@ abstract class JdbcDatabase implements Database<Connection> {
} }
} }
public void mergeConfig(Connection txn, TransportId t, TransportConfig c)
throws DbException {
// Merge the new configuration with the existing one
mergeStringMap(txn, t, c, "transportConfigs");
}
public void mergeLocalProperties(Connection txn, TransportId t, public void mergeLocalProperties(Connection txn, TransportId t,
TransportProperties p) throws DbException { TransportProperties p) throws DbException {
// Merge the new properties with the existing ones // Merge the new properties with the existing ones
@@ -2446,15 +2419,16 @@ abstract class JdbcDatabase implements Database<Connection> {
} }
} }
public void mergeSettings(Connection txn, Settings s) throws DbException { public void mergeSettings(Connection txn, Settings s, String namespace) throws DbException {
PreparedStatement ps = null; PreparedStatement ps = null;
try { try {
// Update any settings that already exist // Update any settings that already exist
String sql = "UPDATE settings SET value = ? WHERE key = ?"; String sql = "UPDATE settings SET value = ? WHERE key = ? AND namespace = ?";
ps = txn.prepareStatement(sql); ps = txn.prepareStatement(sql);
for (Entry<String, String> e : s.entrySet()) { for (Entry<String, String> e : s.entrySet()) {
ps.setString(1, e.getValue()); ps.setString(1, e.getValue());
ps.setString(2, e.getKey()); ps.setString(2, e.getKey());
ps.setString(3, namespace);
ps.addBatch(); ps.addBatch();
} }
int[] batchAffected = ps.executeBatch(); int[] batchAffected = ps.executeBatch();
@@ -2464,13 +2438,14 @@ abstract class JdbcDatabase implements Database<Connection> {
if (batchAffected[i] > 1) throw new DbStateException(); if (batchAffected[i] > 1) throw new DbStateException();
} }
// Insert any settings that don't already exist // Insert any settings that don't already exist
sql = "INSERT INTO settings (key, value) VALUES (?, ?)"; sql = "INSERT INTO settings (key, value, namespace) VALUES (?, ?, ?)";
ps = txn.prepareStatement(sql); ps = txn.prepareStatement(sql);
int updateIndex = 0, inserted = 0; int updateIndex = 0, inserted = 0;
for (Entry<String, String> e : s.entrySet()) { for (Entry<String, String> e : s.entrySet()) {
if (batchAffected[updateIndex] == 0) { if (batchAffected[updateIndex] == 0) {
ps.setString(1, e.getKey()); ps.setString(1, e.getKey());
ps.setString(2, e.getValue()); ps.setString(2, e.getValue());
ps.setString(3, namespace);
ps.addBatch(); ps.addBatch();
inserted++; inserted++;
} }

View File

@@ -1,6 +1,5 @@
package org.briarproject.plugins; package org.briarproject.plugins;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
@@ -28,6 +27,8 @@ import org.briarproject.api.plugins.simplex.SimplexPluginFactory;
import org.briarproject.api.property.TransportPropertyManager; import org.briarproject.api.property.TransportPropertyManager;
import org.briarproject.api.system.Clock; import org.briarproject.api.system.Clock;
import org.briarproject.api.ui.UiCallback; import org.briarproject.api.ui.UiCallback;
import org.briarproject.api.Settings;
import org.briarproject.api.settings.SettingsManager;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -167,7 +168,9 @@ class PluginManagerImpl implements PluginManager {
public void run() { public void run() {
try { try {
TransportId id = factory.getId(); TransportId id = factory.getId();
SimplexCallback callback = new SimplexCallback(id); String namespace = id.toString();
SimplexCallback callback = new SimplexCallback(id, namespace);
SimplexPlugin plugin = factory.createPlugin(callback); SimplexPlugin plugin = factory.createPlugin(callback);
if (plugin == null) { if (plugin == null) {
if (LOG.isLoggable(INFO)) { if (LOG.isLoggable(INFO)) {
@@ -230,7 +233,8 @@ class PluginManagerImpl implements PluginManager {
public void run() { public void run() {
try { try {
TransportId id = factory.getId(); TransportId id = factory.getId();
DuplexCallback callback = new DuplexCallback(id); String namespace = id.toString();
DuplexCallback callback = new DuplexCallback(id, namespace);
DuplexPlugin plugin = factory.createPlugin(callback); DuplexPlugin plugin = factory.createPlugin(callback);
if (plugin == null) { if (plugin == null) {
if (LOG.isLoggable(INFO)) { if (LOG.isLoggable(INFO)) {
@@ -309,18 +313,22 @@ class PluginManagerImpl implements PluginManager {
private abstract class PluginCallbackImpl implements PluginCallback { private abstract class PluginCallbackImpl implements PluginCallback {
protected final TransportId id; protected final TransportId id;
protected final String namespace;
protected PluginCallbackImpl(TransportId id) { protected PluginCallbackImpl(TransportId id, String namespace) {
this.id = id; this.id = id;
this.namespace = namespace;
} }
public TransportConfig getConfig() { public Settings getSettings() {
try { try {
return db.getConfig(id); return db.getSettings(namespace);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return new TransportConfig(); return new Settings();
} }
} }
public TransportProperties getLocalProperties() { public TransportProperties getLocalProperties() {
@@ -343,12 +351,14 @@ class PluginManagerImpl implements PluginManager {
} }
} }
public void mergeConfig(TransportConfig c) { public void mergeSettings(Settings s) {
try { try {
db.mergeConfig(id, c); db.mergeSettings(s, namespace);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
} }
public void mergeLocalProperties(TransportProperties p) { public void mergeLocalProperties(TransportProperties p) {
@@ -386,8 +396,8 @@ class PluginManagerImpl implements PluginManager {
private class SimplexCallback extends PluginCallbackImpl private class SimplexCallback extends PluginCallbackImpl
implements SimplexPluginCallback { implements SimplexPluginCallback {
private SimplexCallback(TransportId id) { private SimplexCallback(TransportId id, String namespace) {
super(id); super(id, namespace);
} }
public void readerCreated(TransportConnectionReader r) { public void readerCreated(TransportConnectionReader r) {
@@ -402,8 +412,8 @@ class PluginManagerImpl implements PluginManager {
private class DuplexCallback extends PluginCallbackImpl private class DuplexCallback extends PluginCallbackImpl
implements DuplexPluginCallback { implements DuplexPluginCallback {
private DuplexCallback(TransportId id) { private DuplexCallback(TransportId id, String namespace) {
super(id); super(id, namespace);
} }
public void incomingConnectionCreated(DuplexTransportConnection d) { public void incomingConnectionCreated(DuplexTransportConnection d) {
@@ -415,4 +425,4 @@ class PluginManagerImpl implements PluginManager {
connectionManager.manageOutgoingConnection(c, id, d); connectionManager.manageOutgoingConnection(c, id, d);
} }
} }
} }

View File

@@ -76,4 +76,4 @@ class LanTcpPlugin extends TcpPlugin {
// Unrecognised prefix - may be compatible // Unrecognised prefix - may be compatible
return true; return true;
} }
} }

View File

@@ -0,0 +1,44 @@
package org.briarproject.settings;
import com.google.inject.Inject;
import org.briarproject.api.settings.SettingsManager;
import org.briarproject.api.Settings;
import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.db.DbException;
import java.util.logging.Logger;
import java.util.Collection;
class SettingsManagerImpl implements SettingsManager {
private final DatabaseComponent db;
private static final Logger LOG =
Logger.getLogger("SettingsManagerImpl");
@Inject
SettingsManagerImpl(DatabaseComponent db) {
this.db = db;
}
/**
* Returns the settings object identified by the provided namespace
* string
*/
@Override
public Settings getSettings(String namespace) throws DbException {
return db.getSettings(namespace);
}
/**
* Merges (read syncs) the provided settings identified by the provided namespace
* string
*/
@Override
public void mergeSettings(Settings s, String namespace) throws DbException {
db.mergeSettings(s, namespace);
}
}

View File

@@ -0,0 +1,13 @@
package org.briarproject.settings;
import com.google.inject.AbstractModule;
import org.briarproject.api.settings.SettingsManager;
public class SettingsModule extends AbstractModule {
@Override
protected void configure() {
bind(SettingsManager.class).to(SettingsManagerImpl.class);
}
}

View File

@@ -28,7 +28,7 @@ public class ModemPluginFactory implements DuplexPluginFactory {
public DuplexPlugin createPlugin(DuplexPluginCallback callback) { public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
// This plugin is not enabled by default // This plugin is not enabled by default
String enabled = callback.getConfig().get("enabled"); String enabled = callback.getSettings().get("enabled");
if (StringUtils.isNullOrEmpty(enabled)) return null; if (StringUtils.isNullOrEmpty(enabled)) return null;
return new ModemPlugin(modemFactory, serialPortList, callback, return new ModemPlugin(modemFactory, serialPortList, callback,
MAX_LATENCY); MAX_LATENCY);

View File

@@ -3,7 +3,7 @@ package org.briarproject.db;
import org.briarproject.BriarTestCase; import org.briarproject.BriarTestCase;
import org.briarproject.TestMessage; import org.briarproject.TestMessage;
import org.briarproject.TestUtils; import org.briarproject.TestUtils;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
@@ -611,13 +611,13 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).commitTransaction(txn); oneOf(database).commitTransaction(txn);
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class))); oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
// Check whether the transport is in the DB (which it's not) // Check whether the transport is in the DB (which it's not)
exactly(8).of(database).startTransaction(); exactly(6).of(database).startTransaction();
will(returnValue(txn)); will(returnValue(txn));
exactly(2).of(database).containsContact(txn, contactId); exactly(2).of(database).containsContact(txn, contactId);
will(returnValue(true)); will(returnValue(true));
exactly(8).of(database).containsTransport(txn, transportId); exactly(6).of(database).containsTransport(txn, transportId);
will(returnValue(false)); will(returnValue(false));
exactly(8).of(database).abortTransaction(txn); exactly(6).of(database).abortTransaction(txn);
}}); }});
DatabaseComponent db = createDatabaseComponent(database, eventBus, DatabaseComponent db = createDatabaseComponent(database, eventBus,
shutdown); shutdown);
@@ -625,13 +625,6 @@ public class DatabaseComponentImplTest extends BriarTestCase {
db.addLocalAuthor(localAuthor); db.addLocalAuthor(localAuthor);
assertEquals(contactId, db.addContact(author, localAuthorId)); assertEquals(contactId, db.addContact(author, localAuthorId));
try {
db.getConfig(transportId);
fail();
} catch (NoSuchTransportException expected) {
// Expected
}
try { try {
db.getLocalProperties(transportId); db.getLocalProperties(transportId);
fail(); fail();
@@ -646,13 +639,6 @@ public class DatabaseComponentImplTest extends BriarTestCase {
// Expected // Expected
} }
try {
db.mergeConfig(transportId, new TransportConfig());
fail();
} catch (NoSuchTransportException expected) {
// Expected
}
try { try {
db.mergeLocalProperties(transportId, new TransportProperties()); db.mergeLocalProperties(transportId, new TransportProperties());
fail(); fail();

View File

@@ -4,7 +4,6 @@ import org.briarproject.BriarTestCase;
import org.briarproject.TestDatabaseConfig; import org.briarproject.TestDatabaseConfig;
import org.briarproject.TestMessage; import org.briarproject.TestMessage;
import org.briarproject.TestUtils; import org.briarproject.TestUtils;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
@@ -21,6 +20,7 @@ import org.briarproject.api.sync.MessageId;
import org.briarproject.api.transport.IncomingKeys; import org.briarproject.api.transport.IncomingKeys;
import org.briarproject.api.transport.OutgoingKeys; import org.briarproject.api.transport.OutgoingKeys;
import org.briarproject.api.transport.TransportKeys; import org.briarproject.api.transport.TransportKeys;
import org.briarproject.api.Settings;
import org.briarproject.system.SystemClock; import org.briarproject.system.SystemClock;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@@ -568,7 +568,7 @@ public class H2DatabaseTest extends BriarTestCase {
} }
@Test @Test
public void testUpdateTransportConfig() throws Exception { public void testUpdateSettings() throws Exception {
Database<Connection> db = open(false); Database<Connection> db = open(false);
Connection txn = db.startTransaction(); Connection txn = db.startTransaction();
@@ -576,22 +576,22 @@ public class H2DatabaseTest extends BriarTestCase {
db.addTransport(txn, transportId, 123); db.addTransport(txn, transportId, 123);
// Set the transport config // Set the transport config
TransportConfig c = new TransportConfig(); Settings s = new Settings();
c.put("foo", "foo"); s.put("foo", "foo");
c.put("bar", "bar"); s.put("bar", "bar");
db.mergeConfig(txn, transportId, c); db.mergeSettings(txn, s, "test");
assertEquals(c, db.getConfig(txn, transportId)); assertEquals(s, db.getSettings(txn, "test"));
// Update one of the properties and add another // Update one of the properties and add another
TransportConfig c1 = new TransportConfig(); Settings s1 = new Settings();
c1.put("bar", "baz"); s1.put("bar", "baz");
c1.put("bam", "bam"); s1.put("bam", "bam");
db.mergeConfig(txn, transportId, c1); db.mergeSettings(txn, s1, "test");
TransportConfig merged = new TransportConfig(); Settings merged = new Settings();
merged.put("foo", "foo"); merged.put("foo", "foo");
merged.put("bar", "baz"); merged.put("bar", "baz");
merged.put("bam", "bam"); merged.put("bam", "bam");
assertEquals(merged, db.getConfig(txn, transportId)); assertEquals(merged, db.getSettings(txn, "test"));
db.commitTransaction(txn); db.commitTransaction(txn);
db.close(); db.close();

View File

@@ -1,6 +1,6 @@
package org.briarproject.plugins; package org.briarproject.plugins;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.crypto.PseudoRandom; import org.briarproject.api.crypto.PseudoRandom;
@@ -58,19 +58,19 @@ public abstract class DuplexClientTest extends DuplexTest {
protected static class ClientCallback implements DuplexPluginCallback { protected static class ClientCallback implements DuplexPluginCallback {
private TransportConfig config = null; private Settings settings = null;
private TransportProperties local = null; private TransportProperties local = null;
private Map<ContactId, TransportProperties> remote = null; private Map<ContactId, TransportProperties> remote = null;
public ClientCallback(TransportConfig config, TransportProperties local, public ClientCallback(Settings settings, TransportProperties local,
Map<ContactId, TransportProperties> remote) { Map<ContactId, TransportProperties> remote) {
this.config = config; this.settings = settings;
this.local = local; this.local = local;
this.remote = remote; this.remote = remote;
} }
public TransportConfig getConfig() { public Settings getSettings() {
return config; return settings;
} }
public TransportProperties getLocalProperties() { public TransportProperties getLocalProperties() {
@@ -81,8 +81,8 @@ public abstract class DuplexClientTest extends DuplexTest {
return remote; return remote;
} }
public void mergeConfig(TransportConfig c) { public void mergeSettings(Settings s) {
config = c; settings = s;
} }
public void mergeLocalProperties(TransportProperties p) { public void mergeLocalProperties(TransportProperties p) {

View File

@@ -1,6 +1,6 @@
package org.briarproject.plugins; package org.briarproject.plugins;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.plugins.duplex.DuplexPluginCallback; import org.briarproject.api.plugins.duplex.DuplexPluginCallback;
@@ -57,19 +57,19 @@ public abstract class DuplexServerTest extends DuplexTest {
private final CountDownLatch latch = new CountDownLatch(1); private final CountDownLatch latch = new CountDownLatch(1);
private TransportConfig config; private Settings settings;
private TransportProperties local; private TransportProperties local;
private Map<ContactId, TransportProperties> remote; private Map<ContactId, TransportProperties> remote;
public ServerCallback(TransportConfig config, TransportProperties local, public ServerCallback(Settings settings, TransportProperties local,
Map<ContactId, TransportProperties> remote) { Map<ContactId, TransportProperties> remote) {
this.config = config; this.settings = settings;
this.local = local; this.local = local;
this.remote = remote; this.remote = remote;
} }
public TransportConfig getConfig() { public Settings getSettings() {
return config; return settings;
} }
public TransportProperties getLocalProperties() { public TransportProperties getLocalProperties() {
@@ -80,8 +80,8 @@ public abstract class DuplexServerTest extends DuplexTest {
return remote; return remote;
} }
public void mergeConfig(TransportConfig c) { public void mergeSettings(Settings s) {
config = c; settings = s;
} }
public void mergeLocalProperties(TransportProperties p) { public void mergeLocalProperties(TransportProperties p) {

View File

@@ -1,6 +1,6 @@
package org.briarproject.plugins.bluetooth; package org.briarproject.plugins.bluetooth;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.plugins.DuplexClientTest; import org.briarproject.plugins.DuplexClientTest;
@@ -25,7 +25,7 @@ public class BluetoothClientTest extends DuplexClientTest {
Map<ContactId, TransportProperties> remote = Map<ContactId, TransportProperties> remote =
Collections.singletonMap(contactId, p); Collections.singletonMap(contactId, p);
// Create the plugin // Create the plugin
callback = new ClientCallback(new TransportConfig(), callback = new ClientCallback(new Settings(),
new TransportProperties(), remote); new TransportProperties(), remote);
plugin = new BluetoothPlugin(executor, new SystemClock(), plugin = new BluetoothPlugin(executor, new SystemClock(),
new SecureRandom(), callback, 0, 0); new SecureRandom(), callback, 0, 0);

View File

@@ -1,6 +1,6 @@
package org.briarproject.plugins.bluetooth; package org.briarproject.plugins.bluetooth;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.plugins.DuplexServerTest; import org.briarproject.plugins.DuplexServerTest;
import org.briarproject.system.SystemClock; import org.briarproject.system.SystemClock;
@@ -20,7 +20,7 @@ public class BluetoothServerTest extends DuplexServerTest {
TransportProperties local = new TransportProperties(); TransportProperties local = new TransportProperties();
local.put("uuid", BluetoothTest.EMPTY_UUID); local.put("uuid", BluetoothTest.EMPTY_UUID);
// Create the plugin // Create the plugin
callback = new ServerCallback(new TransportConfig(), local, callback = new ServerCallback(new Settings(), local,
Collections.singletonMap(contactId, new TransportProperties())); Collections.singletonMap(contactId, new TransportProperties()));
plugin = new BluetoothPlugin(executor, new SystemClock(), plugin = new BluetoothPlugin(executor, new SystemClock(),
new SecureRandom(), callback, 0, 0); new SecureRandom(), callback, 0, 0);

View File

@@ -1,6 +1,6 @@
package org.briarproject.plugins.tcp; package org.briarproject.plugins.tcp;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.plugins.DuplexClientTest; import org.briarproject.plugins.DuplexClientTest;
@@ -28,7 +28,7 @@ public class LanTcpClientTest extends DuplexClientTest {
Map<ContactId, TransportProperties> remote = Map<ContactId, TransportProperties> remote =
Collections.singletonMap(contactId, p); Collections.singletonMap(contactId, p);
// Create the plugin // Create the plugin
callback = new ClientCallback(new TransportConfig(), callback = new ClientCallback(new Settings(),
new TransportProperties(), remote); new TransportProperties(), remote);
plugin = new LanTcpPlugin(executor, callback, MAX_LATENCY, plugin = new LanTcpPlugin(executor, callback, MAX_LATENCY,
MAX_IDLE_TIME, POLLING_INTERVAL); MAX_IDLE_TIME, POLLING_INTERVAL);

View File

@@ -1,7 +1,7 @@
package org.briarproject.plugins.tcp; package org.briarproject.plugins.tcp;
import org.briarproject.BriarTestCase; import org.briarproject.BriarTestCase;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.plugins.duplex.DuplexPlugin; import org.briarproject.api.plugins.duplex.DuplexPlugin;
@@ -176,8 +176,8 @@ public class LanTcpPluginTest extends BriarTestCase {
private final CountDownLatch connectionsLatch = new CountDownLatch(1); private final CountDownLatch connectionsLatch = new CountDownLatch(1);
private final TransportProperties local = new TransportProperties(); private final TransportProperties local = new TransportProperties();
public TransportConfig getConfig() { public Settings getSettings() {
return new TransportConfig(); return new Settings();
} }
public TransportProperties getLocalProperties() { public TransportProperties getLocalProperties() {
@@ -188,7 +188,7 @@ public class LanTcpPluginTest extends BriarTestCase {
return remote; return remote;
} }
public void mergeConfig(TransportConfig c) {} public void mergeSettings(Settings s) {}
public void mergeLocalProperties(TransportProperties p) { public void mergeLocalProperties(TransportProperties p) {
local.putAll(p); local.putAll(p);

View File

@@ -1,6 +1,6 @@
package org.briarproject.plugins.tcp; package org.briarproject.plugins.tcp;
import org.briarproject.api.TransportConfig; import org.briarproject.api.Settings;
import org.briarproject.api.TransportProperties; import org.briarproject.api.TransportProperties;
import org.briarproject.plugins.DuplexServerTest; import org.briarproject.plugins.DuplexServerTest;
@@ -18,7 +18,7 @@ public class LanTcpServerTest extends DuplexServerTest {
private static final int POLLING_INTERVAL = 60 * 1000; private static final int POLLING_INTERVAL = 60 * 1000;
private LanTcpServerTest(Executor executor) { private LanTcpServerTest(Executor executor) {
callback = new ServerCallback(new TransportConfig(), callback = new ServerCallback(new Settings(),
new TransportProperties(), new TransportProperties(),
Collections.singletonMap(contactId, new TransportProperties())); Collections.singletonMap(contactId, new TransportProperties()));
plugin = new LanTcpPlugin(executor, callback, MAX_LATENCY, plugin = new LanTcpPlugin(executor, callback, MAX_LATENCY,