removed option --use-libatasmart
authorJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 19 Sep 2014 09:47:43 +0000 (11:47 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 19 Sep 2014 09:47:43 +0000 (11:47 +0200)
NEWS
src/lib/psensor.c
src/main.c
src/server/server.c

diff --git a/NEWS b/NEWS
index 17505a0..75a0839 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ v1.1.2
 * Fixed small UI layout/padding issues.
 * Splitted sensor preferences using a tab panel.
 * New preferences to enable/disable each sensor provider.
+* psensor: removed option +--use-libatasmart+.
 
 v1.1.1
 ------
index ef974f0..826aa47 100644 (file)
@@ -409,28 +409,6 @@ double get_max_temp(struct psensor **sensors)
        return get_max_value(sensors, SENSOR_TYPE_TEMP);
 }
 
-struct psensor **get_all_sensors(int use_libatasmart, int values_max_length)
-{
-       struct psensor **psensors;
-
-       psensors = NULL;
-
-       if (!use_libatasmart)
-               hddtemp_psensor_list_append(&psensors, values_max_length);
-
-#ifdef HAVE_ATASMART
-       else
-               atasmart_psensor_list_append(&psensors, values_max_length);
-#endif
-
-       if (!psensors) {        /* there is no detected sensors */
-               psensors = malloc(sizeof(struct psensor *));
-               *psensors = NULL;
-       }
-
-       return psensors;
-}
-
 const char *psensor_type_to_str(unsigned int type)
 {
        if (type & SENSOR_TYPE_NVCTRL) {
index ba3eafb..f5c0f2a 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 
 #include "cfg.h"
+#include <hdd.h>
 #include "psensor.h"
 #include "graph.h"
 #include "ui.h"
@@ -174,6 +175,11 @@ static void *update_measures(void *data)
 #ifdef HAVE_GTOP
                gtop2_psensor_list_update(sensors);
 #endif
+#ifdef HAVE_ATASMART
+               atasmart_psensor_list_update(sensors);
+#endif
+
+               hddtemp_psensor_list_update(sensors);
 
                psensor_log_measures(sensors);
 
@@ -444,10 +450,8 @@ static void cleanup(struct ui_psensor *ui)
  * Creates the list of sensors.
  *
  * 'url': remote psensor server url, null for local monitoring.
- * 'use_libatasmart': whether the libatasmart must be used.
  */
-static struct psensor **create_sensors_list(const char *url,
-                                           unsigned int use_libatasmart)
+static struct psensor **create_sensors_list(const char *url)
 {
        struct psensor **sensors;
 
@@ -461,11 +465,20 @@ static struct psensor **create_sensors_list(const char *url,
                exit(EXIT_FAILURE);
 #endif
        } else {
-               sensors = get_all_sensors(use_libatasmart, 600);
+               sensors = malloc(sizeof(struct psensor *));
+               *sensors = NULL;
 
                if (config_is_lmsensor_enabled())
                        lmsensor_psensor_list_append(&sensors, 600);
 
+               if (config_is_hddtemp_enabled())
+                       hddtemp_psensor_list_append(&sensors, 600);
+
+#ifdef HAVE_ATASMART
+               if (config_is_libatasmart_enabled())
+                       atasmart_psensor_list_append(&sensors, 600);
+#endif
+
 #ifdef HAVE_NVIDIA
                if (config_is_nvctrl_enabled())
                        nvidia_psensor_list_append(&sensors, 600);
@@ -494,7 +507,7 @@ int main(int argc, char **argv)
 {
        struct ui_psensor ui;
        pthread_t thread;
-       int optc, cmdok, opti, use_libatasmart, new_instance, ret;
+       int optc, cmdok, opti, new_instance, ret;
        char *url = NULL;
        GApplication *app;
 
@@ -507,16 +520,12 @@ int main(int argc, char **argv)
        textdomain(PACKAGE);
 #endif
 
-       use_libatasmart = new_instance = 0;
+       new_instance = 0;
 
        cmdok = 1;
        while ((optc = getopt_long(argc, argv, "vhd:u:n", long_options,
                                   &opti)) != -1) {
                switch (optc) {
-               case 0:
-                       if (!strcmp(long_options[opti].name, "use-libatasmart"))
-                               use_libatasmart = 1;
-                       break;
                case 'u':
                        if (optarg)
                                url = strdup(optarg);
@@ -589,7 +598,7 @@ int main(int argc, char **argv)
 
        psensor_init();
 
-       ui.sensors = create_sensors_list(url, use_libatasmart);
+       ui.sensors = create_sensors_list(url);
        associate_cb_alarm_raised(ui.sensors, &ui);
 
        if (ui.config->slog_enabled)
index 5c1a95c..f9ddad2 100644 (file)
@@ -42,6 +42,7 @@
 #include <pgtop2.h>
 #endif
 
+#include <hdd.h>
 #include <lmsensor.h>
 #include <plog.h>
 #include "psensor_json.h"
@@ -397,7 +398,8 @@ int main(int argc, char *argv[])
 
        psensor_init();
 
-       server_data.sensors = get_all_sensors(0, 600);
+       hddtemp_psensor_list_append(&server_data.sensors, 600);
+
        lmsensor_psensor_list_append(&server_data.sensors, 600);
 
 #ifdef HAVE_GTOP