Package org.gnome.gio
Interface DBusMessageFilterFunction
- All Superinterfaces:
FunctionPointer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
@Generated("io.github.jwharm.JavaGI")
public interface DBusMessageFilterFunction
extends FunctionPointer
Functional interface declaration of the
DBusMessageFilterFunction
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionrun
(DBusConnection connection, DBusMessage message, boolean incoming) Signature for function used in g_dbus_connection_add_filter().default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int, java.lang.foreign.MemorySegment)
method.default MemorySegment
upcall
(MemorySegment connection, MemorySegment message, int incoming, MemorySegment userData) Theupcall
method is called from native code.
-
Method Details
-
run
Signature for function used in g_dbus_connection_add_filter().A filter function is passed a
GDBusMessage
and expected to return aGDBusMessage
too. Passive filter functions that don't modify the message can simply return themessage
object:
Filter functions that wants to drop a message can simply returnstatic GDBusMessage * passive_filter (GDBusConnection *connection GDBusMessage *message, gboolean incoming, gpointer user_data) { // inspect @message return message; }
null
:
Finally, a filter function may modify a message by copying it:static GDBusMessage * drop_filter (GDBusConnection *connection GDBusMessage *message, gboolean incoming, gpointer user_data) { if (should_drop_message) { g_object_unref (message); message = NULL; } return message; }
If the returnedstatic GDBusMessage * modifying_filter (GDBusConnection *connection GDBusMessage *message, gboolean incoming, gpointer user_data) { GDBusMessage *copy; GError *error; error = NULL; copy = g_dbus_message_copy (message, &error); // handle @error being set g_object_unref (message); // modify @copy return copy; }
GDBusMessage
is different frommessage
and cannot be sent onconnection
(it could use features, such as file descriptors, not compatible withconnection
), then a warning is logged to standard error. Applications can check this ahead of time using g_dbus_message_to_blob() passing aGDBusCapabilityFlags
value obtained fromconnection
. -
upcall
default MemorySegment upcall(MemorySegment connection, MemorySegment message, int incoming, MemorySegment userData) Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.gio.DBusConnection, org.gnome.gio.DBusMessage, boolean)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int, java.lang.foreign.MemorySegment)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-