diff options
author | Havoc Pennington <hp@redhat.com> | 2007-06-18 19:32:51 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2007-06-18 19:32:51 +0000 |
commit | 54b943432c7c947db88066751dd36a372cc9a618 (patch) | |
tree | 9b3eb7bc94cc0058c3fbcf2dc361fac40561a210 /test/name-test/test-ids.c | |
parent | ded479fda43da9dbe5780d0a2b287b5b1dcac64e (diff) | |
download | dbus-54b943432c7c947db88066751dd36a372cc9a618.tar.gz |
2007-06-18 Havoc Pennington <hp@redhat.com>
* doc/dbus-specification.xml: document org.freedesktop.DBus.GetId()
* bus/driver.c (bus_driver_handle_get_id): implement org.freedesktop.DBus.GetId()
* bus/bus.c (bus_context_new): generate a unique ID for each bus context
* dbus/dbus-connection.c (dbus_connection_get_server_id): new function
* dbus/dbus-bus.c (dbus_bus_get_id): new function
* dbus/dbus-server.c (dbus_server_get_id): new function
Diffstat (limited to 'test/name-test/test-ids.c')
-rw-r--r-- | test/name-test/test-ids.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/name-test/test-ids.c b/test/name-test/test-ids.c new file mode 100644 index 00000000..f08d4ac9 --- /dev/null +++ b/test/name-test/test-ids.c @@ -0,0 +1,55 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <dbus/dbus.h> +#include <dbus/dbus-connection-internal.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +static void +die (const char *message) +{ + fprintf (stderr, "*** test-ids: %s", message); + exit (1); +} + +int +main (int argc, + char **argv) +{ + DBusError error; + DBusConnection *connection; + char *id; + char *server_id; + + dbus_error_init (&error); + connection = dbus_bus_get (DBUS_BUS_SESSION, &error); + if (connection == NULL) + { + fprintf (stderr, "*** Failed to open connection to system bus: %s\n", + error.message); + dbus_error_free (&error); + return 1; + } + + server_id = dbus_connection_get_server_id (connection); + if (server_id == NULL) + die ("No bus server ID retrieved\n"); + /* printf("'%s'\n", server_id); */ + if (strlen (server_id) != 32) + die ("Bus server id should have length 32\n"); + dbus_free (server_id); + + id = dbus_bus_get_id (connection, NULL); + if (id == NULL) + die ("No bus ID retrieved\n"); + /* printf("'%s'\n", id); */ + if (strlen (id) != 32) + die ("Bus ID should have length 32\n"); + dbus_free (id); + + _dbus_verbose ("*** Test IDs exiting\n"); + + return 0; +} |