146
146
constructed (GObject * object)
148
DbusTestDbusMock * self = DBUS_TEST_DBUS_MOCK(object);
149
const gchar * paramval = NULL;
151
148
if (mock_cnt == 0) {
152
149
dbus_test_task_set_name(DBUS_TEST_TASK(object), "DBusMock");
160
/* Execute: python3 -m dbusmock $name / com.canonical.DbusTest.DbusMock */
161
g_object_set(object, "executable", "python3", NULL);
163
GArray * params = g_array_new(TRUE, TRUE, sizeof(gchar *));
164
/* NOTE: No free func, none of the memory is managed by the array */
166
paramval = "-m"; g_array_append_val(params, paramval);
167
paramval = "dbusmock"; g_array_append_val(params, paramval);
169
/* If we're set for system, go there, otherwise default to session */
170
if (dbus_test_task_get_bus(DBUS_TEST_TASK(self)) == DBUS_TEST_SERVICE_BUS_SYSTEM) {
171
paramval = "-s"; g_array_append_val(params, paramval);
174
g_array_append_val(params, self->priv->name);
175
paramval = "/"; g_array_append_val(params, paramval);
176
paramval = "com.canonical.DbusTest.DbusMock"; g_array_append_val(params, paramval);
178
g_object_set(object, "parameters", params, NULL);
179
g_array_unref(params);
425
/* Configure the executable and parameters for the mock */
427
configure_process (DbusTestDbusMock * self)
429
const gchar * paramval = NULL;
431
/* Execute: python3 -m dbusmock $name / com.canonical.DbusTest.DbusMock */
432
g_object_set(G_OBJECT(self), "executable", "python3", NULL);
434
GArray * params = g_array_new(TRUE, TRUE, sizeof(gchar *));
435
/* NOTE: No free func, none of the memory is managed by the array */
437
paramval = "-m"; g_array_append_val(params, paramval);
438
paramval = "dbusmock"; g_array_append_val(params, paramval);
440
/* If we're set for system, go there, otherwise default to session */
441
if (dbus_test_task_get_bus(DBUS_TEST_TASK(self)) == DBUS_TEST_SERVICE_BUS_SYSTEM) {
442
paramval = "--system"; g_array_append_val(params, paramval);
445
g_array_append_val(params, self->priv->name);
446
paramval = "/"; g_array_append_val(params, paramval);
447
paramval = "com.canonical.DbusTest.DbusMock"; g_array_append_val(params, paramval);
449
g_object_set(G_OBJECT(self), "parameters", params, NULL);
450
g_array_unref(params);
449
453
/* Run the mock */
451
455
run (DbusTestTask * task)
454
458
DbusTestDbusMock * self = DBUS_TEST_DBUS_MOCK(task);
456
460
/* Grab the new bus */
457
self->priv->bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
461
if (dbus_test_task_get_bus(DBUS_TEST_TASK(self)) == DBUS_TEST_SERVICE_BUS_SYSTEM) {
462
self->priv->bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
464
self->priv->bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
468
g_warning("Unable to get bus to start DBus Mock: %s", error->message);
459
473
/* Use the process code to get the process running */
474
configure_process(self);
460
475
DBUS_TEST_TASK_CLASS (dbus_test_dbus_mock_parent_class)->run (task);
462
477
/**** Initialize the DBus Mock instance ****/