Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/modules/temperature


Modified Files:
        Makefile.am e_mod_config.c e_mod_main.c e_mod_main.h 


Log Message:


e:
1. configure/build changes to allow cross-compiling painlessly
2. pager module namespace changes - this was still dirty afdter the namespace
cleanup, so clean it up
3. add a powersave subsystem - doesnt have an "automatic" way to turn on and
off right now, this i think is best provided by modules (that do things like
monitor acpi status's (eg close lid of laptop), AC power status etc. etc.
this allows e to nicely defer "power" expensive actions to avoid disk
spinups etc.
4. move to use the new ecore poller system  - discussed long ago as part of
power management/saving issues. now it exists
5. add a canvas idle flush call that helsp cope with the new shm greedy
software x11 engine stuff
6. use the new powersave subsystem where appropriate
7. fix non-zeroed/initted memory access in e_fm_main
8. fix mem leak for e menus
9. remove ipc handlers for changed/removed config values
10. use animaotr not timer for menu scrolls - then menu scrolls obey the fps
config
11. fix up timer/poll happienss of cursor idle stuff
12. remove avoid damage from popups for now - causing problems
13. change battery and temp readouts to b e shorter so they fit
14. pager can emit signals on focus change for mini-windows now
15. temperature module now uses a slave process and uses stdin/out to talk to
it and get output - this makes e smoother as in my expereicne i found getting
the temp on my laptop actually took like 200ms so e "hang" for 200ms while
reading the acpi files - so now the subprocess does it and just writesa back
to e when it gets it.

ecore:
1. add ecore_pollers. see the documentation on them in doxygen comments :)
2. fix timers to only go off when they have to - bug there that made e's
select time out a LOT more than it needed to. defensive coding hid the
problem. now fixed. e should be much more power friendly now.
3. formatting/niceness in ecore_exe stuff
4. some comments on comments with SIGIO ideas vs. select
5. add call to be able to add an idle enterer at the start of the list of
them, not just the end (as has been the default)
6. fix ecore_evas to support auto evas idler calls after 0.5 secs of idle in
all canvases - and to do it right
7. if argb destination - set the shape EVENT shape (to mask out events in
transparent regions much like shape does withotu translucency)
8. in ecore_x add support for the event shape

evas:
1. fix cache to work properly and not just always fill up (as it seemed to
like to think cahce useage dropped below 0 when it didnt and thus just
over-fill)
2. software x11 engine now ONLY uses shm segments - no ximages over the
socket. this ximage hack was there to avoid the 2 round trips involved in
setting up an shm image - now i mitigated that wih an shm image cache pool.
it keeps shm images around and repurposes them for new update regions if
appropriate. this means many fewer shm creates (about 1/100th the number) and
since we recycle the memory less 0 memory page filling by the kernel - in the
end, i recorded about a 10-20% speedup over the old software x11 engine.
simple tests i have seen up to 120% speedups. idle flush now does something -
it frees all the cached shm segments. it has a hard-coded limit of 4mb worth
of shm segments (or 32 segments - whichever comes first) to keep around. once
can never complain much about speedups methinks :). also evas will defer sync
until the NEXT frame is written - this means evas can calculate the next
frame of data while x dma's/copies the images to the screen at the same time
(if you hve a dual core or multi-cpu machnike or your xserver is able to use
DMA to copy image data to the screen/video ram then this should see a decent
speedup).



===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/Makefile.am,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- Makefile.am 26 May 2007 11:59:34 -0000      1.13
+++ Makefile.am 11 Jan 2008 07:33:56 -0000      1.14
@@ -25,5 +25,17 @@
 module_la_LDFLAGS      = -module -avoid-version
 module_la_DEPENDENCIES = $(top_builddir)/config.h
 
+tempgetdir = $(pkgdir)
+tempget_DATA = \
+tempget$(EXEEXT)
+
+x_mode = a=rx,u+x
+install-data-hook:
+       @chmod $(x_mode) $(DESTDIR)$(tempgetdir)/tempget$(EXEEXT) || true
+
+noinst_PROGRAMS        = tempget
+tempget_SOURCES        = tempget.c
+tempget_LDFLAGS        = @e_libs@
+
 uninstall:
        rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_config.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- e_mod_config.c      25 Jul 2007 17:00:51 -0000      1.35
