mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Plugin factories.
This commit is contained in:
9
api/net/sf/briar/api/plugins/BatchPluginFactory.java
Normal file
9
api/net/sf/briar/api/plugins/BatchPluginFactory.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package net.sf.briar.api.plugins;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
public interface BatchPluginFactory {
|
||||||
|
|
||||||
|
BatchPlugin createPlugin(Executor executor,
|
||||||
|
BatchPluginCallback callback);
|
||||||
|
}
|
||||||
9
api/net/sf/briar/api/plugins/StreamPluginFactory.java
Normal file
9
api/net/sf/briar/api/plugins/StreamPluginFactory.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package net.sf.briar.api.plugins;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
public interface StreamPluginFactory {
|
||||||
|
|
||||||
|
StreamPlugin createPlugin(Executor executor,
|
||||||
|
StreamPluginCallback callback);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.sf.briar.plugins.bluetooth;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import net.sf.briar.api.plugins.StreamPluginCallback;
|
||||||
|
import net.sf.briar.api.plugins.StreamPlugin;
|
||||||
|
import net.sf.briar.api.plugins.StreamPluginFactory;
|
||||||
|
|
||||||
|
public class BluetoothPluginFactory implements StreamPluginFactory {
|
||||||
|
|
||||||
|
private static final long POLLING_INTERVAL = 3L * 60L * 1000L; // 3 mins
|
||||||
|
|
||||||
|
public StreamPlugin createPlugin(Executor executor,
|
||||||
|
StreamPluginCallback callback) {
|
||||||
|
return new BluetoothPlugin(executor, callback, POLLING_INTERVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.sf.briar.plugins.file;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import net.sf.briar.api.plugins.BatchPluginCallback;
|
||||||
|
import net.sf.briar.api.plugins.BatchPlugin;
|
||||||
|
import net.sf.briar.api.plugins.BatchPluginFactory;
|
||||||
|
import net.sf.briar.util.OsUtils;
|
||||||
|
|
||||||
|
public class RemovableDrivePluginFactory implements BatchPluginFactory {
|
||||||
|
|
||||||
|
private static final long POLLING_INTERVAL = 10L * 1000L; // 10 seconds
|
||||||
|
|
||||||
|
public BatchPlugin createPlugin(Executor executor,
|
||||||
|
BatchPluginCallback callback) {
|
||||||
|
RemovableDriveFinder finder;
|
||||||
|
RemovableDriveMonitor monitor;
|
||||||
|
if(OsUtils.isLinux()) {
|
||||||
|
finder = new LinuxRemovableDriveFinder();
|
||||||
|
monitor = new LinuxRemovableDriveMonitor();
|
||||||
|
} else if(OsUtils.isMac()) {
|
||||||
|
finder = new MacRemovableDriveFinder();
|
||||||
|
monitor = new MacRemovableDriveMonitor();
|
||||||
|
} else if(OsUtils.isWindows()) {
|
||||||
|
finder = new WindowsRemovableDriveFinder();
|
||||||
|
monitor = new PollingRemovableDriveMonitor(finder,
|
||||||
|
POLLING_INTERVAL);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new RemovableDrivePlugin(executor, callback, finder, monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.sf.briar.plugins.socket;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import net.sf.briar.api.plugins.StreamPluginCallback;
|
||||||
|
import net.sf.briar.api.plugins.StreamPlugin;
|
||||||
|
import net.sf.briar.api.plugins.StreamPluginFactory;
|
||||||
|
|
||||||
|
public class SimpleSocketPluginFactory implements StreamPluginFactory {
|
||||||
|
|
||||||
|
private static final long POLLING_INTERVAL = 5L * 60L * 1000L; // 5 mins
|
||||||
|
|
||||||
|
public StreamPlugin createPlugin(Executor executor,
|
||||||
|
StreamPluginCallback callback) {
|
||||||
|
return new SimpleSocketPlugin(executor, callback, POLLING_INTERVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user