Class DBusMessage

All Implemented Interfaces:
PointerInterface

public class DBusMessage extends Object
A type for representing D-Bus messages that can be sent or received
on a #GDBusConnection.

https://docs.gtk.org/gio/class.DBusMessage.html

  • Constructor Details

    • DBusMessage

      public DBusMessage(PointerContainer pointer)
    • DBusMessage

      public DBusMessage()
      Creates a new empty #GDBusMessage.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newMethodCallDBusMessage

      public static DBusMessage newMethodCallDBusMessage(@Nullable Str name, @Nonnull Str path, @Nullable Str interface_, @Nonnull Str method)
      Creates a new #GDBusMessage for a method call.
      Parameters:
      name - A valid D-Bus name or %NULL.
      path - A valid object path.
      interface_ - A valid D-Bus interface name or %NULL.
      method - A valid method name.
      Returns:
      A #GDBusMessage. Free with g_object_unref().
    • newMethodCallDBusMessage

      public static DBusMessage newMethodCallDBusMessage(String name, String path, String interface_, String method)
      Creates a new #GDBusMessage for a method call.
      Parameters:
      name - A valid D-Bus name or %NULL.
      path - A valid object path.
      interface_ - A valid D-Bus interface name or %NULL.
      method - A valid method name.
      Returns:
      A #GDBusMessage. Free with g_object_unref().
    • newSignalDBusMessage

      public static DBusMessage newSignalDBusMessage(@Nonnull Str path, @Nonnull Str interface_, @Nonnull Str signal)
      Creates a new #GDBusMessage for 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().
    • newSignalDBusMessage

      public static DBusMessage newSignalDBusMessage(String path, String interface_, String signal)
      Creates a new #GDBusMessage for 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().
    • copy

      public DBusMessage copy() throws AllocationError
      Copies @message. The copy is a deep copy and the returned
      #GDBusMessage is completely identical except that it is guaranteed
      to not be locked.

      This operation can fail if e.g. @message contains file descriptors
      and the per-process or system-wide open files limit is reached.
      Returns:
      A new #GDBusMessage or %NULL if @error is set. Free with g_object_unref().
      Throws:
      AllocationError
    • getArg0

      public Str getArg0()
      Convenience to get the first item in the body of @message.
      Returns:
      The string item or %NULL if the first item in the body of @message is not a string.
    • getBody

      public Variant getBody()
      Gets the body of a message.
      Returns:
      A #GVariant or %NULL if the body is empty. Do not free, it is owned by @message.
    • getByteOrder

      public int getByteOrder()
      Gets the byte order of @message.
      Returns:
      The byte order.
    • getDestination

      public Str getDestination()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field.
      Returns:
      The value.
    • getErrorName

      public Str getErrorName()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field.
      Returns:
      The value.
    • getFlags

      public int getFlags()
      Gets the flags for @message.
      Returns:
      Flags that are set (typically values from the #GDBusMessageFlags enumeration bitwise ORed together).
    • getHeader

      public Variant getHeader(int header_field)
      Gets a header field on @message.

      The caller is responsible for checking the type of the returned #GVariant
      matches what is expected.
      Parameters:
      header_field - A 8-bit unsigned integer (typically a value from the #GDBusMessageHeaderField enumeration)
      Returns:
      A #GVariant with the value if the header was found, %NULL otherwise. Do not free, it is owned by @message.
    • getInterface

      public Str getInterface()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field.
      Returns:
      The value.
    • getLocked

      public boolean getLocked()
      Checks whether @message is locked. To monitor changes to this
      value, conncet to the #GObject::notify signal to listen for changes
      on the #GDBusMessage:locked property.
      Returns:
      %TRUE if @message is locked, %FALSE otherwise.
    • getMember

      public Str getMember()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field.
      Returns:
      The value.
    • getMessageType

      public int getMessageType()
      Gets the type of @message.
      Returns:
      A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration).
    • getNumUnixFds

      public int getNumUnixFds()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field.
      Returns:
      The value.
    • getPath

      public Str getPath()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field.
      Returns:
      The value.
    • getReplySerial

      public int getReplySerial()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field.
      Returns:
      The value.
    • getSender

      public Str getSender()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field.
      Returns:
      The value.
    • getSerial

      public int getSerial()
      Gets the serial for @message.
      Returns:
      A #guint32.
    • getSignature

      public Str getSignature()
      Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field.

      This will always be non-%NULL, but may be an empty string.
      Returns:
      The value.
    • getUnixFdList

      public UnixFDList getUnixFdList()
      Gets the UNIX file descriptors associated with @message, if any.

      This method is only available on UNIX.

      The file descriptors normally correspond to %G_VARIANT_TYPE_HANDLE
      values 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 by
      `g_unix_fd_list_get (list, 5, ...)`.
      Returns:
      A #GUnixFDList or %NULL if no file descriptors are associated. Do not free, this object is owned by @message.
    • lock

      public void lock()
      If @message is locked, does nothing. Otherwise locks the message.
    • newMethodError

      public DBusMessage newMethodError(@Nonnull Str error_name, @Nonnull Str error_message_format, Object... _elipse)
      Creates a new #GDBusMessage that is an error reply to @method_call_message.
      Parameters:
      error_name - A valid D-Bus error name.
      error_message_format - The D-Bus error message in a printf() format.
      _elipse - Arguments for @error_message_format.
      Returns:
      A #GDBusMessage. Free with g_object_unref().
    • newMethodError

      public DBusMessage newMethodError(String error_name, String error_message_format, Object... _elipse)
      Creates a new #GDBusMessage that is an error reply to @method_call_message.
      Parameters:
      error_name - A valid D-Bus error name.
      error_message_format - The D-Bus error message in a printf() format.
      _elipse - Arguments for @error_message_format.
      Returns:
      A #GDBusMessage. Free with g_object_unref().
    • newMethodErrorLiteral

      public DBusMessage newMethodErrorLiteral(@Nonnull Str error_name, @Nonnull Str error_message)
      Creates a new #GDBusMessage that is an error reply to @method_call_message.
      Parameters:
      error_name - A valid D-Bus error name.
      error_message - The D-Bus error message.
      Returns:
      A #GDBusMessage. Free with g_object_unref().
    • newMethodErrorLiteral

      public DBusMessage newMethodErrorLiteral(String error_name, String error_message)
      Creates a new #GDBusMessage that is an error reply to @method_call_message.
      Parameters:
      error_name - A valid D-Bus error name.
      error_message - The D-Bus error message.
      Returns:
      A #GDBusMessage. Free with g_object_unref().
    • newMethodReply

      public DBusMessage newMethodReply()
      Creates a new #GDBusMessage that is a reply to @method_call_message.
      Returns:
      #GDBusMessage. Free with g_object_unref().
    • print

      public Str print(int indent)
      Produces a human-readable multi-line description of @message.

      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:
       Flags:   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)
       

      or
       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 g_free().
    • setBody

      public void setBody(@Nonnull Variant body)
      Sets the body @message. As a side-effect the
      %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field is set to the
      type string of @body (or cleared if @body is %NULL).

      If @body is floating, @message assumes ownership of @body.
      Parameters:
      body - Either %NULL or a #GVariant that is a tuple.
    • setByteOrder

      public void setByteOrder(int byte_order)
      Sets the byte order of @message.
      Parameters:
      byte_order - The byte order.
    • setDestination

      public void setDestination(@Nullable Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field.
      Parameters:
      value - The value to set.
    • setDestination

      public void setDestination(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field.
      Parameters:
      value - The value to set.
    • setErrorName

      public void setErrorName(@Nonnull Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field.
      Parameters:
      value - The value to set.
    • setErrorName

      public void setErrorName(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field.
      Parameters:
      value - The value to set.
    • setFlags

      public void setFlags(int flags)
      Sets the flags to set on @message.
      Parameters:
      flags - Flags for @message that are set (typically values from the #GDBusMessageFlags enumeration bitwise ORed together).
    • setHeader

      public void setHeader(int header_field, @Nullable Variant value)
      Sets a header field on @message.

      If @value is floating, @message assumes ownership of @value.
      Parameters:
      header_field - A 8-bit unsigned integer (typically a value from the #GDBusMessageHeaderField enumeration)
      value - A #GVariant to set the header field or %NULL to clear the header field.
    • setInterface

      public void setInterface(@Nullable Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field.
      Parameters:
      value - The value to set.
    • setInterface

      public void setInterface(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field.
      Parameters:
      value - The value to set.
    • setMember

      public void setMember(@Nullable Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field.
      Parameters:
      value - The value to set.
    • setMember

      public void setMember(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field.
      Parameters:
      value - The value to set.
    • setMessageType

      public void setMessageType(int type)
      Sets @message to be of @type.
      Parameters:
      type - A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration).
    • setNumUnixFds

      public void setNumUnixFds(int value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field.
      Parameters:
      value - The value to set.
    • setPath

      public void setPath(@Nullable Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field.
      Parameters:
      value - The value to set.
    • setPath

      public void setPath(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field.
      Parameters:
      value - The value to set.
    • setReplySerial

      public void setReplySerial(int value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field.
      Parameters:
      value - The value to set.
    • setSender

      public void setSender(@Nullable Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field.
      Parameters:
      value - The value to set.
    • setSender

      public void setSender(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field.
      Parameters:
      value - The value to set.
    • setSerial

      public void setSerial(int serial)
      Sets the serial for @message.
      Parameters:
      serial - A #guint32.
    • setSignature

      public void setSignature(@Nullable Str value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field.
      Parameters:
      value - The value to set.
    • setSignature

      public void setSignature(String value)
      Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field.
      Parameters:
      value - The value to set.
    • setUnixFdList

      public void setUnixFdList(@Nullable UnixFDList fd_list)
      Sets the UNIX file descriptors associated with @message. As a
      side-effect the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header
      field is set to the number of fds in @fd_list (or cleared if
      @fd_list is %NULL).

      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_HANDLE in the body of the message.
      Parameters:
      fd_list - A #GUnixFDList or %NULL.
    • toGerror

      public boolean toGerror() throws AllocationError
      If @message is not of type %G_DBUS_MESSAGE_TYPE_ERROR does
      nothing and returns %FALSE.

      Otherwise this method encodes the error in @message as a #GError
      using g_dbus_error_set_dbus_error() using the information in the
      %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field of @message as
      well as the first string item in @message's body.
      Returns:
      %TRUE if @error was set, %FALSE otherwise.
      Throws:
      AllocationError
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()