2005-01-01 18:39:44 -08:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2005-06-22 19:49:32 -07:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#endif
|
|
|
|
|
2011-10-31 08:52:42 -07:00
|
|
|
#ifdef __OpenBSD__
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/sensors.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* gadcon requirements */
|
2006-05-31 09:31:51 -07:00
|
|
|
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
2006-04-20 04:30:25 -07:00
|
|
|
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
2008-11-03 19:57:45 -08:00
|
|
|
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
2012-07-27 01:25:22 -07:00
|
|
|
static const char *_gc_label(const E_Gadcon_Client_Class *client_class);
|
|
|
|
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
|
|
|
|
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class);
|
2006-04-20 04:30:25 -07:00
|
|
|
/* and actually define the gadcon class that this module provides (just 1) */
|
|
|
|
static const E_Gadcon_Client_Class _gadcon_class =
|
2005-09-23 10:13:47 -07:00
|
|
|
{
|
2008-11-11 16:50:51 -08:00
|
|
|
GADCON_CLIENT_CLASS_VERSION, "temperature",
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
List of changes:
1. Gadcon sities:
-- 'E_Gadcon_Site' enum to list all available sities,
-- added 'is_site' callback for distinguish gadcon sities,
-- 'e_gadcon_site_is_*' helpers written to use in gadget modules,
-- gadcon config dialogs modified to show only gadgets that appropriate
to selected gadcon site,
-- all gadget modules updated for using new callback.
When callback is not provided in module, then gadget can be used in
any gadcon site.
2. Filemanager:
-- added error icon to unexisting path dialog,
-- added callback 'func.abort' to 'E_Fm2_Op_Registry_Entry' to specify
abort operation sequence (if not provided, then operation is not
cancelable),
-- added parameter to 'e_fm2_op_registry_entry_add' to specify abort
method on construct 'E_Fm2_Op_Registry_Entry' or make non-cancelable
operation if this function is not provided,
-- added 'e_fm2_operation_abort' call to cancel efm2 operation,
-- added method '_e_fm2_operation_abort_internal' that represent efm2
default handler of operation cancelling,
-- 'done' and 'total' fields of 'E_Fm2_Op_Registry_Entry' changed to
off_t type, also all message handlers modified to work with it
(to show progress for large files correctly),
-- improved file operation progress processing,
-- added cancel button to operation progress gadget in filemanager window,
-- added delete file glyph to operation progress gadget,
-- improved status message for efm2 operation progress.
3. Filemanager slave:
-- fixed critical bug in message handling via stdin/stdout,
-- fixed critical bug in removing task from list,
-- improved 'E_FM_OP_ABORT' handling,
-- fix rollback counting on moving files.
4. Fileman_opinfo module:
-- a new theme writed: status string and gadget for view operation status
in summary and detail modes,
-- summary mode: operation glyph, state message, progressbar, abort button,
-- detail mode: all for summary + from filename, to filename,
-- summary/detailed button works as trigger,
-- added source of module theme and used images.
4. Pathbar module:
-- non-critical fix, just for safety.
Also patch contains several minor updates to serve main task.
SVN revision: 41224
2009-06-29 07:38:03 -07:00
|
|
|
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
|
|
|
|
e_gadcon_site_is_not_toolbar
|
2006-08-08 23:38:35 -07:00
|
|
|
},
|
|
|
|
E_GADCON_CLIENT_STYLE_PLAIN
|
2005-09-23 10:13:47 -07:00
|
|
|
};
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* actual module specifics */
|
2010-05-20 03:12:41 -07:00
|
|
|
|
2006-12-17 14:01:45 -08:00
|
|
|
static void _temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2010-05-20 03:12:41 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
|
2005-02-10 03:58:14 -08:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _temperature_face_shutdown(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *hdata, void *fdata __UNUSED__);
|
|
|
|
static Eina_Bool _temperature_face_id_max(const Eina_Hash *hash __UNUSED__, const void *key, void *hdata __UNUSED__, void *fdata);
|
2006-12-17 14:01:45 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static E_Config_DD *conf_edd = NULL;
|
2006-12-17 14:01:45 -08:00
|
|
|
static E_Config_DD *conf_face_edd = NULL;
|
2005-01-01 18:39:44 -08:00
|
|
|
|
2007-09-16 03:55:16 -07:00
|
|
|
static int uuid = 0;
|
|
|
|
|
2006-12-17 14:01:45 -08:00
|
|
|
static Config *temperature_config = NULL;
|
2005-01-01 18:39:44 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static E_Gadcon_Client *
|
2006-05-31 09:31:51 -07:00
|
|
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
2005-12-17 03:21:54 -08:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
E_Gadcon_Client *gcc;
|
2006-12-17 14:01:45 -08:00
|
|
|
Config_Face *inst;
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
inst = eina_hash_find(temperature_config->faces, id);
|
2006-12-17 14:01:45 -08:00
|
|
|
if (!inst)
|
|
|
|
{
|
2010-05-20 03:12:41 -07:00
|
|
|
inst = E_NEW(Config_Face, 1);
|
|
|
|
inst->id = eina_stringshare_add(id);
|
|
|
|
inst->poll_interval = 128;
|
|
|
|
inst->low = 30;
|
|
|
|
inst->high = 80;
|
|
|
|
inst->sensor_type = SENSOR_TYPE_NONE;
|
|
|
|
inst->sensor_name = NULL;
|
|
|
|
inst->units = CELCIUS;
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-21 18:55:28 -07:00
|
|
|
inst->backend = UDEV;
|
2010-05-20 03:12:41 -07:00
|
|
|
#endif
|
|
|
|
if (!temperature_config->faces)
|
|
|
|
temperature_config->faces = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_direct_add(temperature_config->faces, inst->id, inst);
|
2006-12-17 14:01:45 -08:00
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if (!inst->id) inst->id = eina_stringshare_add(id);
|
2008-01-10 23:33:57 -08:00
|
|
|
E_CONFIG_LIMIT(inst->poll_interval, 1, 1024);
|
2006-12-17 14:01:45 -08:00
|
|
|
E_CONFIG_LIMIT(inst->low, 0, 100);
|
|
|
|
E_CONFIG_LIMIT(inst->high, 0, 220);
|
|
|
|
E_CONFIG_LIMIT(inst->units, CELCIUS, FAHRENHEIT);
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-20 03:12:41 -07:00
|
|
|
E_CONFIG_LIMIT(inst->backend, TEMPGET, UDEV);
|
|
|
|
#endif
|
2006-12-17 14:01:45 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
o = edje_object_add(gc->evas);
|
|
|
|
e_theme_edje_object_set(o, "base/theme/modules/temperature",
|
2006-08-22 21:02:03 -07:00
|
|
|
"e/modules/temperature/main");
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-12-30 15:32:25 -08:00
|
|
|
gcc = e_gadcon_client_new(gc, name, id, style, o);
|
2006-04-20 04:30:25 -07:00
|
|
|
gcc->data = inst;
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst->gcc = gcc;
|
|
|
|
inst->o_temp = o;
|
2006-12-17 14:01:45 -08:00
|
|
|
inst->module = temperature_config->module;
|
|
|
|
inst->have_temp = -1;
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-20 03:12:41 -07:00
|
|
|
if (inst->backend == TEMPGET)
|
|
|
|
{
|
|
|
|
inst->tempget_data_handler =
|
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DATA,
|
2010-05-23 15:23:14 -07:00
|
|
|
_temperature_cb_exe_data, inst);
|
2010-05-20 03:12:41 -07:00
|
|
|
inst->tempget_del_handler =
|
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
2010-05-23 15:23:14 -07:00
|
|
|
_temperature_cb_exe_del, inst);
|
2010-05-20 03:12:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-22 00:04:26 -07:00
|
|
|
eeze_init();
|
2010-05-23 15:23:14 -07:00
|
|
|
inst->temp_poller =
|
|
|
|
ecore_poller_add(ECORE_POLLER_CORE, inst->poll_interval,
|
|
|
|
temperature_udev_update_poll, inst);
|
2010-05-20 03:12:41 -07:00
|
|
|
temperature_udev_update(inst);
|
|
|
|
}
|
2010-05-23 15:23:14 -07:00
|
|
|
#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);
|
2010-05-20 03:12:41 -07:00
|
|
|
#endif
|
2010-05-23 15:23:14 -07:00
|
|
|
|
2008-03-09 23:45:05 -07:00
|
|
|
temperature_face_update_config(inst);
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
2006-12-17 14:01:45 -08:00
|
|
|
_temperature_face_cb_mouse_down, inst);
|
2006-04-20 04:30:25 -07:00
|
|
|
return gcc;
|
2005-12-17 03:21:54 -08:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
|
|
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
2005-01-01 18:39:44 -08:00
|
|
|
{
|
2006-12-17 14:01:45 -08:00
|
|
|
Config_Face *inst;
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst = gcc->data;
|
2010-05-20 03:12:41 -07:00
|
|
|
|
2008-01-10 23:33:57 -08:00
|
|
|
if (inst->tempget_exe)
|
|
|
|
{
|
2010-05-23 15:23:14 -07:00
|
|
|
ecore_exe_terminate(inst->tempget_exe);
|
|
|
|
ecore_exe_free(inst->tempget_exe);
|
|
|
|
inst->tempget_exe = NULL;
|
2008-01-10 23:33:57 -08:00
|
|
|
}
|
|
|
|
if (inst->tempget_data_handler)
|
|
|
|
{
|
2010-05-20 03:12:41 -07:00
|
|
|
ecore_event_handler_del(inst->tempget_data_handler);
|
|
|
|
inst->tempget_data_handler = NULL;
|
2008-01-10 23:33:57 -08:00
|
|
|
}
|
|
|
|
if (inst->tempget_del_handler)
|
|
|
|
{
|
2010-05-23 15:23:14 -07:00
|
|
|
ecore_event_handler_del(inst->tempget_del_handler);
|
|
|
|
inst->tempget_del_handler = NULL;
|
2008-01-10 23:33:57 -08:00
|
|
|
}
|
2010-05-20 03:12:41 -07:00
|
|
|
#ifdef HAVE_EEEZ_UDEV
|
|
|
|
if (inst->temp_poller)
|
|
|
|
ecore_poller_del(inst->temp_poller);
|
2010-05-22 00:04:26 -07:00
|
|
|
eeze_shutdown();
|
2010-05-20 03:12:41 -07:00
|
|
|
#endif
|
2006-12-17 14:01:45 -08:00
|
|
|
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));
|
|
|
|
inst->config_dialog = NULL;
|
2005-01-01 18:39:44 -08:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
2010-08-19 08:27:13 -07:00
|
|
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
|
2005-01-01 18:39:44 -08:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
|
|
|
e_gadcon_client_min_size_set(gcc, 16, 16);
|
2005-02-10 03:58:14 -08:00
|
|
|
}
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2011-11-14 13:46:57 -08:00
|
|
|
static const char *
|
2012-07-27 01:25:22 -07:00
|
|
|
_gc_label(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
2006-05-09 06:02:48 -07:00
|
|
|
{
|
|
|
|
return _("Temperature");
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2012-07-27 01:25:22 -07:00
|
|
|
_gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
|
2006-05-09 06:02:48 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o;
|
2010-05-23 15:23:14 -07:00
|
|
|
char buf[PATH_MAX];
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-05-09 06:02:48 -07:00
|
|
|
o = edje_object_add(evas);
|
2007-03-24 16:12:23 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/e-module-temperature.edj",
|
2006-05-09 06:02:48 -07:00
|
|
|
e_module_dir_get(temperature_config->module));
|
|
|
|
edje_object_file_set(o, buf, "icon");
|
|
|
|
return o;
|
|
|
|
}
|
2007-09-15 17:02:53 -07:00
|
|
|
|
|
|
|
static const char *
|
2012-07-27 01:25:22 -07:00
|
|
|
_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
2007-09-15 17:02:53 -07:00
|
|
|
{
|
|
|
|
Config_Face *inst;
|
2008-11-11 16:50:51 -08:00
|
|
|
char id[128];
|
2007-09-15 17:02:53 -07:00
|
|
|
|
2007-09-16 03:55:16 -07:00
|
|
|
snprintf(id, sizeof(id), "%s.%d", _gadcon_class.name, ++uuid);
|
2007-09-15 17:02:53 -07:00
|
|
|
|
|
|
|
inst = E_NEW(Config_Face, 1);
|
2008-10-15 08:12:56 -07:00
|
|
|
inst->id = eina_stringshare_add(id);
|
2008-01-10 23:33:57 -08:00
|
|
|
inst->poll_interval = 128;
|
2007-09-15 17:02:53 -07:00
|
|
|
inst->low = 30;
|
|
|
|
inst->high = 80;
|
|
|
|
inst->sensor_type = SENSOR_TYPE_NONE;
|
|
|
|
inst->sensor_name = NULL;
|
|
|
|
inst->units = CELCIUS;
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-20 03:12:41 -07:00
|
|
|
inst->backend = TEMPGET;
|
|
|
|
#endif
|
2008-12-17 07:33:43 -08:00
|
|
|
if (!temperature_config->faces)
|
|
|
|
temperature_config->faces = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_direct_add(temperature_config->faces, inst->id, inst);
|
2007-09-15 17:02:53 -07:00
|
|
|
return inst->id;
|
|
|
|
}
|
|
|
|
|
2005-02-10 03:58:14 -08:00
|
|
|
static void
|
2010-08-19 08:27:13 -07:00
|
|
|
_temperature_face_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2005-02-10 03:58:14 -08:00
|
|
|
{
|
2006-12-17 14:01:45 -08:00
|
|
|
Config_Face *inst;
|
2006-04-20 04:30:25 -07:00
|
|
|
Evas_Event_Mouse_Down *ev;
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst = data;
|
|
|
|
ev = event_info;
|
2012-08-15 00:22:04 -07:00
|
|
|
if (ev->button == 3)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2011-03-17 10:08:36 -07:00
|
|
|
E_Menu *m;
|
2010-05-20 03:12:41 -07:00
|
|
|
E_Menu_Item *mi;
|
|
|
|
int cx, cy;
|
|
|
|
|
2011-03-17 10:08:36 -07:00
|
|
|
m = e_menu_new();
|
|
|
|
mi = e_menu_item_new(m);
|
2010-05-20 03:12:41 -07:00
|
|
|
e_menu_item_label_set(mi, _("Settings"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "configure");
|
|
|
|
e_menu_item_callback_set(mi, _temperature_face_cb_menu_configure, inst);
|
|
|
|
|
2011-03-17 10:08:36 -07:00
|
|
|
m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0);
|
2006-12-17 14:01:45 -08:00
|
|
|
|
2012-08-15 00:22:04 -07:00
|
|
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, NULL, NULL);
|
|
|
|
e_menu_activate_mouse(m, 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);
|
|
|
|
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
|
|
|
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
|
|
|
}
|
2005-01-01 18:39:44 -08:00
|
|
|
}
|
|
|
|
|
2010-05-20 03:12:41 -07:00
|
|
|
void
|
2006-12-17 14:01:45 -08:00
|
|
|
_temperature_face_level_set(Config_Face *inst, double level)
|
2005-01-01 18:39:44 -08:00
|
|
|
{
|
|
|
|
Edje_Message_Float msg;
|
2005-02-10 03:58:14 -08:00
|
|
|
|
2005-01-01 18:39:44 -08:00
|
|
|
if (level < 0.0) level = 0.0;
|
|
|
|
else if (level > 1.0) level = 1.0;
|
|
|
|
msg.val = level;
|
2006-04-20 04:30:25 -07:00
|
|
|
edje_object_message_send(inst->o_temp, EDJE_MESSAGE_FLOAT, 1, &msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:27:13 -07:00
|
|
|
_temperature_face_cb_menu_configure(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2006-12-17 14:01:45 -08:00
|
|
|
Config_Face *inst;
|
|
|
|
|
|
|
|
inst = data;
|
|
|
|
if (inst->config_dialog) return;
|
|
|
|
config_temperature_module(inst);
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_temperature_face_shutdown(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *hdata, void *fdata __UNUSED__)
|
2006-12-17 14:01:45 -08:00
|
|
|
{
|
|
|
|
Config_Face *inst;
|
|
|
|
|
|
|
|
inst = hdata;
|
2008-10-15 08:12:56 -07:00
|
|
|
if (inst->sensor_name) eina_stringshare_del(inst->sensor_name);
|
|
|
|
if (inst->id) eina_stringshare_del(inst->id);
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-20 03:12:41 -07:00
|
|
|
if (inst->tempdevs)
|
|
|
|
{
|
|
|
|
const char *s;
|
2010-05-23 15:23:14 -07:00
|
|
|
|
2010-05-20 03:12:41 -07:00
|
|
|
EINA_LIST_FREE(inst->tempdevs, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
}
|
|
|
|
#endif
|
2010-05-23 15:23:14 -07:00
|
|
|
E_FREE(inst);
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2005-12-15 14:37:14 -08:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_temperature_face_id_max(const Eina_Hash *hash __UNUSED__, const void *key, void *hdata __UNUSED__, void *fdata)
|
2007-09-15 17:02:53 -07:00
|
|
|
{
|
|
|
|
const char *p;
|
2008-02-11 22:14:27 -08:00
|
|
|
int *max;
|
|
|
|
int num = -1;
|
2007-09-15 17:02:53 -07:00
|
|
|
|
2007-09-16 03:55:16 -07:00
|
|
|
max = fdata;
|
2007-09-15 17:02:53 -07:00
|
|
|
p = strrchr(key, '.');
|
|
|
|
if (p) num = atoi(p + 1);
|
|
|
|
if (num > *max) *max = num;
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2007-09-15 17:02:53 -07:00
|
|
|
}
|
|
|
|
|
2005-12-15 14:37:14 -08:00
|
|
|
void
|
2006-12-17 14:01:45 -08:00
|
|
|
temperature_face_update_config(Config_Face *inst)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2012-08-22 00:32:12 -07:00
|
|
|
char buf[8192];
|
2008-03-09 23:45:05 -07:00
|
|
|
|
|
|
|
if (inst->tempget_exe)
|
|
|
|
{
|
2010-05-20 03:12:41 -07:00
|
|
|
ecore_exe_terminate(inst->tempget_exe);
|
|
|
|
ecore_exe_free(inst->tempget_exe);
|
|
|
|
inst->tempget_exe = NULL;
|
2008-03-09 23:45:05 -07:00
|
|
|
}
|
2010-05-20 03:12:41 -07:00
|
|
|
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-20 03:12:41 -07:00
|
|
|
if (inst->backend == TEMPGET)
|
|
|
|
{
|
|
|
|
if (inst->temp_poller)
|
|
|
|
{
|
|
|
|
ecore_poller_del(inst->temp_poller);
|
|
|
|
inst->temp_poller = NULL;
|
|
|
|
}
|
2010-05-23 15:23:14 -07:00
|
|
|
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,
|
2010-08-21 06:52:25 -07:00
|
|
|
(inst->sensor_name ? inst->sensor_name : "(null)"),
|
2010-05-23 15:23:14 -07:00
|
|
|
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);
|
|
|
|
}
|
2010-05-20 03:12:41 -07:00
|
|
|
}
|
2010-05-23 15:23:14 -07:00
|
|
|
else if (inst->backend == UDEV)
|
2010-05-21 20:05:45 -07:00
|
|
|
{
|
|
|
|
/*avoid creating a new poller if possible*/
|
2010-05-20 03:12:41 -07:00
|
|
|
if (inst->temp_poller)
|
2010-05-21 20:05:45 -07:00
|
|
|
ecore_poller_poller_interval_set(inst->temp_poller,
|
|
|
|
inst->poll_interval);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inst->temp_poller =
|
|
|
|
ecore_poller_add(ECORE_POLLER_CORE, inst->poll_interval,
|
|
|
|
temperature_udev_update_poll, inst);
|
|
|
|
}
|
2010-05-20 03:12:41 -07:00
|
|
|
}
|
2010-05-23 15:23:14 -07:00
|
|
|
#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,
|
2010-08-21 06:52:25 -07:00
|
|
|
(inst->sensor_name ? inst->sensor_name : "(null)"),
|
2010-05-23 15:23:14 -07:00
|
|
|
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);
|
|
|
|
}
|
2010-05-20 03:12:41 -07:00
|
|
|
#endif
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *
|
2008-02-05 16:13:25 -08:00
|
|
|
temperature_get_bus_files(const char* bus)
|
2007-01-28 08:08:12 -08:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *result, *therms;
|
2008-11-11 16:50:51 -08:00
|
|
|
char path[PATH_MAX];
|
|
|
|
char busdir[PATH_MAX];
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
result = NULL;
|
2007-01-28 08:08:12 -08:00
|
|
|
if (result)
|
|
|
|
{
|
2008-02-05 16:13:25 -08:00
|
|
|
snprintf(busdir, sizeof(busdir), "/sys/bus/%s/devices", bus);
|
|
|
|
/* Look through all the devices for the given bus. */
|
|
|
|
therms = ecore_file_ls(busdir);
|
|
|
|
if (therms)
|
|
|
|
{
|
|
|
|
char *name;
|
2008-11-11 16:50:51 -08:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(therms, name)
|
2007-01-28 08:08:12 -08:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *files;
|
|
|
|
char *file;
|
2010-05-21 20:05:45 -07:00
|
|
|
|
2008-02-05 16:13:25 -08:00
|
|
|
/* Search each device for temp*_input, these should be
|
|
|
|
* temperature devices. */
|
2008-11-11 16:50:51 -08:00
|
|
|
snprintf(path, sizeof(path), "%s/%s", busdir, name);
|
2008-02-05 16:13:25 -08:00
|
|
|
files = ecore_file_ls(path);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FREE(files, file)
|
2010-05-21 20:05:45 -07:00
|
|
|
{
|
|
|
|
if ((!strncmp("temp", file, 4)) &&
|
|
|
|
(!strcmp("_input", &file[strlen(file) - 6])))
|
2008-02-05 16:13:25 -08:00
|
|
|
{
|
2010-05-21 20:05:45 -07:00
|
|
|
char *f;
|
|
|
|
|
|
|
|
snprintf(path, sizeof(path),
|
|
|
|
"%s/%s/%s", busdir, name, file);
|
|
|
|
f = strdup(path);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
if (f) result = eina_list_append(result, f);
|
2008-02-05 16:13:25 -08:00
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
free(file);
|
2007-01-28 08:08:12 -08:00
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
free(name);
|
2007-01-28 08:08:12 -08:00
|
|
|
}
|
2008-02-05 16:13:25 -08:00
|
|
|
}
|
2007-01-28 08:08:12 -08:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* module setup */
|
|
|
|
EAPI E_Module_Api e_modapi =
|
|
|
|
{
|
|
|
|
E_MODULE_API_VERSION,
|
|
|
|
"Temperature"
|
|
|
|
};
|
|
|
|
|
2006-06-06 08:33:44 -07:00
|
|
|
EAPI void *
|
2006-04-20 04:30:25 -07:00
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
2006-12-17 14:01:45 -08:00
|
|
|
conf_face_edd = E_CONFIG_DD_NEW("Temperature_Config_Face", Config_Face);
|
2006-04-20 04:30:25 -07:00
|
|
|
#undef T
|
|
|
|
#undef D
|
2006-12-17 14:01:45 -08:00
|
|
|
#define T Config_Face
|
|
|
|
#define D conf_face_edd
|
2007-09-15 17:02:53 -07:00
|
|
|
E_CONFIG_VAL(D, T, id, STR);
|
2008-01-10 23:33:57 -08:00
|
|
|
E_CONFIG_VAL(D, T, poll_interval, INT);
|
2006-04-20 04:30:25 -07:00
|
|
|
E_CONFIG_VAL(D, T, low, INT);
|
|
|
|
E_CONFIG_VAL(D, T, high, INT);
|
2006-12-15 00:32:31 -08:00
|
|
|
E_CONFIG_VAL(D, T, sensor_type, INT);
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-20 03:12:41 -07:00
|
|
|
E_CONFIG_VAL(D, T, backend, INT);
|
|
|
|
#endif
|
2006-04-20 04:30:25 -07:00
|
|
|
E_CONFIG_VAL(D, T, sensor_name, STR);
|
|
|
|
E_CONFIG_VAL(D, T, units, INT);
|
|
|
|
|
2006-12-17 14:01:45 -08:00
|
|
|
conf_edd = E_CONFIG_DD_NEW("Temperature_Config", Config);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Config
|
|
|
|
#define D conf_edd
|
|
|
|
E_CONFIG_HASH(D, T, faces, conf_face_edd);
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
temperature_config = e_config_domain_load("module.temperature", conf_edd);
|
|
|
|
if (!temperature_config)
|
2008-11-11 16:50:51 -08:00
|
|
|
temperature_config = E_NEW(Config, 1);
|
2007-09-16 03:55:16 -07:00
|
|
|
else
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(temperature_config->faces, _temperature_face_id_max, &uuid);
|
2006-05-09 06:02:48 -07:00
|
|
|
temperature_config->module = m;
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_provider_register(&_gadcon_class);
|
2006-07-24 21:15:11 -07:00
|
|
|
return m;
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2010-08-19 08:27:13 -07:00
|
|
|
e_modapi_shutdown(E_Module *m __UNUSED__)
|
2005-12-15 14:37:14 -08:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_provider_unregister(&_gadcon_class);
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(temperature_config->faces, _temperature_face_shutdown, NULL);
|
|
|
|
eina_hash_free(temperature_config->faces);
|
2006-04-20 04:30:25 -07:00
|
|
|
free(temperature_config);
|
|
|
|
temperature_config = NULL;
|
2006-12-17 14:01:45 -08:00
|
|
|
E_CONFIG_DD_FREE(conf_face_edd);
|
2006-04-20 04:30:25 -07:00
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2010-08-19 08:27:13 -07:00
|
|
|
e_modapi_save(E_Module *m __UNUSED__)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
|
|
|
e_config_domain_save("module.temperature", conf_edd, temperature_config);
|
|
|
|
return 1;
|
|
|
|
}
|