From b6f7c810cf97914b6b90836f3d59ea256f318bcb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 22 Jan 2018 16:47:21 +0000 Subject: Make dbus-gmain.h internal, and rename its symbols If we embed dbus-gmain in dbus-glib, dbus-python, at-spi2-core and others as a submodule or subtree, we won't want it to export the same ABI in all of them. Signed-off-by: Simon McVittie --- dbus/Makefile.am | 2 +- dbus/dbus-glib-lowlevel.h | 6 +++++- dbus/dbus-glib.c | 48 ++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-gmain.c | 16 ++++++-------- dbus/dbus-gmain.h | 13 +++++++----- test/core/30574.c | 10 ++++----- test/core/test-thread-client.c | 2 +- test/core/test-thread-server.c | 4 ++-- 8 files changed, 76 insertions(+), 25 deletions(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 91ca3ab..ae56918 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -27,6 +27,7 @@ DBUS_GLIB_INTERNALS = \ libdbus_glib_1_la_SOURCES = \ dbus-glib.c \ dbus-gmain.c \ + dbus-gmain.h \ dbus-gmarshal.c \ dbus-gmarshal.h \ dbus-gobject.c \ @@ -45,7 +46,6 @@ libdbus_glib_HEADERS = \ dbus-gvalue-parse-variant.h \ dbus-glib.h \ dbus-glib-lowlevel.h \ - dbus-gmain.h \ $(NULL) libdbus_glibdir = $(includedir)/dbus-1.0/dbus diff --git a/dbus/dbus-glib-lowlevel.h b/dbus/dbus-glib-lowlevel.h index bd479ad..d08f951 100644 --- a/dbus/dbus-glib-lowlevel.h +++ b/dbus/dbus-glib-lowlevel.h @@ -25,7 +25,6 @@ #define DBUS_GLIB_LOWLEVEL_H #include -#include #include G_BEGIN_DECLS @@ -38,6 +37,11 @@ void dbus_set_g_error (GError **gerror, GType dbus_connection_get_g_type (void) G_GNUC_CONST; GType dbus_message_get_g_type (void) G_GNUC_CONST; +void dbus_connection_setup_with_g_main (DBusConnection *connection, + GMainContext *context); +void dbus_server_setup_with_g_main (DBusServer *server, + GMainContext *context); + void dbus_g_proxy_send (DBusGProxy *proxy, DBusMessage *message, dbus_uint32_t *client_serial); diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c index 66bab44..1219c18 100644 --- a/dbus/dbus-glib.c +++ b/dbus/dbus-glib.c @@ -24,6 +24,7 @@ #include #include "dbus/dbus-glib.h" #include "dbus/dbus-glib-lowlevel.h" +#include "dbus-gmain.h" #include "dbus-gtest.h" #include "dbus-gutils.h" #include "dbus-gvalue.h" @@ -589,3 +590,50 @@ dbus_g_bus_get_private (DBusBusType type, return DBUS_G_CONNECTION_FROM_CONNECTION (connection); } + +/** + * dbus_connection_setup_with_g_main: + * @connection: the connection + * @context: the #GMainContext or %NULL for default context + * + * Sets the watch and timeout functions of a #DBusConnection + * to integrate the connection with the GLib main loop. + * Pass in %NULL for the #GMainContext unless you're + * doing something specialized. + * + * If called twice for the same context, does nothing the second + * time. If called once with context A and once with context B, + * context B replaces context A as the context monitoring the + * connection. + * + * Deprecated: New code should use GDBus instead. + */ +void +dbus_connection_setup_with_g_main (DBusConnection *connection, + GMainContext *context) +{ + dbus_gmain_set_up_connection (connection, context); +} + +/** + * dbus_server_setup_with_g_main: + * @server: the server + * @context: the #GMainContext or %NULL for default + * + * Sets the watch and timeout functions of a #DBusServer + * to integrate the server with the GLib main loop. + * In most cases the context argument should be %NULL. + * + * If called twice for the same context, does nothing the second + * time. If called once with context A and once with context B, + * context B replaces context A as the context monitoring the + * connection. + * + * Deprecated: New code should use GDBus instead. + */ +void +dbus_server_setup_with_g_main (DBusServer *server, + GMainContext *context) +{ + dbus_gmain_set_up_server (server, context); +} diff --git a/dbus/dbus-gmain.c b/dbus/dbus-gmain.c index 412a7a6..034354c 100644 --- a/dbus/dbus-gmain.c +++ b/dbus/dbus-gmain.c @@ -508,7 +508,7 @@ connection_setup_new_from_old (GMainContext *context, } /** - * dbus_connection_setup_with_g_main: + * dbus_gmain_set_up_connection: * @connection: the connection * @context: the #GMainContext or %NULL for default context * @@ -521,12 +521,10 @@ connection_setup_new_from_old (GMainContext *context, * time. If called once with context A and once with context B, * context B replaces context A as the context monitoring the * connection. - * - * Deprecated: New code should use GDBus instead. */ void -dbus_connection_setup_with_g_main (DBusConnection *connection, - GMainContext *context) +dbus_gmain_set_up_connection (DBusConnection *connection, + GMainContext *context) { ConnectionSetup *old_setup; ConnectionSetup *cs; @@ -588,7 +586,7 @@ dbus_connection_setup_with_g_main (DBusConnection *connection, } /** - * dbus_server_setup_with_g_main: + * dbus_gmain_set_up_server: * @server: the server * @context: the #GMainContext or %NULL for default * @@ -600,12 +598,10 @@ dbus_connection_setup_with_g_main (DBusConnection *connection, * time. If called once with context A and once with context B, * context B replaces context A as the context monitoring the * connection. - * - * Deprecated: New code should use GDBus instead. */ void -dbus_server_setup_with_g_main (DBusServer *server, - GMainContext *context) +dbus_gmain_set_up_server (DBusServer *server, + GMainContext *context) { ConnectionSetup *old_setup; ConnectionSetup *cs; diff --git a/dbus/dbus-gmain.h b/dbus/dbus-gmain.h index 111772e..e442c2d 100644 --- a/dbus/dbus-gmain.h +++ b/dbus/dbus-gmain.h @@ -29,14 +29,17 @@ G_BEGIN_DECLS -void dbus_connection_setup_with_g_main (DBusConnection *connection, - GMainContext *context); -void dbus_server_setup_with_g_main (DBusServer *server, - GMainContext *context); +G_GNUC_INTERNAL +void dbus_gmain_set_up_connection (DBusConnection *connection, + GMainContext *context); + +G_GNUC_INTERNAL +void dbus_gmain_set_up_server (DBusServer *server, + GMainContext *context); G_END_DECLS -#endif /* DBUS_GLIB_LOWLEVEL_H */ +#endif /* DBUS_GMAIN_H */ diff --git a/test/core/30574.c b/test/core/30574.c index 2cf1e21..a5aa5cc 100644 --- a/test/core/30574.c +++ b/test/core/30574.c @@ -22,7 +22,7 @@ set_reply (DBusPendingCall * pending, void *user_data) SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; closure->reply = dbus_pending_call_steal_reply (pending); - dbus_connection_setup_with_g_main (bus, NULL); + dbus_gmain_set_up_connection (bus, NULL); g_main_loop_quit (closure->loop); } @@ -35,17 +35,17 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, SpiReentrantCallClosure closure; closure.loop = g_main_loop_new (main_context, FALSE); - dbus_connection_setup_with_g_main (bus, (switch_after_send ? NULL : + dbus_gmain_set_up_connection (bus, (switch_after_send ? NULL : main_context)); if (!dbus_connection_send_with_reply (bus, message, &pending, 3000)) { - dbus_connection_setup_with_g_main (bus, NULL); + dbus_gmain_set_up_connection (bus, NULL); return NULL; } dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL); if (switch_after_send) - dbus_connection_setup_with_g_main (bus, main_context); + dbus_gmain_set_up_connection (bus, main_context); g_main_loop_run (closure.loop); g_main_loop_unref (closure.loop); @@ -99,7 +99,7 @@ main(int argc, const char *argv[]) fprintf(stderr, "Couldn't connect to bus: %s\n", error.name); return 1; } - dbus_connection_setup_with_g_main (bus, NULL); + dbus_gmain_set_up_connection (bus, NULL); send_test_message (FALSE); send_test_message (FALSE); send_test_message (TRUE); diff --git a/test/core/test-thread-client.c b/test/core/test-thread-client.c index e246a33..ecd6c0e 100644 --- a/test/core/test-thread-client.c +++ b/test/core/test-thread-client.c @@ -82,7 +82,7 @@ main (int argc, char *argv[]) return 1; } - dbus_connection_setup_with_g_main (connection, NULL); + dbus_gmain_set_up_connection (connection, NULL); for (i = 0; i < N_TEST_THREADS; i++) { diff --git a/test/core/test-thread-server.c b/test/core/test-thread-server.c index 33fb08c..34cbb1e 100644 --- a/test/core/test-thread-server.c +++ b/test/core/test-thread-server.c @@ -154,7 +154,7 @@ new_connection_callback (DBusServer *server, g_print ("new_connection_callback\n"); dbus_connection_ref (new_connection); - dbus_connection_setup_with_g_main (new_connection, NULL); + dbus_gmain_set_up_connection (new_connection, NULL); data = thread_test_data_new (); @@ -200,7 +200,7 @@ main (int argc, char *argv[]) new_connection_callback, NULL, NULL); - dbus_server_setup_with_g_main (server, NULL); + dbus_gmain_set_up_server (server, NULL); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); -- cgit v1.2.1