more eudev->eeze_udev cleanup, add even more legacy udev code (hurgh)
SVN revision: 48854
This commit is contained in:
parent
0cccb61516
commit
77fa364241
|
@ -11,7 +11,7 @@ typedef struct kbdmouse
|
|||
|
||||
static void
|
||||
/* event will always be a syspath starting with /sys */
|
||||
catch_events(const char *device, const char *event, void *data, Eudev_Watch *watch)
|
||||
catch_events(const char *device, const char *event, void *data, Eeze_Udev_Watch *watch)
|
||||
{
|
||||
kbdmouse *akbdmouse = data;
|
||||
Eina_List *l;
|
||||
|
@ -92,8 +92,8 @@ int main()
|
|||
akbdmouse->hash = hash;
|
||||
|
||||
printf("For my first trick, I will find all of your keyboards and return their syspaths.\n");
|
||||
/* find all keyboards using type EUDEV_TYPE_KEYBOARD */
|
||||
type = eeze_udev_find_by_type(EUDEV_TYPE_KEYBOARD, NULL);
|
||||
/* find all keyboards using type EEZE_UDEV_TYPE_KEYBOARD */
|
||||
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
|
||||
EINA_LIST_FOREACH(type, l, name)
|
||||
{ /* add the devpath to the hash for use in the cb later */
|
||||
eina_hash_direct_add(hash, name, eeze_udev_syspath_get_devpath(name));
|
||||
|
@ -106,8 +106,8 @@ int main()
|
|||
akbdmouse->kbds = type;
|
||||
|
||||
printf("\nNext, I will find all of your mice and print the corresponding manufacturer.\n");
|
||||
/* find all mice using type EUDEV_TYPE_MOUSE */
|
||||
type = eeze_udev_find_by_type(EUDEV_TYPE_MOUSE, NULL);
|
||||
/* find all mice using type EEZE_UDEV_TYPE_MOUSE */
|
||||
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
|
||||
EINA_LIST_FOREACH(type, l, name)
|
||||
{ /* add the devpath to the hash for use in the cb later */
|
||||
eina_hash_direct_add(hash, name, eeze_udev_syspath_get_devpath(name)); /* get a property using the device's syspath */
|
||||
|
@ -120,8 +120,8 @@ int main()
|
|||
akbdmouse->mice = type;
|
||||
|
||||
printf("\nNow let's try something a little more difficult. Mountable filesystems!\n");
|
||||
/* find all mountable drives using type EUDEV_TYPE_DRIVE_MOUNTABLE */
|
||||
type = eeze_udev_find_by_type(EUDEV_TYPE_DRIVE_MOUNTABLE, NULL);
|
||||
/* find all mountable drives using type EEZE_UDEV_TYPE_DRIVE_MOUNTABLE */
|
||||
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
|
||||
EINA_LIST_FOREACH(type, l, name)
|
||||
{
|
||||
printf("Found device: %s\n", name); /* get a property using the device's syspath */
|
||||
|
@ -135,26 +135,26 @@ int main()
|
|||
eina_list_free(type);
|
||||
|
||||
printf("\nInternal drives, anyone? With serial numbers?\n");
|
||||
/* find all internal drives using type EUDEV_TYPE_DRIVE_INTERNAL */
|
||||
type = eeze_udev_find_by_type(EUDEV_TYPE_DRIVE_INTERNAL, NULL);
|
||||
/* find all internal drives using type EEZE_UDEV_TYPE_DRIVE_INTERNAL */
|
||||
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
|
||||
EINA_LIST_FOREACH(type, l, name) /* get a property using the device's syspath */
|
||||
printf("%s: %s\n", name, eeze_udev_syspath_get_property(name, "ID_SERIAL"));
|
||||
eina_list_free(type);
|
||||
|
||||
printf("\nGot any removables? I'm gonna find em!\n");
|
||||
/* find all removable media using type EUDEV_TYPE_DRIVE_REMOVABLE */
|
||||
type = eeze_udev_find_by_type(EUDEV_TYPE_DRIVE_REMOVABLE, NULL);
|
||||
/* find all removable media using type EEZE_UDEV_TYPE_DRIVE_REMOVABLE */
|
||||
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
|
||||
EINA_LIST_FOREACH(type, l, name) /* get a property using the device's syspath */
|
||||
printf("\tOoh, a %s attached on your %s bus!\n", eeze_udev_syspath_get_property(name, "ID_MODEL"),
|
||||
eeze_udev_syspath_get_property(name, "ID_BUS"));
|
||||
eina_list_free(type);
|
||||
|
||||
|
||||
/* set a udev watch, grab all events because no EUDEV_TYPE filter is specified,
|
||||
/* set a udev watch, grab all events because no EEZE_UDEV_TYPE filter is specified,
|
||||
* set the events to be sent to callback function catch_events(), and attach
|
||||
* kbdmouse to the watch as associated data
|
||||
*/
|
||||
eeze_udev_watch_add(EUDEV_TYPE_NONE, catch_events, akbdmouse);
|
||||
eeze_udev_watch_add(EEZE_UDEV_TYPE_NONE, catch_events, akbdmouse);
|
||||
printf("\nAnd now for something more complicated. Plug or unplug your keyboard or mouse for me.\n");
|
||||
|
||||
/* main loop must be started to use ecore fd polling */
|
||||
|
|
|
@ -9,16 +9,15 @@
|
|||
#ifdef EAPI
|
||||
#undef EAPI
|
||||
#endif
|
||||
#ifndef _MSC_VER
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#else
|
||||
# define EAPI
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -89,21 +88,21 @@
|
|||
/*FIXME: these probably need to be bitmasks with categories*/
|
||||
typedef enum
|
||||
{
|
||||
EUDEV_TYPE_NONE,
|
||||
EUDEV_TYPE_KEYBOARD,
|
||||
EUDEV_TYPE_MOUSE,
|
||||
EUDEV_TYPE_TOUCHPAD,
|
||||
EUDEV_TYPE_DRIVE_MOUNTABLE,
|
||||
EUDEV_TYPE_DRIVE_INTERNAL,
|
||||
EUDEV_TYPE_DRIVE_REMOVABLE,
|
||||
EUDEV_TYPE_DRIVE_CDROM,
|
||||
EUDEV_TYPE_POWER_AC,
|
||||
EUDEV_TYPE_POWER_BAT
|
||||
/* EUDEV_TYPE_ANDROID */
|
||||
} Eudev_Type;
|
||||
EEZE_UDEV_TYPE_NONE,
|
||||
EEZE_UDEV_TYPE_KEYBOARD,
|
||||
EEZE_UDEV_TYPE_MOUSE,
|
||||
EEZE_UDEV_TYPE_TOUCHPAD,
|
||||
EEZE_UDEV_TYPE_DRIVE_MOUNTABLE,
|
||||
EEZE_UDEV_TYPE_DRIVE_INTERNAL,
|
||||
EEZE_UDEV_TYPE_DRIVE_REMOVABLE,
|
||||
EEZE_UDEV_TYPE_DRIVE_CDROM,
|
||||
EEZE_UDEV_TYPE_POWER_AC,
|
||||
EEZE_UDEV_TYPE_POWER_BAT
|
||||
/* EEZE_UDEV_TYPE_ANDROID */
|
||||
} Eeze_Udev_Type;
|
||||
|
||||
struct Eudev_Watch;
|
||||
typedef struct Eudev_Watch Eudev_Watch;
|
||||
struct Eeze_Udev_Watch;
|
||||
typedef struct Eeze_Udev_Watch Eeze_Udev_Watch;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -112,7 +111,7 @@ extern "C" {
|
|||
EAPI int eeze_udev_init(void);
|
||||
EAPI int eeze_udev_shutdown(void);
|
||||
|
||||
EAPI Eina_List *eeze_udev_find_by_type(const Eudev_Type type, const char *name);
|
||||
EAPI Eina_List *eeze_udev_find_by_type(const Eeze_Udev_Type type, const char *name);
|
||||
EAPI Eina_List *eeze_udev_find_by_filter(const char *subsystem, const char *type, const char *name);
|
||||
|
||||
EAPI const char *eeze_udev_syspath_rootdev_get(const char *syspath);
|
||||
|
@ -127,8 +126,8 @@ extern "C" {
|
|||
EAPI Eina_Bool eeze_udev_syspath_is_kbd(const char *syspath);
|
||||
EAPI Eina_Bool eeze_udev_syspath_is_touchpad(const char *syspath);
|
||||
|
||||
EAPI Eudev_Watch *eeze_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, void *, Eudev_Watch *), void *user_data);
|
||||
EAPI void *eeze_udev_watch_del(Eudev_Watch *watch);
|
||||
EAPI Eeze_Udev_Watch *eeze_udev_watch_add(Eeze_Udev_Type type, void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *), void *user_data);
|
||||
EAPI void *eeze_udev_watch_del(Eeze_Udev_Watch *watch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ eeze_udev_syspath_rootdev_get(const char *syspath)
|
|||
}
|
||||
|
||||
/**
|
||||
* Find devices using a EUDEV_TYPE_* and/or a name.
|
||||
* Find devices using a EEZE_UDEV_TYPE_* and/or a name.
|
||||
*
|
||||
* @param type A Eudev_Type or 0
|
||||
* @param type A Eeze_Udev_Type or 0
|
||||
* @param name A filter for the device name or NULL
|
||||
* @return A Eina_List* of matched devices or NULL on failure
|
||||
*
|
||||
|
@ -51,7 +51,7 @@ eeze_udev_syspath_rootdev_get(const char *syspath)
|
|||
* @ingroup udev
|
||||
*/
|
||||
EAPI Eina_List *
|
||||
eeze_udev_find_by_type(const Eudev_Type etype, const char *name)
|
||||
eeze_udev_find_by_type(const Eeze_Udev_Type etype, const char *name)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_enumerate *en;
|
||||
|
@ -69,50 +69,50 @@ eeze_udev_find_by_type(const Eudev_Type etype, const char *name)
|
|||
|
||||
switch (etype)
|
||||
{
|
||||
case EUDEV_TYPE_NONE:
|
||||
case EEZE_UDEV_TYPE_NONE:
|
||||
break;
|
||||
case EUDEV_TYPE_KEYBOARD:
|
||||
case EEZE_UDEV_TYPE_KEYBOARD:
|
||||
udev_enumerate_add_match_subsystem(en, "input");
|
||||
udev_enumerate_add_match_property(en, "ID_INPUT_KEYBOARD", "1");
|
||||
break;
|
||||
case EUDEV_TYPE_MOUSE:
|
||||
case EEZE_UDEV_TYPE_MOUSE:
|
||||
udev_enumerate_add_match_subsystem(en, "input");
|
||||
udev_enumerate_add_match_property(en, "ID_INPUT_MOUSE", "1");
|
||||
break;
|
||||
case EUDEV_TYPE_TOUCHPAD:
|
||||
case EEZE_UDEV_TYPE_TOUCHPAD:
|
||||
udev_enumerate_add_match_subsystem(en, "input");
|
||||
udev_enumerate_add_match_property(en, "ID_INPUT_TOUCHPAD", "1");
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_MOUNTABLE:
|
||||
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||
udev_enumerate_add_match_subsystem(en, "block");
|
||||
udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
|
||||
udev_enumerate_add_nomatch_sysattr(en, "capability", "52");
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_INTERNAL:
|
||||
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||
udev_enumerate_add_match_subsystem(en, "block");
|
||||
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
||||
udev_enumerate_add_match_property(en, "ID_BUS", "ata");
|
||||
udev_enumerate_add_match_sysattr(en, "removable", "0");
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_REMOVABLE:
|
||||
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
||||
udev_enumerate_add_match_subsystem(en, "block");
|
||||
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
||||
udev_enumerate_add_match_sysattr(en, "removable", "1");
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_CDROM:
|
||||
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
||||
udev_enumerate_add_match_subsystem(en, "block");
|
||||
udev_enumerate_add_match_property(en, "ID_CDROM", "1");
|
||||
break;
|
||||
case EUDEV_TYPE_POWER_AC:
|
||||
case EEZE_UDEV_TYPE_POWER_AC:
|
||||
udev_enumerate_add_match_subsystem(en, "power_supply");
|
||||
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Mains");
|
||||
break;
|
||||
case EUDEV_TYPE_POWER_BAT:
|
||||
case EEZE_UDEV_TYPE_POWER_BAT:
|
||||
udev_enumerate_add_match_subsystem(en, "power_supply");
|
||||
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Battery");
|
||||
break;
|
||||
/*
|
||||
case EUDEV_TYPE_ANDROID:
|
||||
case EEZE_UDEV_TYPE_ANDROID:
|
||||
udev_enumerate_add_match_subsystem(en, "block");
|
||||
udev_enumerate_add_match_property(en, "ID_MODEL", "Android_*");
|
||||
break;
|
||||
|
|
|
@ -2,24 +2,48 @@
|
|||
#include <Eeze_Udev.h>
|
||||
|
||||
/* opaque */
|
||||
struct Eudev_Watch
|
||||
struct Eeze_Udev_Watch
|
||||
{
|
||||
struct udev_monitor *mon;
|
||||
Ecore_Fd_Handler *handler;
|
||||
Eudev_Type type;
|
||||
Eeze_Udev_Type type;
|
||||
};
|
||||
|
||||
/* private */
|
||||
struct _store_data
|
||||
{
|
||||
void(*func)(const char *, const char *, void *, Eudev_Watch *);
|
||||
void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *);
|
||||
void *data;
|
||||
struct udev_monitor *mon;
|
||||
Eudev_Type type;
|
||||
Eudev_Watch *watch;
|
||||
Eeze_Udev_Type type;
|
||||
Eeze_Udev_Watch *watch;
|
||||
};
|
||||
|
||||
/* private function to further filter watch results based on Eudev_Type
|
||||
|
||||
/* private function to simulate udevadm info -a
|
||||
* walks up the device tree checking each node for sysattr
|
||||
* with value value
|
||||
*/
|
||||
static Eina_Bool
|
||||
_walk_parents_for_attr(struct udev_device *device, const char *sysattr, const char* value)
|
||||
{
|
||||
struct udev_device *parent, *child = device;
|
||||
const char *test;
|
||||
|
||||
while ((parent = udev_device_get_parent(child)))
|
||||
{
|
||||
if (!(test = udev_device_get_sysattr_value(parent, sysattr)))
|
||||
continue;
|
||||
if (!value)
|
||||
return 1;
|
||||
else if (!strcmp(test, value))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* private function to further filter watch results based on Eeze_Udev_Type
|
||||
* specified
|
||||
*/
|
||||
static int
|
||||
|
@ -28,9 +52,9 @@ _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 *, const char *, void *, Eudev_Watch *) = store->func;
|
||||
void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *) = store->func;
|
||||
void *sdata = store->data;
|
||||
Eudev_Watch *watch = store->watch;
|
||||
Eeze_Udev_Watch *watch = store->watch;
|
||||
int cap = 0;
|
||||
|
||||
if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
||||
|
@ -40,31 +64,40 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
|
||||
switch (store->type)
|
||||
{
|
||||
case EUDEV_TYPE_KEYBOARD:
|
||||
case EEZE_UDEV_TYPE_KEYBOARD:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
||||
goto error;
|
||||
if (_walk_parents_for_attr(device, "bInterfaceProtocol", "01"))
|
||||
break;
|
||||
goto error;
|
||||
#endif
|
||||
if (!udev_device_get_property_value(device, "ID_INPUT_KEYBOARD"))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_MOUSE:
|
||||
case EEZE_UDEV_TYPE_MOUSE:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
||||
goto error;
|
||||
if (_walk_parents_for_attr(device, "bInterfaceProtocol", "02"))
|
||||
break;
|
||||
goto error;
|
||||
#endif
|
||||
if (!udev_device_get_property_value(device, "ID_INPUT_MOUSE"))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_TOUCHPAD:
|
||||
case EEZE_UDEV_TYPE_TOUCHPAD:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
||||
goto error;
|
||||
if (_walk_parents_for_attr(device, "resolution", NULL))
|
||||
break;
|
||||
goto error;
|
||||
#endif
|
||||
if (!udev_device_get_property_value(device, "ID_INPUT_TOUCHPAD"))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_MOUNTABLE:
|
||||
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||
goto error;
|
||||
|
@ -75,7 +108,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
(strcmp("filesystem", test)) || (cap == 52))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_INTERNAL:
|
||||
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||
goto error;
|
||||
|
@ -84,7 +117,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
!(test = udev_device_get_sysattr_value(device, "removable")) || (atoi(test)))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_REMOVABLE:
|
||||
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||
goto error;
|
||||
|
@ -93,7 +126,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
(!(test = udev_device_get_sysattr_value(device, "capability")) || (atoi(test) != 10)))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_CDROM:
|
||||
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||
goto error;
|
||||
|
@ -101,7 +134,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
if (!udev_device_get_property_value(device, "ID_CDROM"))
|
||||
goto error;
|
||||
break;
|
||||
case EUDEV_TYPE_POWER_AC:
|
||||
case EEZE_UDEV_TYPE_POWER_AC:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "power_supply")))
|
||||
goto error;
|
||||
|
@ -109,7 +142,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
if (!(test = (udev_device_get_property_value(device, "POWER_SUPPLY_TYPE"))) ||
|
||||
(strcmp("Mains", test)))
|
||||
break;
|
||||
case EUDEV_TYPE_POWER_BAT:
|
||||
case EEZE_UDEV_TYPE_POWER_BAT:
|
||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "power_supply")))
|
||||
goto error;
|
||||
|
@ -118,7 +151,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
|||
(strcmp("Battery", test)))
|
||||
break;
|
||||
/*
|
||||
case EUDEV_TYPE_ANDROID:
|
||||
case EEZE_UDEV_TYPE_ANDROID:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
|
||||
break;
|
||||
*/
|
||||
|
@ -157,25 +190,25 @@ 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;
|
||||
* must take (const char *device, const char *event_type, void *data, Eudev_Watch *watch)
|
||||
* must take (const char *device, const char *event_type, void *data, Eeze_Udev_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
|
||||
*
|
||||
* @ingroup udev
|
||||
*/
|
||||
EAPI Eudev_Watch *
|
||||
eeze_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, void *, Eudev_Watch *), void *user_data)
|
||||
EAPI Eeze_Udev_Watch *
|
||||
eeze_udev_watch_add(Eeze_Udev_Type type, void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *), void *user_data)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_monitor *mon;
|
||||
int fd;
|
||||
Ecore_Fd_Handler *handler;
|
||||
Eudev_Watch *watch;
|
||||
Eeze_Udev_Watch *watch;
|
||||
struct _store_data *store;
|
||||
|
||||
if (!(store = malloc(sizeof(struct _store_data)))) return NULL;
|
||||
if (!(watch = malloc(sizeof(Eudev_Watch))))
|
||||
if (!(watch = malloc(sizeof(Eeze_Udev_Watch))))
|
||||
goto error;
|
||||
|
||||
if (!(udev = udev_new()))
|
||||
|
@ -185,35 +218,35 @@ eeze_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, voi
|
|||
#ifndef OLD_UDEV_RRRRRRRRRRRRRR
|
||||
switch (type)
|
||||
{
|
||||
case EUDEV_TYPE_KEYBOARD:
|
||||
case EEZE_UDEV_TYPE_KEYBOARD:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_MOUSE:
|
||||
case EEZE_UDEV_TYPE_MOUSE:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_TOUCHPAD:
|
||||
case EEZE_UDEV_TYPE_TOUCHPAD:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_MOUNTABLE:
|
||||
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_INTERNAL:
|
||||
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_REMOVABLE:
|
||||
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_DRIVE_CDROM:
|
||||
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_POWER_AC:
|
||||
case EEZE_UDEV_TYPE_POWER_AC:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
||||
break;
|
||||
case EUDEV_TYPE_POWER_BAT:
|
||||
case EEZE_UDEV_TYPE_POWER_BAT:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
||||
break;
|
||||
/*
|
||||
case EUDEV_TYPE_ANDROID:
|
||||
case EEZE_UDEV_TYPE_ANDROID:
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
|
||||
break;
|
||||
*/
|
||||
|
@ -248,7 +281,7 @@ error:
|
|||
/**
|
||||
* Deletes a watch.
|
||||
*
|
||||
* @param watch An Eudev_Watch object
|
||||
* @param watch An Eeze_Udev_Watch object
|
||||
* @return The data originally associated with the watch, or NULL
|
||||
*
|
||||
* Deletes a watch, closing file descriptors and freeing related udev memory.
|
||||
|
@ -256,7 +289,7 @@ error:
|
|||
* @ingroup udev
|
||||
*/
|
||||
EAPI void *
|
||||
eeze_udev_watch_del(Eudev_Watch *watch)
|
||||
eeze_udev_watch_del(Eeze_Udev_Watch *watch)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_monitor *mon = watch->mon;
|
||||
|
|
Loading…
Reference in New Issue