SOURCES: xfce4-sensors-plugin-lm_sensors_3.patch (NEW) - fix for b...
hawk
hawk at pld-linux.org
Sun May 4 14:27:16 CEST 2008
Author: hawk Date: Sun May 4 12:27:16 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- fix for building with lm_sensors 3.x
---- Files affected:
SOURCES:
xfce4-sensors-plugin-lm_sensors_3.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/xfce4-sensors-plugin-lm_sensors_3.patch
diff -u /dev/null SOURCES/xfce4-sensors-plugin-lm_sensors_3.patch:1.1
--- /dev/null Sun May 4 14:27:16 2008
+++ SOURCES/xfce4-sensors-plugin-lm_sensors_3.patch Sun May 4 14:27:10 2008
@@ -0,0 +1,284 @@
+diff -urNp xfce4-sensors-plugin-0.10.99.3.orig/panel-plugin/lmsensors.c xfce4-sensors-plugin-0.10.99.3/panel-plugin/lmsensors.c
+--- xfce4-sensors-plugin-0.10.99.3.orig/panel-plugin/lmsensors.c 2007-11-24 15:32:09.000000000 +0100
++++ xfce4-sensors-plugin-0.10.99.3/panel-plugin/lmsensors.c 2008-05-04 13:49:58.069250721 +0200
+@@ -34,10 +34,12 @@ int get_number_chip_features (const sens
+ } */
+
+
++#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
+ int sensors_get_feature_wrapper (const sensors_chip_name name, int number, double *value)
+ {
+ return sensors_get_feature (name, number, value);
+ }
++#endif
+
+
+ t_chip *setup_chip (GPtrArray *chips, const sensors_chip_name *name, int num_sensorchips)
+@@ -53,12 +55,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 = _("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");
+
+@@ -78,14 +96,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;
+@@ -94,6 +121,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) {
+ g_free (chipfeature->name); /* ? */
+ res = sensors_get_label (*(name), number, &(chipfeature->name));
+@@ -102,6 +130,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++;
+@@ -110,6 +219,7 @@ t_chipfeature *find_chipfeature (cons
+ }
+ }
+ }
++ g_free(chipfeature);
+
+ TRACE ("leaves find_chipfeature with null");
+ g_free (chipfeature);
+@@ -122,8 +232,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");
+@@ -176,6 +287,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
+ }
+
+
+diff -urNp xfce4-sensors-plugin-0.10.99.3.orig/panel-plugin/lmsensors.h xfce4-sensors-plugin-0.10.99.3/panel-plugin/lmsensors.h
+--- xfce4-sensors-plugin-0.10.99.3.orig/panel-plugin/lmsensors.h 2007-11-24 15:33:26.000000000 +0100
++++ xfce4-sensors-plugin-0.10.99.3/panel-plugin/lmsensors.h 2008-05-04 13:50:38.317841500 +0200
+@@ -26,6 +26,8 @@ void refresh_lmsensors (gpointer chip_fe
+ * @Param value: pointer where the double feature value is to be stored
+ * @Return: 0 on success
+ */
++#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
+ int sensors_get_feature_wrapper (const sensors_chip_name name, int number, double *value);
++#endif
+
+ #endif /* XFCE4_SENSORS_LMSENSORS_H */
+diff -urNp xfce4-sensors-plugin-0.10.99.3.orig/panel-plugin/middlelayer.c xfce4-sensors-plugin-0.10.99.3/panel-plugin/middlelayer.c
+--- xfce4-sensors-plugin-0.10.99.3.orig/panel-plugin/middlelayer.c 2007-11-24 16:03:25.000000000 +0100
++++ xfce4-sensors-plugin-0.10.99.3/panel-plugin/middlelayer.c 2008-05-04 13:47:17.174892384 +0200
+@@ -114,6 +114,7 @@ refresh_all_chips (GPtrArray *chips )
+ }
+
+
++#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
+ void
+ categorize_sensor_type (t_chipfeature* chipfeature)
+ {
+@@ -150,7 +151,7 @@ categorize_sensor_type (t_chipfeature* c
+
+ TRACE ("leaves categorize_sensor_type");
+ }
+-
++#endif
+
+ int
+ sensor_get_value (t_chip *chip, int number, double *value)
+@@ -162,7 +163,11 @@ sensor_get_value (t_chip *chip, int numb
+
+ if (chip->type==LMSENSOR ) {
+ #ifdef HAVE_LIBSENSORS
+- return sensors_get_feature_wrapper (*(chip->chip_name), number, value);
++ #if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
++ return sensors_get_feature_wrapper (*(chip->chip_name), number, value);
++ #else
++ return sensors_get_value (chip->chip_name, number, value);
++ #endif
+ #else
+ return -1;
+ #endif
+@@ -224,7 +229,7 @@ free_chip (gpointer chip, gpointer data)
+ g_free (c->description);
+ if (c->type==LMSENSOR) {
+ g_free (c->chip_name->prefix);
+- g_free (c->chip_name->busname);
++ g_free (c->chip_name->path);
+ }
+ /* g_free (c->chip_name); */ /* is a _copied_ structure of libsensors */
+ g_ptr_array_foreach (c->chip_features, free_chipfeature, NULL);
================================================================
More information about the pld-cvs-commit
mailing list