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:
David Zeuthen
2010-06-11 15:45:18 -04:00
parent e0f8d30dea
commit 32f2e9a85b
22 changed files with 1514 additions and 1384 deletions

View File

@@ -34,11 +34,7 @@ static GMainLoop *loop = NULL;
/* ---------------------------------------------------------------------------------------------------- */
static void
introspection_on_proxy_appeared (GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
GDBusProxy *proxy,
gpointer user_data)
test_introspection (GDBusProxy *proxy)
{
GError *error;
const gchar *xml_data;
@@ -104,48 +100,47 @@ introspection_on_proxy_appeared (GDBusConnection *connection,
g_main_loop_quit (loop);
}
static void
introspection_on_proxy_vanished (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
}
static void
test_introspection_parser (void)
{
guint watcher_id;
GDBusProxy *proxy;
GDBusConnection *connection;
GError *error;
session_bus_up ();
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,
introspection_on_proxy_appeared,
introspection_on_proxy_vanished,
NULL,
NULL);
/* TODO: wait a bit for the bus to come up.. ideally session_bus_up() won't return
* until one can connect to the bus but that's not how things work right now
*/
usleep (500 * 1000);
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);
/* this is safe; testserver will exit once the bus goes away */
g_assert (g_spawn_command_line_async (SRCDIR "/gdbus-testserver.py", NULL));
g_main_loop_run (loop);
_g_assert_property_notify (proxy, "g-name-owner");
g_bus_unwatch_proxy (watcher_id);
test_introspection (proxy);
/* tear down bus */
session_bus_down ();
g_object_unref (proxy);
g_object_unref (connection);
}
/* ---------------------------------------------------------------------------------------------------- */
int