+++ e_mod_config.c      11 Jan 2008 07:33:56 -0000      1.36
@@ -18,7 +18,7 @@
 struct _E_Config_Dialog_Data
 {
    int poll_method;
-   double poll_time;
+   int poll_interval;
    
    int unit_method;
    Unit units;
@@ -70,6 +70,7 @@
 _fill_data(E_Config_Dialog_Data *cfdata) 
 {
    double      p;
+   int         pi;
    Ecore_List *therms;
    char       *name;
    char        path[PATH_MAX];
@@ -80,16 +81,16 @@
    else 
      cfdata->unit_method = 1;
    
-   p = cfdata->inst->poll_time;
-   cfdata->poll_time = p;
-   if ((p >= 0) && (p <= 5)) 
-     cfdata->poll_method = 1; /* Fast */
-   else if ((p > 5) && (p <= 10)) 
-     cfdata->poll_method = 10; /* Normal */
-   else if ((p > 10) && (p <= 30)) 
-     cfdata->poll_method = 30; /* Slow */
-   else if (p > 30) 
-     cfdata->poll_method = 60; /* Very Slow */
+   pi = cfdata->inst->poll_interval;
+   cfdata->poll_interval = pi;
+   if ((pi >= 1) && (pi <= 64)) 
+     cfdata->poll_method = 4; /* Fast */
+   else if ((pi > 64) && (pi <= 128)) 
+     cfdata->poll_method = 128; /* Normal */
+   else if ((pi > 128) && (pi <= 256)) 
+     cfdata->poll_method = 256; /* Slow */
+   else if (pi > 256) 
+     cfdata->poll_method = 512; /* Very Slow */
    
    p = cfdata->inst->low;
    if (cfdata->units == FAHRENHEIT)
@@ -219,13 +220,13 @@
    
    of = e_widget_framelist_add(evas, _("Check Interval"), 0);
    rg = e_widget_radio_group_new(&(cfdata->poll_method));
-   ob = e_widget_radio_add(evas, _("Fast"), 1, rg);
+   ob = e_widget_radio_add(evas, _("Fast"), 4, rg);
    e_widget_framelist_object_append(of, ob);
-   ob = e_widget_radio_add(evas, _("Normal"), 10, rg);
+   ob = e_widget_radio_add(evas, _("Normal"), 128, rg);
    e_widget_framelist_object_append(of, ob);
-   ob = e_widget_radio_add(evas, _("Slow"), 30, rg);
+   ob = e_widget_radio_add(evas, _("Slow"), 256, rg);
    e_widget_framelist_object_append(of, ob);
-   ob = e_widget_radio_add(evas, _("Very Slow"), 60, rg);
+   ob = e_widget_radio_add(evas, _("Very Slow"), 512, rg);
    e_widget_framelist_object_append(of, ob);
    e_widget_list_object_append(o, of, 1, 1, 0.5);
 
@@ -289,7 +290,7 @@
      cfdata->inst->units = CELCIUS;    
    else 
      cfdata->inst->units = FAHRENHEIT;
-   cfdata->inst->poll_time = (double)cfdata->poll_method;
+   cfdata->inst->poll_interval = cfdata->poll_method;
    if (cfdata->inst->units == FAHRENHEIT)
      {
        cfdata->inst->low = CEL_2_FAR(cfdata->low_method);
@@ -340,7 +341,7 @@
      }
 
    of = e_widget_framelist_add(evas, _("Check Interval"), 0);
-   ob = e_widget_slider_add(evas, 1, 0, _("%1.1f seconds"), 0.5, 1000.0, 0.5, 
0, &(cfdata->poll_time), NULL, 200);
+   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f ticks"), 1, 1024, 4, 0, NULL, 
&(cfdata->poll_interval), 200);
    e_widget_framelist_object_append(of, ob);
    e_widget_list_object_append(o, of, 1, 1, 0.5);
 
@@ -403,7 +404,7 @@
      cfdata->inst->units = CELCIUS;    
    else 
      cfdata->inst->units = FAHRENHEIT;
-   cfdata->inst->poll_time = cfdata->poll_time;
+   cfdata->inst->poll_interval = cfdata->poll_interval;
    cfdata->inst->low = cfdata->low_temp;
    cfdata->inst->high = cfdata->high_temp;
    if (cfdata->inst->sensor_name)
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_main.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -3 -r1.88 -r1.89
--- e_mod_main.c        31 Oct 2007 12:23:15 -0000      1.88
+++ e_mod_main.c        11 Jan 2008 07:33:56 -0000      1.89
@@ -36,10 +36,10 @@
 /**/
 /* actual module specifics */
 
+static int _temperature_cb_exe_data(void *data, int type, void *event);
+static int _temperature_cb_exe_del(void *data, int type, void *event);
 static void _temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
 static void _temperature_face_cb_post_menu(void *data, E_Menu *m);
-static void _temperature_sensor_init(Config_Face *inst);
-static int  _temperature_cb_check(void *data);
 static void _temperature_face_level_set(Config_Face *inst, double level);
 static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, 
E_Menu_Item *mi);
 
