1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */
#include <config.h>
#undef G_DISABLE_ASSERT
#include <stdlib.h>
#include "dbus/dbus-glib.h"
#include "tools/dbus-glib-bindings.h"
#include "test-objects.h"
#include "test-dup-prop.h"
#define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces"
#define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces"
#define TEST_DP_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/DupPropInterfaces"
static GMainLoop *loop = NULL;
int
main (int argc,
char **argv)
{
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
guint32 ret;
TestBeatlesSong *song;
TestDpObj *dp_obj;
g_type_init ();
/* Get the connection and ensure the name is not used yet */
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
g_warning ("Failed to make connection to session bus: %s",
error->message);
g_error_free (error);
exit(1);
}
proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (!org_freedesktop_DBus_request_name (proxy, TEST_NAMESPACE,
0, &ret, &error)) {
g_warning ("There was an error requesting the name: %s",
error->message);
g_error_free (error);
exit(1);
}
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
/* Someone else registered the name before us */
exit(1);
}
song = test_beatles_song_new ();
/* Register the app on the bus */
dbus_g_connection_register_g_object (connection,
TEST_OBJECT_PATH,
G_OBJECT (song));
dp_obj = test_dp_obj_new ();
dbus_g_connection_register_g_object (connection,
TEST_DP_OBJECT_PATH,
G_OBJECT (dp_obj));
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
return 0;
}
|