summaryrefslogtreecommitdiffstats
path: root/src/lmsensors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lmsensors.cpp')
-rw-r--r--src/lmsensors.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lmsensors.cpp b/src/lmsensors.cpp
index 73b8253..073d172 100644
--- a/src/lmsensors.cpp
+++ b/src/lmsensors.cpp
@@ -45,17 +45,23 @@ LMSensors::~LMSensors()
bool LMSensors::initSensors()
{
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
FILE *fp=fopen("/etc/sensors.conf","r");
if(!fp) {
qWarning("KSensors error: /etc/sensors.conf not found !");
return false;
}
+#else
+ FILE *fp=NULL;
+#endif
int err= sensors_init(fp);
if(err) {
qWarning("KSensors error: sensors_init fail, error code %d",err);
return false;
}
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
fclose(fp);
+#endif
return true;
}
@@ -63,12 +69,19 @@ void LMSensors::createLMSensors()
{
const sensors_chip_name *chip_name;
int err= 0;
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
while( (chip_name= sensors_get_detected_chips(&err)) )
+ {
if( existSensor(chip_name,"temp") ||
existSensor(chip_name,"fan") )
{
(void)new LMSensorsChip(chip_name,this);
}
+ }
+#else
+ while( (chip_name= sensors_get_detected_chips(NULL, &err)) )
+ (void)new LMSensorsChip(chip_name,this);
+#endif
}
void LMSensors::createHDSensors()
@@ -84,6 +97,7 @@ void LMSensors::createI8KSensors()
}
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
int LMSensors::existSensor(const sensors_chip_name *chip_name,const char *sensor_name)
{
int nr1,nr2;
@@ -91,10 +105,13 @@ const sensors_feature_data *sensor_data;
nr1=nr2= 0;
while( (sensor_data= sensors_get_all_features(*chip_name, &nr1, &nr2)) )
+ {
if( strstr(sensor_data->name,sensor_name) )
return sensor_data->number;
+ }
return 0;
}
+#endif
void LMSensors::setMonitorized(bool enable)
{