mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-12 21:50:36 +01:00
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:
parent
107b4d4bae
commit
33952347ff
@ -1009,6 +1009,7 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
|
|
||||||
blob = g_dbus_message_to_blob (message,
|
blob = g_dbus_message_to_blob (message,
|
||||||
&blob_size,
|
&blob_size,
|
||||||
|
connection->priv->capabilities,
|
||||||
error);
|
error);
|
||||||
if (blob == NULL)
|
if (blob == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1070,9 +1070,9 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
gssize
|
gssize
|
||||||
g_dbus_message_bytes_needed (guchar *blob,
|
g_dbus_message_bytes_needed (guchar *blob,
|
||||||
gsize blob_len,
|
gsize blob_len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gssize ret;
|
gssize ret;
|
||||||
|
|
||||||
@ -1122,6 +1122,7 @@ g_dbus_message_bytes_needed (guchar *blob,
|
|||||||
* g_dbus_message_new_from_blob:
|
* g_dbus_message_new_from_blob:
|
||||||
* @blob: A blob represent a binary D-Bus message.
|
* @blob: A blob represent a binary D-Bus message.
|
||||||
* @blob_len: The length of @blob.
|
* @blob_len: The length of @blob.
|
||||||
|
* @capabilities: A #GDBusCapabilityFlags describing what protocol features are supported.
|
||||||
* @error: Return location for error or %NULL.
|
* @error: Return location for error or %NULL.
|
||||||
*
|
*
|
||||||
* Creates a new #GDBusMessage from the data stored at @blob.
|
* Creates a new #GDBusMessage from the data stored at @blob.
|
||||||
@ -1132,9 +1133,10 @@ g_dbus_message_bytes_needed (guchar *blob,
|
|||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
GDBusMessage *
|
GDBusMessage *
|
||||||
g_dbus_message_new_from_blob (guchar *blob,
|
g_dbus_message_new_from_blob (guchar *blob,
|
||||||
gsize blob_len,
|
gsize blob_len,
|
||||||
GError **error)
|
GDBusCapabilityFlags capabilities,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GMemoryInputStream *mis;
|
GMemoryInputStream *mis;
|
||||||
@ -1149,6 +1151,8 @@ g_dbus_message_new_from_blob (guchar *blob,
|
|||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
GVariant *signature;
|
GVariant *signature;
|
||||||
|
|
||||||
|
/* TODO: check against @capabilities */
|
||||||
|
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (blob != NULL, NULL);
|
g_return_val_if_fail (blob != NULL, NULL);
|
||||||
@ -1565,6 +1569,7 @@ append_body_to_blob (GVariant *value,
|
|||||||
* g_dbus_message_to_blob:
|
* g_dbus_message_to_blob:
|
||||||
* @message: A #GDBusMessage.
|
* @message: A #GDBusMessage.
|
||||||
* @out_size: Return location for size of generated blob.
|
* @out_size: Return location for size of generated blob.
|
||||||
|
* @capabilities: A #GDBusCapabilityFlags describing what protocol features are supported.
|
||||||
* @error: Return location for error.
|
* @error: Return location for error.
|
||||||
*
|
*
|
||||||
* Serializes @message to a blob.
|
* Serializes @message to a blob.
|
||||||
@ -1575,9 +1580,10 @@ append_body_to_blob (GVariant *value,
|
|||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
guchar *
|
guchar *
|
||||||
g_dbus_message_to_blob (GDBusMessage *message,
|
g_dbus_message_to_blob (GDBusMessage *message,
|
||||||
gsize *out_size,
|
gsize *out_size,
|
||||||
GError **error)
|
GDBusCapabilityFlags capabilities,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GMemoryOutputStream *mos;
|
GMemoryOutputStream *mos;
|
||||||
GDataOutputStream *dos;
|
GDataOutputStream *dos;
|
||||||
@ -1597,6 +1603,8 @@ g_dbus_message_to_blob (GDBusMessage *message,
|
|||||||
gint num_fds_in_message;
|
gint num_fds_in_message;
|
||||||
gint num_fds_according_to_header;
|
gint num_fds_according_to_header;
|
||||||
|
|
||||||
|
/* TODO: check against @capabilities */
|
||||||
|
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
|
g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
|
||||||
|
@ -158,6 +158,7 @@ const gchar *g_dbus_message_get_arg0 (GDBusMessage
|
|||||||
|
|
||||||
GDBusMessage *g_dbus_message_new_from_blob (guchar *blob,
|
GDBusMessage *g_dbus_message_new_from_blob (guchar *blob,
|
||||||
gsize blob_len,
|
gsize blob_len,
|
||||||
|
GDBusCapabilityFlags capabilities,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gssize g_dbus_message_bytes_needed (guchar *blob,
|
gssize g_dbus_message_bytes_needed (guchar *blob,
|
||||||
@ -166,6 +167,7 @@ gssize g_dbus_message_bytes_needed (guchar
|
|||||||
|
|
||||||
guchar *g_dbus_message_to_blob (GDBusMessage *message,
|
guchar *g_dbus_message_to_blob (GDBusMessage *message,
|
||||||
gsize *out_size,
|
gsize *out_size,
|
||||||
|
GDBusCapabilityFlags capabilities,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean g_dbus_message_to_gerror (GDBusMessage *message,
|
gboolean g_dbus_message_to_gerror (GDBusMessage *message,
|
||||||
|
@ -583,6 +583,7 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream,
|
|||||||
|
|
||||||
message = g_dbus_message_new_from_blob ((guchar *) worker->read_buffer,
|
message = g_dbus_message_new_from_blob ((guchar *) worker->read_buffer,
|
||||||
worker->read_buffer_cur_size,
|
worker->read_buffer_cur_size,
|
||||||
|
worker->capabilities,
|
||||||
&error);
|
&error);
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
{
|
{
|
||||||
|
@ -522,6 +522,7 @@ check_serialization (GVariant *value,
|
|||||||
error = NULL;
|
error = NULL;
|
||||||
blob = g_dbus_message_to_blob (message,
|
blob = g_dbus_message_to_blob (message,
|
||||||
&blob_size,
|
&blob_size,
|
||||||
|
G_DBUS_CAPABILITY_FLAGS_NONE,
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (blob != NULL);
|
g_assert (blob != NULL);
|
||||||
@ -555,7 +556,10 @@ check_serialization (GVariant *value,
|
|||||||
/* Then serialize back and check that the body is identical */
|
/* Then serialize back and check that the body is identical */
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
recovered_message = g_dbus_message_new_from_blob (blob, blob_size, &error);
|
recovered_message = g_dbus_message_new_from_blob (blob,
|
||||||
|
blob_size,
|
||||||
|
G_DBUS_CAPABILITY_FLAGS_NONE,
|
||||||
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert (recovered_message != NULL);
|
g_assert (recovered_message != NULL);
|
||||||
g_assert (g_dbus_message_get_body (recovered_message) != NULL);
|
g_assert (g_dbus_message_get_body (recovered_message) != NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user