Class DBusMessage
- All Implemented Interfaces:
Proxy
DBusConnection.- Since:
- 2.26
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDBusMessage.Builder<B extends DBusMessage.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DBusMessage.DBusMessage(MemorySegment address) Create a DBusMessage proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DBusMessageasParent()Returns this instance as if it were its parent type.static DBusMessage.Builder<? extends DBusMessage.Builder> builder()ADBusMessage.Builderobject constructs aDBusMessagewith the specified properties.static longbytesNeeded(@org.jspecify.annotations.Nullable byte @Nullable [] blob) Utility function to calculate how many bytes are needed to completely deserialize the D-Bus message stored atblob.copy()Copiesmessage.The copy is a deep copy and the returnedGDBusMessageis completely identical except that it is guaranteed to not be locked.static DBusMessagefromBlob(@org.jspecify.annotations.Nullable byte @Nullable [] blob, Set<DBusCapabilityFlags> capabilities) Creates a newGDBusMessagefrom the data stored atblob.The byte order that the message was in can be retrieved using g_dbus_message_get_byte_order().static DBusMessagefromBlob(@org.jspecify.annotations.Nullable byte @Nullable [] blob, DBusCapabilityFlags... capabilities) Creates a newGDBusMessagefrom the data stored atblob.The byte order that the message was in can be retrieved using g_dbus_message_get_byte_order().@Nullable StringgetArg0()Convenience to get the first item in the body ofmessage.@Nullable StringConvenience to get the first item in the body ofmessage.@Nullable VariantgetBody()Gets the body of a message.Gets the byte order ofmessage.@Nullable StringConvenience getter for theDBusMessageHeaderField.DESTINATIONheader field.@Nullable StringConvenience getter for theDBusMessageHeaderField.ERROR_NAMEheader field.getFlags()Gets the flags formessage.@Nullable VariantgetHeader(DBusMessageHeaderField headerField) Gets a header field onmessage.byte[]Gets an array of all header fields on this DBusMessage that are set.@Nullable StringConvenience getter for theDBusMessageHeaderField.INTERFACEheader field.booleanChecks whether this DBusMessage is locked.@Nullable StringConvenience getter for theDBusMessageHeaderField.MEMBERheader field.Gets the type ofmessage.intConvenience getter for theDBusMessageHeaderField.NUM_UNIX_FDSheader field.@Nullable StringgetPath()Convenience getter for theDBusMessageHeaderField.PATHheader field.intConvenience getter for theDBusMessageHeaderField.REPLY_SERIALheader field.@Nullable StringConvenience getter for theDBusMessageHeaderField.SENDERheader field.intGets the serial formessage.Convenience getter for theDBusMessageHeaderField.SIGNATUREheader field.static @Nullable TypegetType()Get the GType of the DBusMessage class@Nullable UnixFDListGets the UNIX file descriptors associated withmessage,if any.voidlock()If this DBusMessage is locked, does nothing.static DBusMessagemethodCall(@Nullable String name, String path, @Nullable String interface_, String method) Creates a newGDBusMessagefor a method call.newMethodError(String errorName, String errorMessageFormat, Object... varargs) Creates a newGDBusMessagethat is an error reply tomethodCallMessage.newMethodErrorLiteral(String errorName, String errorMessage) Creates a newGDBusMessagethat is an error reply tomethodCallMessage.Creates a newGDBusMessagethat is a reply tomethodCallMessage.print(int indent) Produces a human-readable multi-line description ofmessage.voidSets the bodymessage.As a side-effect theDBusMessageHeaderField.SIGNATUREheader field is set to the type string ofbody(or cleared ifbodyisnull).voidsetByteOrder(DBusMessageByteOrder byteOrder) Sets the byte order ofmessage.voidsetDestination(@Nullable String value) Convenience setter for theDBusMessageHeaderField.DESTINATIONheader field.voidsetErrorName(String value) Convenience setter for theDBusMessageHeaderField.ERROR_NAMEheader field.voidsetFlags(Set<DBusMessageFlags> flags) Sets the flags to set onmessage.voidsetFlags(DBusMessageFlags... flags) Sets the flags to set onmessage.voidsetHeader(DBusMessageHeaderField headerField, @Nullable Variant value) Sets a header field onmessage.voidsetInterface(@Nullable String value) Convenience setter for theDBusMessageHeaderField.INTERFACEheader field.voidConvenience setter for theDBusMessageHeaderField.MEMBERheader field.voidSets this DBusMessage to be oftype.voidsetNumUnixFds(int value) Convenience setter for theDBusMessageHeaderField.NUM_UNIX_FDSheader field.voidConvenience setter for theDBusMessageHeaderField.PATHheader field.voidsetReplySerial(int value) Convenience setter for theDBusMessageHeaderField.REPLY_SERIALheader field.voidConvenience setter for theDBusMessageHeaderField.SENDERheader field.voidsetSerial(int serial) Sets the serial formessage.voidsetSignature(@Nullable String value) Convenience setter for theDBusMessageHeaderField.SIGNATUREheader field.voidsetUnixFdList(@Nullable UnixFDList fdList) Sets the UNIX file descriptors associated withmessage.As a side-effect theDBusMessageHeaderField.NUM_UNIX_FDSheader field is set to the number of fds infdList(or cleared iffdListisnull).static DBusMessageCreates a newGDBusMessagefor a signal emission.byte[]toBlob(Set<DBusCapabilityFlags> capabilities) Serializes this DBusMessage to a blob.byte[]toBlob(DBusCapabilityFlags... capabilities) Serializes this DBusMessage to a blob.booleantoGerror()If this DBusMessage is not of typeDBusMessageType.ERRORdoes nothing and returnsfalse.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
DBusMessage
Create a DBusMessage proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
DBusMessage
public DBusMessage()Creates a new DBusMessage.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
fromBlob
public static DBusMessage fromBlob(@org.jspecify.annotations.Nullable byte @Nullable [] blob, Set<DBusCapabilityFlags> capabilities) throws GErrorException Creates a newGDBusMessagefrom the data stored atblob.The byte order that the message was in can be retrieved using g_dbus_message_get_byte_order().If the
blobcannot be parsed, contains invalid fields, or contains invalid headers,IOErrorEnum.INVALID_ARGUMENTwill be returned.- Parameters:
blob- A blob representing a binary D-Bus message.capabilities- AGDBusCapabilityFlagsdescribing what protocol features are supported.- Returns:
- A new
GDBusMessageornulliferroris set. Free with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.26
-
fromBlob
public static DBusMessage fromBlob(@org.jspecify.annotations.Nullable byte @Nullable [] blob, DBusCapabilityFlags... capabilities) throws GErrorException Creates a newGDBusMessagefrom the data stored atblob.The byte order that the message was in can be retrieved using g_dbus_message_get_byte_order().If the
blobcannot be parsed, contains invalid fields, or contains invalid headers,IOErrorEnum.INVALID_ARGUMENTwill be returned.- Parameters:
blob- A blob representing a binary D-Bus message.capabilities- AGDBusCapabilityFlagsdescribing what protocol features are supported.- Returns:
- A new
GDBusMessageornulliferroris set. Free with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.26
-
methodCall
public static DBusMessage methodCall(@Nullable String name, String path, @Nullable String interface_, String method) Creates a newGDBusMessagefor a method call.- Parameters:
name- A valid D-Bus name ornull.path- A valid object path.interface_- A valid D-Bus interface name ornull.method- A valid method name.- Returns:
- A
GDBusMessage. Free with g_object_unref(). - Since:
- 2.26
-
signal
Creates a newGDBusMessagefor a signal emission.- Parameters:
path- A valid object path.interface_- A valid D-Bus interface name.signal- A valid signal name.- Returns:
- A
GDBusMessage. Free with g_object_unref(). - Since:
- 2.26
-
bytesNeeded
public static long bytesNeeded(@org.jspecify.annotations.Nullable byte @Nullable [] blob) throws GErrorException Utility function to calculate how many bytes are needed to completely deserialize the D-Bus message stored atblob.- Parameters:
blob- A blob representing a binary D-Bus message.- Returns:
- Number of bytes needed or -1 if
erroris set (e.g. ifblobcontains invalid data or not enough data is available to determine the size). - Throws:
GErrorException- seeGError- Since:
- 2.26
-
copy
Copiesmessage.The copy is a deep copy and the returnedGDBusMessageis completely identical except that it is guaranteed to not be locked.This operation can fail if e.g. this DBusMessage contains file descriptors and the per-process or system-wide open files limit is reached.
- Returns:
- A new
GDBusMessageornulliferroris set. Free with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.26
-
getArg0
Convenience to get the first item in the body ofmessage.See
getArg0Path()for returning object-path-typed arg0 values.- Returns:
- The string item or
nullif the first item in the body of this DBusMessage is not a string. - Since:
- 2.26
-
getArg0Path
-
getBody
Gets the body of a message.- Returns:
- A
GVariantornullif the body is empty. Do not free, it is owned bymessage. - Since:
- 2.26
-
getByteOrder
-
getDestination
Convenience getter for theDBusMessageHeaderField.DESTINATIONheader field.- Returns:
- The value.
- Since:
- 2.26
-
getErrorName
Convenience getter for theDBusMessageHeaderField.ERROR_NAMEheader field.- Returns:
- The value.
- Since:
- 2.26
-
getFlags
Gets the flags formessage.- Returns:
- Flags that are set (typically values from the
GDBusMessageFlagsenumeration bitwise ORed together). - Since:
- 2.26
-
getHeader
Gets a header field onmessage.The caller is responsible for checking the type of the returned
GVariantmatches what is expected.- Parameters:
headerField- A 8-bit unsigned integer (typically a value from theGDBusMessageHeaderFieldenumeration)- Returns:
- A
GVariantwith the value if the header was found,nullotherwise. Do not free, it is owned bymessage. - Since:
- 2.26
-
getHeaderFields
public byte[] getHeaderFields()Gets an array of all header fields on this DBusMessage that are set.- Returns:
- An array of header fields
terminated by
DBusMessageHeaderField.INVALID. Each element is aguchar. Free with g_free(). - Since:
- 2.26
-
getInterface
Convenience getter for theDBusMessageHeaderField.INTERFACEheader field.- Returns:
- The value.
- Since:
- 2.26
-
getLocked
public boolean getLocked()Checks whether this DBusMessage is locked. To monitor changes to this value, connect to theGObject::notify signal to listen for changes on theGDBusMessage:locked property.- Returns:
trueif this DBusMessage is locked,falseotherwise.- Since:
- 2.26
-
getMember
Convenience getter for theDBusMessageHeaderField.MEMBERheader field.- Returns:
- The value.
- Since:
- 2.26
-
getMessageType
Gets the type ofmessage.- Returns:
- A 8-bit unsigned integer (typically a value from the
GDBusMessageTypeenumeration). - Since:
- 2.26
-
getNumUnixFds
public int getNumUnixFds()Convenience getter for theDBusMessageHeaderField.NUM_UNIX_FDSheader field.- Returns:
- The value.
- Since:
- 2.26
-
getPath
Convenience getter for theDBusMessageHeaderField.PATHheader field.- Returns:
- The value.
- Since:
- 2.26
-
getReplySerial
public int getReplySerial()Convenience getter for theDBusMessageHeaderField.REPLY_SERIALheader field.- Returns:
- The value.
- Since:
- 2.26
-
getSender
Convenience getter for theDBusMessageHeaderField.SENDERheader field.- Returns:
- The value.
- Since:
- 2.26
-
getSerial
public int getSerial()Gets the serial formessage.- Returns:
- A
guint32. - Since:
- 2.26
-
getSignature
Convenience getter for theDBusMessageHeaderField.SIGNATUREheader field.This will always be non-
null, but may be an empty string.- Returns:
- The value.
- Since:
- 2.26
-
getUnixFdList
Gets the UNIX file descriptors associated withmessage,if any.This method is only available on UNIX.
The file descriptors normally correspond to
G_VARIANT_TYPE_HANDLEvalues in the body of the message. For example, if g_variant_get_handle() returns 5, that is intended to be a reference to the file descriptor that can be accessed byg_unix_fd_list_get (list, 5, ...).- Returns:
- A
GUnixFDListornullif no file descriptors are associated. Do not free, this object is owned bymessage. - Since:
- 2.26
-
lock
public void lock()If this DBusMessage is locked, does nothing. Otherwise locks the message.- Since:
- 2.26
-
newMethodError
Creates a newGDBusMessagethat is an error reply tomethodCallMessage.- Parameters:
errorName- A valid D-Bus error name.errorMessageFormat- The D-Bus error message in a printf() format.varargs- Arguments forerrorMessageFormat.- Returns:
- A
GDBusMessage. Free with g_object_unref(). - Since:
- 2.26
-
newMethodErrorLiteral
Creates a newGDBusMessagethat is an error reply tomethodCallMessage.- Parameters:
errorName- A valid D-Bus error name.errorMessage- The D-Bus error message.- Returns:
- A
GDBusMessage. Free with g_object_unref(). - Since:
- 2.26
-
newMethodReply
Creates a newGDBusMessagethat is a reply tomethodCallMessage.- Returns:
GDBusMessage. Free with g_object_unref().- Since:
- 2.26
-
print
Produces a human-readable multi-line description ofmessage.The contents of the description has no ABI guarantees, the contents and formatting is subject to change at any time. Typical output looks something like this:
orFlags: none Version: 0 Serial: 4 Headers: path -> objectpath '/org/gtk/GDBus/TestObject' interface -> 'org.gtk.GDBus.TestInterface' member -> 'GimmeStdout' destination -> ':1.146' Body: () UNIX File Descriptors: (none)Flags: no-reply-expected Version: 0 Serial: 477 Headers: reply-serial -> uint32 4 destination -> ':1.159' sender -> ':1.146' num-unix-fds -> uint32 1 Body: () UNIX File Descriptors: fd 12: dev=0:10,mode=020620,ino=5,uid=500,gid=5,rdev=136:2,size=0,atime=1273085037,mtime=1273085851,ctime=1272982635- Parameters:
indent- Indentation level.- Returns:
- A string that should be freed with
GLib.free(java.lang.foreign.MemorySegment). - Since:
- 2.26
-
setBody
Sets the bodymessage.As a side-effect theDBusMessageHeaderField.SIGNATUREheader field is set to the type string ofbody(or cleared ifbodyisnull).If
bodyis floating, this DBusMessage assumes ownership ofbody.- Parameters:
body- Eithernullor aGVariantthat is a tuple.- Since:
- 2.26
-
setByteOrder
Sets the byte order ofmessage.- Parameters:
byteOrder- The byte order.
-
setDestination
Convenience setter for theDBusMessageHeaderField.DESTINATIONheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setErrorName
Convenience setter for theDBusMessageHeaderField.ERROR_NAMEheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setFlags
Sets the flags to set onmessage.- Parameters:
flags- Flags for this DBusMessage that are set (typically values from theGDBusMessageFlagsenumeration bitwise ORed together).- Since:
- 2.26
-
setFlags
Sets the flags to set onmessage.- Parameters:
flags- Flags for this DBusMessage that are set (typically values from theGDBusMessageFlagsenumeration bitwise ORed together).- Since:
- 2.26
-
setHeader
Sets a header field onmessage.If
valueis floating, this DBusMessage assumes ownership ofvalue.- Parameters:
headerField- A 8-bit unsigned integer (typically a value from theGDBusMessageHeaderFieldenumeration)value- AGVariantto set the header field ornullto clear the header field.- Since:
- 2.26
-
setInterface
Convenience setter for theDBusMessageHeaderField.INTERFACEheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setMember
Convenience setter for theDBusMessageHeaderField.MEMBERheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setMessageType
Sets this DBusMessage to be oftype.- Parameters:
type- A 8-bit unsigned integer (typically a value from theGDBusMessageTypeenumeration).- Since:
- 2.26
-
setNumUnixFds
public void setNumUnixFds(int value) Convenience setter for theDBusMessageHeaderField.NUM_UNIX_FDSheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setPath
Convenience setter for theDBusMessageHeaderField.PATHheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setReplySerial
public void setReplySerial(int value) Convenience setter for theDBusMessageHeaderField.REPLY_SERIALheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setSender
Convenience setter for theDBusMessageHeaderField.SENDERheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setSerial
public void setSerial(int serial) Sets the serial formessage.The D-Bus specification does not allow the
serialto be zero.- Parameters:
serial- Aguint32, which must not be zero.- Since:
- 2.26
-
setSignature
Convenience setter for theDBusMessageHeaderField.SIGNATUREheader field.- Parameters:
value- The value to set.- Since:
- 2.26
-
setUnixFdList
Sets the UNIX file descriptors associated withmessage.As a side-effect theDBusMessageHeaderField.NUM_UNIX_FDSheader field is set to the number of fds infdList(or cleared iffdListisnull).This method is only available on UNIX.
When designing D-Bus APIs that are intended to be interoperable, please note that non-GDBus implementations of D-Bus can usually only access file descriptors if they are referenced by a value of type
G_VARIANT_TYPE_HANDLEin the body of the message.- Parameters:
fdList- AGUnixFDListornull.- Since:
- 2.26
-
toBlob
Serializes this DBusMessage to a blob. The byte order returned by g_dbus_message_get_byte_order() will be used.- Parameters:
capabilities- AGDBusCapabilityFlagsdescribing what protocol features are supported.- Returns:
- A pointer to a
valid binary D-Bus message of
outSizebytes generated by this DBusMessage ornulliferroris set. Free with g_free(). - Throws:
GErrorException- seeGError- Since:
- 2.26
-
toBlob
Serializes this DBusMessage to a blob. The byte order returned by g_dbus_message_get_byte_order() will be used.- Parameters:
capabilities- AGDBusCapabilityFlagsdescribing what protocol features are supported.- Returns:
- A pointer to a
valid binary D-Bus message of
outSizebytes generated by this DBusMessage ornulliferroris set. Free with g_free(). - Throws:
GErrorException- seeGError- Since:
- 2.26
-
toGerror
If this DBusMessage is not of typeDBusMessageType.ERRORdoes nothing and returnsfalse.Otherwise this method encodes the error in this DBusMessage as a
GErrorusing g_dbus_error_set_dbus_error() using the information in theDBusMessageHeaderField.ERROR_NAMEheader field of this DBusMessage as well as the first string item inmessage'sbody.- Returns:
trueiferrorwas set,falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.26
-
builder
ADBusMessage.Builderobject constructs aDBusMessagewith the specified properties. Use the variousset...()methods to set properties, and finish construction withDBusMessage.Builder.build().- Returns:
- the builder object
-