/**
* g_dbus_message_new_method_call:
- * @name: A valid D-Bus name or %NULL.
+ * @name: (allow-none): A valid D-Bus name or %NULL.
* @path: A valid object path.
- * @interface_: A valid D-Bus interface name or %NULL.
+ * @interface_: (allow-none): A valid D-Bus interface name or %NULL.
* @method: A valid method name.
*
* Creates a new #GDBusMessage for a method call.
* g_dbus_message_set_header:
* @message: A #GDBusMessage.
* @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.
+ * @value: (allow-none): A #GVariant to set the header field or %NULL to clear the header field.
*
* Sets a header field on @message.
*
type_string = g_variant_type_peek_string (type);
#ifdef DEBUG_SERIALIZER
- if (!just_align)
{
gchar *s;
s = g_variant_type_dup_string (type);
- g_print ("%*sReading type %s from offset 0x%04x",
+ g_print ("%*s%s type %s from offset 0x%04x",
indent, "",
+ just_align ? "Aligning" : "Reading",
s,
(gint) g_seekable_tell (G_SEEKABLE (mis)));
g_free (s);
break;
case 'a': /* G_VARIANT_TYPE_ARRAY */
- {
- guint32 array_len;
- goffset offset;
- goffset target;
- const GVariantType *element_type;
- GVariantBuilder builder;
+ if (!ensure_input_padding (mis, 4, &local_error))
+ goto fail;
- if (!ensure_input_padding (mis, 4, &local_error))
- goto fail;
+ /* If we are only aligning for this array type, it is the child type of
+ * another array, which is empty. So, we do not need to add padding for
+ * this nonexistent array's elements: we only need to align for this
+ * array itself (4 bytes). See
+ * <https://bugzilla.gnome.org/show_bug.cgi?id=673612>.
+ */
+ if (!just_align)
+ {
+ guint32 array_len;
+ goffset offset;
+ goffset target;
+ const GVariantType *element_type;
+ GVariantBuilder builder;
- if (just_align)
- {
- array_len = 0;
- }
- else
- {
- array_len = g_data_input_stream_read_uint32 (dis, NULL, &local_error);
- if (local_error != NULL)
- goto fail;
+ array_len = g_data_input_stream_read_uint32 (dis, NULL, &local_error);
+ if (local_error != NULL)
+ goto fail;
- is_leaf = FALSE;
+ is_leaf = FALSE;
#ifdef DEBUG_SERIALIZER
- g_print (": array spans 0x%04x bytes\n", array_len);
+ g_print (": array spans 0x%04x bytes\n", array_len);
#endif /* DEBUG_SERIALIZER */
- if (array_len > (2<<26))
- {
- /* G_GUINT32_FORMAT doesn't work with gettext, so use u */
- g_set_error (&local_error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- g_dngettext (GETTEXT_PACKAGE,
- "Encountered array of length %u byte. Maximum length is 2<<26 bytes (64 MiB).",
- "Encountered array of length %u bytes. Maximum length is 2<<26 bytes (64 MiB).",
- array_len),
- array_len);
- goto fail;
- }
- }
+ if (array_len > (2<<26))
+ {
+ /* G_GUINT32_FORMAT doesn't work with gettext, so use u */
+ g_set_error (&local_error,
+ G_IO_ERROR,
+ G_IO_ERROR_INVALID_ARGUMENT,
+ g_dngettext (GETTEXT_PACKAGE,
+ "Encountered array of length %u byte. Maximum length is 2<<26 bytes (64 MiB).",
+ "Encountered array of length %u bytes. Maximum length is 2<<26 bytes (64 MiB).",
+ array_len),
+ array_len);
+ goto fail;
+ }
- g_variant_builder_init (&builder, type);
- element_type = g_variant_type_element (type);
+ g_variant_builder_init (&builder, type);
+ element_type = g_variant_type_element (type);
- if (array_len == 0)
- {
- GVariant *item;
- item = parse_value_from_blob (mis,
- dis,
- element_type,
- TRUE,
- indent + 2,
- NULL);
- g_assert (item == NULL);
- }
- else
- {
- /* TODO: optimize array of primitive types */
- offset = g_seekable_tell (G_SEEKABLE (mis));
- target = offset + array_len;
- while (offset < target)
- {
- GVariant *item;
- item = parse_value_from_blob (mis,
- dis,
- element_type,
- FALSE,
- indent + 2,
- &local_error);
- if (item == NULL)
- {
- g_variant_builder_clear (&builder);
- goto fail;
- }
- g_variant_builder_add_value (&builder, item);
- g_variant_unref (item);
- offset = g_seekable_tell (G_SEEKABLE (mis));
- }
- }
+ if (array_len == 0)
+ {
+ GVariant *item;
+ item = parse_value_from_blob (mis,
+ dis,
+ element_type,
+ TRUE,
+ indent + 2,
+ NULL);
+ g_assert (item == NULL);
+ }
+ else
+ {
+ /* TODO: optimize array of primitive types */
+ offset = g_seekable_tell (G_SEEKABLE (mis));
+ target = offset + array_len;
+ while (offset < target)
+ {
+ GVariant *item;
+ item = parse_value_from_blob (mis,
+ dis,
+ element_type,
+ FALSE,
+ indent + 2,
+ &local_error);
+ if (item == NULL)
+ {
+ g_variant_builder_clear (&builder);
+ goto fail;
+ }
+ g_variant_builder_add_value (&builder, item);
+ g_variant_unref (item);
+ offset = g_seekable_tell (G_SEEKABLE (mis));
+ }
+ }
- if (!just_align)
- {
- ret = g_variant_builder_end (&builder);
- }
- else
- {
- g_variant_builder_clear (&builder);
- }
- }
+ ret = g_variant_builder_end (&builder);
+ }
break;
default:
* and formatting is subject to change at any time. Typical output
* looks something like this:
* <programlisting>
- * Type: method-call
- * Flags: none
- * Version: 0
- * Serial: 4
- * Headers:
+ * Type: method-call
+ * Flags: none
+ * Version: 0
+ * Serial: 4
+ * Headers:
* path -> objectpath '/org/gtk/GDBus/TestObject'
* interface -> 'org.gtk.GDBus.TestInterface'
* member -> 'GimmeStdout'
* destination -> ':1.146'
- * Body: ()
+ * Body: ()
* UNIX File Descriptors:
* (none)
* </programlisting>
* or
* <programlisting>
- * Type: method-return
- * Flags: no-reply-expected
- * Version: 0
- * Serial: 477
- * Headers:
+ * Type: method-return
+ * 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:
+ * 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
* </programlisting>
*