251 lines
9.0 KiB
Diff
251 lines
9.0 KiB
Diff
diff -up xfce4-sensors-plugin-0.10.99.2/panel-plugin/middlelayer.c.lmsens3x xfce4-sensors-plugin-0.10.99.2/panel-plugin/middlelayer.c
|
|
--- xfce4-sensors-plugin-0.10.99.2/panel-plugin/middlelayer.c.lmsens3x 2007-10-28 16:21:52.000000000 +0100
|
|
+++ xfce4-sensors-plugin-0.10.99.2/panel-plugin/middlelayer.c 2007-11-23 22:58:34.000000000 +0100
|
|
@@ -110,6 +110,7 @@ refresh_all_chips (GPtrArray *chips )
|
|
}
|
|
|
|
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
void
|
|
categorize_sensor_type (t_chipfeature* chipfeature)
|
|
{
|
|
@@ -141,7 +142,7 @@ categorize_sensor_type (t_chipfeature* c
|
|
|
|
TRACE ("leaves categorize_sensor_type");
|
|
}
|
|
-
|
|
+#endif
|
|
|
|
int
|
|
sensors_get_feature_wrapper (t_chip *chip, int number, double *value)
|
|
@@ -153,7 +154,11 @@ sensors_get_feature_wrapper (t_chip *chi
|
|
|
|
if (chip->type==LMSENSOR ) {
|
|
#ifdef HAVE_LIBSENSORS
|
|
- return sensors_get_feature (*(chip->chip_name), number, value);
|
|
+ #if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
+ return sensors_get_feature (*(chip->chip_name), number, value);
|
|
+ #else
|
|
+ return sensors_get_value (chip->chip_name, number, value);
|
|
+ #endif
|
|
#else
|
|
return -1;
|
|
#endif
|
|
diff -up xfce4-sensors-plugin-0.10.99.2/panel-plugin/lmsensors.c.lmsens3x xfce4-sensors-plugin-0.10.99.2/panel-plugin/lmsensors.c
|
|
--- xfce4-sensors-plugin-0.10.99.2/panel-plugin/lmsensors.c.lmsens3x 2007-10-20 19:40:40.000000000 +0200
|
|
+++ xfce4-sensors-plugin-0.10.99.2/panel-plugin/lmsensors.c 2007-11-23 22:59:15.000000000 +0100
|
|
@@ -47,12 +47,28 @@ t_chip *setup_chip (GPtrArray *chips, co
|
|
chip->chip_name = (sensors_chip_name *) g_malloc (sizeof(sensors_chip_name));
|
|
memcpy ( (void *) (chip->chip_name), (void *) name, sizeof(sensors_chip_name) );
|
|
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
chip->sensorId = g_strdup_printf ("%s-%x-%x", name->prefix, name->bus, name->addr);
|
|
+#else
|
|
+ switch (name->bus.type) {
|
|
+ case SENSORS_BUS_TYPE_I2C:
|
|
+ case SENSORS_BUS_TYPE_SPI:
|
|
+ chip->sensorId = g_strdup_printf ("%s-%x-%x", name->prefix,
|
|
+ name->bus.nr, name->addr);
|
|
+ break;
|
|
+ default:
|
|
+ chip->sensorId = g_strdup_printf ("%s-%x", name->prefix, name->addr);
|
|
+ }
|
|
+#endif
|
|
chip->num_features=0;
|
|
chip->name = g_strdup (_("LM Sensors"));
|
|
chip->chip_features = g_ptr_array_new();
|
|
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
chip->description = g_strdup (sensors_get_adapter_name (num_sensorchips-1));
|
|
+#else
|
|
+ chip->description = g_strdup (sensors_get_adapter_name (&name->bus));
|
|
+#endif
|
|
|
|
TRACE("leaves setup_chip");
|
|
|
|
@@ -71,14 +87,23 @@ void setup_chipfeature (t_chipfeature *c
|
|
chipfeature->address = number;
|
|
chipfeature->show = FALSE;
|
|
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
categorize_sensor_type (chipfeature);
|
|
+#endif
|
|
|
|
TRACE("leaves setup_chipfeature");
|
|
}
|
|
|
|
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
t_chipfeature *find_chipfeature (const sensors_chip_name *name, t_chip *chip, int number)
|
|
{
|
|
+#else
|
|
+t_chipfeature *find_chipfeature (const sensors_chip_name *name, t_chip *chip, const sensors_feature *feature)
|
|
+{
|
|
+ const sensors_subfeature *sub_feature = NULL;
|
|
+ int number = -1;
|
|
+#endif
|
|
int res;
|
|
double sensorFeature;
|
|
t_chipfeature *chipfeature;
|
|
@@ -87,6 +112,7 @@ t_chipfeature *find_chipfeature (cons
|
|
|
|
chipfeature = g_new0 (t_chipfeature, 1);
|
|
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
if (sensors_get_ignored (*(name), number)==1) {
|
|
res = sensors_get_label(*(name), number,
|
|
&(chipfeature->name));
|
|
@@ -95,6 +121,87 @@ t_chipfeature *find_chipfeature (cons
|
|
res = sensors_get_feature (*(name), number,
|
|
&sensorFeature);
|
|
|
|
+#else /* libsensors 4 code */
|
|
+
|
|
+ switch (feature->type) {
|
|
+ case SENSORS_FEATURE_IN:
|
|
+ sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_IN_INPUT);
|
|
+ if (!sub_feature)
|
|
+ break;
|
|
+
|
|
+ number = sub_feature->number;
|
|
+ chipfeature->class = VOLTAGE;
|
|
+ chipfeature->min_value = 2.8;
|
|
+ chipfeature->max_value = 12.2;
|
|
+
|
|
+ if ((sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_IN_MIN)) &&
|
|
+ !sensors_get_value(name, sub_feature->number, &sensorFeature))
|
|
+ chipfeature->min_value = sensorFeature;
|
|
+
|
|
+ if ((sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_IN_MAX)) &&
|
|
+ !sensors_get_value(name, sub_feature->number, &sensorFeature))
|
|
+ chipfeature->max_value = sensorFeature;
|
|
+
|
|
+ break;
|
|
+
|
|
+ case SENSORS_FEATURE_FAN:
|
|
+ sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_FAN_INPUT);
|
|
+ if (!sub_feature)
|
|
+ break;
|
|
+
|
|
+ number = sub_feature->number;
|
|
+ chipfeature->class = SPEED;
|
|
+ chipfeature->min_value = 1000.0;
|
|
+ chipfeature->max_value = 3500.0;
|
|
+
|
|
+ if ((sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_FAN_MIN)) &&
|
|
+ !sensors_get_value(name, sub_feature->number, &sensorFeature))
|
|
+ chipfeature->min_value = sensorFeature;
|
|
+
|
|
+ break;
|
|
+
|
|
+ case SENSORS_FEATURE_TEMP:
|
|
+ sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_TEMP_INPUT);
|
|
+ if (!sub_feature)
|
|
+ break;
|
|
+
|
|
+ number = sub_feature->number;
|
|
+ chipfeature->class = TEMPERATURE;
|
|
+ chipfeature->min_value = 0.0;
|
|
+ chipfeature->max_value = 80.0;
|
|
+
|
|
+ if ((sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_TEMP_MIN)) &&
|
|
+ !sensors_get_value(name, sub_feature->number, &sensorFeature))
|
|
+ chipfeature->min_value = sensorFeature;
|
|
+
|
|
+ if (((sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_TEMP_MAX)) ||
|
|
+ (sub_feature = sensors_get_subfeature(name, feature,
|
|
+ SENSORS_SUBFEATURE_TEMP_CRIT))) &&
|
|
+ !sensors_get_value(name, sub_feature->number, &sensorFeature))
|
|
+ chipfeature->max_value = sensorFeature;
|
|
+ }
|
|
+
|
|
+ if (number != -1) {
|
|
+
|
|
+ chipfeature->name = sensors_get_label(name, feature);
|
|
+
|
|
+ if (!chipfeature->name)
|
|
+ chipfeature->name = feature->name;
|
|
+
|
|
+ if (chipfeature->name) {
|
|
+ res = sensors_get_value (name, number,
|
|
+ &sensorFeature);
|
|
+
|
|
+#endif /* libsensor3 / libsensors4 code */
|
|
+
|
|
if (res==0) {
|
|
setup_chipfeature (chipfeature, number, sensorFeature);
|
|
chip->num_features++;
|
|
@@ -103,6 +210,7 @@ t_chipfeature *find_chipfeature (cons
|
|
}
|
|
}
|
|
}
|
|
+ g_free(chipfeature);
|
|
|
|
TRACE("leaves find_chipfeature with null");
|
|
return NULL;
|
|
@@ -114,8 +222,9 @@ int initialize_libsensors (GPtrArray *ch
|
|
int sensorsInit, nr1, nr2, num_sensorchips; /* , numchips; */
|
|
t_chip *chip;
|
|
t_chipfeature *chipfeature; /* , *furtherchipfeature; */
|
|
- FILE *file;
|
|
const sensors_chip_name *detected_chip;
|
|
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
+ FILE *file;
|
|
const sensors_feature_data *sfd;
|
|
|
|
TRACE("enters initialize_libsensors");
|
|
@@ -167,6 +276,45 @@ int initialize_libsensors (GPtrArray *ch
|
|
TRACE ("leaves initialize_libsensors with -1");
|
|
return -1;
|
|
}
|
|
+#else
|
|
+ const sensors_feature *sfd;
|
|
+ TRACE("enters initialize_libsensors");
|
|
+
|
|
+ sensorsInit = sensors_init(NULL);
|
|
+ if (sensorsInit != 0)
|
|
+ {
|
|
+ g_printf(_("Error: Could not connect to sensors!"));
|
|
+ /* FIXME: better popup window? write to special logfile? */
|
|
+ return -2;
|
|
+ }
|
|
+
|
|
+ num_sensorchips = 0;
|
|
+ detected_chip = sensors_get_detected_chips (NULL, &num_sensorchips);
|
|
+ /* iterate over chips on mainboard */
|
|
+ while (detected_chip!=NULL)
|
|
+ {
|
|
+ chip = setup_chip (chips, detected_chip, num_sensorchips);
|
|
+
|
|
+ nr1 = 0;
|
|
+ nr2 = 0;
|
|
+ /* iterate over chip features, i.e. id, cpu temp, mb temp... */
|
|
+ /* numchips = get_number_chip_features (detected_chip); */
|
|
+ sfd = sensors_get_features (detected_chip, &nr1);
|
|
+ while (sfd != NULL)
|
|
+ {
|
|
+ chipfeature = find_chipfeature (detected_chip, chip, sfd);
|
|
+ if (chipfeature!=NULL) {
|
|
+ g_ptr_array_add (chip->chip_features, chipfeature);
|
|
+ }
|
|
+ sfd = sensors_get_features (detected_chip, &nr1);
|
|
+ }
|
|
+
|
|
+ detected_chip = sensors_get_detected_chips (NULL, &num_sensorchips);
|
|
+ } /* end while sensor chipNames */
|
|
+
|
|
+ TRACE ("leaves initialize_libsensors with 1");
|
|
+ return 1;
|
|
+#endif
|
|
}
|
|
|
|
|