Package org.eclipse.swt.internal
Class GDBus
- java.lang.Object
-
- org.eclipse.swt.internal.GDBus
-
public class GDBus extends java.lang.Object
General purpose DBus interface for SWT to interact with the operating system and vice versa. (See also WebkitGDBus for the webkit specific gdbus interface). This implementation uses GDBus (Gnome DBus) to implement the DBus interface. It can be reached via: gdbus call --session --dest org.eclipse.swt --object-path /org/eclipse/swt --method org.eclipse.swt.YOUR_METHOD YOUR_ARGS where YOUR_ARGS can be something like "MyString" or "['/tmp/myFile', '/tmp/myFile2']" etc.. For hygiene purposes, GVariant/GDBus native types/values should *never* leave this class. Convert on the way in/out. Technical notes: - Concurrent gdbus names can co-exist. (i.e, multiple session names in single proc). Meaning if you don't like org.eclipse.swt, you can add more session names. - This implementation is only a small subset of GDBus. E.g not all types are translated and not functionality implemented. Add them as you need them. - At time of writing (v 1.4), only handles incoming gdbus calls. But could be easily extended to handle outgoing gdbus calls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GDBus.GDBusMethod
-
Constructor Summary
Constructors Constructor Description GDBus()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object[]
convertGVariantToJava(long gVariant)
Converts the given GVariant(s) to Java Object(s).static long
convertJavaToGVariant(java.lang.Object javaObject)
Converts the given Java Object to a GVariant * representation.static void
init(GDBus.GDBusMethod[] methods, java.lang.String appName)
Instantiate GDBus for use by SWT.
-
-
-
Method Detail
-
init
public static void init(GDBus.GDBusMethod[] methods, java.lang.String appName)
Instantiate GDBus for use by SWT. Note, a new SWT instance that runs this "Steals" the session bus, but upon termination it returns the session back to the previous owner. To make this more flexible we append appName (derived from the application executable but can be set with the command-line argument -name) to the session name.- Parameters:
methods
- GDBus methods that we should handle.appName
- appName to append to GDBus object name if not null
-
convertGVariantToJava
public static java.lang.Object[] convertGVariantToJava(long gVariant)
Converts the given GVariant(s) to Java Object(s). If GVariant is not an array, this returns an Object[] array with one element. Only subset of types is currently supported, add type(s) as/when you need them. For inspiration, see WebkitGDBus.java:convert..()- Parameters:
gVariant
- a pointer to the native GVariant
-
convertJavaToGVariant
public static long convertJavaToGVariant(java.lang.Object javaObject) throws SWTException
Converts the given Java Object to a GVariant * representation. (Only subset of types is currently supported). We assume that input Object may contain invalid types.- Returns:
- pointer GVariant *
- Throws:
SWTException
-
-