diff --git a/legacy/eeze/src/bin/eeze_udev_test.c b/legacy/eeze/src/bin/eeze_udev_test.c index 41e17a5720..5ba404412d 100644 --- a/legacy/eeze/src/bin/eeze_udev_test.c +++ b/legacy/eeze/src/bin/eeze_udev_test.c @@ -11,32 +11,32 @@ typedef struct kbdmouse static void /* event will always be a syspath starting with /sys */ -catch_events(const char *event, void *data, Eudev_Watch *watch) +catch_events(const char *device, const char *event, void *data, Eudev_Watch *watch) { kbdmouse *akbdmouse = data; Eina_List *l; const char *name, *dev, *type; int new = 0; - /* the event that comes through will be prefixed by "/sys" + /* the device that comes through will be prefixed by "/sys" * but the saved name will not, so we check for the saved name - * inside the event name + * inside the device name */ EINA_LIST_FOREACH(akbdmouse->kbds, l, name) - if (strstr(event, name)) goto end; + if (strstr(device, name)) goto end; EINA_LIST_FOREACH(akbdmouse->mice, l, name) - if (strstr(event, name)) goto end; + if (strstr(device, name)) goto end; /* check to see if the device was just plugged in */ - if (e_udev_syspath_is_kbd(event) || e_udev_syspath_is_mouse(event)) + if (e_udev_syspath_is_kbd(device) || e_udev_syspath_is_mouse(device)) { new = 1; goto end; } - /* if we reach here, the event is neither a keyboard nor a mouse that we saw + /* if we reach here, the device is neither a keyboard nor a mouse that we saw * previously, so we print a moderately amusing message and bail */ - printf("Sneaky sneaky! But %s is not a keyboard or a mouse!!\n", event); + printf("Sneaky sneaky! But %s is not a keyboard or a mouse!!\n", device); return; end: @@ -46,7 +46,7 @@ end: */ if (new) { - dev = e_udev_syspath_get_devpath(event); + dev = e_udev_syspath_get_devpath(device); type = "plugged in"; } else diff --git a/legacy/eeze/src/lib/udev/E_Udev.h b/legacy/eeze/src/lib/udev/E_Udev.h index 0c3ea23efd..cbf78c13e9 100644 --- a/legacy/eeze/src/lib/udev/E_Udev.h +++ b/legacy/eeze/src/lib/udev/E_Udev.h @@ -127,7 +127,7 @@ extern "C" { EAPI Eina_Bool e_udev_syspath_is_kbd(const char *syspath); EAPI Eina_Bool e_udev_syspath_is_touchpad(const char *syspath); - EAPI Eudev_Watch *e_udev_watch_add(Eudev_Type type, void(*func)(const char *, void *, Eudev_Watch *), void *user_data); + EAPI Eudev_Watch *e_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, void *, Eudev_Watch *), void *user_data); EAPI void *e_udev_watch_del(Eudev_Watch *watch); #ifdef __cplusplus diff --git a/legacy/eeze/src/lib/udev/e_udev_watch.c b/legacy/eeze/src/lib/udev/e_udev_watch.c index c0069b4781..d2a64dd29a 100644 --- a/legacy/eeze/src/lib/udev/e_udev_watch.c +++ b/legacy/eeze/src/lib/udev/e_udev_watch.c @@ -12,7 +12,7 @@ struct Eudev_Watch /* private */ struct _store_data { - void(*func)(const char *, void *, Eudev_Watch *); + void(*func)(const char *, const char *, void *, Eudev_Watch *); void *data; struct udev_monitor *mon; Eudev_Type type; @@ -28,7 +28,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler) struct _store_data *store = data; struct udev_device *device; const char *ret, *test; - void(*func)(const char *, void *, Eudev_Watch *) = store->func; + void(*func)(const char *, const char *, void *, Eudev_Watch *) = store->func; void *sdata = store->data; Eudev_Watch *watch = store->watch; int cap = 0; @@ -89,13 +89,25 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler) default: break; } - + test = eina_stringshare_add(udev_device_get_action(device)); + if (!test) + { + udev_device_unref(device); + return 0; + } ret = eina_stringshare_add(udev_device_get_syspath(device)); - if (!ret) return 0; + if (!ret) + { + udev_device_unref(device); + eina_stringshare_del(test); + return 0; + } udev_device_unref(device); - (*func)(ret, sdata, watch); + (*func)(ret, test, sdata, watch); + eina_stringshare_del(test); + eina_stringshare_del(ret); return 1; @@ -108,7 +120,8 @@ error: * * @param subsystem The subsystem type. See @ref Subsystem_Types * @param device_type The device type. See @ref Device_Types - * @param func The function to call when the watch receives data + * @param func The function to call when the watch receives data; + * must take (const char *device, const char *event_type, void *data, Eudev_Watch *watch) * @param user_data Data to pass to the callback function * * @return A watch struct for the watch type specified, or NULL on failure @@ -116,7 +129,7 @@ error: * @ingroup udev */ EAPI Eudev_Watch * -e_udev_watch_add(Eudev_Type type, void(*func)(const char *, void *, Eudev_Watch *), void *user_data) +e_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, void *, Eudev_Watch *), void *user_data) { struct udev *udev; struct udev_monitor *mon;