X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusmessage.c;h=50105e82f4f9b7d7eda06806cd71efe9d97236b3;hb=958da1e9dc82fbb91862501226b8928faf2f9558;hp=5464cefa10cec88304ffecb0e284aaa446c0c417;hpb=1011e4269f2c1bb16ad0a72b4b92abaf625c6b56;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index 5464cef..50105e8 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -13,9 +13,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Author: David Zeuthen
*/
@@ -29,11 +27,11 @@
#include
#include
#include
-#ifdef HAVE_SYS_MKDEV_H
+
+#if MAJOR_IN_MKDEV
#include
-#endif
-#ifdef HAVE_UNISTD_H
-#include
+#elif MAJOR_IN_SYSMACROS
+#include
#endif
#include "gdbusutils.h"
@@ -66,9 +64,18 @@ struct _GMemoryBuffer
GDataStreamByteOrder byte_order;
};
+static gboolean
+g_memory_buffer_is_byteswapped (GMemoryBuffer *mbuf)
+{
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ return mbuf->byte_order == G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN;
+#else
+ return mbuf->byte_order == G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN;
+#endif
+}
+
static guchar
-g_memory_buffer_read_byte (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_byte (GMemoryBuffer *mbuf)
{
if (mbuf->pos >= mbuf->valid_len)
return 0;
@@ -76,8 +83,7 @@ g_memory_buffer_read_byte (GMemoryBuffer *mbuf,
}
static gint16
-g_memory_buffer_read_int16 (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_int16 (GMemoryBuffer *mbuf)
{
gint16 v;
@@ -89,24 +95,15 @@ g_memory_buffer_read_int16 (GMemoryBuffer *mbuf,
memcpy (&v, mbuf->data + mbuf->pos, 2);
mbuf->pos += 2;
- switch (mbuf->byte_order)
- {
- case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
- v = GINT16_FROM_BE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
- v = GINT16_FROM_LE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
- default:
- break;
- }
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ v = GUINT16_SWAP_LE_BE (v);
+
return v;
}
static guint16
-g_memory_buffer_read_uint16 (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_uint16 (GMemoryBuffer *mbuf)
{
guint16 v;
@@ -118,24 +115,15 @@ g_memory_buffer_read_uint16 (GMemoryBuffer *mbuf,
memcpy (&v, mbuf->data + mbuf->pos, 2);
mbuf->pos += 2;
- switch (mbuf->byte_order)
- {
- case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
- v = GINT16_FROM_BE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
- v = GINT16_FROM_LE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
- default:
- break;
- }
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ v = GUINT16_SWAP_LE_BE (v);
+
return v;
}
static gint32
-g_memory_buffer_read_int32 (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_int32 (GMemoryBuffer *mbuf)
{
gint32 v;
@@ -147,24 +135,15 @@ g_memory_buffer_read_int32 (GMemoryBuffer *mbuf,
memcpy (&v, mbuf->data + mbuf->pos, 4);
mbuf->pos += 4;
- switch (mbuf->byte_order)
- {
- case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
- v = GINT32_FROM_BE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
- v = GINT32_FROM_LE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
- default:
- break;
- }
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ v = GUINT32_SWAP_LE_BE (v);
+
return v;
}
static guint32
-g_memory_buffer_read_uint32 (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_uint32 (GMemoryBuffer *mbuf)
{
guint32 v;
@@ -176,24 +155,15 @@ g_memory_buffer_read_uint32 (GMemoryBuffer *mbuf,
memcpy (&v, mbuf->data + mbuf->pos, 4);
mbuf->pos += 4;
- switch (mbuf->byte_order)
- {
- case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
- v = GUINT32_FROM_BE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
- v = GUINT32_FROM_LE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
- default:
- break;
- }
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ v = GUINT32_SWAP_LE_BE (v);
+
return v;
}
static gint64
-g_memory_buffer_read_int64 (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_int64 (GMemoryBuffer *mbuf)
{
gint64 v;
@@ -205,24 +175,15 @@ g_memory_buffer_read_int64 (GMemoryBuffer *mbuf,
memcpy (&v, mbuf->data + mbuf->pos, 8);
mbuf->pos += 8;
- switch (mbuf->byte_order)
- {
- case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
- v = GINT64_FROM_BE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
- v = GINT64_FROM_LE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
- default:
- break;
- }
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ v = GUINT64_SWAP_LE_BE (v);
+
return v;
}
static guint64
-g_memory_buffer_read_uint64 (GMemoryBuffer *mbuf,
- GError **error)
+g_memory_buffer_read_uint64 (GMemoryBuffer *mbuf)
{
guint64 v;
@@ -234,19 +195,11 @@ g_memory_buffer_read_uint64 (GMemoryBuffer *mbuf,
memcpy (&v, mbuf->data + mbuf->pos, 8);
mbuf->pos += 8;
- switch (mbuf->byte_order)
- {
- case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN:
- v = GUINT64_FROM_BE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN:
- v = GUINT64_FROM_LE (v);
- break;
- case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN:
- default:
- break;
- }
- return v;
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ v = GUINT64_SWAP_LE_BE (v);
+
+ return v;
}
#define MIN_ARRAY_SIZE 128
@@ -263,8 +216,8 @@ g_nearest_pow (gint num)
}
static void
-array_resize (GMemoryBuffer *mbuf,
- gsize size)
+array_resize (GMemoryBuffer *mbuf,
+ gsize size)
{
gpointer data;
gsize len;
@@ -287,8 +240,8 @@ array_resize (GMemoryBuffer *mbuf,
static gboolean
g_memory_buffer_write (GMemoryBuffer *mbuf,
- const void *buffer,
- gsize count)
+ const void *buffer,
+ gsize count)
{
guint8 *dest;
gsize new_size;
@@ -1123,7 +1076,8 @@ g_dbus_message_get_header_fields (GDBusMessage *message)
*
* Gets the body of a message.
*
- * Returns: A #GVariant or %NULL if the body is empty. Do not free, it is owned by @message.
+ * Returns: (transfer none): A #GVariant or %NULL if the body is
+ * empty. Do not free, it is owned by @message.
*
* Since: 2.26
*/
@@ -1351,9 +1305,8 @@ validate_headers (GDBusMessage *message,
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-ensure_input_padding (GMemoryBuffer *buf,
- gsize padding_size,
- GError **error)
+ensure_input_padding (GMemoryBuffer *buf,
+ gsize padding_size)
{
gsize offset;
gsize wanted_offset;
@@ -1365,9 +1318,9 @@ ensure_input_padding (GMemoryBuffer *buf,
}
static const gchar *
-read_string (GMemoryBuffer *mbuf,
- gsize len,
- GError **error)
+read_string (GMemoryBuffer *mbuf,
+ gsize len,
+ GError **error)
{
gchar *str;
const gchar *end_valid;
@@ -1385,7 +1338,6 @@ read_string (GMemoryBuffer *mbuf,
(gulong)len),
(gulong)len,
(gulong)(mbuf->valid_len - mbuf->pos));
- mbuf->pos = mbuf->valid_len;
return NULL;
}
@@ -1395,7 +1347,7 @@ read_string (GMemoryBuffer *mbuf,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Expected NUL byte after the string `%s' but found byte %d"),
+ _("Expected NUL byte after the string '%s' but found byte %d"),
str, mbuf->data[mbuf->pos + len]);
g_free (str);
mbuf->pos += len + 1;
@@ -1415,7 +1367,7 @@ read_string (GMemoryBuffer *mbuf,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
_("Expected valid UTF-8 string but found invalid bytes at byte offset %d (length of string is %d). "
- "The valid UTF-8 string up until that point was `%s'"),
+ "The valid UTF-8 string up until that point was '%s'"),
offset,
(gint) len,
valid_str);
@@ -1430,11 +1382,11 @@ read_string (GMemoryBuffer *mbuf,
/* returns a non-floating GVariant! */
static GVariant *
-parse_value_from_blob (GMemoryBuffer *buf,
- const GVariantType *type,
- gboolean just_align,
- guint indent,
- GError **error)
+parse_value_from_blob (GMemoryBuffer *buf,
+ const GVariantType *type,
+ gboolean just_align,
+ guint indent,
+ GError **error)
{
GVariant *ret;
GError *local_error;
@@ -1463,14 +1415,11 @@ parse_value_from_blob (GMemoryBuffer *buf,
switch (type_string[0])
{
case 'b': /* G_VARIANT_TYPE_BOOLEAN */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
if (!just_align)
{
gboolean v;
- v = g_memory_buffer_read_uint32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_uint32 (buf);
ret = g_variant_new_boolean (v);
}
break;
@@ -1479,94 +1428,73 @@ parse_value_from_blob (GMemoryBuffer *buf,
if (!just_align)
{
guchar v;
- v = g_memory_buffer_read_byte (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_byte (buf);
ret = g_variant_new_byte (v);
}
break;
case 'n': /* G_VARIANT_TYPE_INT16 */
- if (!ensure_input_padding (buf, 2, &local_error))
- goto fail;
+ ensure_input_padding (buf, 2);
if (!just_align)
{
gint16 v;
- v = g_memory_buffer_read_int16 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_int16 (buf);
ret = g_variant_new_int16 (v);
}
break;
case 'q': /* G_VARIANT_TYPE_UINT16 */
- if (!ensure_input_padding (buf, 2, &local_error))
- goto fail;
+ ensure_input_padding (buf, 2);
if (!just_align)
{
guint16 v;
- v = g_memory_buffer_read_uint16 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_uint16 (buf);
ret = g_variant_new_uint16 (v);
}
break;
case 'i': /* G_VARIANT_TYPE_INT32 */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
if (!just_align)
{
gint32 v;
- v = g_memory_buffer_read_int32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_int32 (buf);
ret = g_variant_new_int32 (v);
}
break;
case 'u': /* G_VARIANT_TYPE_UINT32 */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
if (!just_align)
{
guint32 v;
- v = g_memory_buffer_read_uint32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_uint32 (buf);
ret = g_variant_new_uint32 (v);
}
break;
case 'x': /* G_VARIANT_TYPE_INT64 */
- if (!ensure_input_padding (buf, 8, &local_error))
- goto fail;
+ ensure_input_padding (buf, 8);
if (!just_align)
{
gint64 v;
- v = g_memory_buffer_read_int64 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_int64 (buf);
ret = g_variant_new_int64 (v);
}
break;
case 't': /* G_VARIANT_TYPE_UINT64 */
- if (!ensure_input_padding (buf, 8, &local_error))
- goto fail;
+ ensure_input_padding (buf, 8);
if (!just_align)
{
guint64 v;
- v = g_memory_buffer_read_uint64 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_uint64 (buf);
ret = g_variant_new_uint64 (v);
}
break;
case 'd': /* G_VARIANT_TYPE_DOUBLE */
- if (!ensure_input_padding (buf, 8, &local_error))
- goto fail;
+ ensure_input_padding (buf, 8);
if (!just_align)
{
union {
@@ -1574,23 +1502,18 @@ parse_value_from_blob (GMemoryBuffer *buf,
gdouble v_double;
} u;
G_STATIC_ASSERT (sizeof (gdouble) == sizeof (guint64));
- u.v_uint64 = g_memory_buffer_read_uint64 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ u.v_uint64 = g_memory_buffer_read_uint64 (buf);
ret = g_variant_new_double (u.v_double);
}
break;
case 's': /* G_VARIANT_TYPE_STRING */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
if (!just_align)
{
guint32 len;
const gchar *v;
- len = g_memory_buffer_read_uint32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ len = g_memory_buffer_read_uint32 (buf);
v = read_string (buf, (gsize) len, &local_error);
if (v == NULL)
goto fail;
@@ -1599,15 +1522,12 @@ parse_value_from_blob (GMemoryBuffer *buf,
break;
case 'o': /* G_VARIANT_TYPE_OBJECT_PATH */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
if (!just_align)
{
guint32 len;
const gchar *v;
- len = g_memory_buffer_read_uint32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ len = g_memory_buffer_read_uint32 (buf);
v = read_string (buf, (gsize) len, &local_error);
if (v == NULL)
goto fail;
@@ -1616,7 +1536,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
g_set_error (&local_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Parsed value `%s' is not a valid D-Bus object path"),
+ _("Parsed value '%s' is not a valid D-Bus object path"),
v);
goto fail;
}
@@ -1629,9 +1549,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
{
guchar len;
const gchar *v;
- len = g_memory_buffer_read_byte (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ len = g_memory_buffer_read_byte (buf);
v = read_string (buf, (gsize) len, &local_error);
if (v == NULL)
goto fail;
@@ -1640,7 +1558,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
g_set_error (&local_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Parsed value `%s' is not a valid D-Bus signature"),
+ _("Parsed value '%s' is not a valid D-Bus signature"),
v);
goto fail;
}
@@ -1649,21 +1567,17 @@ parse_value_from_blob (GMemoryBuffer *buf,
break;
case 'h': /* G_VARIANT_TYPE_HANDLE */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
if (!just_align)
{
gint32 v;
- v = g_memory_buffer_read_int32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ v = g_memory_buffer_read_int32 (buf);
ret = g_variant_new_handle (v);
}
break;
case 'a': /* G_VARIANT_TYPE_ARRAY */
- if (!ensure_input_padding (buf, 4, &local_error))
- goto fail;
+ ensure_input_padding (buf, 4);
/* 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
@@ -1679,9 +1593,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
const GVariantType *element_type;
GVariantBuilder builder;
- array_len = g_memory_buffer_read_uint32 (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ array_len = g_memory_buffer_read_uint32 (buf);
is_leaf = FALSE;
#ifdef DEBUG_SERIALIZER
@@ -1751,8 +1663,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
GVariant *key;
GVariant *value;
- if (!ensure_input_padding (buf, 8, &local_error))
- goto fail;
+ ensure_input_padding (buf, 8);
is_leaf = FALSE;
#ifdef DEBUG_SERIALIZER
@@ -1787,8 +1698,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
}
else if (g_variant_type_is_tuple (type))
{
- if (!ensure_input_padding (buf, 8, &local_error))
- goto fail;
+ ensure_input_padding (buf, 8);
is_leaf = FALSE;
#ifdef DEBUG_SERIALIZER
@@ -1837,9 +1747,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
GVariantType *variant_type;
GVariant *value;
- siglen = g_memory_buffer_read_byte (buf, &local_error);
- if (local_error != NULL)
- goto fail;
+ siglen = g_memory_buffer_read_byte (buf);
sig = read_string (buf, (gsize) siglen, &local_error);
if (sig == NULL)
goto fail;
@@ -1848,7 +1756,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
g_set_error (&local_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Parsed value `%s' for variant is not a valid D-Bus signature"),
+ _("Parsed value '%s' for variant is not a valid D-Bus signature"),
sig);
goto fail;
}
@@ -1872,7 +1780,7 @@ parse_value_from_blob (GMemoryBuffer *buf,
g_set_error (&local_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Error deserializing GVariant with type string `%s' from the D-Bus wire format"),
+ _("Error deserializing GVariant with type string '%s' from the D-Bus wire format"),
s);
g_free (s);
goto fail;
@@ -1945,9 +1853,9 @@ parse_value_from_blob (GMemoryBuffer *buf,
* Since: 2.26
*/
gssize
-g_dbus_message_bytes_needed (guchar *blob,
- gsize blob_len,
- GError **error)
+g_dbus_message_bytes_needed (guchar *blob,
+ gsize blob_len,
+ GError **error)
{
gssize ret;
@@ -2044,7 +1952,7 @@ g_dbus_message_new_from_blob (guchar *blob,
mbuf.data = (gchar *)blob;
mbuf.len = mbuf.valid_len = blob_len;
- endianness = g_memory_buffer_read_byte (&mbuf, NULL);
+ endianness = g_memory_buffer_read_byte (&mbuf);
switch (endianness)
{
case 'l':
@@ -2064,9 +1972,9 @@ g_dbus_message_new_from_blob (guchar *blob,
goto out;
}
- message->type = g_memory_buffer_read_byte (&mbuf, NULL);
- message->flags = g_memory_buffer_read_byte (&mbuf, NULL);
- major_protocol_version = g_memory_buffer_read_byte (&mbuf, NULL);
+ message->type = g_memory_buffer_read_byte (&mbuf);
+ message->flags = g_memory_buffer_read_byte (&mbuf);
+ major_protocol_version = g_memory_buffer_read_byte (&mbuf);
if (major_protocol_version != 1)
{
g_set_error (error,
@@ -2076,8 +1984,8 @@ g_dbus_message_new_from_blob (guchar *blob,
major_protocol_version);
goto out;
}
- message_body_len = g_memory_buffer_read_uint32 (&mbuf, NULL);
- message->serial = g_memory_buffer_read_uint32 (&mbuf, NULL);
+ message_body_len = g_memory_buffer_read_uint32 (&mbuf);
+ message->serial = g_memory_buffer_read_uint32 (&mbuf);
#ifdef DEBUG_SERIALIZER
g_print ("Parsing blob (blob_len = 0x%04x bytes)\n", (gint) blob_len);
@@ -2128,7 +2036,7 @@ g_dbus_message_new_from_blob (guchar *blob,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Signature header with signature `%s' found but message body is empty"),
+ _("Signature header with signature '%s' found but message body is empty"),
signature_str);
goto out;
}
@@ -2142,7 +2050,7 @@ g_dbus_message_new_from_blob (guchar *blob,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Parsed value `%s' is not a valid D-Bus signature (for body)"),
+ _("Parsed value '%s' is not a valid D-Bus signature (for body)"),
signature_str);
goto out;
}
@@ -2205,7 +2113,7 @@ g_dbus_message_new_from_blob (guchar *blob,
static gsize
ensure_output_padding (GMemoryBuffer *mbuf,
- gsize padding_size)
+ gsize padding_size)
{
gsize offset;
gsize wanted_offset;
@@ -2224,11 +2132,11 @@ ensure_output_padding (GMemoryBuffer *mbuf,
/* note that value can be NULL for e.g. empty arrays - type is never NULL */
static gboolean
-append_value_to_blob (GVariant *value,
- const GVariantType *type,
- GMemoryBuffer *mbuf,
- gsize *out_padding_added,
- GError **error)
+append_value_to_blob (GVariant *value,
+ const GVariantType *type,
+ GMemoryBuffer *mbuf,
+ gsize *out_padding_added,
+ GError **error)
{
gsize padding_added;
const gchar *type_string;
@@ -2375,12 +2283,14 @@ append_value_to_blob (GVariant *value,
case 'a': /* G_VARIANT_TYPE_ARRAY */
{
+ const GVariantType *element_type;
GVariant *item;
GVariantIter iter;
goffset array_len_offset;
goffset array_payload_begin_offset;
goffset cur_offset;
gsize array_len;
+ guint fixed_size;
padding_added = ensure_output_padding (mbuf, 4);
if (value != NULL)
@@ -2404,17 +2314,34 @@ append_value_to_blob (GVariant *value,
*/
array_payload_begin_offset = mbuf->valid_len;
+ element_type = g_variant_type_element (type);
+ fixed_size = get_type_fixed_size (element_type);
+
if (g_variant_n_children (value) == 0)
{
gsize padding_added_for_item;
if (!append_value_to_blob (NULL,
- g_variant_type_element (type),
+ element_type,
mbuf,
&padding_added_for_item,
error))
goto fail;
array_payload_begin_offset += padding_added_for_item;
}
+ else if (fixed_size != 0)
+ {
+ GVariant *use_value;
+
+ if (g_memory_buffer_is_byteswapped (mbuf))
+ use_value = g_variant_byteswap (value);
+ else
+ use_value = g_variant_ref (value);
+
+ ensure_output_padding (mbuf, fixed_size);
+ array_len = g_variant_get_size (use_value);
+ g_memory_buffer_write (mbuf, g_variant_get_data (use_value), array_len);
+ g_variant_unref (use_value);
+ }
else
{
guint n;
@@ -2503,7 +2430,7 @@ append_value_to_blob (GVariant *value,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Error serializing GVariant with type string `%s' to the D-Bus wire format"),
+ _("Error serializing GVariant with type string '%s' to the D-Bus wire format"),
g_variant_get_type_string (value));
goto fail;
}
@@ -2520,9 +2447,9 @@ append_value_to_blob (GVariant *value,
}
static gboolean
-append_body_to_blob (GVariant *value,
+append_body_to_blob (GVariant *value,
GMemoryBuffer *mbuf,
- GError **error)
+ GError **error)
{
GVariant *item;
GVariantIter iter;
@@ -2692,7 +2619,7 @@ g_dbus_message_to_blob (GDBusMessage *message,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Message body has signature `%s' but there is no signature header"),
+ _("Message body has signature '%s' but there is no signature header"),
signature_str);
g_free (tupled_signature_str);
goto out;
@@ -2702,7 +2629,7 @@ g_dbus_message_to_blob (GDBusMessage *message,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Message body has type signature `%s' but signature in the header field is `%s'"),
+ _("Message body has type signature '%s' but signature in the header field is '%s'"),
tupled_signature_str, g_variant_get_type_string (message->body));
g_free (tupled_signature_str);
goto out;
@@ -2718,7 +2645,7 @@ g_dbus_message_to_blob (GDBusMessage *message,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Message body is empty but signature in the header field is `(%s)'"),
+ _("Message body is empty but signature in the header field is '(%s)'"),
signature_str);
goto out;
}
@@ -3268,7 +3195,7 @@ g_dbus_message_to_gerror (GDBusMessage *message,
g_dbus_error_set_dbus_error (error,
error_name,
"",
- _("Error return with body of type `%s'"),
+ _("Error return with body of type '%s'"),
g_variant_get_type_string (body));
}
else
@@ -3351,35 +3278,35 @@ _sort_keys_func (gconstpointer a,
* 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:
- *
- * 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)
- *
+ * ]|
* or
- *
- * 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
- *
+ * ]|
*
* Returns: A string that should be freed with g_free().
*
@@ -3468,10 +3395,10 @@ g_dbus_message_print (GDBusMessage *message,
statbuf.st_mode);
g_string_append_printf (fs, "%s" "ino=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "",
(guint64) statbuf.st_ino);
- g_string_append_printf (fs, "%s" "uid=%d", fs->len > 0 ? "," : "",
- statbuf.st_uid);
- g_string_append_printf (fs, "%s" "gid=%d", fs->len > 0 ? "," : "",
- statbuf.st_gid);
+ g_string_append_printf (fs, "%s" "uid=%u", fs->len > 0 ? "," : "",
+ (guint) statbuf.st_uid);
+ g_string_append_printf (fs, "%s" "gid=%u", fs->len > 0 ? "," : "",
+ (guint) statbuf.st_gid);
g_string_append_printf (fs, "%s" "rdev=%d:%d", fs->len > 0 ? "," : "",
major (statbuf.st_rdev), minor (statbuf.st_rdev));
g_string_append_printf (fs, "%s" "size=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "",