mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
GDBus: Introduce G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL
This is preferable to the current magical solution whereby the serial is only rewritten if non-zero. In particular, it makes it easier to send the same message on multiple connections without having to reset the serial number. Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
9d7b00638f
commit
493d8cb292
@ -1324,11 +1324,10 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
if (blob == NULL)
|
if (blob == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (flags & G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL)
|
||||||
serial_to_use = g_dbus_message_get_serial (message);
|
serial_to_use = g_dbus_message_get_serial (message);
|
||||||
if (serial_to_use == 0)
|
else
|
||||||
{
|
|
||||||
serial_to_use = ++connection->last_serial; /* TODO: handle overflow */
|
serial_to_use = ++connection->last_serial; /* TODO: handle overflow */
|
||||||
}
|
|
||||||
|
|
||||||
switch (blob[0])
|
switch (blob[0])
|
||||||
{
|
{
|
||||||
@ -1376,17 +1375,17 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection,
|
|||||||
* g_dbus_connection_send_message:
|
* g_dbus_connection_send_message:
|
||||||
* @connection: A #GDBusConnection.
|
* @connection: A #GDBusConnection.
|
||||||
* @message: A #GDBusMessage
|
* @message: A #GDBusMessage
|
||||||
* @flags: Flags affecting how the message is sent (currently unused).
|
* @flags: Flags affecting how the message is sent.
|
||||||
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
|
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
|
||||||
* @error: Return location for error or %NULL.
|
* @error: Return location for error or %NULL.
|
||||||
*
|
*
|
||||||
* Asynchronously sends @message to the peer represented by @connection.
|
* Asynchronously sends @message to the peer represented by @connection.
|
||||||
*
|
*
|
||||||
* If g_dbus_message_get_serial() returns non-zero for @message, then
|
* Unless @flags contain the
|
||||||
* that value is used for the message serial number. Otherwise a
|
* %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number
|
||||||
* serial number will be assigned by @connection and set on @message
|
* will be assigned by @connection and set on @message via
|
||||||
* via g_dbus_message_set_serial(). If @out_serial is not %NULL, then
|
* g_dbus_message_set_serial(). If @out_serial is not %NULL, then the
|
||||||
* the serial number used will be written to this location prior to
|
* serial number used will be written to this location prior to
|
||||||
* submitting the message to the underlying transport.
|
* submitting the message to the underlying transport.
|
||||||
*
|
*
|
||||||
* If @connection is closed then the operation will fail with
|
* If @connection is closed then the operation will fail with
|
||||||
@ -1690,7 +1689,7 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
|
|||||||
* g_dbus_connection_send_message_with_reply:
|
* g_dbus_connection_send_message_with_reply:
|
||||||
* @connection: A #GDBusConnection.
|
* @connection: A #GDBusConnection.
|
||||||
* @message: A #GDBusMessage.
|
* @message: A #GDBusMessage.
|
||||||
* @flags: Flags affecting how the message is sent (currently unused).
|
* @flags: Flags affecting how the message is sent.
|
||||||
* @timeout_msec: The timeout in milliseconds or -1 to use the default timeout.
|
* @timeout_msec: The timeout in milliseconds or -1 to use the default timeout.
|
||||||
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
|
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
|
||||||
* @cancellable: A #GCancellable or %NULL.
|
* @cancellable: A #GCancellable or %NULL.
|
||||||
@ -1700,11 +1699,11 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
|
|||||||
*
|
*
|
||||||
* Asynchronously sends @message to the peer represented by @connection.
|
* Asynchronously sends @message to the peer represented by @connection.
|
||||||
*
|
*
|
||||||
* If g_dbus_message_get_serial() returns non-zero for @message, then
|
* Unless @flags contain the
|
||||||
* that value is used for the message serial number. Otherwise a
|
* %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number
|
||||||
* serial number will be assigned by @connection and set on @message
|
* will be assigned by @connection and set on @message via
|
||||||
* via g_dbus_message_set_serial(). If @out_serial is not %NULL, then
|
* g_dbus_message_set_serial(). If @out_serial is not %NULL, then the
|
||||||
* the serial number used will be written to this location prior to
|
* serial number used will be written to this location prior to
|
||||||
* submitting the message to the underlying transport.
|
* submitting the message to the underlying transport.
|
||||||
*
|
*
|
||||||
* If @connection is closed then the operation will fail with
|
* If @connection is closed then the operation will fail with
|
||||||
@ -1828,7 +1827,7 @@ send_message_with_reply_sync_cb (GDBusConnection *connection,
|
|||||||
* g_dbus_connection_send_message_with_reply_sync:
|
* g_dbus_connection_send_message_with_reply_sync:
|
||||||
* @connection: A #GDBusConnection.
|
* @connection: A #GDBusConnection.
|
||||||
* @message: A #GDBusMessage.
|
* @message: A #GDBusMessage.
|
||||||
* @flags: Flags affecting how the message is sent (currently unused).
|
* @flags: Flags affecting how the message is sent.
|
||||||
* @timeout_msec: The timeout in milliseconds or -1 to use the default timeout.
|
* @timeout_msec: The timeout in milliseconds or -1 to use the default timeout.
|
||||||
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
|
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
|
||||||
* @cancellable: A #GCancellable or %NULL.
|
* @cancellable: A #GCancellable or %NULL.
|
||||||
@ -1839,11 +1838,11 @@ send_message_with_reply_sync_cb (GDBusConnection *connection,
|
|||||||
* timeout is reached. See g_dbus_connection_send_message_with_reply()
|
* timeout is reached. See g_dbus_connection_send_message_with_reply()
|
||||||
* for the asynchronous version of this method.
|
* for the asynchronous version of this method.
|
||||||
*
|
*
|
||||||
* If g_dbus_message_get_serial() returns non-zero for @message, then
|
* Unless @flags contain the
|
||||||
* that value is used for the message serial number. Otherwise a
|
* %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number
|
||||||
* serial number will be assigned by @connection and set on @message
|
* will be assigned by @connection and set on @message via
|
||||||
* via g_dbus_message_set_serial(). If @out_serial is not %NULL, then
|
* g_dbus_message_set_serial(). If @out_serial is not %NULL, then the
|
||||||
* the serial number used will be written to this location prior to
|
* serial number used will be written to this location prior to
|
||||||
* submitting the message to the underlying transport.
|
* submitting the message to the underlying transport.
|
||||||
*
|
*
|
||||||
* If @connection is closed then the operation will fail with
|
* If @connection is closed then the operation will fail with
|
||||||
|
@ -1155,14 +1155,18 @@ typedef enum /*< flags >*/
|
|||||||
/**
|
/**
|
||||||
* GDBusSendMessageFlags:
|
* GDBusSendMessageFlags:
|
||||||
* @G_DBUS_SEND_MESSAGE_FLAGS_NONE: No flags set.
|
* @G_DBUS_SEND_MESSAGE_FLAGS_NONE: No flags set.
|
||||||
|
* @G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL: Do not automatically
|
||||||
|
* assign a serial number from the #GDBusConnection object when
|
||||||
|
* sending a message.
|
||||||
*
|
*
|
||||||
* Flags used when sending #GDBusMessage<!-- -->s on a #GDBusConnection.
|
* Flags used when sending #GDBusMessage<!-- -->s on a #GDBusConnection.
|
||||||
*
|
*
|
||||||
* Since: 2.26
|
* Since: 2.26
|
||||||
*/
|
*/
|
||||||
typedef enum /*< flags >*/
|
typedef enum
|
||||||
{
|
{
|
||||||
G_DBUS_SEND_MESSAGE_FLAGS_NONE = 0,
|
G_DBUS_SEND_MESSAGE_FLAGS_NONE = 0,
|
||||||
|
G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL = (1<<0)
|
||||||
} GDBusSendMessageFlags;
|
} GDBusSendMessageFlags;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Loading…
Reference in New Issue
Block a user