diff --git a/docs/reference/gio/gio-sections-common.txt b/docs/reference/gio/gio-sections-common.txt index 39999c452..314d1009e 100644 --- a/docs/reference/gio/gio-sections-common.txt +++ b/docs/reference/gio/gio-sections-common.txt @@ -3026,6 +3026,8 @@ g_dbus_method_invocation_return_gerror g_dbus_method_invocation_return_dbus_error g_dbus_method_invocation_take_error g_dbus_method_invocation_return_value_with_unix_fd_list +G_DBUS_METHOD_INVOCATION_HANDLED +G_DBUS_METHOD_INVOCATION_UNHANDLED G_DBUS_METHOD_INVOCATION G_IS_DBUS_METHOD_INVOCATION diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py index 5234b3807..cda047173 100644 --- a/gio/gdbus-2.0/codegen/codegen.py +++ b/gio/gdbus-2.0/codegen/codegen.py @@ -1522,7 +1522,7 @@ class CodeGenerator: ' *\n' ' * If a signal handler returns %%TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call %s_complete_%s() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %%G_DBUS_ERROR_UNKNOWN_METHOD error is returned.\n' ' *\n' - ' * Returns: %%TRUE if the invocation was handled, %%FALSE to let other signal handlers run.\n' + ' * Returns: %%G_DBUS_METHOD_INVOCATION_HANDLED or %%TRUE if the invocation was handled, %%G_DBUS_METHOD_INVOCATION_UNHANDLED or %%FALSE to let other signal handlers run.\n' %(i.name, m.name, i.name_lower, m.name_lower), False)) self.write_gtkdoc_deprecated_and_since_and_close(m, self.outfile, 2) if m.unix_fd: diff --git a/gio/gdbusmethodinvocation.h b/gio/gdbusmethodinvocation.h index 061256ffe..775070a2c 100644 --- a/gio/gdbusmethodinvocation.h +++ b/gio/gdbusmethodinvocation.h @@ -33,6 +33,41 @@ G_BEGIN_DECLS #define G_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocation)) #define G_IS_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_METHOD_INVOCATION)) +/** + * G_DBUS_METHOD_INVOCATION_HANDLED: + * + * The value returned by handlers of the signals generated by + * the `gdbus-codegen` tool to indicate that a method call has been + * handled by an implementation. It is equal to %TRUE, but using + * this macro is sometimes more readable. + * + * In code that needs to be backwards-compatible with older GLib, + * use %TRUE instead, often written like this: + * + * |[ + * g_dbus_method_invocation_return_error (invocation, ...); + * return TRUE; // handled + * ]| + * + * Since: 2.68 + */ +#define G_DBUS_METHOD_INVOCATION_HANDLED TRUE GLIB_AVAILABLE_MACRO_IN_2_68 + +/** + * G_DBUS_METHOD_INVOCATION_UNHANDLED: + * + * The value returned by handlers of the signals generated by + * the `gdbus-codegen` tool to indicate that a method call has not been + * handled by an implementation. It is equal to %FALSE, but using + * this macro is sometimes more readable. + * + * In code that needs to be backwards-compatible with older GLib, + * use %FALSE instead. + * + * Since: 2.68 + */ +#define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE GLIB_AVAILABLE_MACRO_IN_2_68 + GLIB_AVAILABLE_IN_ALL GType g_dbus_method_invocation_get_type (void) G_GNUC_CONST; GLIB_AVAILABLE_IN_ALL diff --git a/gio/tests/gdbus-auth.c b/gio/tests/gdbus-auth.c index 8be4473c7..18288f36d 100644 --- a/gio/tests/gdbus-auth.c +++ b/gio/tests/gdbus-auth.c @@ -121,7 +121,7 @@ test_auth_on_timeout (gpointer user_data) { g_error ("Timeout waiting for client"); g_assert_not_reached (); - return FALSE; + return G_SOURCE_REMOVE; } diff --git a/gio/tests/gdbus-close-pending.c b/gio/tests/gdbus-close-pending.c index d2c5b62f5..bd8fda5a7 100644 --- a/gio/tests/gdbus-close-pending.c +++ b/gio/tests/gdbus-close-pending.c @@ -188,7 +188,7 @@ delayed_close_cb (gpointer data) close_async (df->stream, df->io_priority, df->cancellable, df->callback, df->user_data); - return FALSE; + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-connection-loss.c b/gio/tests/gdbus-connection-loss.c index a34a9923c..cc88cb0cc 100644 --- a/gio/tests/gdbus-connection-loss.c +++ b/gio/tests/gdbus-connection-loss.c @@ -53,7 +53,7 @@ on_timeout (gpointer user_data) { /* tear down bus */ session_bus_stop (); - return FALSE; /* remove source */ + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-connection-slow.c b/gio/tests/gdbus-connection-slow.c index dd1ababd4..27a6af3c4 100644 --- a/gio/tests/gdbus-connection-slow.c +++ b/gio/tests/gdbus-connection-slow.c @@ -49,7 +49,7 @@ test_connection_flush_on_timeout (gpointer user_data) guint iteration = GPOINTER_TO_UINT (user_data); g_printerr ("Timeout waiting 1000 msec on iteration %d\n", iteration); g_assert_not_reached (); - return FALSE; + return G_SOURCE_REMOVE; } static void @@ -125,7 +125,7 @@ large_message_timeout_cb (gpointer data) g_error ("Error: timeout waiting for dbus name to appear"); - return FALSE; + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c index 7bd7a02f4..278570609 100644 --- a/gio/tests/gdbus-connection.c +++ b/gio/tests/gdbus-connection.c @@ -65,7 +65,7 @@ test_connection_quit_mainloop (gpointer user_data) _log ("quit_mainloop_fired"); *quit_mainloop_fired = TRUE; g_main_loop_quit (loop); - return TRUE; + return G_SOURCE_CONTINUE; } /* ---------------------------------------------------------------------------------------------------- */ @@ -934,7 +934,7 @@ test_connection_filter_on_timeout (gpointer user_data) { g_printerr ("Timeout waiting 30 sec on service\n"); g_assert_not_reached (); - return FALSE; + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-example-objectmanager-server.c b/gio/tests/gdbus-example-objectmanager-server.c index c460e66e9..dcedba2d1 100644 --- a/gio/tests/gdbus-example-objectmanager-server.c +++ b/gio/tests/gdbus-example-objectmanager-server.c @@ -53,7 +53,7 @@ on_animal_poke (ExampleAnimal *animal, g_assert_not_reached (); out: - return TRUE; /* to indicate that the method was handled */ + return G_DBUS_METHOD_INVOCATION_HANDLED; } diff --git a/gio/tests/gdbus-example-server.c b/gio/tests/gdbus-example-server.c index 6f1123d85..00e482724 100644 --- a/gio/tests/gdbus-example-server.c +++ b/gio/tests/gdbus-example-server.c @@ -315,7 +315,7 @@ on_timeout_cb (gpointer user_data) g_assert_no_error (error); - return TRUE; + return G_SOURCE_CONTINUE; } /* ---------------------------------------------------------------------------------------------------- */ diff --git a/gio/tests/gdbus-exit-on-close.c b/gio/tests/gdbus-exit-on-close.c index 3c4e5ecd6..4241fc7a4 100644 --- a/gio/tests/gdbus-exit-on-close.c +++ b/gio/tests/gdbus-exit-on-close.c @@ -57,7 +57,7 @@ quit_later_cb (gpointer data G_GNUC_UNUSED) { g_main_loop_quit (loop); - return FALSE; + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-overflow.c b/gio/tests/gdbus-overflow.c index 53ec9c0b6..ca3d5d0e7 100644 --- a/gio/tests/gdbus-overflow.c +++ b/gio/tests/gdbus-overflow.c @@ -95,7 +95,7 @@ static gboolean overflow_on_500ms_later_func (gpointer user_data) { g_main_loop_quit (loop); - return FALSE; /* don't keep the idle */ + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c index 617d7561a..ca53528d2 100644 --- a/gio/tests/gdbus-peer.c +++ b/gio/tests/gdbus-peer.c @@ -644,7 +644,7 @@ check_connection (gpointer user_data) } } - return FALSE; + return G_SOURCE_REMOVE; } static gboolean @@ -654,7 +654,7 @@ on_do_disconnect_in_idle (gpointer data) g_debug ("GDC %p has ref_count %d", c, G_OBJECT (c)->ref_count); g_dbus_connection_disconnect (c); g_object_unref (c); - return FALSE; + return G_SOURCE_REMOVE; } #endif @@ -1719,7 +1719,7 @@ codegen_on_animal_poke (ExampleAnimal *animal, g_assert_not_reached (); out: - return TRUE; /* to indicate that the method was handled */ + return G_DBUS_METHOD_INVOCATION_HANDLED; } /* Runs in thread we created GDBusServer in (since we didn't pass G_DBUS_SERVER_FLAGS_RUN_IN_THREAD) */ @@ -1794,7 +1794,7 @@ static gboolean codegen_quit_mainloop_timeout (gpointer data) { g_main_loop_quit (loop); - return FALSE; + return G_SOURCE_REMOVE; } static void diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index bb1d059ca..9a3ffa927 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -33,6 +33,11 @@ #include "gdbus-test-codegen-generated-interface-info.h" +#if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_68 +# undef G_DBUS_METHOD_INVOCATION_HANDLED +# define G_DBUS_METHOD_INVOCATION_HANDLED TRUE +#endif + /* ---------------------------------------------------------------------------------------------------- */ static guint @@ -100,7 +105,7 @@ on_handle_hello_world (FooiGenBar *object, response = g_strdup_printf ("Word! You said '%s'. I'm Skeleton, btw!", greeting); foo_igen_bar_complete_hello_world (object, invocation, response); g_free (response); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -145,7 +150,7 @@ on_handle_test_primitive_types (FooiGenBar *object, g_free (s1); g_free (s2); g_free (s3); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -185,7 +190,7 @@ on_handle_test_non_primitive_types (FooiGenBar *object, array_of_bytestrings, str->str); g_string_free (str, TRUE); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -202,7 +207,7 @@ on_handle_request_signal_emission (FooiGenBar *object, foo_igen_bar_emit_test_signal (object, 43, a_strv, a_bytestring_array, a_variant); /* consumes a_variant */ foo_igen_bar_complete_request_signal_emission (object, invocation); } - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -218,7 +223,7 @@ on_handle_request_multi_property_mods (FooiGenBar *object, foo_igen_bar_set_y (object, foo_igen_bar_get_y (object) + 1); foo_igen_bar_set_i (object, foo_igen_bar_get_i (object) + 1); foo_igen_bar_complete_request_multi_property_mods (object, invocation); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -238,7 +243,7 @@ on_handle_property_cancellation (FooiGenBar *object, g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (object)); /* this makes us return the reply D-Bus method */ foo_igen_bar_complete_property_cancellation (object, invocation); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } /* ---------------------------------------------------------------------------------------------------- */ @@ -293,7 +298,7 @@ on_handle_force_method (FooiGenBat *object, g_variant_unref (ret_ay); g_variant_unref (ret_struct); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } @@ -382,7 +387,7 @@ on_handle_check_not_authorized (FooiGenAuthorize *object, gpointer user_data) { foo_igen_authorize_complete_check_not_authorized (object, invocation); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -391,7 +396,7 @@ on_handle_check_authorized (FooiGenAuthorize *object, gpointer user_data) { foo_igen_authorize_complete_check_authorized (object, invocation); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -400,7 +405,7 @@ on_handle_check_not_authorized_from_object (FooiGenAuthorize *object, gpointer user_data) { foo_igen_authorize_complete_check_not_authorized_from_object (object, invocation); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } /* ---------------------------------------------------------------------------------------------------- */ @@ -414,7 +419,7 @@ on_handle_get_self (FooiGenMethodThreads *object, s = g_strdup_printf ("%p", (void *)g_thread_self ()); foo_igen_method_threads_complete_get_self (object, invocation, s); g_free (s); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } /* ---------------------------------------------------------------------------------------------------- */ @@ -2645,7 +2650,7 @@ handle_hello_fd (FooiGenFDPassing *object, const gchar *arg_greeting) { foo_igen_fdpassing_complete_hello_fd (object, invocation, fd_list, arg_greeting); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 @@ -2657,7 +2662,7 @@ handle_no_annotation (FooiGenFDPassing *object, const gchar *arg_greeting_locale) { foo_igen_fdpassing_complete_no_annotation (object, invocation, fd_list, arg_greeting, arg_greeting_locale); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -2667,7 +2672,7 @@ handle_no_annotation_nested (FooiGenFDPassing *object, GVariant *arg_files) { foo_igen_fdpassing_complete_no_annotation_nested (object, invocation, fd_list); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } #else static gboolean @@ -2677,7 +2682,7 @@ handle_no_annotation (FooiGenFDPassing *object, const gchar *arg_greeting_locale) { foo_igen_fdpassing_complete_no_annotation (object, invocation, arg_greeting, arg_greeting_locale); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } static gboolean @@ -2686,7 +2691,7 @@ handle_no_annotation_nested (FooiGenFDPassing *object, GVariant *arg_files) { foo_igen_fdpassing_complete_no_annotation_nested (object, invocation); - return TRUE; + return G_DBUS_METHOD_INVOCATION_HANDLED; } #endif diff --git a/gio/tests/gdbus-tests.c b/gio/tests/gdbus-tests.c index bed0d24f7..1003d07e0 100644 --- a/gio/tests/gdbus-tests.c +++ b/gio/tests/gdbus-tests.c @@ -48,7 +48,7 @@ on_property_notify_timeout (gpointer user_data) PropertyNotifyData *data = user_data; data->timed_out = TRUE; g_main_loop_quit (data->loop); - return TRUE; + return G_SOURCE_CONTINUE; } gboolean @@ -83,7 +83,7 @@ static gboolean _give_up (gpointer data) { g_error ("%s", (const gchar *) data); - g_return_val_if_reached (TRUE); + g_return_val_if_reached (G_SOURCE_CONTINUE); } typedef struct @@ -175,7 +175,7 @@ on_signal_received_timeout (gpointer user_data) SignalReceivedData *data = user_data; data->timed_out = TRUE; g_main_loop_quit (data->loop); - return TRUE; + return G_SOURCE_CONTINUE; } gboolean