Don't need tempget for udev processing.

Don't need exe data handlers for udev processing.
Cut down on the number of rogue tempget processes (if using Internal
method).
Fix some formatting.
Use PATH_MAX and E_FREE.



SVN revision: 49167
This commit is contained in:
Christopher Michael 2010-05-23 22:23:14 +00:00
parent 131a5b9fca
commit 8b97b2ee11
3 changed files with 58 additions and 37 deletions

View File

@ -92,22 +92,30 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
#ifdef HAVE_EEZE
if (inst->backend == TEMPGET)
{
#endif
inst->tempget_data_handler =
ecore_event_handler_add(ECORE_EXE_EVENT_DATA,
_temperature_cb_exe_data, inst);
_temperature_cb_exe_data, inst);
inst->tempget_del_handler =
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
_temperature_cb_exe_del, inst);
#ifdef HAVE_EEZE
_temperature_cb_exe_del, inst);
}
else
{
eeze_init();
inst->temp_poller = ecore_poller_add(ECORE_POLLER_CORE, inst->poll_interval, temperature_udev_update_poll, inst);
inst->temp_poller =
ecore_poller_add(ECORE_POLLER_CORE, inst->poll_interval,
temperature_udev_update_poll, inst);
temperature_udev_update(inst);
}
#else
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);
#endif
temperature_face_update_config(inst);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
@ -124,9 +132,9 @@ _gc_shutdown(E_Gadcon_Client *gcc)
if (inst->tempget_exe)
{
ecore_exe_terminate(inst->tempget_exe);
ecore_exe_free(inst->tempget_exe);
inst->tempget_exe = NULL;
ecore_exe_terminate(inst->tempget_exe);
ecore_exe_free(inst->tempget_exe);
inst->tempget_exe = NULL;
}
if (inst->tempget_data_handler)
{
@ -135,8 +143,8 @@ _gc_shutdown(E_Gadcon_Client *gcc)
}
if (inst->tempget_del_handler)
{
ecore_event_handler_del(inst->tempget_del_handler);
inst->tempget_del_handler = NULL;
ecore_event_handler_del(inst->tempget_del_handler);
inst->tempget_del_handler = NULL;
}
#ifdef HAVE_EEEZ_UDEV
if (inst->temp_poller)
@ -168,7 +176,7 @@ static Evas_Object *
_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas)
{
Evas_Object *o;
char buf[4096];
char buf[PATH_MAX];
o = edje_object_add(evas);
snprintf(buf, sizeof(buf), "%s/e-module-temperature.edj",
@ -202,8 +210,6 @@ _gc_id_new(E_Gadcon_Client_Class *client_class)
return inst->id;
}
static void
_temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
@ -230,11 +236,11 @@ _temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *eve
e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
&cx, &cy, NULL, NULL);
&cx, &cy, NULL, NULL);
e_menu_activate_mouse(mn,
e_util_zone_current_get(e_manager_current_get()),
cx + ev->output.x, cy + ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
e_util_zone_current_get(e_manager_current_get()),
cx + ev->output.x, cy + ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
}
}
@ -282,11 +288,12 @@ _temperature_face_shutdown(const Eina_Hash *hash __UNUSED__, const void *key __U
if (inst->tempdevs)
{
const char *s;
EINA_LIST_FREE(inst->tempdevs, s)
eina_stringshare_del(s);
}
#endif
free(inst);
E_FREE(inst);
return EINA_TRUE;
}
@ -324,21 +331,21 @@ temperature_face_update_config(Config_Face *inst)
ecore_poller_del(inst->temp_poller);
inst->temp_poller = NULL;
}
#endif
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 |
ECORE_EXE_NOT_LEADER, inst);
#ifdef HAVE_EEZE
if (!inst->tempget_exe)
{
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 |
ECORE_EXE_NOT_LEADER, inst);
}
}
else
else if (inst->backend == UDEV)
{
/*avoid creating a new poller if possible*/
if (inst->temp_poller)
@ -351,6 +358,20 @@ temperature_face_update_config(Config_Face *inst)
temperature_udev_update_poll, inst);
}
}
#else
if (!inst->tempget_exe)
{
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 |
ECORE_EXE_NOT_LEADER, inst);
}
#endif
}

View File

@ -24,7 +24,7 @@ struct _Config_Face
#ifdef HAVE_EEZE
Eina_List *tempdevs;
int backend;
Ecore_Poller *temp_poller;
Ecore_Poller *temp_poller;
#endif
int sensor_type;
const char *sensor_name;
@ -61,15 +61,16 @@ typedef enum _Backend
TEMPGET,
UDEV
} Backend;
int temperature_udev_update_poll(void *data);
void temperature_udev_update(void *data);
#endif
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *m);
EAPI int e_modapi_shutdown (E_Module *m);
EAPI int e_modapi_save (E_Module *m);
EAPI void *e_modapi_init(E_Module *m);
EAPI int e_modapi_shutdown(E_Module *m);
EAPI int e_modapi_save(E_Module *m);
int _temperature_cb_exe_data(void *data, int type, void *event);
int _temperature_cb_exe_del(void *data, int type, void *event);

View File

@ -1,7 +1,6 @@
#include "e.h"
#include "e_mod_main.h"
int
_temperature_cb_exe_data(void *data, int type, void *event)
{