if (!g_dbus_connection_flush_sync (G_DBUS_CONNECTION (object),
cancellable,
&error))
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
}
/**
if (!g_dbus_connection_close_sync (G_DBUS_CONNECTION (object),
cancellable,
&error))
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
}
/**
if (out_serial != NULL)
*out_serial = serial_to_use;
- g_dbus_message_set_serial (message, serial_to_use);
+ if (!(flags & G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL))
+ g_dbus_message_set_serial (message, serial_to_use);
g_dbus_message_lock (message);
_g_dbus_worker_send_message (connection->worker,
error = NULL;
if (!g_dbus_connection_send_message_unlocked (connection, message, flags, out_serial, &error))
{
- g_simple_async_result_set_from_error (simple, error);
+ g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
goto out;
(GDestroyNotify) g_object_unref);
}
- data->timeout_source = g_timeout_source_new (timeout_msec);
- g_source_set_priority (data->timeout_source, G_PRIORITY_DEFAULT);
- g_source_set_callback (data->timeout_source,
- send_message_with_reply_timeout_cb,
- send_message_data_ref (data),
- (GDestroyNotify) send_message_data_unref);
- g_source_attach (data->timeout_source, data->main_context);
- g_source_unref (data->timeout_source);
+ if (timeout_msec != G_MAXINT)
+ {
+ data->timeout_source = g_timeout_source_new (timeout_msec);
+ g_source_set_priority (data->timeout_source, G_PRIORITY_DEFAULT);
+ g_source_set_callback (data->timeout_source,
+ send_message_with_reply_timeout_cb,
+ send_message_data_ref (data),
+ (GDestroyNotify) send_message_data_unref);
+ g_source_attach (data->timeout_source, data->main_context);
+ g_source_unref (data->timeout_source);
+ }
g_hash_table_insert (connection->map_method_serial_to_send_message_data,
GUINT_TO_POINTER (*out_serial),
* @connection: A #GDBusConnection.
* @message: A #GDBusMessage.
* @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, -1 to use the default
+ * timeout or %G_MAXINT for no timeout.
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
* @cancellable: A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't
* @connection: A #GDBusConnection.
* @message: A #GDBusMessage.
* @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, -1 to use the default
+ * timeout or %G_MAXINT for no timeout.
* @out_serial: Return location for serial number assigned to @message when sending it or %NULL.
* @cancellable: A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
const gchar *interface_name,
const gchar *member,
const gchar *object_path,
- const gchar *arg0)
+ const gchar *arg0,
+ gboolean negate)
{
GString *rule;
rule = g_string_new ("type='signal'");
+ if (negate)
+ g_string_prepend_c (rule, '-');
if (sender != NULL)
g_string_append_printf (rule, ",sender='%s'", sender);
if (interface_name != NULL)
GError *error;
GDBusMessage *message;
+ if (match_rule[0] == '-')
+ return;
+
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* path */
"org.freedesktop.DBus", /* interface */
GError *error;
GDBusMessage *message;
+ if (match_rule[0] == '-')
+ return;
+
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* path */
"org.freedesktop.DBus", /* interface */
CONNECTION_LOCK (connection);
- rule = args_to_rule (sender, interface_name, member, object_path, arg0);
+ /* If G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE was specified, we will end up
+ * with a '-' character to prefix the rule (which will otherwise be
+ * normal).
+ *
+ * This allows us to hash the rule and do our lifecycle tracking in
+ * the usual way, but the '-' prevents the match rule from ever
+ * actually being send to the bus (either for add or remove).
+ */
+ rule = args_to_rule (sender, interface_name, member, object_path, arg0,
+ (flags & G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE) != 0);
if (sender != NULL && (g_dbus_is_unique_name (sender) || g_strcmp0 (sender, "org.freedesktop.DBus") == 0))
sender_unique_name = sender;
value = NULL;
if (value == NULL)
- {
- g_simple_async_result_set_from_error (state->simple, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (state->simple, error);
else
g_simple_async_result_set_op_res_gpointer (state->simple, value,
(GDestroyNotify) g_variant_unref);
* @parameters: A #GVariant tuple with parameters for the method or %NULL if not passing parameters.
* @reply_type: The expected type of the reply, or %NULL.
* @flags: Flags from the #GDBusCallFlags enumeration.
- * @timeout_msec: The timeout in milliseconds or -1 to use the default timeout.
+ * @timeout_msec: The timeout in milliseconds, -1 to use the default
+ * timeout or %G_MAXINT for no timeout.
* @cancellable: A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't
* care about the result of the method invocation.
* @parameters: A #GVariant tuple with parameters for the method or %NULL if not passing parameters.
* @reply_type: The expected type of the reply, or %NULL.
* @flags: Flags from the #GDBusCallFlags enumeration.
- * @timeout_msec: The timeout in milliseconds or -1 to use the default timeout.
+ * @timeout_msec: The timeout in milliseconds, -1 to use the default
+ * timeout or %G_MAXINT for no timeout.
* @cancellable: A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
&error))
{
g_assert (error != NULL);
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
+ g_simple_async_result_take_error (simple, error);
g_object_unref (source_object);
}
else
if (connection == NULL)
{
g_assert (error != NULL);
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
+ g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}