Apply a few coding style fixes and adjust a few debug messages
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 18 Jul 2012 13:27:49 +0000 (14:27 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 18 Jul 2012 13:27:49 +0000 (14:27 +0100)
boot-manager/boot-manager-application.c
boot-manager/boot-manager-service.c
boot-manager/boot-manager-service.h
boot-manager/job-manager.c
boot-manager/la-handler-service.c
boot-manager/luc-starter.c
boot-manager/main.c
boot-manager/shutdown-consumer-service.c
boot-manager/target-startup-monitor.c

index 20565d2..61e79e2 100644 (file)
@@ -45,18 +45,18 @@ enum
 
 
 
-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);
 
 
 
@@ -177,7 +177,7 @@ boot_manager_application_init (BootManagerApplication *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);
 }
 
@@ -341,8 +341,9 @@ boot_manager_application_startup (GApplication *app)
 }
 
 
+
 static gboolean
-boot_manager_application_int_handler (GApplication *app)
+boot_manager_application_sigint_handler (GApplication *app)
 {
   BootManagerApplication *application = BOOT_MANAGER_APPLICATION (app);
 
@@ -354,10 +355,10 @@ boot_manager_application_int_handler (GApplication *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);
index d8e0b84..0bd94df 100644 (file)
@@ -36,25 +36,25 @@ enum
 
 
 
-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);
 
 
 
@@ -108,10 +108,10 @@ boot_manager_service_init (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 */
@@ -147,7 +147,8 @@ boot_manager_service_finalize (GObject *object)
   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);
 }
@@ -197,25 +198,25 @@ boot_manager_service_set_property (GObject      *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;
 }
@@ -223,26 +224,26 @@ boot_manager_service_handle_begin_luc_registration (BootManager           *objec
 
 
 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;
     }
@@ -251,16 +252,19 @@ boot_manager_service_handle_finish_luc_registration (BootManager           *obje
   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;
@@ -269,7 +273,7 @@ boot_manager_service_handle_finish_luc_registration (BootManager           *obje
 
 
 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)
@@ -292,15 +296,15 @@ boot_manager_service_handle_register_with_luc (BootManager           *object,
   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);
 
@@ -557,8 +561,4 @@ boot_manager_service_write_luc (BootManagerService *service,
   /* 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;
 }
index c1575c0..cbbe599 100644 (file)
@@ -28,15 +28,15 @@ typedef struct _BootManagerService      BootManagerService;
 
 
 
-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
index 01e8df8..0707cf5 100644 (file)
@@ -66,6 +66,8 @@ static void           job_manager_remember_job     (JobManager        *manager,
 static void           job_manager_forget_job       (JobManager        *manager,
                                                     const gchar       *job_name);
 
+
+
 struct _JobManagerClass
 {
   GObjectClass __parent__;
@@ -170,8 +172,8 @@ job_manager_constructed (GObject *object)
 {
   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);
 }
@@ -276,7 +278,7 @@ job_manager_stop_unit_reply (GObject       *object,
 
   /* 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);
@@ -462,5 +464,5 @@ job_manager_stop (JobManager        *manager,
 
   /* 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);
 }
index a0d7adb..cc38738 100644 (file)
@@ -104,6 +104,7 @@ struct _LAHandlerServiceConsumerBundle
 };
 
 
+
 G_DEFINE_TYPE (LAHandlerService, la_handler_service, G_TYPE_OBJECT);
 
 
@@ -146,17 +147,6 @@ static void
 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 =
@@ -171,8 +161,8 @@ la_handler_service_init (LAHandlerService *service)
 {
   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 */
@@ -194,7 +184,6 @@ la_handler_service_init (LAHandlerService *service)
 
 
 
-
 static void
 la_handler_service_finalize (GObject *object)
 {
@@ -345,8 +334,7 @@ la_handler_service_handle_consumer_shutdown_finish (JobManager   *manager,
   /* 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);
     }
@@ -445,6 +433,8 @@ la_handler_service_start (LAHandlerService *service,
                                            error);
 }
 
+
+
 void
 la_handler_service_register (LAHandlerService *service,
                              const gchar      *unit,
index 19fcca6..a125f0d 100644 (file)
@@ -36,30 +36,30 @@ enum
 
 
 
-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);
 
 
 
@@ -79,7 +79,7 @@ struct _LUCStarter
 
   GList              *start_order;
   GHashTable         *start_groups;
-  
+
   GHashTable         *cancellables;
 };
 
@@ -127,7 +127,6 @@ luc_starter_class_init (LUCStarterClass *klass)
 static void
 luc_starter_init (LUCStarter *starter)
 {
-  
 }
 
 
@@ -388,8 +387,8 @@ luc_starter_cancel_start (const gchar  *app,
 
 
 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);
index b37b79e..a467e2d 100644 (file)
@@ -64,9 +64,9 @@ main (int    argc,
   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);
@@ -78,7 +78,7 @@ main (int    argc,
   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);
index 0e9f917..4cf299e 100644 (file)
@@ -28,6 +28,9 @@ enum
   PROP_UNIT_NAME,
 };
 
+
+
+/* signal identifiers */
 enum
 {
   SIGNAL_SHUTDOWN_REQUESTED,
@@ -170,18 +173,18 @@ shutdown_consumer_service_get_property (GObject    *object,
 
   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;
     }
 }
 
@@ -197,18 +200,18 @@ shutdown_consumer_service_set_property (GObject      *object,
 
   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;
     }
 }
 
index e188152..c8d31ca 100644 (file)
@@ -145,12 +145,12 @@ target_startup_monitor_get_property (GObject    *object,
 
   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;
     }
 }
 
@@ -166,12 +166,12 @@ target_startup_monitor_set_property (GObject      *object,
 
   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;
     }
 }