avoid config in the psensor struct
[psensor.git] / src / lib / psensor.c
index f266631..58731d5 100644 (file)
@@ -23,6 +23,8 @@
 #include <libintl.h>
 #define _(str) gettext(str)
 
+#include <stdio.h>
+
 #include <hdd.h>
 #include <psensor.h>
 #include <temperature.h>
@@ -48,7 +50,6 @@ struct psensor *psensor_create(char *id,
        psensor->values_max_length = values_max_length;
        psensor->measures = measures_dbl_create(values_max_length);
 
-       psensor->alarm_enabled = 0;
        psensor->alarm_high_threshold = 0;
        psensor->alarm_low_threshold = 0;
 
@@ -61,7 +62,6 @@ struct psensor *psensor_create(char *id,
        psensor->color = NULL;
 
        psensor->graph_enabled = 1;
-       psensor->appindicator_enabled = 0;
 
        psensor->provider_data = NULL;
        psensor->provider_data_free_fct = &free;
@@ -155,29 +155,15 @@ int psensor_list_size(struct psensor **sensors)
        return size;
 }
 
-bool psensor_list_contains_type(struct psensor **sensors, unsigned int type)
-{
-       if (!sensors)
-               return false;
-
-       while (*sensors) {
-               if ((*sensors)->type & type)
-                       return true;
-               sensors++;
-       }
-
-       return false;
-}
-
 struct psensor **psensor_list_add(struct psensor **sensors,
                                  struct psensor *sensor)
 {
        int size;
+       struct psensor **result;
 
        size = psensor_list_size(sensors);
 
-       struct psensor **result
-           = malloc((size + 1 + 1) * sizeof(struct psensor *));
+       result = malloc((size + 1 + 1) * sizeof(struct psensor *));
 
        if (sensors)
                memcpy(result, sensors, size * sizeof(struct psensor *));
@@ -278,15 +264,13 @@ void psensor_set_current_measure(struct psensor *s, double v, struct timeval tv)
        if (s->max == UNKNOWN_DBL_VALUE || v > s->max)
                s->max = v;
 
-       if (s->alarm_enabled) {
-               if (v > s->alarm_high_threshold || v < s->alarm_low_threshold) {
-                       if (!s->alarm_raised && s->cb_alarm_raised)
-                               s->cb_alarm_raised(s, s->cb_alarm_raised_data);
-
-                       s->alarm_raised = 1;
-               } else {
-                       s->alarm_raised = 0;
+       if (v > s->alarm_high_threshold || v < s->alarm_low_threshold) {
+               if (!s->alarm_raised && s->cb_alarm_raised) {
+                       s->alarm_raised = true;
+                       s->cb_alarm_raised(s, s->cb_alarm_raised_data);
                }
+       } else {
+               s->alarm_raised = false;
        }
 }