[liboobs] Use service priority value 0 to keep previous value



commit c40b9e0a7ff8a24d5dce3ac696ae0f905bf9f5a3
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Mon Oct 5 11:49:28 2009 +0200

    Use service priority value 0 to keep previous value
    
    Most of the time, we want to enable/disable a service, but keep its previous priority, instead of changing it to an arbitrary value. This will be used by services-admin, which will always pass a null value. If the script was not present in this runlevel, the null priority will be sent to the backends, which will set it to the default for us (50 ATM).

 oobs/oobs-service.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/oobs/oobs-service.c b/oobs/oobs-service.c
index fb9dca3..6a4d02e 100644
--- a/oobs/oobs-service.c
+++ b/oobs/oobs-service.c
@@ -178,6 +178,7 @@ oobs_service_get_name (OobsService *service)
  * @runlevel: A #OobsServicesRunlevel.
  * @status: status for the service in the given runlevel
  * @priority: priority for the service in the given runlevel.
+ * Use 0 to either keep the previous priority, or get the default value in case the script is new.
  *
  * Sets the configuration of a service for a given runlevel.
  **/
@@ -206,7 +207,11 @@ oobs_service_set_runlevel_configuration (OobsService          *service,
     }
 
   service_runlevel->status = status;
-  service_runlevel->priority = priority;
+
+  /* Keep previous priority. If the script was not used previously,
+   * the backends will use a default value. */
+  if (priority != 0)
+    service_runlevel->priority = priority;
 }
 
 /**
@@ -238,5 +243,5 @@ oobs_service_get_runlevel_configuration (OobsService          *service,
     *status = (service_runlevel) ? service_runlevel->status : OOBS_SERVICE_STOP;
 
   if (priority)
-    *priority = (service_runlevel) ? service_runlevel->priority : -1;
+    *priority = (service_runlevel) ? service_runlevel->priority : 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]