summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--glib/dbus-glib.h6
-rw-r--r--glib/dbus-gmain.c36
-rw-r--r--glib/test-dbus-glib.c2
-rw-r--r--glib/test-thread-client.c2
-rw-r--r--glib/test-thread-server.c4
-rw-r--r--tools/dbus-monitor.c2
7 files changed, 46 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a9ee363..e13e05d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2003-04-23 James Willcox <jwillcox@gnome.org>
+
+ * glib/dbus-glib.h:
+ * glib/dbus-gmain.c: (add_timeout), (wakeup_main), (create_source),
+ (dbus_connection_setup_with_g_main),
+ (dbus_server_setup_with_g_main):
+ * glib/test-dbus-glib.c: (main):
+ * glib/test-thread-client.c: (main):
+ * glib/test-thread-server.c: (new_connection_callback), (main):
+ * tools/dbus-monitor.c: (main):
+
+ Added a GMainContext argument to dbus_connection_setup_with_g_main()
+ and dbus_server_setup_with_g_main().
+
2003-04-20 Havoc Pennington <hp@pobox.com>
* doc/dbus-specification.sgml: document the restrictions on
diff --git a/glib/dbus-glib.h b/glib/dbus-glib.h
index 6d90df94..f92d729e 100644
--- a/glib/dbus-glib.h
+++ b/glib/dbus-glib.h
@@ -27,7 +27,9 @@
#include <glib.h>
void dbus_gthread_init (void);
-void dbus_connection_setup_with_g_main (DBusConnection *connection);
-void dbus_server_setup_with_g_main (DBusServer *server);
+void dbus_connection_setup_with_g_main (DBusConnection *connection,
+ GMainContext *context);
+void dbus_server_setup_with_g_main (DBusServer *server,
+ GMainContext *context);
#endif /* DBUS_GLIB_H */
diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c
index 3a90ee3d..15490fbd 100644
--- a/glib/dbus-gmain.c
+++ b/glib/dbus-gmain.c
@@ -55,6 +55,8 @@ struct DBusGSource
GList *poll_fds; /**< descriptors we're watching */
GHashTable *watches; /**< hash of DBusWatch objects */
+ GMainContext *context; /**< the GMainContext to use, NULL for default */
+
void *connection_or_server; /**< DBusConnection or DBusServer */
};
@@ -304,15 +306,18 @@ static dbus_bool_t
add_timeout (DBusTimeout *timeout,
void *data)
{
- guint timeout_tag;
+ DBusGSource *dbus_source = data;
+ GSource *source;
if (!dbus_timeout_get_enabled (timeout))
return TRUE;
- timeout_tag = g_timeout_add (dbus_timeout_get_interval (timeout),
- timeout_handler, timeout);
+ source = g_timeout_source_new (dbus_timeout_get_interval (timeout));
+ g_source_set_callback (source, timeout_handler, timeout, NULL);
+ g_source_attach (source, dbus_source->context);
- dbus_timeout_set_data (timeout, GUINT_TO_POINTER (timeout_tag), NULL);
+ dbus_timeout_set_data (timeout, GUINT_TO_POINTER (g_source_get_id (source)),
+ NULL);
return TRUE;
}
@@ -352,7 +357,9 @@ free_source (GSource *source)
static void
wakeup_main (void *data)
{
- g_main_context_wakeup (NULL);
+ DBusGSource *dbus_source = data;
+
+ g_main_context_wakeup (dbus_source->context);
}
@@ -364,7 +371,8 @@ wakeup_main (void *data)
static GSource*
create_source (void *connection_or_server,
- GSourceFuncs *funcs)
+ GSourceFuncs *funcs,
+ GMainContext *context)
{
GSource *source;
DBusGSource *dbus_source;
@@ -374,6 +382,7 @@ create_source (void *connection_or_server,
dbus_source = (DBusGSource *)source;
dbus_source->watches = g_hash_table_new (NULL, NULL);
dbus_source->connection_or_server = connection_or_server;
+ dbus_source->context = context;
return source;
}
@@ -385,11 +394,12 @@ create_source (void *connection_or_server,
* @param connection the connection
*/
void
-dbus_connection_setup_with_g_main (DBusConnection *connection)
+dbus_connection_setup_with_g_main (DBusConnection *connection,
+ GMainContext *context)
{
GSource *source;
- source = create_source (connection, &dbus_connection_funcs);
+ source = create_source (connection, &dbus_connection_funcs, context);
if (!dbus_connection_set_watch_functions (connection,
add_watch,
@@ -407,9 +417,9 @@ dbus_connection_setup_with_g_main (DBusConnection *connection)
dbus_connection_set_wakeup_main_function (connection,
wakeup_main,
- NULL, NULL);
+ source, NULL);
- g_source_attach (source, NULL);
+ g_source_attach (source, context);
g_static_mutex_lock (&connection_slot_lock);
if (connection_slot == -1 )
@@ -436,11 +446,11 @@ dbus_connection_setup_with_g_main (DBusConnection *connection)
* @param server the server
*/
void
-dbus_server_setup_with_g_main (DBusServer *server)
+dbus_server_setup_with_g_main (DBusServer *server, GMainContext *context)
{
GSource *source;
- source = create_source (server, &dbus_server_funcs);
+ source = create_source (server, &dbus_server_funcs, context);
dbus_server_set_watch_functions (server,
add_watch,
@@ -454,7 +464,7 @@ dbus_server_setup_with_g_main (DBusServer *server)
timeout_toggled,
NULL, NULL);
- g_source_attach (source, NULL);
+ g_source_attach (source, context);
g_static_mutex_lock (&server_slot_lock);
if (server_slot == -1 )
diff --git a/glib/test-dbus-glib.c b/glib/test-dbus-glib.c
index c838b688..9fcbe4c0 100644
--- a/glib/test-dbus-glib.c
+++ b/glib/test-dbus-glib.c
@@ -28,7 +28,7 @@ main (int argc, char **argv)
return 1;
}
- dbus_connection_setup_with_g_main (connection);
+ dbus_connection_setup_with_g_main (connection, NULL);
message = dbus_message_new ("org.freedesktop.DBus", "org.freedesktop.DBus.Hello");
diff --git a/glib/test-thread-client.c b/glib/test-thread-client.c
index 38926ef0..3ae0a517 100644
--- a/glib/test-thread-client.c
+++ b/glib/test-thread-client.c
@@ -80,7 +80,7 @@ main (int argc, char *argv[])
return 1;
}
- dbus_connection_setup_with_g_main (connection);
+ dbus_connection_setup_with_g_main (connection, NULL);
for (i = 0; i < N_TEST_THREADS; i++)
{
diff --git a/glib/test-thread-server.c b/glib/test-thread-server.c
index 367a2b33..a92febf3 100644
--- a/glib/test-thread-server.c
+++ b/glib/test-thread-server.c
@@ -162,7 +162,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);
+ dbus_connection_setup_with_g_main (new_connection, NULL);
data = thread_test_data_new ();
@@ -238,7 +238,7 @@ main (int argc, char *argv[])
new_connection_callback,
NULL, NULL);
- dbus_server_setup_with_g_main (server);
+ dbus_server_setup_with_g_main (server, NULL);
loop = g_main_loop_new (NULL, FALSE);
g_main_run (loop);
diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c
index 466a0836..8a8e6585 100644
--- a/tools/dbus-monitor.c
+++ b/tools/dbus-monitor.c
@@ -111,7 +111,7 @@ main (int argc, char *argv[])
exit (1);
}
- dbus_connection_setup_with_g_main (connection);
+ dbus_connection_setup_with_g_main (connection, NULL);
handler = dbus_message_handler_new (handler_func, NULL, NULL);
dbus_connection_add_filter (connection, handler);