Added a convention to check if it's v1 of the library (which is necessary on some platforms)

This commit is contained in:
nathan 2015-11-15 17:39:31 +01:00
parent 409f1f7410
commit 6ece94345d

View File

@ -16,14 +16,36 @@
package dorkbox.util.jna.linux; package dorkbox.util.jna.linux;
import com.sun.jna.Library;
import com.sun.jna.Native; import com.sun.jna.Native;
/** /**
* Helper for AppIndicator, because it is absolutely mindboggling how those whom maintain the standard, can't agree to what that standard * Helper for AppIndicator, because it is absolutely mindboggling how those whom maintain the standard, can't agree to what that standard
* library naming convention or features rae is. We just try until we find one that work, and are able to map the symbols we need. * library naming convention or features set is. We just try until we find one that work, and are able to map the symbols we need.
*/ */
public public
class AppIndicatorQuery { class AppIndicatorQuery {
public static
Object get_v1() {
// version 1 is better than version 3, because of dumb shit redhat did.
// to wit, installing the google chrome browser, will ALSO install the correct appindicator library.
try {
Object appindicator = Native.loadLibrary("appindicator", Library.class);
if (appindicator != null) {
String s = appindicator.toString();
// make sure it's actually v1. If it's NOT v1 (ie: v3) then fallback to GTK version
if (s.indexOf(".so.1") < 1) {
return null;
}
}
return appindicator;
} catch (Throwable ignored) {
ignored.printStackTrace();
}
return null;
}
public static public static
Object get() { Object get() {
Object library; Object library;
@ -37,6 +59,8 @@ class AppIndicatorQuery {
} catch (Throwable ignored) { } catch (Throwable ignored) {
} }
// whoops. Symbolic links are bugged out. Look manually for it...
// version 1 is better than version 3, because of dumb shit redhat did. // version 1 is better than version 3, because of dumb shit redhat did.
try { try {
library = Native.loadLibrary("appindicator1", AppIndicator.class); library = Native.loadLibrary("appindicator1", AppIndicator.class);