GDBus: Make message serialization routines take capabilities param

This is needed to e.g. allow encoding maybe types (once we add
G_DBUS_CAPABILITY_FLAGS_MAYBE_TYPES) if, and only if, that capability
has been negotiated with the peer (via authentication).
This commit is contained in:
David Zeuthen
2010-05-13 14:01:41 -04:00
parent 107b4d4bae
commit 33952347ff
5 changed files with 26 additions and 10 deletions

View File

@@ -1070,9 +1070,9 @@ parse_value_from_blob (GMemoryInputStream *mis,
* 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;
@@ -1122,6 +1122,7 @@ g_dbus_message_bytes_needed (guchar *blob,
* g_dbus_message_new_from_blob:
* @blob: A blob represent a binary D-Bus message.
* @blob_len: The length of @blob.
* @capabilities: A #GDBusCapabilityFlags describing what protocol features are supported.
* @error: Return location for error or %NULL.
*
* Creates a new #GDBusMessage from the data stored at @blob.
@@ -1132,9 +1133,10 @@ g_dbus_message_bytes_needed (guchar *blob,
* Since: 2.26
*/
GDBusMessage *
g_dbus_message_new_from_blob (guchar *blob,
gsize blob_len,
GError **error)
g_dbus_message_new_from_blob (guchar *blob,
gsize blob_len,
GDBusCapabilityFlags capabilities,
GError **error)
{
gboolean ret;
GMemoryInputStream *mis;
@@ -1149,6 +1151,8 @@ g_dbus_message_new_from_blob (guchar *blob,
GVariantIter iter;
GVariant *signature;
/* TODO: check against @capabilities */
ret = FALSE;
g_return_val_if_fail (blob != NULL, NULL);
@@ -1565,6 +1569,7 @@ append_body_to_blob (GVariant *value,
* g_dbus_message_to_blob:
* @message: A #GDBusMessage.
* @out_size: Return location for size of generated blob.
* @capabilities: A #GDBusCapabilityFlags describing what protocol features are supported.
* @error: Return location for error.
*
* Serializes @message to a blob.
@@ -1575,9 +1580,10 @@ append_body_to_blob (GVariant *value,
* Since: 2.26
*/
guchar *
g_dbus_message_to_blob (GDBusMessage *message,
gsize *out_size,
GError **error)
g_dbus_message_to_blob (GDBusMessage *message,
gsize *out_size,
GDBusCapabilityFlags capabilities,
GError **error)
{
GMemoryOutputStream *mos;
GDataOutputStream *dos;
@@ -1597,6 +1603,8 @@ g_dbus_message_to_blob (GDBusMessage *message,
gint num_fds_in_message;
gint num_fds_according_to_header;
/* TODO: check against @capabilities */
ret = NULL;
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);