diff --git a/briar-desktop/.classpath b/briar-desktop/.classpath
index 9c8a71767..35d353c93 100644
--- a/briar-desktop/.classpath
+++ b/briar-desktop/.classpath
@@ -7,7 +7,7 @@
-
+
diff --git a/briar-desktop/libs/jnotify-0.93.jar b/briar-desktop/libs/jnotify-0.93.jar
deleted file mode 100644
index b3169f5ca..000000000
Binary files a/briar-desktop/libs/jnotify-0.93.jar and /dev/null differ
diff --git a/briar-desktop/libs/jnotify-0.94.jar b/briar-desktop/libs/jnotify-0.94.jar
new file mode 100644
index 000000000..c4904349d
Binary files /dev/null and b/briar-desktop/libs/jnotify-0.94.jar differ
diff --git a/briar-desktop/libs/jnotify-x86.dll b/briar-desktop/libs/jnotify-x86.dll
new file mode 100644
index 000000000..19ede477f
Binary files /dev/null and b/briar-desktop/libs/jnotify-x86.dll differ
diff --git a/briar-desktop/libs/jnotify-x86_64.dll b/briar-desktop/libs/jnotify-x86_64.dll
new file mode 100644
index 000000000..d7b55b694
Binary files /dev/null and b/briar-desktop/libs/jnotify-x86_64.dll differ
diff --git a/briar-desktop/libs/libjnotify-amd64.so b/briar-desktop/libs/libjnotify-amd64.so
new file mode 100644
index 000000000..6a82249a6
Binary files /dev/null and b/briar-desktop/libs/libjnotify-amd64.so differ
diff --git a/briar-desktop/libs/libjnotify-i386.so b/briar-desktop/libs/libjnotify-i386.so
new file mode 100644
index 000000000..9ec386030
Binary files /dev/null and b/briar-desktop/libs/libjnotify-i386.so differ
diff --git a/briar-desktop/libs/libjnotify.dylib b/briar-desktop/libs/libjnotify.dylib
index 19a9e4aeb..537e97ead 100644
Binary files a/briar-desktop/libs/libjnotify.dylib and b/briar-desktop/libs/libjnotify.dylib differ
diff --git a/briar-desktop/libs/libjnotify.so b/briar-desktop/libs/libjnotify.so
deleted file mode 100644
index b406827a9..000000000
Binary files a/briar-desktop/libs/libjnotify.so and /dev/null differ
diff --git a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java
index eec65b5eb..17116e05e 100644
--- a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java
+++ b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java
@@ -19,7 +19,36 @@ JNotifyListener {
protected abstract String[] getPathsToWatch();
+ private static boolean triedLoad = false;
+ private static Throwable loadError = null;
+
+ private static Throwable tryLoad() {
+ try {
+ Class.forName("net.contentobjects.jnotify.JNotify");
+ return null;
+ } catch (UnsatisfiedLinkError e) {
+ return e;
+ } catch (ClassNotFoundException e) {
+ return e;
+ }
+ }
+
+ public static synchronized void checkEnabled() throws IOException {
+ if (!triedLoad) {
+ loadError = tryLoad();
+ triedLoad = true;
+ }
+ if (loadError != null) {
+ // gymnastics due to having to support earlier Android APIs
+ // TODO(infinity0): add a utility that does this and convert other exceptions too
+ IOException e = new IOException("JNotify not loaded");
+ e.initCause(loadError);
+ throw e;
+ }
+ }
+
public void start(Callback callback) throws IOException {
+ checkEnabled();
List watches = new ArrayList();
int mask = JNotify.FILE_CREATED;
for(String path : getPathsToWatch()) {
@@ -36,6 +65,7 @@ JNotifyListener {
}
public void stop() throws IOException {
+ checkEnabled();
List watches;
synchronized(this) {
assert started;
diff --git a/briar-tests/.classpath b/briar-tests/.classpath
index c93e2a667..71ffe1890 100644
--- a/briar-tests/.classpath
+++ b/briar-tests/.classpath
@@ -5,7 +5,7 @@
-
+
diff --git a/briar-tests/build.xml b/briar-tests/build.xml
index 06a023d91..f5d288ba6 100644
--- a/briar-tests/build.xml
+++ b/briar-tests/build.xml
@@ -76,10 +76,11 @@
-
+
+
@@ -90,7 +91,7 @@
-
+
@@ -153,7 +154,7 @@
-
+
diff --git a/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java b/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java
index ce083633a..427afe364 100644
--- a/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java
+++ b/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java
@@ -82,7 +82,8 @@ public class UnixRemovableDriveMonitorTest extends BriarTestCase {
TestUtils.deleteTestDirectory(testDir);
}
- private RemovableDriveMonitor createMonitor(final File dir) {
+ private RemovableDriveMonitor createMonitor(final File dir) throws IOException {
+ UnixRemovableDriveMonitor.checkEnabled();
return new UnixRemovableDriveMonitor() {
@Override
protected String[] getPathsToWatch() {
diff --git a/jnotify-0.94.patch b/jnotify-0.94.patch
new file mode 100644
index 000000000..83feb7d5d
--- /dev/null
+++ b/jnotify-0.94.patch
@@ -0,0 +1,113 @@
+briar-desktop/libs/jnotify-0.94.jar is built via:
+$ wget "http://downloads.sourceforge.net/project/jnotify/jnotify/jnotify-0.94/jnotify-lib-0.94.zip?r=&ts=$(date +%s)"
+$ unzip -d jnotify-lib-0.94 jnotify-lib-0.94.zip && cd jnotify-lib-0.94
+$ unzip -d src jnotify-0.94-src.zip
+$ wget -O build.xml "http://jnotify.cvs.sourceforge.net/viewvc/jnotify/jnotify/build.xml?revision=1.7&pathrev=HEAD"
+$ wget -O build.properties "http://jnotify.cvs.sourceforge.net/viewvc/jnotify/jnotify/build.properties?revision=1.13"
+$ patch -lp1 < /path/to/this/patch
+$ ant build_java # if this fails with invalid flag: -g:{lines,vars,source}, try removing the debug attributes from
+
+diff -ru jnotify-0.94/net/contentobjects/jnotify/linux/JNotify_linux.java jnotify-0.94-briar/net/contentobjects/jnotify/linux/JNotify_linux.java
+--- jnotify-0.94/net/contentobjects/jnotify/linux/JNotify_linux.java 2012-04-25 00:03:54.000000000 +0100
++++ jnotify-0.94-briar/net/contentobjects/jnotify/linux/JNotify_linux.java 2014-01-30 12:31:41.959082350 +0000
+@@ -37,6 +37,7 @@
+ package net.contentobjects.jnotify.linux;
+
+ import net.contentobjects.jnotify.JNotifyException;
++import net.contentobjects.jnotify.Util;
+
+ public class JNotify_linux
+ {
+@@ -45,7 +46,7 @@
+
+ static
+ {
+- System.loadLibrary("jnotify");
++ Util.loadNative();
+ int res = nativeInit();
+ if (res != 0)
+ {
+diff -ru jnotify-0.94/net/contentobjects/jnotify/macosx/JNotify_macosx.java jnotify-0.94-briar/net/contentobjects/jnotify/macosx/JNotify_macosx.java
+--- jnotify-0.94/net/contentobjects/jnotify/macosx/JNotify_macosx.java 2010-01-26 19:43:42.000000000 +0000
++++ jnotify-0.94-briar/net/contentobjects/jnotify/macosx/JNotify_macosx.java 2014-01-30 12:31:41.959082350 +0000
+@@ -1,6 +1,7 @@
+ package net.contentobjects.jnotify.macosx;
+
+ import net.contentobjects.jnotify.JNotifyException;
++import net.contentobjects.jnotify.Util;
+
+ public class JNotify_macosx
+ {
+@@ -10,7 +11,7 @@
+
+ static
+ {
+- System.loadLibrary("jnotify"); //$NON-NLS-1$
++ Util.loadNative();
+ Thread thread = new Thread("FSEvent thread") //$NON-NLS-1$
+ {
+ public void run()
+diff -ru jnotify-0.94/net/contentobjects/jnotify/Util.java jnotify-0.94-briar/net/contentobjects/jnotify/Util.java
+--- jnotify-0.94/net/contentobjects/jnotify/Util.java 2006-02-14 08:18:10.000000000 +0000
++++ jnotify-0.94-briar/net/contentobjects/jnotify/Util.java 2014-01-30 12:31:41.959082350 +0000
+@@ -30,4 +30,26 @@
+ return "UNKNOWN";
+ }
+ }
++
++ public static void loadNative() throws UnsatisfiedLinkError {
++ try
++ {
++ try
++ {
++ System.loadLibrary("jnotify");
++ }
++ catch (UnsatisfiedLinkError e) {
++ System.loadLibrary("jnotify-" + System.getProperty("os.arch"));
++ }
++ }
++ catch (UnsatisfiedLinkError e)
++ {
++ // add some extra debugging info
++ String msg = "Error loading library, os.arch=" + System.getProperty("os.arch") +
++ ", java.library.path=" + System.getProperty("java.library.path");
++ UnsatisfiedLinkError e2 = new UnsatisfiedLinkError(msg);
++ e2.initCause(e);
++ throw e2;
++ }
++ }
+ }
+diff -ru jnotify-0.94/net/contentobjects/jnotify/win32/JNotify_win32.java jnotify-0.94-briar/net/contentobjects/jnotify/win32/JNotify_win32.java
+--- jnotify-0.94/net/contentobjects/jnotify/win32/JNotify_win32.java 2012-04-25 00:04:50.000000000 +0100
++++ jnotify-0.94-briar/net/contentobjects/jnotify/win32/JNotify_win32.java 2014-01-30 12:31:41.959082350 +0000
+@@ -39,28 +39,13 @@
+ package net.contentobjects.jnotify.win32;
+
+ import net.contentobjects.jnotify.JNotifyException;
+-
++import net.contentobjects.jnotify.Util;
+
+ public class JNotify_win32
+ {
+ static
+ {
+- try
+- {
+- if (System.getProperty("os.arch").equals("amd64"))
+- {
+- System.loadLibrary("jnotify_64bit");
+- }
+- else
+- {
+- System.loadLibrary("jnotify");
+- }
+- }
+- catch (UnsatisfiedLinkError e)
+- {
+- System.err.println("Error loading library, java.library.path=" + System.getProperty("java.library.path"));
+- throw e;
+- }
++ Util.loadNative();
+ int res = nativeInit();
+ if (res != 0)
+ {