-static void boot_manager_application_finalize (GObject *object);
-static void boot_manager_application_constructed (GObject *object);
-static void boot_manager_application_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void boot_manager_application_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void boot_manager_application_startup (GApplication *application);
-static gboolean boot_manager_application_int_handler (GApplication *application);
+static void boot_manager_application_finalize (GObject *object);
+static void boot_manager_application_constructed (GObject *object);
+static void boot_manager_application_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void boot_manager_application_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void boot_manager_application_startup (GApplication *application);
+static gboolean boot_manager_application_sigint_handler (GApplication *application);
/* install the signal handler */
application->sigint_id =
- g_unix_signal_add (SIGINT, (GSourceFunc) boot_manager_application_int_handler,
+ g_unix_signal_add (SIGINT, (GSourceFunc) boot_manager_application_sigint_handler,
application);
}
}
+
static gboolean
-boot_manager_application_int_handler (GApplication *app)
+boot_manager_application_sigint_handler (GApplication *app)
{
BootManagerApplication *application = BOOT_MANAGER_APPLICATION (app);
BootManagerApplication *
-boot_manager_application_new (GDBusConnection *connection,
- JobManager *job_manager,
- LAHandlerService *la_handler,
- BootManagerService *boot_manager_service)
+boot_manager_application_new (GDBusConnection *connection,
+ JobManager *job_manager,
+ LAHandlerService *la_handler,
+ BootManagerService *boot_manager_service)
{
g_return_val_if_fail (IS_JOB_MANAGER (job_manager), NULL);
g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (boot_manager_service), NULL);
-static void boot_manager_service_finalize (GObject *object);
-static void boot_manager_service_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void boot_manager_service_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static gboolean boot_manager_service_handle_begin_luc_registration (BootManager *object,
- GDBusMethodInvocation *invocation,
- BootManagerService *service);
-static gboolean boot_manager_service_handle_finish_luc_registration (BootManager *object,
- GDBusMethodInvocation *invocation,
- BootManagerService *service);
-static gboolean boot_manager_service_handle_register_with_luc (BootManager *object,
- GDBusMethodInvocation *invocation,
- GVariant *apps,
- BootManagerService *service);
+static void boot_manager_service_finalize (GObject *object);
+static void boot_manager_service_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void boot_manager_service_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static gboolean boot_manager_service_handle_begin_luc_registration (BootManager *interface,
+ GDBusMethodInvocation *invocation,
+ BootManagerService *service);
+static gboolean boot_manager_service_handle_finish_luc_registration (BootManager *interface,
+ GDBusMethodInvocation *invocation,
+ BootManagerService *service);
+static gboolean boot_manager_service_handle_register_with_luc (BootManager *interface,
+ GDBusMethodInvocation *invocation,
+ GVariant *apps,
+ BootManagerService *service);
{
service->interface = boot_manager_skeleton_new ();
- /* initialise started_registration */
+ /* initially, no registration is assumed to have been started */
service->started_registration = FALSE;
- /* prepare current_user_contex */
+ /* reset current user context */
service->current_user_context = NULL;
/* implement the RegisterWithLUC() handler */
g_object_unref (service->interface);
/* release the current user context */
- g_variant_unref (service->current_user_context);
+ if (service->current_user_context != NULL)
+ g_variant_unref (service->current_user_context);
(*G_OBJECT_CLASS (boot_manager_service_parent_class)->finalize) (object);
}
static gboolean
-boot_manager_service_handle_begin_luc_registration (BootManager *object,
+boot_manager_service_handle_begin_luc_registration (BootManager *interface,
GDBusMethodInvocation *invocation,
BootManagerService *service)
{
GVariantBuilder *luc_builder;
- g_return_val_if_fail (IS_BOOT_MANAGER (object), FALSE);
+ g_return_val_if_fail (IS_BOOT_MANAGER (interface), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (service), FALSE);
- /* last user context registration started */
+ /* mark the last user context registration as started */
service->started_registration = TRUE;
/* initialize the current user context */
- luc_builder = g_variant_builder_new (G_VARIANT_TYPE("a{ias}"));
+ luc_builder = g_variant_builder_new (G_VARIANT_TYPE ("a{ias}"));
service->current_user_context = g_variant_new ("a{ias}", luc_builder);
g_variant_builder_unref (luc_builder);
- /* notify the caller that we have handled the register request */
+ /* notify the caller that we have handled the method call */
g_dbus_method_invocation_return_value (invocation, NULL);
return TRUE;
}
static gboolean
-boot_manager_service_handle_finish_luc_registration (BootManager *object,
+boot_manager_service_handle_finish_luc_registration (BootManager *interface,
GDBusMethodInvocation *invocation,
BootManagerService *service)
{
GError *error = NULL;
gchar *log_text;
- g_return_val_if_fail (IS_BOOT_MANAGER (object), FALSE);
+ g_return_val_if_fail (IS_BOOT_MANAGER (interface), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (service), FALSE);
/* check if last user context registration started */
if (!service->started_registration)
{
- log_text = g_strdup_printf ("Failed to finish LUC registration. Begin registration"
- " did not start");
+ log_text = g_strdup_printf ("Failed to finish LUC registration: "
+ "the registration sequence has not been started yet");
DLT_LOG (boot_manager_context, DLT_LOG_ERROR, DLT_STRING (log_text));
g_free (log_text);
- /* notify the caller that we have handled the register request */
+ /* notify the caller that we have handled the method call */
g_dbus_method_invocation_return_value (invocation, NULL);
return TRUE;
}
boot_manager_service_write_luc (service, &error);
if (error != NULL)
{
- log_text = g_strdup_printf ("Failed to finish LUC registration: %s",
- error->message);
+ log_text = g_strdup_printf ("Failed to finish LUC registration: %s", error->message);
DLT_LOG (boot_manager_context, DLT_LOG_ERROR, DLT_STRING (log_text));
g_free (log_text);
g_error_free (error);
}
- /* last user context registration finished */
+ /* mark the last user context registration as finished */
service->started_registration = FALSE;
+ /* clear the current user context */
+ g_variant_unref (service->current_user_context);
+ service->current_user_context = NULL;
+
/* notify the caller that we have handled the register request */
g_dbus_method_invocation_return_value (invocation, NULL);
return TRUE;
static gboolean
-boot_manager_service_handle_register_with_luc (BootManager *object,
+boot_manager_service_handle_register_with_luc (BootManager *interface,
GDBusMethodInvocation *invocation,
GVariant *apps,
BootManagerService *service)
gint luc_type;
gint builder_luc_type;
- g_return_val_if_fail (IS_BOOT_MANAGER (object), FALSE);
+ g_return_val_if_fail (IS_BOOT_MANAGER (interface), FALSE);
g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (service), FALSE);
/* check if last user context registration started */
if (!service->started_registration)
{
- log_text = g_strdup_printf ("Failed to register apps. Begin registration "
- "did not start");
+ log_text = g_strdup_printf ("Failed to register apps with the LUC: "
+ "The registration sequence has not been started yet");
DLT_LOG (boot_manager_context, DLT_LOG_ERROR, DLT_STRING (log_text));
g_free (log_text);
/* release the GFiles */
g_object_unref (luc_file);
g_object_unref (luc_dir);
-
- /* clear the current user context */
- g_variant_unref (service->current_user_context);
- service->current_user_context = NULL;
}
-GType boot_manager_service_get_type (void) G_GNUC_CONST;
-
-BootManagerService *boot_manager_service_new (GDBusConnection *connection) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gboolean boot_manager_service_start_up (BootManagerService *service,
- GError **error);
-GVariant *boot_manager_service_read_luc (BootManagerService *service,
- GError **error);
-void boot_manager_service_write_luc (BootManagerService *service,
- GError **error);
+GType boot_manager_service_get_type (void) G_GNUC_CONST;
+
+BootManagerService *boot_manager_service_new (GDBusConnection *connection) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gboolean boot_manager_service_start_up (BootManagerService *service,
+ GError **error);
+GVariant *boot_manager_service_read_luc (BootManagerService *service,
+ GError **error);
+void boot_manager_service_write_luc (BootManagerService *service,
+ GError **error);
G_END_DECLS
static void job_manager_forget_job (JobManager *manager,
const gchar *job_name);
+
+
struct _JobManagerClass
{
GObjectClass __parent__;
{
JobManager *manager = JOB_MANAGER (object);
- /* connect to systemd's "JobRemoved" signal so that we are notified whenever a job is
- * finished */
+ /* connect to systemd's "JobRemoved" signal so that we are notified
+ * whenever a job is finished */
g_signal_connect (manager->systemd_manager, "job-removed",
G_CALLBACK (job_manager_job_removed), manager);
}
/* finish the stop unit call */
if (!systemd_manager_call_stop_unit_finish (job->manager->systemd_manager,
- &job_name, result, &error))
+ &job_name, result, &error))
{
/* there was an error. notify the caller */
job->callback (job->manager, job->unit, "failed", error, job->user_data);
/* ask systemd to stop the unit asynchronously */
systemd_manager_call_stop_unit (manager->systemd_manager, unit, "fail", cancellable,
- job_manager_stop_unit_reply, job);
+ job_manager_stop_unit_reply, job);
}
};
+
G_DEFINE_TYPE (LAHandlerService, la_handler_service, G_TYPE_OBJECT);
la_handler_service_constructed (GObject *object)
{
LAHandlerService *service = LA_HANDLER_SERVICE (object);
- GError *error = NULL;
- gchar *log_text;
-
- if (error != NULL)
- {
- log_text = g_strdup_printf ("Failed to connect to the boot manager service: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
- g_error_free (error);
- }
/* get a bus name on the system bus */
service->bus_name_id =
{
service->interface = la_handler_skeleton_new ();
- /* the number that follows the prefix in the shutdown consumer's object path, making
- * every shutdown consumer unique */
+ /* the number that follows the prefix in the shutdown consumer's object path,
+ * making every shutdown consumer unique */
service->index = 1;
/* the string that precedes the index in the shutdown consumer's object path */
-
static void
la_handler_service_finalize (GObject *object)
{
/* log any potential errors */
if (error != NULL)
{
- log_text =
- g_strdup_printf ("Failed to stop unit \"%s\": %s", unit, error->message);
+ log_text = g_strdup_printf ("Failed to stop unit \"%s\": %s", unit, error->message);
DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
g_free (log_text);
}
error);
}
+
+
void
la_handler_service_register (LAHandlerService *service,
const gchar *unit,
-static void luc_starter_constructed (GObject *object);
-static void luc_starter_finalize (GObject *object);
-static void luc_starter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void luc_starter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static gint luc_starter_compare_luc_types (gconstpointer a,
- gconstpointer b,
- gpointer user_data);
-static void luc_starter_start_next_group (LUCStarter *starter);
-static void luc_starter_start_app (const gchar *app,
- LUCStarter *starter);
-static void luc_starter_start_app_finish (JobManager *manager,
- const gchar *unit,
- const gchar *result,
- GError *error,
- gpointer user_data);
-static void luc_starter_cancel_start (const gchar *app,
- GCancellable *cancellable,
- gpointer user_data);
+static void luc_starter_constructed (GObject *object);
+static void luc_starter_finalize (GObject *object);
+static void luc_starter_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void luc_starter_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static gint luc_starter_compare_luc_types (gconstpointer a,
+ gconstpointer b,
+ gpointer user_data);
+static void luc_starter_start_next_group (LUCStarter *starter);
+static void luc_starter_start_app (const gchar *app,
+ LUCStarter *starter);
+static void luc_starter_start_app_finish (JobManager *manager,
+ const gchar *unit,
+ const gchar *result,
+ GError *error,
+ gpointer user_data);
+static void luc_starter_cancel_start (const gchar *app,
+ GCancellable *cancellable,
+ gpointer user_data);
GList *start_order;
GHashTable *start_groups;
-
+
GHashTable *cancellables;
};
static void
luc_starter_init (LUCStarter *starter)
{
-
}
LUCStarter *
-luc_starter_new (JobManager *job_manager,
- BootManagerService *boot_manager_service)
+luc_starter_new (JobManager *job_manager,
+ BootManagerService *boot_manager_service)
{
g_return_val_if_fail (IS_JOB_MANAGER (job_manager), NULL);
g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (boot_manager_service), NULL);
DLT_REGISTER_CONTEXT (boot_manager_context, "MGR",
"Context of the boot manager itself");
DLT_REGISTER_CONTEXT (la_handler_context, "LAH",
- "Context of the legacy application handler that hooks legacy "
- "applications up with the shutdown concept of the Node State "
- "Manager");
+ "Context of the legacy application handler that hooks legacy "
+ "applications up with the shutdown concept of the Node State "
+ "Manager");
/* have DLT unregistered at exit */
atexit (unregister_dlt);
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (connection == NULL)
{
- g_warning ("Failed to connect to D-Bus: %s", error->message);
+ g_warning ("Failed to connect to the system bus: %s", error->message);
/* clean up */
g_error_free (error);
PROP_UNIT_NAME,
};
+
+
+/* signal identifiers */
enum
{
SIGNAL_SHUTDOWN_REQUESTED,
switch (prop_id)
{
- case PROP_CONNECTION:
- g_value_set_object (value, service->connection);
- break;
- case PROP_OBJECT_PATH:
- g_value_set_string (value, service->object_path);
- break;
- case PROP_UNIT_NAME:
- g_value_set_string (value, service->unit_name);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, service->connection);
+ break;
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, service->object_path);
+ break;
+ case PROP_UNIT_NAME:
+ g_value_set_string (value, service->unit_name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
switch (prop_id)
{
- case PROP_CONNECTION:
- service->connection = g_value_dup_object (value);
- break;
- case PROP_OBJECT_PATH:
- service->object_path = g_value_dup_string (value);
- break;
- case PROP_UNIT_NAME:
- service->unit_name = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_CONNECTION:
+ service->connection = g_value_dup_object (value);
+ break;
+ case PROP_OBJECT_PATH:
+ service->object_path = g_value_dup_string (value);
+ break;
+ case PROP_UNIT_NAME:
+ service->unit_name = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
switch (prop_id)
{
- case PROP_SYSTEMD_MANAGER:
- g_value_set_object (value, monitor->systemd_manager);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_SYSTEMD_MANAGER:
+ g_value_set_object (value, monitor->systemd_manager);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
switch (prop_id)
{
- case PROP_SYSTEMD_MANAGER:
- monitor->systemd_manager = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_SYSTEMD_MANAGER:
+ monitor->systemd_manager = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}