@@ -59,23 +59,23 @@
    Evas_Object *o;
    E_Gadcon_Client *gcc;
    Config_Face *inst;
+   char buf[PATH_MAX];
 
    inst = evas_hash_find(temperature_config->faces, id);
    if (!inst)
      {
        inst = E_NEW(Config_Face, 1);
        inst->id = evas_stringshare_add(id);
-       inst->poll_time = 10.0;
+       inst->poll_interval = 128;
        inst->low = 30;
        inst->high = 80;
        inst->sensor_type = SENSOR_TYPE_NONE;
        inst->sensor_name = NULL;
-       inst->sensor_path = NULL;
        inst->units = CELCIUS;
        temperature_config->faces = 
evas_hash_direct_add(temperature_config->faces, inst->id, inst);
      }
    if (!inst->id) evas_stringshare_add(id);
-   E_CONFIG_LIMIT(inst->poll_time, 0.5, 1000.0);
+   E_CONFIG_LIMIT(inst->poll_interval, 1, 1024);
    E_CONFIG_LIMIT(inst->low, 0, 100);
    E_CONFIG_LIMIT(inst->high, 0, 220);
    E_CONFIG_LIMIT(inst->units, CELCIUS, FAHRENHEIT);
@@ -91,14 +91,27 @@
    inst->o_temp = o;
    inst->module = temperature_config->module;
    inst->have_temp = -1;
-   inst->temperature_check_timer = 
-     ecore_timer_add(inst->poll_time, _temperature_cb_check, inst);
- 
+   snprintf(buf, sizeof(buf),
+           "%s/%s/tempget %i \"%s\" %i", 
+           e_module_dir_get(temperature_config->module), MODULE_ARCH, 
+           inst->sensor_type,
+           (inst->sensor_name != NULL ? inst->sensor_name : "(null)"),
+           inst->poll_interval);
+   inst->tempget_exe = ecore_exe_pipe_run(buf, 
+                                         ECORE_EXE_PIPE_READ | 
+                                         ECORE_EXE_PIPE_READ_LINE_BUFFERED,
+                                         inst);
+   inst->tempget_data_handler = 
+     ecore_event_handler_add(ECORE_EXE_EVENT_DATA,
+                            _temperature_cb_exe_data,
+                            inst);
+   inst->tempget_del_handler = 
+     ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
+                            _temperature_cb_exe_del,
+                            inst);
    
    evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
                                  _temperature_face_cb_mouse_down, inst);
-   _temperature_sensor_init(inst);
-   _temperature_cb_check(inst);
    return gcc;
 }
 
@@ -108,8 +121,22 @@
    Config_Face *inst;
    
    inst = gcc->data;
