Add removable drive manager with placeholder task implementations.

This commit is contained in:
akwizgran
2021-05-07 12:15:51 +01:00
parent 5fe22bcd57
commit 8f4a0ef030
18 changed files with 357 additions and 9 deletions

View File

@@ -0,0 +1,9 @@
package org.briarproject.bramble.api;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
@NotNullByDefault
public interface Consumer<T> {
void accept(T t);
}

View File

@@ -1,4 +1,4 @@
package org.briarproject.bramble.api.plugin;
package org.briarproject.bramble.api.plugin.file;
public interface FileConstants {

View File

@@ -1,4 +1,6 @@
package org.briarproject.bramble.api.plugin;
package org.briarproject.bramble.api.plugin.file;
import org.briarproject.bramble.api.plugin.TransportId;
public interface RemovableDriveConstants {

View File

@@ -0,0 +1,40 @@
package org.briarproject.bramble.api.plugin.file;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.io.File;
import javax.annotation.Nullable;
@NotNullByDefault
public interface RemovableDriveManager {
/**
* Returns the currently running reader task for the given contact,
* or null if no task is running.
*/
@Nullable
RemovableDriveTask getCurrentReaderTask(ContactId c);
/**
* Returns the currently running writer task for the given contact,
* or null if no task is running.
*/
@Nullable
RemovableDriveTask getCurrentWriterTask(ContactId c);
/**
* Starts and returns a reader task for the given contact, reading from
* the given file. If a reader task for the contact is already running,
* it will be returned and the file argument will be ignored.
*/
RemovableDriveTask startReaderTask(ContactId c, File f);
/**
* Starts and returns a writer task for the given contact, writing to
* the given file. If a writer task for the contact is already running,
* it will be returned and the file argument will be ignored.
*/
RemovableDriveTask startWriterTask(ContactId c, File f);
}

View File

@@ -0,0 +1,34 @@
package org.briarproject.bramble.api.plugin.file;
import org.briarproject.bramble.api.event.EventExecutor;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.io.File;
@NotNullByDefault
public interface RemovableDriveTask {
/**
* Returns the file that this task is reading from or writing to.
*/
File getFile();
/**
* Adds an observer to the task.
*/
void addObserver(Observer o);
/**
* Removes an observer from the task.
*/
void removeObserver(Observer o);
interface Observer {
@EventExecutor
void onProgress(long written, long total);
@EventExecutor
void onCompletion(boolean success);
}
}