mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Skeleton of modem plugin.
This commit is contained in:
@@ -52,7 +52,8 @@ class PluginManagerImpl implements PluginManager {
|
||||
private static final String[] ANDROID_DUPLEX_FACTORIES = new String[] {
|
||||
"net.sf.briar.plugins.droidtooth.DroidtoothPluginFactory",
|
||||
"net.sf.briar.plugins.tcp.LanTcpPluginFactory",
|
||||
"net.sf.briar.plugins.tcp.WanTcpPluginFactory"
|
||||
"net.sf.briar.plugins.tcp.WanTcpPluginFactory",
|
||||
"net.sf.briar.plugins.tor.TorPluginFactory"
|
||||
};
|
||||
|
||||
private static final String[] J2SE_SIMPLEX_FACTORIES = new String[] {
|
||||
@@ -61,6 +62,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
|
||||
private static final String[] J2SE_DUPLEX_FACTORIES = new String[] {
|
||||
"net.sf.briar.plugins.bluetooth.BluetoothPluginFactory",
|
||||
"net.sf.briar.plugins.modem.ModemPluginFactory",
|
||||
"net.sf.briar.plugins.tcp.LanTcpPluginFactory",
|
||||
"net.sf.briar.plugins.tcp.WanTcpPluginFactory",
|
||||
"net.sf.briar.plugins.tor.TorPluginFactory"
|
||||
|
||||
84
src/net/sf/briar/plugins/modem/ModemPlugin.java
Normal file
84
src/net/sf/briar/plugins/modem/ModemPlugin.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package net.sf.briar.plugins.modem;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.crypto.PseudoRandom;
|
||||
import net.sf.briar.api.plugins.PluginCallback;
|
||||
import net.sf.briar.api.plugins.PluginExecutor;
|
||||
import net.sf.briar.api.plugins.duplex.DuplexPlugin;
|
||||
import net.sf.briar.api.plugins.duplex.DuplexTransportConnection;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.util.StringUtils;
|
||||
|
||||
class ModemPlugin implements DuplexPlugin {
|
||||
|
||||
private static final byte[] TRANSPORT_ID =
|
||||
StringUtils.fromHexString("8f573867bedf54884b5868ee5d902832" +
|
||||
"ee5e522da84d0d431712bd672fbd2f79" +
|
||||
"262d27b93879b94ee9afbb80e7fc87fb");
|
||||
private static final TransportId ID = new TransportId(TRANSPORT_ID);
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ModemPlugin.class.getName());
|
||||
|
||||
private final Executor pluginExecutor;
|
||||
private final PluginCallback callback;
|
||||
private final long pollingInterval;
|
||||
|
||||
ModemPlugin(@PluginExecutor Executor pluginExecutor,
|
||||
PluginCallback callback, long pollingInterval) {
|
||||
this.pluginExecutor = pluginExecutor;
|
||||
this.callback = callback;
|
||||
this.pollingInterval = pollingInterval;
|
||||
}
|
||||
|
||||
public TransportId getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "MODEM_PLUGIN_NAME";
|
||||
}
|
||||
|
||||
public void start() throws IOException {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
public void stop() throws IOException {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
public boolean shouldPoll() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public long getPollingInterval() {
|
||||
return pollingInterval;
|
||||
}
|
||||
|
||||
public void poll(Collection<ContactId> connected) {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
public DuplexTransportConnection createConnection(ContactId c) {
|
||||
// FIXME
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean supportsInvitations() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public DuplexTransportConnection sendInvitation(PseudoRandom r,
|
||||
long timeout) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public DuplexTransportConnection acceptInvitation(PseudoRandom r,
|
||||
long timeout) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
27
src/net/sf/briar/plugins/modem/ModemPluginFactory.java
Normal file
27
src/net/sf/briar/plugins/modem/ModemPluginFactory.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package net.sf.briar.plugins.modem;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.h2.util.StringUtils;
|
||||
|
||||
import net.sf.briar.api.android.AndroidExecutor;
|
||||
import net.sf.briar.api.lifecycle.ShutdownManager;
|
||||
import net.sf.briar.api.plugins.PluginExecutor;
|
||||
import net.sf.briar.api.plugins.duplex.DuplexPlugin;
|
||||
import net.sf.briar.api.plugins.duplex.DuplexPluginCallback;
|
||||
import net.sf.briar.api.plugins.duplex.DuplexPluginFactory;
|
||||
import android.content.Context;
|
||||
|
||||
public class ModemPluginFactory implements DuplexPluginFactory {
|
||||
|
||||
private static final long POLLING_INTERVAL = 60L * 60L * 1000L; // 1 hour
|
||||
|
||||
public DuplexPlugin createPlugin(@PluginExecutor Executor pluginExecutor,
|
||||
AndroidExecutor androidExecutor, Context appContext,
|
||||
ShutdownManager shutdownManager, DuplexPluginCallback callback) {
|
||||
// This plugin is not enabled by default
|
||||
String enabled = callback.getConfig().get("enabled");
|
||||
if(StringUtils.isNullOrEmpty(enabled)) return null;
|
||||
return new ModemPlugin(pluginExecutor, callback, POLLING_INTERVAL);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user