summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2018-01-29 08:38:33 +0000
committerSimon McVittie <smcv@debian.org>2018-01-29 08:47:32 +0000
commit399f1454f1aaad4627c2cac28f1ef78d62d007ca (patch)
tree77558b993d3247366a650742f06bdaee962c64e4
parent906508155ff27c76d1d85a7a1f68ab69f6161508 (diff)
downloaddbus-glib-399f1454f1aaad4627c2cac28f1ef78d62d007ca.tar.gz
dbus-gmain: Allow swapping the namespace used
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--configure.ac5
-rw-r--r--dbus-gmain/dbus-gmain.c12
-rw-r--r--dbus-gmain/dbus-gmain.h26
-rw-r--r--dbus-gmain/tests/30574.c13
-rw-r--r--dbus-gmain/tests/test-thread-client.c2
-rw-r--r--dbus-gmain/tests/test-thread-server.c4
-rw-r--r--dbus/dbus-glib.c4
7 files changed, 42 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index bd97d74..889faf9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -285,6 +285,11 @@ AC_PATH_PROG([DBUS_RUN_SESSION], [dbus-run-session], [dbus-run-session])
### gtk-doc Documentation
GTK_DOC_CHECK([1.14], [--flavour no-tmpl])
+# Make dbus-gmain submodule part of dbus-glib's namespace
+AH_BOTTOM([
+#define DBUS_GMAIN_FUNCTION_NAME(name) _dbus_g_ ## name
+])
+
AC_CONFIG_FILES([
Makefile
m4/Makefile
diff --git a/dbus-gmain/dbus-gmain.c b/dbus-gmain/dbus-gmain.c
index 424eee7..bea89aa 100644
--- a/dbus-gmain/dbus-gmain.c
+++ b/dbus-gmain/dbus-gmain.c
@@ -525,9 +525,9 @@ connection_setup_new_from_old (GMainContext *context,
* context B replaces context A as the context monitoring the
* connection.
*/
-void
-dbus_gmain_set_up_connection (DBusConnection *connection,
- GMainContext *context)
+DBUS_GMAIN_FUNCTION (void,
+set_up_connection, DBusConnection *connection,
+ GMainContext *context)
{
ConnectionSetup *old_setup;
ConnectionSetup *cs;
@@ -602,9 +602,9 @@ dbus_gmain_set_up_connection (DBusConnection *connection,
* context B replaces context A as the context monitoring the
* connection.
*/
-void
-dbus_gmain_set_up_server (DBusServer *server,
- GMainContext *context)
+DBUS_GMAIN_FUNCTION (void,
+set_up_server, DBusServer *server,
+ GMainContext *context)
{
ConnectionSetup *old_setup;
ConnectionSetup *cs;
diff --git a/dbus-gmain/dbus-gmain.h b/dbus-gmain/dbus-gmain.h
index e442c2d..e887942 100644
--- a/dbus-gmain/dbus-gmain.h
+++ b/dbus-gmain/dbus-gmain.h
@@ -24,18 +24,30 @@
#ifndef DBUS_GMAIN_H
#define DBUS_GMAIN_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <dbus/dbus.h>
#include <glib.h>
-G_BEGIN_DECLS
+#ifndef DBUS_GMAIN_FUNCTION_NAME
+# define DBUS_GMAIN_FUNCTION_NAME(name) dbus_gmain_ ## name
+#endif
-G_GNUC_INTERNAL
-void dbus_gmain_set_up_connection (DBusConnection *connection,
- GMainContext *context);
+#ifndef DBUS_GMAIN_FUNCTION
+# define DBUS_GMAIN_FUNCTION(ret, name, ...) \
+ G_GNUC_INTERNAL ret DBUS_GMAIN_FUNCTION_NAME (name) (__VA_ARGS__)
+#endif
+
+G_BEGIN_DECLS
-G_GNUC_INTERNAL
-void dbus_gmain_set_up_server (DBusServer *server,
- GMainContext *context);
+DBUS_GMAIN_FUNCTION (void, set_up_connection,
+ DBusConnection *connection,
+ GMainContext *context);
+DBUS_GMAIN_FUNCTION (void, set_up_server,
+ DBusServer *server,
+ GMainContext *context);
G_END_DECLS
diff --git a/dbus-gmain/tests/30574.c b/dbus-gmain/tests/30574.c
index ef66df2..ca7b79f 100644
--- a/dbus-gmain/tests/30574.c
+++ b/dbus-gmain/tests/30574.c
@@ -46,7 +46,7 @@ set_reply (DBusPendingCall * pending, void *user_data)
SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data;
closure->reply = dbus_pending_call_steal_reply (pending);
- dbus_gmain_set_up_connection (bus, NULL);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (bus, NULL);
g_main_loop_quit (closure->loop);
}
@@ -59,17 +59,18 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message,
SpiReentrantCallClosure closure;
closure.loop = g_main_loop_new (main_context, FALSE);
- dbus_gmain_set_up_connection (bus, (switch_after_send ? NULL :
- main_context));
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (bus,
+ (switch_after_send ? NULL :
+ main_context));
if (!dbus_connection_send_with_reply (bus, message, &pending, 3000))
{
- dbus_gmain_set_up_connection (bus, NULL);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (bus, NULL);
return NULL;
}
dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
if (switch_after_send)
- dbus_gmain_set_up_connection (bus, main_context);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (bus, main_context);
g_main_loop_run (closure.loop);
g_main_loop_unref (closure.loop);
@@ -123,7 +124,7 @@ main(int argc, const char *argv[])
fprintf(stderr, "Couldn't connect to bus: %s\n", error.name);
return 1;
}
- dbus_gmain_set_up_connection (bus, NULL);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (bus, NULL);
send_test_message (FALSE);
send_test_message (FALSE);
send_test_message (TRUE);
diff --git a/dbus-gmain/tests/test-thread-client.c b/dbus-gmain/tests/test-thread-client.c
index 8f91646..79de541 100644
--- a/dbus-gmain/tests/test-thread-client.c
+++ b/dbus-gmain/tests/test-thread-client.c
@@ -106,7 +106,7 @@ main (int argc, char *argv[])
return 1;
}
- dbus_gmain_set_up_connection (connection, NULL);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (connection, NULL);
for (i = 0; i < N_TEST_THREADS; i++)
{
diff --git a/dbus-gmain/tests/test-thread-server.c b/dbus-gmain/tests/test-thread-server.c
index 5a1204f..c8839d1 100644
--- a/dbus-gmain/tests/test-thread-server.c
+++ b/dbus-gmain/tests/test-thread-server.c
@@ -178,7 +178,7 @@ new_connection_callback (DBusServer *server,
g_print ("new_connection_callback\n");
dbus_connection_ref (new_connection);
- dbus_gmain_set_up_connection (new_connection, NULL);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (new_connection, NULL);
data = thread_test_data_new ();
@@ -224,7 +224,7 @@ main (int argc, char *argv[])
new_connection_callback,
NULL, NULL);
- dbus_gmain_set_up_server (server, NULL);
+ DBUS_GMAIN_FUNCTION_NAME (set_up_server) (server, NULL);
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c
index abb2f57..9723882 100644
--- a/dbus/dbus-glib.c
+++ b/dbus/dbus-glib.c
@@ -612,7 +612,7 @@ void
dbus_connection_setup_with_g_main (DBusConnection *connection,
GMainContext *context)
{
- dbus_gmain_set_up_connection (connection, context);
+ _dbus_g_set_up_connection (connection, context);
}
/**
@@ -635,5 +635,5 @@ void
dbus_server_setup_with_g_main (DBusServer *server,
GMainContext *context)
{
- dbus_gmain_set_up_server (server, context);
+ _dbus_g_set_up_server (server, context);
}