mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-24 02:47:52 +02:00
Bug 621213 – GDBusProxy and well-known names
Allow constructing a GDBusProxy for well-known names as discussed here http://mail.gnome.org/archives/gtk-devel-list/2009-October/msg00075.html including test cases. Make it possible to create a GDBusProxy for a GBusType instead of a GDBusConnection. This requires G_BUS_TYPE_NONE so add that too. Nuke g_bus_watch_proxy() since one can now more or less use GDBusProxy for this. Port gdbus-example-watch-proxy to this new API and include this example in the GDBusProxy doc page. Also nuke the GType parameter from the GDBusProxy constructors as requested here: https://bugzilla.gnome.org/show_bug.cgi?id=621229 Also update the porting guide and other API docs for this change. Also fix a bug in the signal dispatching code so each subscriber only get notified once, not N times, for the same signal. Also add a test case for this. https://bugzilla.gnome.org/show_bug.cgi?id=621213 Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
@@ -348,11 +348,7 @@ test_sleep_in_thread_func (gpointer _data)
|
||||
}
|
||||
|
||||
static void
|
||||
on_proxy_appeared (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
const gchar *name_owner,
|
||||
GDBusProxy *proxy,
|
||||
gpointer user_data)
|
||||
test_method_calls_on_proxy (GDBusProxy *proxy)
|
||||
{
|
||||
guint n;
|
||||
|
||||
@@ -453,33 +449,38 @@ on_proxy_appeared (GDBusConnection *connection,
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
static void
|
||||
on_proxy_vanished (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_method_calls_in_thread (void)
|
||||
{
|
||||
guint watcher_id;
|
||||
GDBusProxy *proxy;
|
||||
GDBusConnection *connection;
|
||||
GError *error;
|
||||
gchar *name_owner;
|
||||
|
||||
watcher_id = g_bus_watch_proxy (G_BUS_TYPE_SESSION,
|
||||
"com.example.TestService",
|
||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||
"/com/example/TestObject",
|
||||
"com.example.Frob",
|
||||
G_TYPE_DBUS_PROXY,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
on_proxy_appeared,
|
||||
on_proxy_vanished,
|
||||
NULL,
|
||||
NULL);
|
||||
error = NULL;
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
|
||||
NULL,
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
error = NULL;
|
||||
proxy = g_dbus_proxy_new_sync (connection,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL, /* GDBusInterfaceInfo */
|
||||
"com.example.TestService", /* name */
|
||||
"/com/example/TestObject", /* object path */
|
||||
"com.example.Frob", /* interface */
|
||||
NULL, /* GCancellable */
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_main_loop_run (loop);
|
||||
name_owner = g_dbus_proxy_get_name_owner (proxy);
|
||||
g_assert_cmpstr (name_owner, !=, NULL);
|
||||
g_free (name_owner);
|
||||
|
||||
g_bus_unwatch_proxy (watcher_id);
|
||||
test_method_calls_on_proxy (proxy);
|
||||
|
||||
g_object_unref (proxy);
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user