diff --git a/components/net/sf/briar/plugins/bluetooth/BluetoothListener.java b/components/net/sf/briar/plugins/bluetooth/BluetoothListener.java index 57723b2ab5cffd924a96446e0f89700a9a76f97b..414abe7a6107505b20608742849ceb5fe77e7725 100644 --- a/components/net/sf/briar/plugins/bluetooth/BluetoothListener.java +++ b/components/net/sf/briar/plugins/bluetooth/BluetoothListener.java @@ -4,6 +4,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.bluetooth.BluetoothStateException; import javax.bluetooth.DeviceClass; @@ -17,6 +19,9 @@ import net.sf.briar.api.ContactId; class BluetoothListener implements DiscoveryListener { + private static final Logger LOG = + Logger.getLogger(BluetoothListener.class.getName()); + private static final int[] ATTRIBUTES = { 0x100 }; // Service name private final AtomicInteger searches = new AtomicInteger(1); @@ -48,11 +53,10 @@ class BluetoothListener implements DiscoveryListener { // Try to discover the services associated with the UUID try { discoveryAgent.searchServices(ATTRIBUTES, uuids, device, this); - searches.incrementAndGet(); } catch(BluetoothStateException e) { - // FIXME: Logging - e.printStackTrace(); + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); } + searches.incrementAndGet(); } public void inquiryCompleted(int discoveryType) { diff --git a/components/net/sf/briar/plugins/bluetooth/BluetoothPlugin.java b/components/net/sf/briar/plugins/bluetooth/BluetoothPlugin.java index 1c600eb37fe70ef69d1083e3acb418ac6be490ce..ab5d18474a39546099c7434a30d98c42f2e0576b 100644 --- a/components/net/sf/briar/plugins/bluetooth/BluetoothPlugin.java +++ b/components/net/sf/briar/plugins/bluetooth/BluetoothPlugin.java @@ -9,6 +9,8 @@ import java.util.Map.Entry; import java.util.Random; import java.util.TreeMap; import java.util.concurrent.Executor; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.bluetooth.BluetoothStateException; import javax.bluetooth.DiscoveryAgent; @@ -33,6 +35,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { public static final int TRANSPORT_ID = 2; private static final TransportId id = new TransportId(TRANSPORT_ID); + private static final Logger LOG = + Logger.getLogger(BluetoothPlugin.class.getName()); private final long pollingInterval; @@ -94,7 +98,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { try { localDevice.setDiscoverable(DiscoveryAgent.GIAC); } catch(BluetoothStateException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); } // Bind the port String url = "btspp://localhost:" + uuid + ";name=" + uuid; @@ -102,7 +106,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { try { scn = (StreamConnectionNotifier) Connector.open(url); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return; } synchronized(this) { @@ -110,7 +114,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { try { scn.close(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) + LOG.warning(e.getMessage()); } return; } @@ -152,7 +157,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { try { s = scn.acceptAndOpen(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return; } synchronized(this) { @@ -160,7 +165,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { try { s.close(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) + LOG.warning(e.getMessage()); } return; } @@ -243,10 +249,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { listener.wait(); } } catch(BluetoothStateException e) { - // FIXME: Logging - } catch(InterruptedException e) { - // FIXME: Logging - } + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); + } catch(InterruptedException ignored) {} return listener.getUrls(); } @@ -260,7 +264,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin { StreamConnection s = (StreamConnection) Connector.open(url); return new BluetoothTransportConnection(s); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return null; } } diff --git a/components/net/sf/briar/plugins/file/FilePlugin.java b/components/net/sf/briar/plugins/file/FilePlugin.java index 9cb3cd726d6e0e213d93b65559202193bc65ed6c..e6210ba48cd75bfd112c96b12e9249d37c19b69a 100644 --- a/components/net/sf/briar/plugins/file/FilePlugin.java +++ b/components/net/sf/briar/plugins/file/FilePlugin.java @@ -7,6 +7,8 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Map; import java.util.concurrent.Executor; +import java.util.logging.Level; +import java.util.logging.Logger; import net.sf.briar.api.ContactId; import net.sf.briar.api.transport.InvalidConfigException; @@ -23,6 +25,9 @@ import org.apache.commons.io.FileSystemUtils; abstract class FilePlugin extends AbstractPlugin implements BatchTransportPlugin { + private static final Logger LOG = + Logger.getLogger(FilePlugin.class.getName()); + protected abstract File chooseOutputDirectory(); protected abstract void writerFinished(File f); protected abstract void readerFinished(File f); @@ -56,6 +61,7 @@ implements BatchTransportPlugin { OutputStream out = new FileOutputStream(f); return new FileTransportWriter(f, out, capacity, this); } catch(IOException e) { + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); f.delete(); return null; } @@ -102,6 +108,7 @@ implements BatchTransportPlugin { } } } catch(IOException e) { + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return; } } diff --git a/components/net/sf/briar/plugins/file/RemovableDrivePlugin.java b/components/net/sf/briar/plugins/file/RemovableDrivePlugin.java index bbfd2bc29dd7d06033ffde00f46d0cb67fbfca6f..d24c084187d7aa91e1a11c58d3ea93f502bd1d46 100644 --- a/components/net/sf/briar/plugins/file/RemovableDrivePlugin.java +++ b/components/net/sf/briar/plugins/file/RemovableDrivePlugin.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.util.List; import java.util.Map; import java.util.concurrent.Executor; +import java.util.logging.Level; +import java.util.logging.Logger; import net.sf.briar.api.ContactId; import net.sf.briar.api.TransportId; @@ -18,6 +20,8 @@ implements RemovableDriveMonitor.Callback { public static final int TRANSPORT_ID = 0; private static final TransportId id = new TransportId(TRANSPORT_ID); + private static final Logger LOG = + Logger.getLogger(RemovableDrivePlugin.class.getName()); private final RemovableDriveFinder finder; private final RemovableDriveMonitor monitor; @@ -73,6 +77,7 @@ implements RemovableDriveMonitor.Callback { if(i == -1) return null; return drives.get(i); } catch(IOException e) { + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return null; } } diff --git a/components/net/sf/briar/plugins/socket/SocketPlugin.java b/components/net/sf/briar/plugins/socket/SocketPlugin.java index d790210f923da0200258b54dfe1a0a16132ede0d..2571c4eb61f0d30386ab9fda3688fc428d0201a9 100644 --- a/components/net/sf/briar/plugins/socket/SocketPlugin.java +++ b/components/net/sf/briar/plugins/socket/SocketPlugin.java @@ -6,6 +6,8 @@ import java.net.Socket; import java.net.SocketAddress; import java.util.Map; import java.util.concurrent.Executor; +import java.util.logging.Level; +import java.util.logging.Logger; import net.sf.briar.api.ContactId; import net.sf.briar.api.transport.InvalidConfigException; @@ -18,6 +20,9 @@ import net.sf.briar.plugins.AbstractPlugin; abstract class SocketPlugin extends AbstractPlugin implements StreamTransportPlugin { + private static final Logger LOG = + Logger.getLogger(SocketPlugin.class.getName()); + // These fields should be accessed with this's lock held protected StreamTransportCallback callback = null; protected ServerSocket socket = null; @@ -62,7 +67,7 @@ implements StreamTransportPlugin { if(addr == null || ss == null) return; ss.bind(addr); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return; } synchronized(this) { @@ -70,7 +75,8 @@ implements StreamTransportPlugin { try { ss.close(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) + LOG.warning(e.getMessage()); } return; } @@ -101,7 +107,7 @@ implements StreamTransportPlugin { try { s = ss.accept(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage()); return; } synchronized(this) { @@ -109,7 +115,8 @@ implements StreamTransportPlugin { try { s.close(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) + LOG.warning(e.getMessage()); } return; } @@ -138,7 +145,8 @@ implements StreamTransportPlugin { try { socket.close(); } catch(IOException e) { - // FIXME: Logging + if(LOG.isLoggable(Level.WARNING)) + LOG.warning(e.getMessage()); } socket = null; executor.execute(createBinder());