-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carsten Haitzler (The Rasterman) wrote:
| On Fri, 21 Mar 2008 19:20:12 +0100 Fabio Strozzi <[EMAIL PROTECTED]>
| babbled:
|
| attachment was removed by sf.net's mailserver :( resent but as text/plain
| attachment?

Resent!
Should it not work, the patch is available from:
http://fstrozzi.web.cs.unibo.it/temperature.patch

Best regards

- --
Fabio G. Strozzi ~ http://fstrozzi.web.cs.unibo.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH6EV4B3MPiq3KlccRAoWVAJ0XcuyTwWhSa5oj4Qa+5EL60fYL+QCeJ+kN
aHcvucOWPDrb/ryzEekxdLc=
=L1yA
-----END PGP SIGNATURE-----
diff -Naur -x'*.lo' -x'*.o' -x.libs ../temperature-orig/e_mod_config.c 
./e_mod_config.c
--- ../temperature-orig/e_mod_config.c  2008-03-15 22:46:11.000000000 +0100
+++ ./e_mod_config.c    2008-03-15 15:04:40.000000000 +0100
@@ -41,6 +41,8 @@
 static int           _basic_apply_data(E_Config_Dialog *cfd, 
E_Config_Dialog_Data *cfdata);
 static Evas_Object   *_advanced_create_widgets(E_Config_Dialog *cfd, Evas 
*evas, E_Config_Dialog_Data *cfdata);
 static int           _advanced_apply_data(E_Config_Dialog *cfd, 
E_Config_Dialog_Data *cfdata);
+static void          _sensors_names_get(const char *bus, Ecore_List *sensors);
+
 
 void
 config_temperature_module(Config_Face *inst) 
@@ -73,7 +75,7 @@
    int         pi;
    Ecore_List *therms;
    char       *name;
-   char        path[PATH_MAX];
+   const char *bus = NULL;
    
    cfdata->units = cfdata->inst->units;
    if (cfdata->inst->units == CELCIUS) 
@@ -125,68 +127,13 @@
       case SENSOR_TYPE_LINUX_INTELCORETEMP:
         break;
       case SENSOR_TYPE_LINUX_I2C:
-        therms = temperature_get_bus_files("i2c");
-        if (therms)
-          {
-              char *name;
-
-             while ((name = ecore_list_next(therms)))
-               {
-                  if (ecore_file_exists(name))
-                    {
-                       int len;
-
-                       sprintf(path, "%s", ecore_file_file_get(name));
-                       len = strlen(path);
-                       if (len > 6)
-                          path[len - 6] = '\0';
-                       ecore_list_append(cfdata->sensors, strdup(path));
-                       /* TODO: Track down the user friendly names and display 
them instead.
-                        * User friendly names are not available on the system, 
lm-sensors 
-                        * contains a database in /etc/sensors.conf, but the 
format may change,
-                        * so the best way to use that database is thru 
libsensors, but we 
-                        * don't want to add any more library dependencies. 
-                        */
-                    }
-               }
-             ecore_list_destroy(therms);
-          }
-
-        ecore_list_first_goto(cfdata->sensors);
-        while ((name = ecore_list_next(cfdata->sensors)))
-          {
-             if (!strcmp(cfdata->inst->sensor_name, name)) 
-               break;
-             cfdata->sensor++;
-          }
-        break;
+        bus = "i2c";
       case SENSOR_TYPE_LINUX_PCI:
-        therms = temperature_get_bus_files("pci");
-        if (therms)
-          {
-              char *name;
-
-             while ((name = ecore_list_next(therms)))
-               {
-                  if (ecore_file_exists(name))
-                    {
-                       int len;
+        bus = (bus ? bus : "pci");
+      case SENSOR_TYPE_LINUX_PLATFORM:
 
-                       sprintf(path, "%s", ecore_file_file_get(name));
-                       len = strlen(path);
-                       if (len > 6)
-                          path[len - 6] = '\0';
-                       ecore_list_append(cfdata->sensors, strdup(path));
-                       /* TODO: Track down the user friendly names and display 
them instead.
-                        * User friendly names are not available on the system, 
lm-sensors 
-                        * contains a database in /etc/sensors.conf, but the 
format may change,
-                        * so the best way to use that database is thru 
libsensors, but we 
-                        * don't want to add any more library dependencies. 
-                        */
-                    }
-               }
-             ecore_list_destroy(therms);
-          }
+        bus = (bus ? bus : "platform");
+        _sensors_names_get(bus, cfdata->sensors);
 
         ecore_list_first_goto(cfdata->sensors);
         while ((name = ecore_list_next(cfdata->sensors)))