-   if (inst->temperature_check_timer) 
ecore_timer_del(inst->temperature_check_timer);
-   inst->temperature_check_timer = NULL;
+   if (inst->tempget_exe)
+     {
+       ecore_exe_terminate(inst->tempget_exe);
+       ecore_exe_free(inst->tempget_exe);
+       inst->tempget_exe = NULL;
+     }
+   if (inst->tempget_data_handler)
+     {
+       ecore_event_handler_del(inst->tempget_data_handler);
+       inst->tempget_data_handler = NULL;
+     }
+   if (inst->tempget_del_handler)
+     {
+       ecore_event_handler_del(inst->tempget_del_handler);
+       inst->tempget_del_handler = NULL;
+     }
    if (inst->o_temp) evas_object_del(inst->o_temp);
    inst->o_temp = NULL;
    if (inst->config_dialog) e_object_del(E_OBJECT(inst->config_dialog));
@@ -157,12 +184,11 @@
 
    inst = E_NEW(Config_Face, 1);
    inst->id = evas_stringshare_add(id);
-   inst->poll_time = 10.0;
+   inst->poll_interval = 128;
    inst->low = 30;
    inst->high = 80;
    inst->sensor_type = SENSOR_TYPE_NONE;
    inst->sensor_name = NULL;
-   inst->sensor_path = NULL;
    inst->units = CELCIUS;
    temperature_config->faces = evas_hash_direct_add(temperature_config->faces, 
inst->id, inst);
    return inst->id;
@@ -178,7 +204,6 @@
      {
        temperature_config->faces = evas_hash_del(temperature_config->faces, 
id, inst);
        if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
-       if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
        free(inst);
      }
 }
@@ -188,6 +213,83 @@
 
 /***************************************************************************/
 /**/
+static int
+_temperature_cb_exe_data(void *data, int type, void *event)
+{    
+   Ecore_Exe_Event_Data *ev;
+   Config_Face *inst;
+   int temp;
+   
+   ev = event;
+   inst = data;
+   if (ev->exe != inst->tempget_exe) return 1;
+   temp = -999;
+   if ((ev->lines) && (ev->lines[0].line))
+     {
+       int i;
+       
+       for (i = 0; ev->lines[i].line; i++)
+         {
+            if (!strcmp(ev->lines[i].line, "ERROR"))
+              temp = -999;
+            else
+              temp = atoi(ev->lines[i].line);
+         }
+     }
+   if (temp != -999)
+     {
+       char *utf8;
+       char buf[256];
+
+       if (inst->units == FAHRENHEIT)
+         temp = (temp * 9.0 / 5.0) + 32;
+       
+       if (inst->have_temp != 1)
+         {
+            /* enable therm object */
+            edje_object_signal_emit(inst->o_temp, "e,state,known", "");
+            inst->have_temp = 1;
+         }
+
+       if (inst->units == FAHRENHEIT) 
+         snprintf(buf, sizeof(buf), "%i°F", temp);
+       else
+         snprintf(buf, sizeof(buf), "%i°C", temp);  
+       utf8 = ecore_txt_convert("iso-8859-1", "utf-8", buf);
+       
+        _temperature_face_level_set(inst,
+                                   (double)(temp - inst->low) /
+                                   (double)(inst->high - inst->low));
+       edje_object_part_text_set(inst->o_temp, "e.text.reading", utf8);
+       free(utf8);
+     }
+   else
+     {
+       if (inst->have_temp != 0)
+         {
+            /* disable therm object */
+            edje_object_signal_emit(inst->o_temp, "e,state,unknown", "");
+            edje_object_part_text_set(inst->o_temp, "e.text.reading", "N/A");
+            _temperature_face_level_set(inst, 0.5);
+            inst->have_temp = 0;
+         }
+     }
+   return 0;
+}
+
+static int
+_temperature_cb_exe_del(void *data, int type, void *event)
+{
+   Ecore_Exe_Event_Del *ev;
+   Config_Face *inst;
+   
+   ev = event;
+   inst = data;
+   if (ev->exe != inst->tempget_exe) return 1;
+   inst->tempget_exe = NULL;
+   return 0;
+}
+
 static void
 _temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void 
