mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Add removable drive manager with placeholder task implementations.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.bramble.api.plugin;
|
||||
package org.briarproject.bramble.api.plugin.file;
|
||||
|
||||
public interface FileConstants {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user