@@ -217,6 +164,35 @@
      }
 }
 
+static void
+_sensors_names_get(const char *bus, Ecore_List *sensors)
+{
+   char name[PATH_MAX];
+   Ecore_List *files;
+
+   if ((files = temperature_bus_files_get(bus)))
+     {
+       char *f;
+
+       while ((f = ecore_list_next(files)))
+         {
+            if (ecore_file_exists(f))
+              {
+                 snprintf(name, sizeof(name), "%s", ecore_file_file_get(f));
+                 name[sizeof(name)-1] = '\0';
+                 ecore_list_append(sensors, strdup(name));
+                 /* TODO: Track down the user friendly names and display them 
instead.
+                  * User friendly names are not available on the system, 
lm-sensors 
+                  * contains a database in /etc/sensors.conf, but the format 
may change,
+                  * so the best way to use that database is thru libsensors, 
but we 
+                  * don't want to add any more library dependencies. 
+                  */
+              }
+         }
+       ecore_list_destroy(files);
+     }
+}
+
 static void *
 _create_data(E_Config_Dialog *cfd) 
 {
diff -Naur -x'*.lo' -x'*.o' -x.libs ../temperature-orig/e_mod_main.c 
./e_mod_main.c
--- ../temperature-orig/e_mod_main.c    2008-03-15 22:46:12.000000000 +0100
+++ ./e_mod_main.c      2008-03-15 23:03:25.000000000 +0100
@@ -59,7 +59,6 @@
    Evas_Object *o;
    E_Gadcon_Client *gcc;
    Config_Face *inst;
-   char buf[PATH_MAX];
 
    inst = evas_hash_find(temperature_config->faces, id);
    if (!inst)
@@ -102,7 +101,7 @@
                             inst);
    
    temperature_face_update_config(inst);
-   
+
    evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
                                  _temperature_face_cb_mouse_down, inst);
    return gcc;
@@ -404,7 +403,7 @@
 }
 
 Ecore_List *
-temperature_get_bus_files(const char* bus)
+temperature_bus_files_get(const char* bus)
 {
    Ecore_List *result;
    Ecore_List *therms;
@@ -459,6 +458,7 @@
 }
 
 
+
 /***************************************************************************/
 /**/
 /* module setup */
diff -Naur -x'*.lo' -x'*.o' -x.libs ../temperature-orig/e_mod_main.h 
./e_mod_main.h
--- ../temperature-orig/e_mod_main.h    2008-03-15 22:46:13.000000000 +0100
+++ ./e_mod_main.h      2008-03-15 12:30:45.000000000 +0100
@@ -22,6 +22,7 @@
    SENSOR_TYPE_LINUX_I2C,
    SENSOR_TYPE_LINUX_ACPI,
    SENSOR_TYPE_LINUX_PCI,
+   SENSOR_TYPE_LINUX_PLATFORM,
    SENSOR_TYPE_LINUX_PBOOK,
    SENSOR_TYPE_LINUX_INTELCORETEMP
 } Sensor_Type;
@@ -70,7 +71,8 @@
 
 void config_temperature_module(Config_Face *inst);
 void temperature_face_update_config(Config_Face *inst);
-Ecore_List *temperature_get_bus_files(const char* bus);
+Ecore_List *temperature_bus_files_get(const char* bus);
+void temperature_bus_try(Sensor_Type type, const char *bus, int *st, char 
**sp, char **sn);
 
 
 #endif
diff -Naur -x'*.lo' -x'*.o' -x.libs ../temperature-orig/tempget.c ./tempget.c
--- ../temperature-orig/tempget.c       2008-03-15 22:46:12.000000000 +0100
+++ ./tempget.c 2008-03-15 13:07:09.000000000 +0100
@@ -25,8 +25,9 @@
 static int check(void);
 static int poll_cb(void *data);
 
+
 Ecore_List *
-temperature_get_bus_files(const char* bus)
+temperature_bus_files_get(const char* bus)
 {
    Ecore_List *result;
    Ecore_List *therms;
@@ -80,6 +81,40 @@
    return result;
 }
 
