diff --git a/briar-desktop/libs/jnotify-0.93.jar b/briar-desktop/libs/jnotify-0.93.jar deleted file mode 100644 index b3169f5ca6222b0eaa953edaa0d5ced3b08a988d..0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..c4904349d7447018b3f06a9d1f632d90ac191773 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 0000000000000000000000000000000000000000..19ede477f63780d223790b82fbca89256f5dd7a9 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 0000000000000000000000000000000000000000..d7b55b69442578e75e55652eefa68229678960d7 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 0000000000000000000000000000000000000000..6a82249a62889d8986a76fd2e7b38584118b92e0 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 0000000000000000000000000000000000000000..9ec3860308466bcebb8dfd21f5c86a17006a6572 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 19a9e4aebfdd79eb2fe2a958c2312d2eb6653179..537e97ead05b750e3536dc0d734e734bbb4ff50e 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 b406827a95957e2cf5b561652f21420837c0ef9a..0000000000000000000000000000000000000000 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 eec65b5eb3197b63706b835bcdacc35f73bc24ad..8c4edee5f5d75d48b228e9dc2a412e8a7b51b166 100644 --- a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java +++ b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java @@ -19,7 +19,27 @@ JNotifyListener { protected abstract String[] getPathsToWatch(); + final private static Throwable loadError = tryLoad(); + + 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 void checkEnabled() throws IOException { + if (loadError != null) { + throw new IOException("JNotify not loaded", loadError); + } + } + public void start(Callback callback) throws IOException { + checkEnabled(); List<Integer> watches = new ArrayList<Integer>(); int mask = JNotify.FILE_CREATED; for(String path : getPathsToWatch()) { @@ -36,6 +56,7 @@ JNotifyListener { } public void stop() throws IOException { + checkEnabled(); List<Integer> watches; synchronized(this) { assert started; diff --git a/briar-tests/build.xml b/briar-tests/build.xml index 06a023d9181cbbae119773f0f2f3da64128eff7c..f5d288ba6ef8328500fb9393bf14c3b4e3ee6c8b 100644 --- a/briar-tests/build.xml +++ b/briar-tests/build.xml @@ -76,10 +76,11 @@ </javac> </target> <target name='test' depends='compile'> - <junit printsummary='on' fork='yes' forkmode='once'> + <junit printsummary='on' fork='yes' forkmode='once' haltonfailure='yes' showoutput='true'> <assertions> <enable/> </assertions> + <formatter type="plain" usefile="false"/> <classpath> <fileset refid='test-jars'/> <fileset refid='desktop-jars'/> @@ -90,7 +91,7 @@ <path refid='core-classes'/> <path refid='api-classes'/> </classpath> - <jvmarg value='-Djava.library.path=../briar-desktop/libs'/> + <sysproperty key='java.library.path' value='../briar-desktop/libs'/> <test name='org.briarproject.LockFairnessTest'/> <test name='org.briarproject.ProtocolIntegrationTest'/> <test name='org.briarproject.crypto.FortunaGeneratorTest'/> @@ -153,7 +154,7 @@ <path refid='core-classes'/> <path refid='api-classes'/> </classpath> - <jvmarg value='-Djava.library.path=../briar-desktop/libs'/> + <sysproperty key='java.library.path' value='../briar-desktop/libs'/> <test name='org.briarproject.db.H2DatabaseTest'/> </junit> </target> diff --git a/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java b/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java index ce083633a20da8c8f71ac86e2c9682bac274359e..427afe364ce6b04394c247d89921ad8244ef848b 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 0000000000000000000000000000000000000000..83feb7d5d4375fbe4ee3d316093e101c67b1006a --- /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 <javac> + +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) + {