mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Add method for checking whether contact supports transport.
This commit is contained in:
@@ -39,6 +39,12 @@ public interface RemovableDriveManager {
|
|||||||
*/
|
*/
|
||||||
RemovableDriveTask startWriterTask(ContactId c, TransportProperties p);
|
RemovableDriveTask startWriterTask(ContactId c, TransportProperties p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given contact has indicated support for the
|
||||||
|
* removable drive transport.
|
||||||
|
*/
|
||||||
|
boolean isTransportSupportedByContact(ContactId c) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if there is anything to send to the given contact.
|
* Returns true if there is anything to send to the given contact.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|||||||
import org.briarproject.bramble.api.plugin.file.RemovableDriveManager;
|
import org.briarproject.bramble.api.plugin.file.RemovableDriveManager;
|
||||||
import org.briarproject.bramble.api.plugin.file.RemovableDriveTask;
|
import org.briarproject.bramble.api.plugin.file.RemovableDriveTask;
|
||||||
import org.briarproject.bramble.api.properties.TransportProperties;
|
import org.briarproject.bramble.api.properties.TransportProperties;
|
||||||
|
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ import javax.annotation.concurrent.GuardedBy;
|
|||||||
import javax.annotation.concurrent.ThreadSafe;
|
import javax.annotation.concurrent.ThreadSafe;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.briarproject.bramble.api.plugin.file.RemovableDriveConstants.ID;
|
||||||
|
import static org.briarproject.bramble.api.plugin.file.RemovableDriveConstants.PROP_SUPPORTED;
|
||||||
import static org.briarproject.bramble.plugin.file.RemovableDrivePluginFactory.MAX_LATENCY;
|
import static org.briarproject.bramble.plugin.file.RemovableDrivePluginFactory.MAX_LATENCY;
|
||||||
|
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@@ -25,6 +28,7 @@ class RemovableDriveManagerImpl
|
|||||||
|
|
||||||
private final Executor ioExecutor;
|
private final Executor ioExecutor;
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
|
private final TransportPropertyManager transportPropertyManager;
|
||||||
private final RemovableDriveTaskFactory taskFactory;
|
private final RemovableDriveTaskFactory taskFactory;
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
@@ -34,10 +38,14 @@ class RemovableDriveManagerImpl
|
|||||||
private RemovableDriveTask writer = null;
|
private RemovableDriveTask writer = null;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RemovableDriveManagerImpl(@IoExecutor Executor ioExecutor,
|
RemovableDriveManagerImpl(
|
||||||
DatabaseComponent db, RemovableDriveTaskFactory taskFactory) {
|
@IoExecutor Executor ioExecutor,
|
||||||
|
DatabaseComponent db,
|
||||||
|
TransportPropertyManager transportPropertyManager,
|
||||||
|
RemovableDriveTaskFactory taskFactory) {
|
||||||
this.ioExecutor = ioExecutor;
|
this.ioExecutor = ioExecutor;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
this.transportPropertyManager = transportPropertyManager;
|
||||||
this.taskFactory = taskFactory;
|
this.taskFactory = taskFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +88,14 @@ class RemovableDriveManagerImpl
|
|||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTransportSupportedByContact(ContactId c)
|
||||||
|
throws DbException {
|
||||||
|
TransportProperties p =
|
||||||
|
transportPropertyManager.getRemoteProperties(c, ID);
|
||||||
|
return "true".equals(p.get(PROP_SUPPORTED));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWriterTaskNeeded(ContactId c) throws DbException {
|
public boolean isWriterTaskNeeded(ContactId c) throws DbException {
|
||||||
return db.transactionWithResult(true, txn ->
|
return db.transactionWithResult(true, txn ->
|
||||||
|
|||||||
Reference in New Issue
Block a user