+
+void temperature_bus_try(Sensor_Type type, const char *bus, int *st, char 
**sp, char **sn)
+{
+   Ecore_List *files;
+
+   if ((files = temperature_bus_files_get(bus)))
+     {
+       char *f;
+
+       if ((f = ecore_list_next(files)))
+         {
+            if (ecore_file_exists(f))
+              {
+                 int len;
+                 char name[PATH_MAX];
+
+                 snprintf(name, sizeof(name),
+                       "%s", ecore_file_file_get(f));
+                 len = strlen(name);
+                 if (len > 6) name[len - 6] = '\0';
+                 *st = type;
+                 *sp = strdup(f);
+                 *sn = strdup(name);
+                 printf("sensor bus = %s\n"
+                       "sensor path = %s\n"
+                       "sensor name = %s\n",
+                       bus, *sp, *sn);
+              }
+         }
+       ecore_list_destroy(files);
+     }
+}
+
+
 static void
 init(void)
 {
@@ -94,10 +129,15 @@
        if (sensor_name) free(sensor_name);
        if (sensor_path) free(sensor_path);
        sensor_path = NULL;
+
 #ifdef __FreeBSD__
        /* TODO: FreeBSD can also have more temperature sensors! */
        sensor_type = SENSOR_TYPE_FREEBSD;
        sensor_name = strdup("tz0");
+       snprintf(path, sizeof(path), "hw.acpi.thermal.%s.temperature", 
sensor_name);
+       sensor_path = strdup(path);
+       len = 5;
+       sysctlnametomib(sensor_path, mib, &len);
 #else
        therms = ecore_file_ls("/proc/acpi/thermal_zone");
        if ((therms) && (!ecore_list_empty_is(therms)))
@@ -108,6 +148,10 @@
             sensor_type = SENSOR_TYPE_LINUX_ACPI;
             sensor_name = strdup(name);
             ecore_list_destroy(therms);
+            snprintf(path, sizeof(path),
+                  "/proc/acpi/thermal_zone/%s/temperature",
+                  sensor_name);
+            sensor_path = strdup(path);
          }
        else
          {
@@ -116,166 +160,48 @@
               {
                  sensor_type = SENSOR_TYPE_OMNIBOOK;
                  sensor_name = strdup("dummy");
+                 sensor_path = strdup("/proc/omnibook/temperature");
               }
             else if 
(ecore_file_exists("/sys/devices/temperatures/sensor1_temperature"))
               {
                  sensor_type = SENSOR_TYPE_LINUX_PBOOK;
                  sensor_name = strdup("dummy");
+                 sensor_path = 
strdup("/sys/devices/temperatures/sensor1_temperature");
               }
             else if 
(ecore_file_exists("/sys/devices/temperatures/cpu_temperature"))
               {
                  sensor_type = SENSOR_TYPE_LINUX_MACMINI;
                  sensor_name = strdup("dummy");
+                 sensor_path = 
strdup("/sys/devices/temperatures/cpu_temperature");
               }
             else if 
(ecore_file_exists("/sys/devices/platform/coretemp.0/temp1_input"))
               {
                  sensor_type = SENSOR_TYPE_LINUX_INTELCORETEMP;
                  sensor_name = strdup("dummy");
+                 sensor_path = 
strdup("/sys/devices/platform/coretemp.0/temp1_input");
               }
             else
               {
                  // try the i2c bus
-                 therms = temperature_get_bus_files("i2c");
-                 if (therms)
-                   {
-                      char *name;
-                      
-                      if ((name = ecore_list_next(therms)))
-                        {
-                           if (ecore_file_exists(name))
-                             {
-                                int len;
-                                
-                                snprintf(path, sizeof(path),
-                                         "%s", ecore_file_file_get(name));
-                                len = strlen(path);
-                                if (len > 6) path[len - 6] = '\0';
-                                sensor_type = SENSOR_TYPE_LINUX_I2C;
-                                sensor_path = strdup(name);
-                                sensor_name = strdup(path);
-                                printf("sensor type = i2c\n"
-                                      "sensor path = %s\n"
-                                      "sensor name = %s\n",
-                                      sensor_path, sensor_name);
-                             }
-                        }
-                      ecore_list_destroy(therms);
-                   }
-                 if (!sensor_path)
-                   {
-                      // try the pci bus
-                      therms = temperature_get_bus_files("pci");
-                      if (therms)
-                        {
-                           char *name;
+                 temperature_bus_try(SENSOR_TYPE_LINUX_I2C, "i2c",
+                       &sensor_type, &sensor_path, &sensor_name);
 
-                           if ((name = ecore_list_next(therms)))
-                             {
-                                if (ecore_file_exists(name))
-                                  {
-                                     int len;
-
-                                     snprintf(path, sizeof(path),
-                                           "%s", ecore_file_file_get(name));
-                                     len = strlen(path);
-                                     if (len > 6) path[len - 6] = '\0';
-                                     sensor_type = SENSOR_TYPE_LINUX_PCI;
-                                     sensor_path = strdup(name);
-                                     sensor_name = strdup(path);
-                                     printf("sensor type = pci\n"
-                                           "sensor path = %s\n"
-                                           "sensor name = %s\n",
-                                           sensor_path, sensor_name);
-                                  }
-                             }
-                           ecore_list_destroy(therms);
-                        }
-                   }
+                 // try the pci bus
+                 if (sensor_type == SENSOR_TYPE_NONE)
+                   temperature_bus_try(SENSOR_TYPE_LINUX_PCI, "pci",
+                         &sensor_type, &sensor_path, &sensor_name);
+
+                 // try the generic /sys/bus/platform path
+                 if (sensor_type == SENSOR_TYPE_NONE)
+                   temperature_bus_try(SENSOR_TYPE_LINUX_PLATFORM, "platform",
+                         &sensor_type, &sensor_path, &sensor_name);
               }
          }
 #endif
      }
