} poll;
int unit_method;
-
+#ifdef HAVE_EEZE_UDEV
+ int backend;
+#endif
struct
{
int low, high;
/* local function prototypes */
static void *_create_data(E_Config_Dialog *cfd);
-static void _fill_data(E_Config_Dialog_Data *cfdata);
+static void _fill_data_tempget(E_Config_Dialog_Data *cfdata);
static void _fill_sensors(E_Config_Dialog_Data *cfdata, const char *name);
static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
cfdata = E_NEW(E_Config_Dialog_Data, 1);
cfdata->inst = cfd->data;
- _fill_data(cfdata);
+ _fill_data_tempget(cfdata);
return cfdata;
}
static void
-_fill_data(E_Config_Dialog_Data *cfdata)
+_fill_data_tempget(E_Config_Dialog_Data *cfdata)
{
cfdata->unit_method = cfdata->inst->units;
cfdata->poll.interval = cfdata->inst->poll_interval;
cfdata->temp.low = cfdata->inst->low;
cfdata->temp.high = cfdata->inst->high;
cfdata->sensor = 0;
- switch (cfdata->inst->sensor_type)
+#ifdef HAVE_EEZE_UDEV
+ cfdata->backend = cfdata->inst->backend;
+ if (cfdata->backend == TEMPGET)
{
- case SENSOR_TYPE_NONE:
- case SENSOR_TYPE_FREEBSD:
- case SENSOR_TYPE_OMNIBOOK:
- case SENSOR_TYPE_LINUX_MACMINI:
- case SENSOR_TYPE_LINUX_PBOOK:
- case SENSOR_TYPE_LINUX_INTELCORETEMP:
- break;
- case SENSOR_TYPE_LINUX_I2C:
- _fill_sensors(cfdata, "i2c");
- break;
- case SENSOR_TYPE_LINUX_PCI:
- _fill_sensors(cfdata, "pci");
- break;
- case SENSOR_TYPE_LINUX_ACPI:
+#endif
+ switch (cfdata->inst->sensor_type)
{
- Eina_List *l;
-
- if ((l = ecore_file_ls("/proc/acpi/thermal_zone")))
+ case SENSOR_TYPE_NONE:
+ case SENSOR_TYPE_FREEBSD:
+ case SENSOR_TYPE_OMNIBOOK:
+ case SENSOR_TYPE_LINUX_MACMINI:
+ case SENSOR_TYPE_LINUX_PBOOK:
+ case SENSOR_TYPE_LINUX_INTELCORETEMP:
+ break;
+ case SENSOR_TYPE_LINUX_I2C:
+ _fill_sensors(cfdata, "i2c");
+ break;
+ case SENSOR_TYPE_LINUX_PCI:
+ _fill_sensors(cfdata, "pci");
+ break;
+ case SENSOR_TYPE_LINUX_ACPI:
{
- char *name;
- int n = 0;
+ Eina_List *l;
- EINA_LIST_FREE(l, name)
+ if ((l = ecore_file_ls("/proc/acpi/thermal_zone")))
{
- cfdata->sensors =
- eina_list_append(cfdata->sensors, name);
- if (!strcmp(cfdata->inst->sensor_name, name))
- cfdata->sensor = n;
- n++;
+ char *name;
+ int n = 0;
+
+ EINA_LIST_FREE(l, name)
+ {
+ cfdata->sensors =
+ eina_list_append(cfdata->sensors, name);
+ if (!strcmp(cfdata->inst->sensor_name, name))
+ cfdata->sensor = n;
+ n++;
+ }
}
+ break;
}
+ default:
break;
}
- default:
- break;
- }
+#ifdef HAVE_EEZE_UDEV
+ }
+#endif
}
static void
e_widget_toolbook_page_append(otb, NULL, _("Temperatures"), ol,
1, 0, 1, 0, 0.5, 0.0);
-
+#ifdef HAVE_EEZE_UDEV
+ ol = e_widget_list_add(evas, 0, 0);
+ rg = e_widget_radio_group_new(&(cfdata->backend));
+ ow = e_widget_radio_add(evas, _("Internal"), TEMPGET, rg);
+ e_widget_list_object_append(ol, ow, 1, 1, 0.5);
+ ow = e_widget_radio_add(evas, _("udev"), UDEV, rg);
+ e_widget_list_object_append(ol, ow, 1, 1, 0.5);
+ e_widget_toolbook_page_append(otb, NULL, _("Hardware"), ol,
+ 0, 0, 0, 0, 0.5, 0.0);
+#endif
e_widget_toolbook_page_show(otb, 0);
return otb;
}
cfdata->inst->units = cfdata->unit_method;
cfdata->inst->low = cfdata->temp.low;
cfdata->inst->high = cfdata->temp.high;
+#ifdef HAVE_EEZE_UDEV
+ cfdata->inst->backend = cfdata->backend;
+#endif
eina_stringshare_replace(&cfdata->inst->sensor_name,
eina_list_nth(cfdata->sensors, cfdata->sensor));
};
/* 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_face_level_set(Config_Face *inst, double level);
+
static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
static Eina_Bool _temperature_face_shutdown(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *hdata, void *fdata __UNUSED__);
inst = eina_hash_find(temperature_config->faces, id);
if (!inst)
{
- 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;
- if (!temperature_config->faces)
- temperature_config->faces = eina_hash_string_superfast_new(NULL);
- eina_hash_direct_add(temperature_config->faces, inst->id, inst);
+ 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;
+#ifdef HAVE_EEZE_UDEV
+ inst->backend = TEMPGET;
+#endif
+ if (!temperature_config->faces)
+ temperature_config->faces = eina_hash_string_superfast_new(NULL);
+ eina_hash_direct_add(temperature_config->faces, inst->id, inst);
}
if (!inst->id) inst->id = eina_stringshare_add(id);
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);
+#ifdef HAVE_EEZE_UDEV
+ E_CONFIG_LIMIT(inst->backend, TEMPGET, UDEV);
+#endif
o = edje_object_add(gc->evas);
e_theme_edje_object_set(o, "base/theme/modules/temperature",
inst->o_temp = o;
inst->module = temperature_config->module;
inst->have_temp = -1;
-
- 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);
-
+#ifdef HAVE_EEZE_UDEV
+ if (inst->backend == TEMPGET)
+ {
+#endif
+ 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);
+#ifdef HAVE_EEZE_UDEV
+ }
+ else
+ {
+ inst->temp_poller = ecore_poller_add(ECORE_POLLER_CORE, inst->poll_interval, temperature_udev_update_poll, inst);
+ temperature_udev_update(inst);
+ }
+#endif
temperature_face_update_config(inst);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
Config_Face *inst;
inst = gcc->data;
+
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)
{
- ecore_event_handler_del(inst->tempget_data_handler);
- inst->tempget_data_handler = NULL;
+ 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;
+ ecore_event_handler_del(inst->tempget_del_handler);
+ inst->tempget_del_handler = NULL;
}
+#ifdef HAVE_EEEZ_UDEV
+ if (inst->temp_poller)
+ ecore_poller_del(inst->temp_poller);
+#endif
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->sensor_type = SENSOR_TYPE_NONE;
inst->sensor_name = NULL;
inst->units = CELCIUS;
+#ifdef HAVE_EEZE_UDEV
+ inst->backend = TEMPGET;
+#endif
if (!temperature_config->faces)
temperature_config->faces = eina_hash_string_superfast_new(NULL);
eina_hash_direct_add(temperature_config->faces, inst->id, inst);
return inst->id;
}
-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 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);
- _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 != 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)
ev = event_info;
if ((ev->button == 3) && (!inst->menu))
{
- E_Menu *mn;
- E_Menu_Item *mi;
- int cx, cy;
-
- mn = e_menu_new();
- e_menu_post_deactivate_callback_set(mn, _temperature_face_cb_post_menu, inst);
- inst->menu = mn;
-
- mi = e_menu_item_new(mn);
- 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);
-
- e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
-
- e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
- &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_Menu *mn;
+ E_Menu_Item *mi;
+ int cx, cy;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _temperature_face_cb_post_menu, inst);
+ inst->menu = mn;
+
+ mi = e_menu_item_new(mn);
+ 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);
+
+ e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
+
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &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);
}
}
inst->menu = NULL;
}
-static void
+void
_temperature_face_level_set(Config_Face *inst, double level)
{
Edje_Message_Float msg;
inst = hdata;
if (inst->sensor_name) eina_stringshare_del(inst->sensor_name);
if (inst->id) eina_stringshare_del(inst->id);
+#ifdef HAVE_EEZE_UDEV
+ if (inst->tempdevs)
+ {
+ const char *s;
+ EINA_LIST_FREE(inst->tempdevs, s)
+ eina_stringshare_del(s);
+ }
+#endif
free(inst);
return EINA_TRUE;
}
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;
}
- 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_UDEV
+ if (inst->backend == TEMPGET)
+ {
+ if (inst->temp_poller)
+ {
+ 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_UDEV
+ }
+ else
+ {/*avoid creating a new poller if possible*/
+ if (inst->temp_poller)
+ 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);
+ }
+#endif
}
Eina_List *
E_CONFIG_VAL(D, T, low, INT);
E_CONFIG_VAL(D, T, high, INT);
E_CONFIG_VAL(D, T, sensor_type, INT);
+#ifdef HAVE_EEZE_UDEV
+ E_CONFIG_VAL(D, T, backend, INT);
+#endif
E_CONFIG_VAL(D, T, sensor_name, STR);
E_CONFIG_VAL(D, T, units, INT);