Added the ability to store transport configuration details in the

database - unlike transport properties, these are not shared with
contacts. For example, when using email as a transport, the address
for sending and receiving emails would be a transport property, while
the username and password for the email server would be transport
configuration details. Transport plugins can update their
configuration details atomically.

Also clarified the terminology for transport and subscription updates.
This commit is contained in:
akwizgran
2011-08-04 13:41:41 +01:00
parent ec29c4d1d3
commit 5cb4075cfd
19 changed files with 454 additions and 214 deletions

View File

@@ -5,14 +5,14 @@ import java.util.Map;
import java.util.TreeMap;
import net.sf.briar.api.protocol.Tags;
import net.sf.briar.api.protocol.Transports;
import net.sf.briar.api.protocol.TransportUpdate;
import net.sf.briar.api.serial.Consumer;
import net.sf.briar.api.serial.ObjectReader;
import net.sf.briar.api.serial.Reader;
import com.google.inject.Inject;
class TransportReader implements ObjectReader<Transports> {
class TransportReader implements ObjectReader<TransportUpdate> {
private final TransportFactory transportFactory;
@@ -21,32 +21,32 @@ class TransportReader implements ObjectReader<Transports> {
this.transportFactory = transportFactory;
}
public Transports readObject(Reader r) throws IOException {
public TransportUpdate readObject(Reader r) throws IOException {
// Initialise the consumer
Consumer counting = new CountingConsumer(Transports.MAX_SIZE);
Consumer counting = new CountingConsumer(TransportUpdate.MAX_SIZE);
// Read the data
r.addConsumer(counting);
r.readUserDefinedTag(Tags.TRANSPORTS);
// Transport maps are always written in delimited form
Map<String, Map<String, String>> outer =
Map<String, Map<String, String>> transports =
new TreeMap<String, Map<String, String>>();
r.readMapStart();
while(!r.hasMapEnd()) {
String name = r.readString(Transports.MAX_SIZE);
Map<String, String> inner = new TreeMap<String, String>();
String name = r.readString(TransportUpdate.MAX_SIZE);
Map<String, String> properties = new TreeMap<String, String>();
r.readMapStart();
while(!r.hasMapEnd()) {
String key = r.readString(Transports.MAX_SIZE);
String value = r.readString(Transports.MAX_SIZE);
inner.put(key, value);
String key = r.readString(TransportUpdate.MAX_SIZE);
String value = r.readString(TransportUpdate.MAX_SIZE);
properties.put(key, value);
}
r.readMapEnd();
outer.put(name, inner);
transports.put(name, properties);
}
r.readMapEnd();
long timestamp = r.readInt64();
r.removeConsumer(counting);
// Build and return the transports update
return transportFactory.createTransports(outer, timestamp);
// Build and return the transport update
return transportFactory.createTransports(transports, timestamp);
}
}