-   if ((sensor_type) && (sensor_name) && (!sensor_path))
-     {
-       switch (sensor_type)
-         {
-          case SENSOR_TYPE_NONE:
-            break;
-          case SENSOR_TYPE_FREEBSD:
-#ifdef __FreeBSD__
-            snprintf(path, sizeof(path), "hw.acpi.thermal.%s.temperature",
-                     sensor_name);
-            sensor_path = strdup(path);
-            len = 5;
-            sysctlnametomib(sensor_path, mib, &len);
-#endif
-            break;
-          case SENSOR_TYPE_OMNIBOOK:
-            sensor_path = strdup("/proc/omnibook/temperature");
-            break;
-          case SENSOR_TYPE_LINUX_MACMINI:
-            sensor_path = strdup("/sys/devices/temperatures/cpu_temperature");
-            break;
-          case SENSOR_TYPE_LINUX_PBOOK:
-            sensor_path = 
strdup("/sys/devices/temperatures/sensor1_temperature");
-            break;
-          case SENSOR_TYPE_LINUX_INTELCORETEMP:
-            sensor_path = 
strdup("/sys/devices/platform/coretemp.0/temp1_input");
-            break;
-          case SENSOR_TYPE_LINUX_I2C:
-            therms = ecore_file_ls("/sys/bus/i2c/devices");
-            if (therms)
-              {
-                 char *name;
-                 
-                 while ((name = ecore_list_next(therms)))
-                   {
-                      snprintf(path, sizeof(path),
-                               "/sys/bus/i2c/devices/%s/%s_input",
-                               name, sensor_name);
-                      if (ecore_file_exists(path))
-                        {
-                           sensor_path = strdup(path);
-                           /* We really only care about the first
-                            * one for the default. */
-                           break;
-                        }
-                   }
-                 ecore_list_destroy(therms);
-              }
-            break;
-          case SENSOR_TYPE_LINUX_PCI:
-            therms = ecore_file_ls("/sys/bus/pci/devices");
-            if (therms)
-              {
-                 char *name;
-                 
-                 while ((name = ecore_list_next(therms)))
-                   {
-                      snprintf(path, sizeof(path),
-                               "/sys/bus/pci/devices/%s/%s_input",
-                               name, sensor_name);
-                      if (ecore_file_exists(path))
-                        {
-                           sensor_path = strdup(path);
-                           /* We really only care about the first
-                            * one for the default. */
-                           break;
-                        }
-                   }
-                 ecore_list_destroy(therms);
-              }
-            break;
-          case SENSOR_TYPE_LINUX_ACPI:
-            snprintf(path, sizeof(path),
-                     "/proc/acpi/thermal_zone/%s/temperature",
-                     sensor_name);
-            sensor_path = strdup(path);
-            break;
-         }
-     }
 }
 
+
 static int
 check(void)
 {
@@ -341,25 +267,8 @@
        break;
       case SENSOR_TYPE_LINUX_INTELCORETEMP:
       case SENSOR_TYPE_LINUX_I2C:
-       f = fopen(sensor_path, "r");
-       if (f)
-         {
-            fgets(buf, sizeof(buf), f);
-            buf[sizeof(buf) - 1] = 0;
-            
-            /* actually read the temp */
-            if (sscanf(buf, "%i", &temp) == 1)
-              ret = 1;
-            else
-              goto error;
-            /* Hack for temp */
-            temp = temp / 1000;
-            fclose(f);
-         }
-       else
-         goto error;
-       break;
       case SENSOR_TYPE_LINUX_PCI:
+      case SENSOR_TYPE_LINUX_PLATFORM:
        f = fopen(sensor_path, "r");
        if (f)
          {
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-users mailing list
enlightenment-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-users

Reply via email to