[hardware-monitor] 2009-05-02 Ole Laursen <olau hardworking dk>
- From: Ole Laursen <olau src gnome org>
- To: svn-commits-list gnome org
- Subject: [hardware-monitor] 2009-05-02 Ole Laursen <olau hardworking dk>
- Date: Fri, 1 May 2009 19:36:51 -0400 (EDT)
commit 7bce6d2afcf11261f48ebae2fe81d1add383ae2b
Author: Ole Laursen <olau hardworking dk>
Date: Sat May 2 01:30:34 2009 +0200
2009-05-02 Ole Laursen <olau hardworking dk>
* src/monitor-impls.cpp, src/Makefile.am: Ported to lm-sensors-3.x API.
* src/monitor-impls.cpp: Removed special-case for GCC < 3.x.
---
ChangeLog | 4 +++
src/Makefile.am | 3 +-
src/monitor-impls.cpp | 68 +++++++++++++++++++++----------------------------
3 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7bc5cd1..7c376f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-05-02 Ole Laursen <olau hardworking dk>
+ * src/monitor-impls.cpp, src/Makefile.am: Ported to lm-sensors-3.x API.
+
+ * src/monitor-impls.cpp: Removed special-case for GCC < 3.x.
+
* src/applet.cpp: Fixed compiler warning about ambigious if-if-else.
2009-05-01 Ole Laursen <olau hardworking dk>
diff --git a/src/Makefile.am b/src/Makefile.am
index 286fd79..7917772 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,8 +2,7 @@
INCLUDES = \
-DHARDWARE_MONITOR_GLADEDIR=\""$(gladedir)/"\" \
-DGNOMELOCALEDIR=\""$(gnomelocaledir)"\" \
--DGNOMEICONDIR=\""$(icondir)"\" \
--DSENSORS_CONF_FILE=\""/etc/sensors.conf"\"
+-DGNOMEICONDIR=\""$(icondir)"\"
libexec_PROGRAMS = hardware-monitor
diff --git a/src/monitor-impls.cpp b/src/monitor-impls.cpp
index 6d66123..c658491 100644
--- a/src/monitor-impls.cpp
+++ b/src/monitor-impls.cpp
@@ -20,11 +20,7 @@
#include <string>
#include <iomanip>
-#if __GNUC__ < 3
-#include <iostream>
-#else
#include <ostream>
-#endif
#include <sys/time.h> // for high-precision timing for the network load
#include <vector>
#include <algorithm>
@@ -807,18 +803,13 @@ void NetworkLoadMonitor::remove_sync_with(Monitor *other)
Sensors::Sensors()
{
#if HAVE_LIBSENSORS
- std::FILE *conf_file = std::fopen(SENSORS_CONF_FILE, "r");
-
- if (!conf_file)
- return;
-
- if (sensors_init(conf_file) != 0)
+ if (sensors_init(0) != 0)
return;
int i = 0;
const sensors_chip_name *c;
- while ((c = sensors_get_detected_chips(&i)))
+ while ((c = sensors_get_detected_chips(0, &i)))
chips.push_back(*c);
#endif
}
@@ -839,50 +830,49 @@ Sensors &Sensors::instance()
return s;
}
-
Sensors::FeatureInfoSequence Sensors::get_features(std::string base)
{
FeatureInfoSequence vec;
#if HAVE_LIBSENSORS
- const sensors_feature_data *data;
+ const sensors_feature *feature;
for (unsigned int i = 0; i < chips.size(); ++i) {
- sensors_chip_name &chip = chips[i];
- int i1 = 0, i2 = 0;
-
- std::string last_feature;
- while ((data = sensors_get_all_features(chip, &i1, &i2))) {
- std::string name = data->name;
+ sensors_chip_name *chip = &chips[i];
+ int i1 = 0;
- // check whether this is a main feature
- if (name.find(base) != std::string::npos
- && data->mapping == SENSORS_NO_MAPPING
- && sensors_get_ignored(chip, data->number) != 0) {
+ while ((feature = sensors_get_features(chip, &i1))) {
+ std::string name = feature->name;
+ if (name.find(base) != std::string::npos) {
FeatureInfo info;
info.chip_no = i;
- info.feature_no = data->number;
+ info.feature_no = feature->number;
info.max = invalid_max;
- char *desc;
- if (sensors_get_label(chip, info.feature_no, &desc) == 0) {
+ char *desc = sensors_get_label(chip, feature);
+ if (desc) {
info.description = desc;
std::free(desc);
}
vec.push_back(info);
- last_feature = name;
- }
- // check whether this is a max value for the last feature
- else if (data->mapping != SENSORS_NO_MAPPING
- && !last_feature.empty()
- && name.find(last_feature) != std::string::npos
- && name.find("_over") != std::string::npos) {
- double max;
- if (sensors_get_feature(chip, data->number, &max) == 0)
- vec.back().max = max;
- else
- vec.back().max = invalid_max;
+
+ // now see if we can find a max
+ const sensors_subfeature *subfeature;
+ int i2 = 0;
+
+ while ((subfeature = sensors_get_all_subfeatures(chip, feature, &i2))) {
+ std::string subname = subfeature->name;
+ // check whether this is a max value for the last feature
+ if (subname.find(name) != std::string::npos
+ && subname.find("_over") != std::string::npos) {
+ double max;
+ if (sensors_get_value(chip, subfeature->number, &max) == 0)
+ vec.back().max = max;
+ else
+ vec.back().max = invalid_max;
+ }
+ }
}
}
}
@@ -909,7 +899,7 @@ double Sensors::get_value(int chip_no, int feature_no)
double res;
- if (sensors_get_feature(chips[chip_no], feature_no, &res) == 0)
+ if (sensors_get_value(&chips[chip_no], feature_no, &res) == 0)
return res;
else
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]