*event_info)
 {
@@ -237,309 +339,6 @@
 }
 
 static void
-_temperature_sensor_init(Config_Face *inst)
-{
-   Ecore_List *therms;
-   char        path[PATH_MAX];
-#ifdef __FreeBSD__
-   int         len;
-#endif
-
-   if ((!inst->sensor_type) || (!inst->sensor_name))
-     {
-       if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
-       if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
-       inst->sensor_path = NULL;
-#ifdef __FreeBSD__
-       /* TODO: FreeBSD can also have more temperature sensors! */
-       inst->sensor_type = SENSOR_TYPE_FREEBSD;
-       inst->sensor_name = evas_stringshare_add("tz0");
-#else  
-       therms = ecore_file_ls("/proc/acpi/thermal_zone");
-       if ((therms) && (!ecore_list_empty_is(therms)))
-         {
-            char *name;
-
-            name = ecore_list_next(therms);
-            inst->sensor_type = SENSOR_TYPE_LINUX_ACPI;
-            inst->sensor_name = evas_stringshare_add(name);
-
-            ecore_list_destroy(therms);
-         }
-       else
-         {
-            if (therms) ecore_list_destroy(therms);
-
-            if (ecore_file_exists("/proc/omnibook/temperature"))
-              {
-                 inst->sensor_type = SENSOR_TYPE_OMNIBOOK;
-                 inst->sensor_name = evas_stringshare_add("dummy");
-              }
-            else if 
(ecore_file_exists("/sys/devices/temperatures/sensor1_temperature"))
-              {
-                 inst->sensor_type = SENSOR_TYPE_LINUX_PBOOK;
-                 inst->sensor_name = evas_stringshare_add("dummy");
-              }
-            else if 
(ecore_file_exists("/sys/devices/temperatures/cpu_temperature"))
-              {
-                 inst->sensor_type = SENSOR_TYPE_LINUX_MACMINI;
-                 inst->sensor_name = evas_stringshare_add("dummy");
-              }
-            else if 
(ecore_file_exists("/sys/devices/platform/coretemp.0/temp1_input"))
-              {
-                 inst->sensor_type = SENSOR_TYPE_LINUX_INTELCORETEMP;
-                 inst->sensor_name = evas_stringshare_add("dummy");
-              }
-            else
-              {
-                  therms = temperature_get_i2c_files();
-                 if (therms)
-                   {
-                      char *name;
-
-                      if ((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';
-                                inst->sensor_type = SENSOR_TYPE_LINUX_I2C;
-                                inst->sensor_path = evas_stringshare_add(name);
-                                inst->sensor_name = evas_stringshare_add(path);
-                             }
-                        }
-                      ecore_list_destroy(therms);
-                   }
-              }
-         }
-#endif
-     }
-   if ((inst->sensor_type) &&
-       (inst->sensor_name) && 
-       (!inst->sensor_path))
-     {
-       switch (inst->sensor_type)
-         {
-          case SENSOR_TYPE_NONE:
-             break;
-          case SENSOR_TYPE_FREEBSD:
-#ifdef __FreeBSD__
-             snprintf(path, sizeof(path), "hw.acpi.thermal.%s.temperature",
-                      inst->sensor_name);
-             inst->sensor_path = evas_stringshare_add(path);
-
-             len = 5;
-             sysctlnametomib(inst->sensor_path, inst->mib, &len);
-#endif
-             break;
-          case SENSOR_TYPE_OMNIBOOK:
-             inst->sensor_path = 
evas_stringshare_add("/proc/omnibook/temperature");
-             break;
-          case SENSOR_TYPE_LINUX_MACMINI:
-                 inst->sensor_path = 
evas_stringshare_add("/sys/devices/temperatures/cpu_temperature");
-             break;
-          case SENSOR_TYPE_LINUX_PBOOK:
-                 inst->sensor_path = 
evas_stringshare_add("/sys/devices/temperatures/sensor1_temperature");
-             break;
-          case SENSOR_TYPE_LINUX_INTELCORETEMP:
-                 inst->sensor_path = 
evas_stringshare_add("/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)))
-                    {
-                       sprintf(path, "/sys/bus/i2c/devices/%s/%s_input",
-                             name, inst->sensor_name);
-                       if (ecore_file_exists(path))
-                         {
-                            inst->sensor_path = evas_stringshare_add(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",
-                      inst->sensor_name);
-             inst->sensor_path = evas_stringshare_add(path);
-             break;
-         }
-     }
-}
-
-static int
-_temperature_cb_check(void *data)
-{
-   FILE *f;
-   int ret = 0;
-   Config_Face *inst;
-   int temp = 0;
-   char buf[4096];
-#ifdef __FreeBSD__
-   int len;
-#endif
-
-   inst = data;
-
-   /* TODO: Make standard parser. Seems to be two types of temperature string:
-    * - Somename: <temp> C
-    * - <temp>
-    */
-   switch (inst->sensor_type)
-     {
-      case SENSOR_TYPE_NONE:
-        /* TODO: Slow down timer? */
-        break;
-      case SENSOR_TYPE_FREEBSD:
-#ifdef __FreeBSD__
-        len = sizeof(temp);
-        if (sysctl(inst->mib, 5, &temp, &len, NULL, 0) != -1)
-          {
-             temp = (temp - 2732) / 10;
-             ret = 1;
-          }
-        else
-          goto error;
-#endif
-        break;
-      case SENSOR_TYPE_OMNIBOOK:
-        f = fopen(inst->sensor_path, "r");
-        if (f) 
-          {
-             char dummy[4096];
-
-             fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
-             if (sscanf(buf, "%s %s %i", dummy, dummy, &temp) == 3)
-               ret = 1;
-             else
-               goto error;
-             fclose(f);
-          }
-        else
-          goto error;
-        break;
-      case SENSOR_TYPE_LINUX_MACMINI:
-      case SENSOR_TYPE_LINUX_PBOOK:
-        f = fopen(inst->sensor_path, "rb");
-        if (f)
-          {
-             fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
-             if (sscanf(buf, "%i", &temp) == 1)
-               ret = 1;
-             else
-               goto error;
-             fclose(f);
-          }
-        else
-          goto error;
-        break;
-      case SENSOR_TYPE_LINUX_INTELCORETEMP:
-      case SENSOR_TYPE_LINUX_I2C:
-        f = fopen(inst->sensor_path, "r");
-        if (f)
-          {
-             fgets(buf, sizeof(buf), f);
-             buf[sizeof(buf) - 1] = 0;
-
-             /* actuallty 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_ACPI:
-        f = fopen(inst->sensor_path, "r");
-        if (f)
-          {
-             char *p, *q;
-             fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
-             fclose(f);
-             p = strchr(buf, ':');
-             if (p)
-               {
-                  p++;
-                  while (*p == ' ') p++;
-                  q = strchr(p, ' ');
-                  if (q) *q = 0;
-                  temp = atoi(p);
-                  ret = 1;
-               }
-             else
-               goto error;
-          }
-        else
-          goto error;
-        break;
-     }
-
-   if (inst->units == FAHRENHEIT)
-     temp = (temp * 9.0 / 5.0) + 32;
-
-   if (ret)
-     {
-       char *utf8;
-
-       if (inst->have_temp != 1)
-         {
-            /* enable therm object */
-            edje_object_signal_emit(inst->o_temp, "e,state,known", "");
-            inst->have_temp = 1;
-         }
-
-       if (inst->units == FAHRENHEIT) 
-         snprintf(buf, sizeof(buf), "%i°F", temp);
-       else
-         snprintf(buf, sizeof(buf), "%i°C", temp);  
-       utf8 = ecore_txt_convert("iso-8859-1", "utf-8", buf);
-
-        _temperature_face_level_set(inst,
-                                   (double)(temp - inst->low) /
-                                   (double)(inst->high - inst->low));
-       edje_object_part_text_set(inst->o_temp, "e.text.reading", utf8);
-       free(utf8);
-     }
-   else
-     {
-       if (inst->have_temp != 0)
-         {
-            /* disable therm object */
-            edje_object_signal_emit(inst->o_temp, "e,state,unknown", "");
-            edje_object_part_text_set(inst->o_temp, "e.text.reading", "NO 
TEMP");
-            _temperature_face_level_set(inst, 0.5);
-            inst->have_temp = 0;
-         }
-     }
-   return 1;
-   
-error:
-   /* TODO: Error count? Might be a temporary problem */
-   /* TODO: Error dialog */
-   /* TODO: This should be further up, so that it will affect the gadcon */
-   inst->sensor_type = SENSOR_TYPE_NONE;
-   if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
-   inst->sensor_name = NULL;
-   if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
-   inst->sensor_path = NULL;
-   return 1;
-}
-
-static void
 _temperature_face_level_set(Config_Face *inst, double level)
 {
    Edje_Message_Float msg;
@@ -568,7 +367,6 @@
    inst = hdata;
 
    if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
-   if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
    if (inst->id) evas_stringshare_del(inst->id);
    free(inst);
    return 1;
@@ -591,15 +389,21 @@
 void 
 temperature_face_update_config(Config_Face *inst)
 {
-   if (inst->sensor_path)
-     evas_stringshare_del(inst->sensor_path);
-   inst->sensor_path = NULL;
-
-   _temperature_sensor_init(inst);
-
-   if (inst->temperature_check_timer) 
ecore_timer_del(inst->temperature_check_timer);
-   inst->temperature_check_timer = 
-     ecore_timer_add(inst->poll_time, _temperature_cb_check, inst);
+   char buf[PATH_MAX];
+   
+   ecore_exe_terminate(inst->tempget_exe);
+   ecore_exe_free(inst->tempget_exe);
+   inst->tempget_exe = NULL;
+   snprintf(buf, sizeof(buf),
+           "%s/%s/tempget %i \"%s\" %i", 
+           e_module_dir_get(temperature_config->module), MODULE_ARCH, 
+           inst->sensor_type,
+           (inst->sensor_name != NULL ? inst->sensor_name : "(null)"),
+           inst->poll_interval);
+   inst->tempget_exe = ecore_exe_pipe_run(buf, 
+                                         ECORE_EXE_PIPE_READ | 
+                                         ECORE_EXE_PIPE_READ_LINE_BUFFERED,
+                                         inst);
 }
 
 Ecore_List *
@@ -673,7 +477,7 @@
 #define T Config_Face
 #define D conf_face_edd
    E_CONFIG_VAL(D, T, id, STR);
-   E_CONFIG_VAL(D, T, poll_time, DOUBLE);
+   E_CONFIG_VAL(D, T, poll_interval, INT);
    E_CONFIG_VAL(D, T, low, INT);
    E_CONFIG_VAL(D, T, high, INT);
    E_CONFIG_VAL(D, T, sensor_type, INT);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/temperature/e_mod_main.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- e_mod_main.h        31 Oct 2007 12:23:15 -0000      1.31
+++ e_mod_main.h        11 Jan 2008 07:33:56 -0000      1.32
@@ -29,11 +29,10 @@
 {
    const char      *id;
    /* saved * loaded config values */
-   double           poll_time;
+   int              poll_interval;
    int              low, high;
-   Sensor_Type      sensor_type;
+   int              sensor_type;
    const char      *sensor_name;
-   const char      *sensor_path;
    Unit             units;
    /* config state */
    E_Gadcon_Client *gcc;
@@ -43,7 +42,11 @@
 
    E_Config_Dialog *config_dialog;
    E_Menu          *menu;
-   Ecore_Timer     *temperature_check_timer;
+   Ecore_Exe       *tempget_exe;
+   Ecore_Event_Handler *tempget_data_handler;
+   Ecore_Event_Handler *tempget_del_handler;
+   
+//   Ecore_Poller    *temperature_check_poller;
    unsigned char    have_temp;
 #ifdef __FreeBSD__
    int              mib[5];



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to