2005-01-01 18:39:44 -08:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2016-11-28 07:43:07 -08:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2005-06-22 19:49:32 -07:00
|
|
|
#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
|
|
|
|
2015-03-18 15:09:09 -07:00
|
|
|
static Eina_Bool _temperature_face_shutdown(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *hdata, void *fdata EINA_UNUSED);
|
|
|
|
static Eina_Bool _temperature_face_id_max(const Eina_Hash *hash EINA_UNUSED, const void *key, void *hdata EINA_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
|
|
|
|
2016-12-02 18:28:45 -08:00
|
|
|
static void
|
|
|
|
_temperature_thread_free(Tempthread *tth)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(tth->sensor_name);
|
|
|
|
eina_stringshare_del(tth->sensor_path);
|
2017-09-11 17:10:19 -07:00
|
|
|
e_powersave_sleeper_free(tth->sleeper);
|
2016-12-02 18:28:45 -08:00
|
|
|
free(tth->extn);
|
|
|
|
free(tth);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_temperature_face_level_set(Config_Face *inst, double level)
|
|
|
|
{
|
|
|
|
Edje_Message_Float msg;
|
|
|
|
|
|
|
|
if (level < 0.0) level = 0.0;
|
|
|
|
else if (level > 1.0) level = 1.0;
|
|
|
|
msg.val = level;
|
|
|
|
edje_object_message_send(inst->o_temp, EDJE_MESSAGE_FLOAT, 1, &msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_temperature_apply(Config_Face *inst, int temp)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
|
2016-12-04 05:46:02 -08:00
|
|
|
if (inst->temp == temp) return;
|
|
|
|
inst->temp = temp;
|
2016-12-02 18:28:45 -08:00
|
|
|
if (temp != -999)
|
|
|
|
{
|
|
|
|
if (inst->units == FAHRENHEIT) temp = (temp * 9.0 / 5.0) + 32;
|
|
|
|
|
|
|
|
if (!inst->have_temp)
|
|
|
|
{
|
|
|
|
/* enable therm object */
|
|
|
|
edje_object_signal_emit(inst->o_temp, "e,state,known", "");
|
|
|
|
inst->have_temp = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (inst->units == FAHRENHEIT)
|
|
|
|
snprintf(buf, sizeof(buf), "%i°F", temp);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%i°C", temp);
|
|
|
|
|
|
|
|
_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", buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (inst->have_temp)
|
|
|
|
{
|
|
|
|
/* 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 = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2020-08-20 07:20:22 -07:00
|
|
|
inst->sensor_type = SENSOR_TYPE_LINUX_SYS;
|
2010-05-20 03:12:41 -07:00
|
|
|
inst->sensor_name = NULL;
|
2016-12-04 05:46:02 -08:00
|
|
|
inst->temp = -900;
|
2016-07-05 08:45:00 -07:00
|
|
|
inst->units = CELSIUS;
|
2010-05-20 03:12:41 -07:00
|
|
|
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);
|
2016-07-05 08:45:00 -07:00
|
|
|
E_CONFIG_LIMIT(inst->units, CELSIUS, FAHRENHEIT);
|
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",
|
2016-11-30 00:06:45 -08: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;
|
2014-05-07 03:05:14 -07:00
|
|
|
inst->have_temp = EINA_FALSE;
|
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,
|
2016-11-30 00:06: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
|
|
|
|
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
|
2015-03-18 15:09:09 -07:00
|
|
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient EINA_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 *
|
2015-03-18 15:09:09 -07:00
|
|
|
_gc_label(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
|
2006-05-09 06:02:48 -07:00
|
|
|
{
|
|
|
|
return _("Temperature");
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2015-03-18 15:09:09 -07:00
|
|
|
_gc_icon(const E_Gadcon_Client_Class *client_class EINA_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",
|
2016-11-30 00:06:45 -08:00
|
|
|
e_module_dir_get(temperature_config->module));
|
2006-05-09 06:02:48 -07:00
|
|
|
edje_object_file_set(o, buf, "icon");
|
|
|
|
return o;
|
|
|
|
}
|
2007-09-15 17:02:53 -07:00
|
|
|
|
|
|
|
static const char *
|
2015-03-18 15:09:09 -07:00
|
|
|
_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_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;
|
2020-08-20 07:20:22 -07:00
|
|
|
inst->sensor_type = SENSOR_TYPE_LINUX_SYS;
|
2007-09-15 17:02:53 -07:00
|
|
|
inst->sensor_name = NULL;
|
2016-07-05 08:45:00 -07:00
|
|
|
inst->units = CELSIUS;
|
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
|
2015-03-18 15:09:09 -07:00
|
|
|
_temperature_face_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_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);
|
2015-03-13 14:47:36 -07:00
|
|
|
e_menu_activate_mouse(m, e_zone_current_get(),
|
2012-08-15 00:22:04 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_temperature_face_cb_menu_configure(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_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
|
2015-03-18 15:09:09 -07:00
|
|
|
_temperature_face_shutdown(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *hdata, void *fdata EINA_UNUSED)
|
2006-12-17 14:01:45 -08:00
|
|
|
{
|
|
|
|
Config_Face *inst;
|
|
|
|
|
|
|
|
inst = hdata;
|
2016-11-30 00:06:45 -08:00
|
|
|
if (inst->th) ecore_thread_cancel(inst->th);
|
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-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
|
2020-08-20 07:20:22 -07:00
|
|
|
_temperature_face_id_max(const Eina_Hash *hash EINA_UNUSED, const void *key, void *hdata, 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;
|
2020-08-20 07:20:22 -07:00
|
|
|
Config_Face *cf = hdata;
|
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;
|
2020-08-20 07:20:22 -07:00
|
|
|
#if defined (__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__)
|
|
|
|
cf->sensor_type = SENSOR_TYPE_FREEBSD;
|
|
|
|
#else
|
|
|
|
cf->sensor_type = SENSOR_TYPE_LINUX_SYS;
|
|
|
|
#endif
|
2008-12-17 07:33:43 -08:00
|
|
|
return EINA_TRUE;
|
2007-09-15 17:02:53 -07:00
|
|
|
}
|
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
static void
|
2017-02-13 02:18:50 -08:00
|
|
|
_temperature_check_main(void *data, Ecore_Thread *th)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2016-11-30 00:06:45 -08:00
|
|
|
Tempthread *tth = data;
|
|
|
|
int ptemp = -500, temp;
|
2008-03-09 23:45:05 -07:00
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
for (;;)
|
2008-03-09 23:45:05 -07:00
|
|
|
{
|
2016-11-30 00:06:45 -08:00
|
|
|
if (ecore_thread_check(th)) break;
|
2016-12-02 18:28:45 -08:00
|
|
|
temp = temperature_tempget_get(tth);
|
2016-11-30 00:06:45 -08:00
|
|
|
if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp));
|
|
|
|
ptemp = temp;
|
2017-09-11 17:10:19 -07:00
|
|
|
e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval);
|
2016-11-30 00:06:45 -08:00
|
|
|
if (ecore_thread_check(th)) break;
|
2008-03-09 23:45:05 -07:00
|
|
|
}
|
2016-11-30 00:06:45 -08:00
|
|
|
}
|
2010-05-20 03:12:41 -07:00
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
static void
|
2017-02-13 02:18:50 -08:00
|
|
|
_temperature_check_notify(void *data, Ecore_Thread *th, void *msg)
|
2016-11-30 00:06:45 -08:00
|
|
|
{
|
|
|
|
Tempthread *tth = data;
|
|
|
|
Config_Face *inst = tth->inst;
|
|
|
|
int temp = (int)((long)msg);
|
|
|
|
|
|
|
|
if (th != inst->th) return;
|
2016-12-02 18:28:45 -08:00
|
|
|
_temperature_apply(inst, temp);
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
static void
|
2017-02-13 02:18:50 -08:00
|
|
|
_temperature_check_done(void *data, Ecore_Thread *th EINA_UNUSED)
|
2007-01-28 08:08:12 -08:00
|
|
|
{
|
2016-12-02 18:28:45 -08:00
|
|
|
_temperature_thread_free(data);
|
2016-11-30 00:06:45 -08:00
|
|
|
}
|
2008-11-11 16:50:51 -08:00
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
void
|
|
|
|
temperature_face_update_config(Config_Face *inst)
|
|
|
|
{
|
|
|
|
Tempthread *tth;
|
2014-04-04 11:51:21 -07:00
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
if (inst->th) ecore_thread_cancel(inst->th);
|
2014-04-04 11:51:21 -07:00
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
tth = calloc(1, sizeof(Tempthread));
|
|
|
|
tth->poll_interval = inst->poll_interval;
|
|
|
|
tth->sensor_type = inst->sensor_type;
|
|
|
|
tth->inst = inst;
|
2017-09-11 17:10:19 -07:00
|
|
|
tth->sleeper = e_powersave_sleeper_new();
|
2016-11-30 00:06:45 -08:00
|
|
|
if (inst->sensor_name)
|
|
|
|
tth->sensor_name = eina_stringshare_add(inst->sensor_name);
|
2016-12-02 18:28:45 -08:00
|
|
|
|
2020-08-17 10:19:27 -07:00
|
|
|
inst->th = ecore_thread_feedback_run(_temperature_check_main,
|
|
|
|
_temperature_check_notify,
|
|
|
|
_temperature_check_done,
|
|
|
|
_temperature_check_done,
|
|
|
|
tth, EINA_TRUE);
|
2007-01-28 08:08:12 -08:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* module setup */
|
2020-05-13 12:34:25 -07:00
|
|
|
E_API E_Module_Api e_modapi =
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
|
|
|
E_MODULE_API_VERSION,
|
|
|
|
"Temperature"
|
|
|
|
};
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API 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);
|
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);
|
2013-02-01 01:57:10 -08:00
|
|
|
else if (temperature_config->faces)
|
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
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API int
|
2015-03-18 15:09:09 -07:00
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
2005-12-15 14:37:14 -08:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_provider_unregister(&_gadcon_class);
|
2013-02-01 01:57:10 -08:00
|
|
|
if (temperature_config->faces)
|
|
|
|
eina_hash_foreach(temperature_config->faces, _temperature_face_shutdown, NULL);
|
2008-12-17 07:33:43 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API int
|
2015-03-18 15:09:09 -07:00
|
|
|
e_modapi_save(E_Module *m EINA_UNUSED)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
|
|
|
e_config_domain_save("module.temperature", conf_edd, temperature_config);
|
|
|
|
return 1;
|
|
|
|
}
|