summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-01-05 18:46:32 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-01-05 18:46:32 +0000
commit1707697d8aebde35559eb691549b90b1c118a692 (patch)
tree8fef3d7dc9c18d4f09edfe8222a4a514fd307e77 /legacy
parent961244f70ae819ff2b94236f0bcf10501172f92d (diff)
ecrustified for formatting
SVN revision: 55898
Diffstat (limited to 'legacy')
-rw-r--r--legacy/eeze/src/bin/eeze_udev_test.c61
-rw-r--r--legacy/eeze/src/lib/eeze_main.c16
-rw-r--r--legacy/eeze/src/lib/eeze_udev_find.c238
-rw-r--r--legacy/eeze/src/lib/eeze_udev_private.c24
-rw-r--r--legacy/eeze/src/lib/eeze_udev_syspath.c12
-rw-r--r--legacy/eeze/src/lib/eeze_udev_walk.c14
-rw-r--r--legacy/eeze/src/lib/eeze_udev_watch.c436
7 files changed, 426 insertions, 375 deletions
diff --git a/legacy/eeze/src/bin/eeze_udev_test.c b/legacy/eeze/src/bin/eeze_udev_test.c
index 05701c0197..36f7675587 100644
--- a/legacy/eeze/src/bin/eeze_udev_test.c
+++ b/legacy/eeze/src/bin/eeze_udev_test.c
@@ -2,7 +2,6 @@
2#include <Ecore.h> 2#include <Ecore.h>
3#include <stdio.h> 3#include <stdio.h>
4 4
5
6/** 5/**
7 * This demo program shows how to use some eeze_udev functions. It roughly 6 * This demo program shows how to use some eeze_udev functions. It roughly
8 * 1kb as of now, TODO is to fix this but I'm too lazy now and it's only 7 * 1kb as of now, TODO is to fix this but I'm too lazy now and it's only
@@ -18,7 +17,10 @@ typedef struct kbdmouse
18 17
19static void 18static void
20/* event will always be a syspath starting with /sys */ 19/* event will always be a syspath starting with /sys */
21catch_events(const char *device, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch) 20catch_events(const char *device,
21 Eeze_Udev_Event event,
22 void *data,
23 Eeze_Udev_Watch *watch)
22{ 24{
23 kbdmouse *akbdmouse = data; 25 kbdmouse *akbdmouse = data;
24 Eina_List *l; 26 Eina_List *l;
@@ -80,7 +82,8 @@ hash_free(void *data)
80 eina_stringshare_del(data); 82 eina_stringshare_del(data);
81} 83}
82 84
83int main() 85int
86main()
84{ 87{
85 Eina_List *type, *l; 88 Eina_List *type, *l;
86 const char *name, *check, *check2; 89 const char *name, *check, *check2;
@@ -104,9 +107,9 @@ int main()
104 EINA_LIST_FOREACH(type, l, name) 107 EINA_LIST_FOREACH(type, l, name)
105 { 108 {
106 /* add the devpath to the hash for use in the cb later */ 109 /* add the devpath to the hash for use in the cb later */
107 if ((check = eeze_udev_syspath_get_devpath(name))) 110 if ((check = eeze_udev_syspath_get_devpath(name)))
108 eina_hash_direct_add(hash, name, check); 111 eina_hash_direct_add(hash, name, check);
109 printf("Found keyboard: %s\n", name); 112 printf("Found keyboard: %s\n", name);
110 } 113 }
111 /* we save this list for later, because once a device is unplugged it can 114 /* we save this list for later, because once a device is unplugged it can
112 * no longer be detected by udev, and any related properties are unusable unless 115 * no longer be detected by udev, and any related properties are unusable unless
@@ -121,7 +124,7 @@ int main()
121 EINA_LIST_FOREACH(type, l, name) 124 EINA_LIST_FOREACH(type, l, name)
122 { /* add the devpath to the hash for use in the cb later */ 125 { /* add the devpath to the hash for use in the cb later */
123 if ((check = eeze_udev_syspath_get_devpath(name))) 126 if ((check = eeze_udev_syspath_get_devpath(name)))
124 eina_hash_direct_add(hash, name, check); /* get a property using the device's syspath */ 127 eina_hash_direct_add(hash, name, check); /* get a property using the device's syspath */
125 printf("Found mouse %s with vendor: %s\n", name, eeze_udev_walk_get_sysattr(name, "manufacturer")); 128 printf("Found mouse %s with vendor: %s\n", name, eeze_udev_walk_get_sysattr(name, "manufacturer"));
126 } 129 }
127 /* we save this list for later, because once a device is unplugged it can 130 /* we save this list for later, because once a device is unplugged it can
@@ -135,27 +138,27 @@ int main()
135 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL); 138 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
136 type = eeze_udev_find_unlisted_similar(type); 139 type = eeze_udev_find_unlisted_similar(type);
137 EINA_LIST_FREE(type, name) 140 EINA_LIST_FREE(type, name)
138 { 141 {
139 printf("Found device: %s\n", name); /* get a property using the device's syspath */ 142 printf("Found device: %s\n", name); /* get a property using the device's syspath */
140 if ((check = eeze_udev_syspath_get_property(name, "DEVNAME"))) 143 if ((check = eeze_udev_syspath_get_property(name, "DEVNAME")))
141 { 144 {
142 printf("\tYou probably know it better as %s\n", check); 145 printf("\tYou probably know it better as %s\n", check);
143 eina_stringshare_del(check); 146 eina_stringshare_del(check);
144 } 147 }
145 if ((check = eeze_udev_syspath_get_property(name, "ID_FS_TYPE"))) 148 if ((check = eeze_udev_syspath_get_property(name, "ID_FS_TYPE")))
146 { 149 {
147 printf("\tIt's formatted as %s", check); 150 printf("\tIt's formatted as %s", check);
148 eina_stringshare_del(check); 151 eina_stringshare_del(check);
149 check = eeze_udev_syspath_get_property(name, "FSTAB_DIR"); 152 check = eeze_udev_syspath_get_property(name, "FSTAB_DIR");
150 if (check) 153 if (check)
151 { 154 {
152 printf(", and gets mounted at %s", check); 155 printf(", and gets mounted at %s", check);
153 eina_stringshare_del(check); 156 eina_stringshare_del(check);
154 } 157 }
155 printf("!\n"); 158 printf("!\n");
156 } 159 }
157 eina_stringshare_del(name); 160 eina_stringshare_del(name);
158 } 161 }
159 162
160 printf("\nInternal drives, anyone? With serial numbers?\n"); 163 printf("\nInternal drives, anyone? With serial numbers?\n");
161 /* find all internal drives using type EEZE_UDEV_TYPE_DRIVE_INTERNAL */ 164 /* find all internal drives using type EEZE_UDEV_TYPE_DRIVE_INTERNAL */
@@ -187,7 +190,6 @@ int main()
187 eina_stringshare_del(name); 190 eina_stringshare_del(name);
188 } 191 }
189 192
190
191 /* set a udev watch, grab all events because no EEZE_UDEV_TYPE filter is specified, 193 /* set a udev watch, grab all events because no EEZE_UDEV_TYPE filter is specified,
192 * set the events to be sent to callback function catch_events(), and attach 194 * set the events to be sent to callback function catch_events(), and attach
193 * kbdmouse to the watch as associated data 195 * kbdmouse to the watch as associated data
@@ -200,3 +202,4 @@ int main()
200 202
201 return 0; 203 return 0;
202} 204}
205
diff --git a/legacy/eeze/src/lib/eeze_main.c b/legacy/eeze/src/lib/eeze_main.c
index cf3819e455..817873cc37 100644
--- a/legacy/eeze/src/lib/eeze_main.c
+++ b/legacy/eeze/src/lib/eeze_main.c
@@ -17,10 +17,9 @@ _udev *udev;
17int _eeze_udev_log_dom = -1; 17int _eeze_udev_log_dom = -1;
18int _eeze_init_count = 0; 18int _eeze_init_count = 0;
19 19
20
21/** 20/**
22 * @defgroup main main 21 * @defgroup main main
23 * 22 *
24 * These are general eeze functions which include init and shutdown. 23 * These are general eeze functions which include init and shutdown.
25 */ 24 */
26 25
@@ -30,10 +29,10 @@ EAPI Eeze_Version *eeze_version = &_version;
30/** 29/**
31 * Initialize the eeze library. 30 * Initialize the eeze library.
32 * @return The number of times the function has been called, or -1 on failure. 31 * @return The number of times the function has been called, or -1 on failure.
33 * 32 *
34 * This function should be called prior to using any eeze functions, and MUST 33 * This function should be called prior to using any eeze functions, and MUST
35 * be called prior to using any udev functions to avoid a segv. 34 * be called prior to using any udev functions to avoid a segv.
36 * 35 *
37 * @ingroup main 36 * @ingroup main
38 */ 37 */
39EAPI int 38EAPI int
@@ -46,7 +45,7 @@ eeze_init(void)
46 return 0; 45 return 0;
47 46
48 _eeze_udev_log_dom = eina_log_domain_register 47 _eeze_udev_log_dom = eina_log_domain_register
49 ("eeze_udev", EEZE_UDEV_COLOR_DEFAULT); 48 ("eeze_udev", EEZE_UDEV_COLOR_DEFAULT);
50 49
51 if (_eeze_udev_log_dom < 0) 50 if (_eeze_udev_log_dom < 0)
52 { 51 {
@@ -76,11 +75,11 @@ eina_fail:
76 75
77/** 76/**
78 * Shut down the eeze library. 77 * Shut down the eeze library.
79 * @return The number of times the eeze_init has been called, or -1 when 78 * @return The number of times the eeze_init has been called, or -1 when
80 * all occurrences of eeze have been shut down. 79 * all occurrences of eeze have been shut down.
81 * 80 *
82 * This function should be called when no further eeze functions will be called. 81 * This function should be called when no further eeze functions will be called.
83 * 82 *
84 * @ingroup main 83 * @ingroup main
85 */ 84 */
86EAPI int 85EAPI int
@@ -96,3 +95,4 @@ eeze_shutdown(void)
96 eina_shutdown(); 95 eina_shutdown();
97 return _eeze_init_count; 96 return _eeze_init_count;
98} 97}
98
diff --git a/legacy/eeze/src/lib/eeze_udev_find.c b/legacy/eeze/src/lib/eeze_udev_find.c
index d70fa5abc2..69fa53e513 100644
--- a/legacy/eeze/src/lib/eeze_udev_find.c
+++ b/legacy/eeze/src/lib/eeze_udev_find.c
@@ -14,7 +14,7 @@
14 * @addtogroup find Find 14 * @addtogroup find Find
15 * 15 *
16 * These are functions which find/supplement lists of devices. 16 * These are functions which find/supplement lists of devices.
17 * 17 *
18 * @ingroup udev 18 * @ingroup udev
19 * 19 *
20 * @{ 20 * @{
@@ -68,7 +68,7 @@ eeze_udev_find_similar_from_syspath(const char *syspath)
68 udev_list_entry_foreach(cur, devs) 68 udev_list_entry_foreach(cur, devs)
69 { 69 {
70 devname = udev_list_entry_get_name(cur); 70 devname = udev_list_entry_get_name(cur);
71 /* verify unlisted device */ 71 /* verify unlisted device */
72 72
73 EINA_LIST_FOREACH(ret, l, dev) 73 EINA_LIST_FOREACH(ret, l, dev)
74 if (!strcmp(dev, devname)) 74 if (!strcmp(dev, devname))
@@ -77,9 +77,9 @@ eeze_udev_find_similar_from_syspath(const char *syspath)
77 ret = eina_list_prepend(ret, eina_stringshare_add(devname)); 77 ret = eina_list_prepend(ret, eina_stringshare_add(devname));
78 device = udev_device_new_from_syspath(udev, devname); 78 device = udev_device_new_from_syspath(udev, devname);
79 79
80 /* only device roots have this sysattr, 80 /* only device roots have this sysattr,
81 * and we only need to check parents of the roots 81 * and we only need to check parents of the roots
82 */ 82 */
83 if (udev_device_get_sysattr_value(device, "idVendor")) 83 if (udev_device_get_sysattr_value(device, "idVendor"))
84 ret = _get_unlisted_parents(ret, device); 84 ret = _get_unlisted_parents(ret, device);
85 85
@@ -101,7 +101,7 @@ eeze_udev_find_similar_from_syspath(const char *syspath)
101 * stringshared. 101 * stringshared.
102 */ 102 */
103EAPI Eina_List * 103EAPI Eina_List *
104eeze_udev_find_unlisted_similar(Eina_List * list) 104eeze_udev_find_unlisted_similar(Eina_List *list)
105{ 105{
106 _udev_device *device; 106 _udev_device *device;
107 _udev_list_entry *devs, *cur; 107 _udev_list_entry *devs, *cur;
@@ -117,7 +117,7 @@ eeze_udev_find_unlisted_similar(Eina_List * list)
117 en = udev_enumerate_new((udev)); 117 en = udev_enumerate_new((udev));
118 118
119 if (!en) 119 if (!en)
120 return NULL; 120 return NULL;
121 121
122 device = _new_device(dev); 122 device = _new_device(dev);
123 if (!device) continue; 123 if (!device) continue;
@@ -125,14 +125,14 @@ eeze_udev_find_unlisted_similar(Eina_List * list)
125 if ((vendor = udev_device_get_property_value(device, "ID_VENDOR_ID"))) 125 if ((vendor = udev_device_get_property_value(device, "ID_VENDOR_ID")))
126 udev_enumerate_add_match_property(en, "ID_VENDOR_ID", vendor); 126 udev_enumerate_add_match_property(en, "ID_VENDOR_ID", vendor);
127 else 127 else
128 if ((vendor = udev_device_get_property_value(device, "ID_VENDOR"))) 128 if ((vendor = udev_device_get_property_value(device, "ID_VENDOR")))
129 udev_enumerate_add_match_property(en, "ID_VENDOR", vendor); 129 udev_enumerate_add_match_property(en, "ID_VENDOR", vendor);
130 130
131 if ((model = udev_device_get_property_value(device, "ID_MODEL_ID"))) 131 if ((model = udev_device_get_property_value(device, "ID_MODEL_ID")))
132 udev_enumerate_add_match_property(en, "ID_MODEL_ID", model); 132 udev_enumerate_add_match_property(en, "ID_MODEL_ID", model);
133 else 133 else
134 if ((model = udev_device_get_property_value(device, "ID_MODEL"))) 134 if ((model = udev_device_get_property_value(device, "ID_MODEL")))
135 udev_enumerate_add_match_property(en, "ID_MODEL", model); 135 udev_enumerate_add_match_property(en, "ID_MODEL", model);
136 136
137 if ((revision = udev_device_get_property_value(device, "ID_REVISION"))) 137 if ((revision = udev_device_get_property_value(device, "ID_REVISION")))
138 udev_enumerate_add_match_property(en, "ID_REVISION", revision); 138 udev_enumerate_add_match_property(en, "ID_REVISION", revision);
@@ -168,7 +168,8 @@ eeze_udev_find_unlisted_similar(Eina_List * list)
168 * Return a list of syspaths (/sys/$syspath) for matching udev devices. 168 * Return a list of syspaths (/sys/$syspath) for matching udev devices.
169 */ 169 */
170EAPI Eina_List * 170EAPI Eina_List *
171eeze_udev_find_by_type(Eeze_Udev_Type etype, const char *name) 171eeze_udev_find_by_type(Eeze_Udev_Type etype,
172 const char *name)
172{ 173{
173 _udev_enumerate *en; 174 _udev_enumerate *en;
174 _udev_list_entry *devs, *cur; 175 _udev_list_entry *devs, *cur;
@@ -186,69 +187,80 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype, const char *name)
186 187
187 switch (etype) 188 switch (etype)
188 { 189 {
189 case EEZE_UDEV_TYPE_NONE: 190 case EEZE_UDEV_TYPE_NONE:
190 break; 191 break;
191 case EEZE_UDEV_TYPE_KEYBOARD: 192
192 udev_enumerate_add_match_subsystem(en, "input"); 193 case EEZE_UDEV_TYPE_KEYBOARD:
194 udev_enumerate_add_match_subsystem(en, "input");
193#ifndef OLD_UDEV_RRRRRRRRRRRRRR 195#ifndef OLD_UDEV_RRRRRRRRRRRRRR
194 udev_enumerate_add_match_property(en, "ID_INPUT_KEYBOARD", "1"); 196 udev_enumerate_add_match_property(en, "ID_INPUT_KEYBOARD", "1");
195#else 197#else
196 udev_enumerate_add_match_property(en, "ID_CLASS", "kbd"); 198 udev_enumerate_add_match_property(en, "ID_CLASS", "kbd");
197#endif 199#endif
198 break; 200 break;
199 case EEZE_UDEV_TYPE_MOUSE: 201
200 udev_enumerate_add_match_subsystem(en, "input"); 202 case EEZE_UDEV_TYPE_MOUSE:
203 udev_enumerate_add_match_subsystem(en, "input");
201#ifndef OLD_UDEV_RRRRRRRRRRRRRR 204#ifndef OLD_UDEV_RRRRRRRRRRRRRR
202 udev_enumerate_add_match_property(en, "ID_INPUT_MOUSE", "1"); 205 udev_enumerate_add_match_property(en, "ID_INPUT_MOUSE", "1");
203#else 206#else
204 udev_enumerate_add_match_property(en, "ID_CLASS", "mouse"); 207 udev_enumerate_add_match_property(en, "ID_CLASS", "mouse");
205#endif 208#endif
206 break; 209 break;
207 case EEZE_UDEV_TYPE_TOUCHPAD: 210
208 udev_enumerate_add_match_subsystem(en, "input"); 211 case EEZE_UDEV_TYPE_TOUCHPAD:
212 udev_enumerate_add_match_subsystem(en, "input");
209#ifndef OLD_UDEV_RRRRRRRRRRRRRR 213#ifndef OLD_UDEV_RRRRRRRRRRRRRR
210 udev_enumerate_add_match_property(en, "ID_INPUT_TOUCHPAD", "1"); 214 udev_enumerate_add_match_property(en, "ID_INPUT_TOUCHPAD", "1");
211#endif 215#endif
212 break; 216 break;
213 case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE: 217
214 udev_enumerate_add_match_subsystem(en, "block"); 218 case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
215 udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem"); 219 udev_enumerate_add_match_subsystem(en, "block");
216 /* parent node */ 220 udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
217 udev_enumerate_add_nomatch_sysattr(en, "capability", "50"); 221 /* parent node */
218 break; 222 udev_enumerate_add_nomatch_sysattr(en, "capability", "50");
219 case EEZE_UDEV_TYPE_DRIVE_INTERNAL: 223 break;
220 udev_enumerate_add_match_subsystem(en, "block"); 224
221 udev_enumerate_add_match_property(en, "ID_TYPE", "disk"); 225 case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
222 udev_enumerate_add_match_property(en, "ID_BUS", "ata"); 226 udev_enumerate_add_match_subsystem(en, "block");
223 udev_enumerate_add_match_sysattr(en, "removable", "0"); 227 udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
224 break; 228 udev_enumerate_add_match_property(en, "ID_BUS", "ata");
225 case EEZE_UDEV_TYPE_DRIVE_REMOVABLE: 229 udev_enumerate_add_match_sysattr(en, "removable", "0");
226 udev_enumerate_add_match_subsystem(en, "block"); 230 break;
227 udev_enumerate_add_match_property(en, "ID_TYPE", "disk"); 231
228 break; 232 case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
229 case EEZE_UDEV_TYPE_DRIVE_CDROM: 233 udev_enumerate_add_match_subsystem(en, "block");
230 udev_enumerate_add_match_subsystem(en, "block"); 234 udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
231 udev_enumerate_add_match_property(en, "ID_CDROM", "1"); 235 break;
232 break; 236
233 case EEZE_UDEV_TYPE_POWER_AC: 237 case EEZE_UDEV_TYPE_DRIVE_CDROM:
234 udev_enumerate_add_match_subsystem(en, "power_supply"); 238 udev_enumerate_add_match_subsystem(en, "block");
235 udev_enumerate_add_match_sysattr(en, "type", "Mains"); 239 udev_enumerate_add_match_property(en, "ID_CDROM", "1");
236 break; 240 break;
237 case EEZE_UDEV_TYPE_POWER_BAT: 241
238 udev_enumerate_add_match_subsystem(en, "power_supply"); 242 case EEZE_UDEV_TYPE_POWER_AC:
239 udev_enumerate_add_match_sysattr(en, "type", "Battery"); 243 udev_enumerate_add_match_subsystem(en, "power_supply");
240 break; 244 udev_enumerate_add_match_sysattr(en, "type", "Mains");
241 case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR: 245 break;
242 udev_enumerate_add_match_subsystem(en, "hwmon"); 246
243 break; 247 case EEZE_UDEV_TYPE_POWER_BAT:
244 /* 248 udev_enumerate_add_match_subsystem(en, "power_supply");
245 case EEZE_UDEV_TYPE_ANDROID: 249 udev_enumerate_add_match_sysattr(en, "type", "Battery");
246 udev_enumerate_add_match_subsystem(en, "block"); 250 break;
247 udev_enumerate_add_match_property(en, "ID_MODEL", "Android_*"); 251
248 break; 252 case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR:
249 */ 253 udev_enumerate_add_match_subsystem(en, "hwmon");
250 default: 254 break;
251 break; 255
256 /*
257 case EEZE_UDEV_TYPE_ANDROID:
258 udev_enumerate_add_match_subsystem(en, "block");
259 udev_enumerate_add_match_property(en, "ID_MODEL", "Android_*");
260 break;
261 */
262 default:
263 break;
252 } 264 }
253 265
254 udev_enumerate_scan_devices(en); 266 udev_enumerate_scan_devices(en);
@@ -258,53 +270,53 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype, const char *name)
258 devname = udev_list_entry_get_name(cur); 270 devname = udev_list_entry_get_name(cur);
259 device = udev_device_new_from_syspath(udev, devname); 271 device = udev_device_new_from_syspath(udev, devname);
260 272
261 if (etype == EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR) 273 if (etype == EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR) /* ensure that temp input exists somewhere in this device chain */
262 { /* ensure that temp input exists somewhere in this device chain */ 274 {
263 if (!_walk_parents_test_attr(device, "temp1_input", NULL)) 275 if (!_walk_parents_test_attr(device, "temp1_input", NULL))
264 goto out; 276 goto out;
265 277
266 /* if device is not the one which has the temp input, we must go up the chain */ 278 /* if device is not the one which has the temp input, we must go up the chain */
267 if (!(test = udev_device_get_sysattr_value(device, "temp1_input"))) 279 if (!(test = udev_device_get_sysattr_value(device, "temp1_input")))
268 { 280 {
269 devname = NULL; 281 devname = NULL;
270 282
271 for (parent = udev_device_get_parent(device); parent; parent = udev_device_get_parent(parent)) /*check for parent */ 283 for (parent = udev_device_get_parent(device); parent; parent = udev_device_get_parent(parent)) /*check for parent */
272 if (((test = udev_device_get_sysattr_value(parent, "temp1_input")))) 284 if (((test = udev_device_get_sysattr_value(parent, "temp1_input"))))
273 { 285 {
274 devname = udev_device_get_syspath(parent); 286 devname = udev_device_get_syspath(parent);
275 break; 287 break;
276 } 288 }
277 289
278 if (!devname) 290 if (!devname)
279 goto out; 291 goto out;
280 } 292 }
281 } 293 }
282 else if (etype == EEZE_UDEV_TYPE_DRIVE_INTERNAL) 294 else if (etype == EEZE_UDEV_TYPE_DRIVE_INTERNAL)
283 { 295 {
284 if (udev_device_get_property_value(device, "ID_USB_DRIVER")) 296 if (udev_device_get_property_value(device, "ID_USB_DRIVER"))
285 goto out; 297 goto out;
286 } 298 }
287 else if (etype == EEZE_UDEV_TYPE_DRIVE_REMOVABLE) 299 else if (etype == EEZE_UDEV_TYPE_DRIVE_REMOVABLE)
288 { 300 {
289 if (!(test = udev_device_get_property_value(device, "ID_USB_DRIVER"))) 301 if (!(test = udev_device_get_property_value(device, "ID_USB_DRIVER")))
302 goto out;
303 }
304 else if (etype == EEZE_UDEV_TYPE_DRIVE_MOUNTABLE)
305 {
306 int devcheck;
307
308 devcheck = open(udev_device_get_devnode(device), O_RDONLY | O_EXCL);
309 if (errno)
310 {
311 if (devcheck >= 0) close(devcheck);
290 goto out; 312 goto out;
291 } 313 }
292 else if (etype == EEZE_UDEV_TYPE_DRIVE_MOUNTABLE) 314 if (devcheck < 0) goto out;
293 { 315 close(devcheck);
294 int devcheck; 316 }
295
296 devcheck = open(udev_device_get_devnode(device), O_RDONLY | O_EXCL);
297 if (errno)
298 {
299 if (devcheck >= 0) close(devcheck);
300 goto out;
301 }
302 if (devcheck < 0) goto out;
303 close(devcheck);
304 }
305 317
306 if (name && (!strstr(devname, name))) 318 if (name && (!strstr(devname, name)))
307 goto out; 319 goto out;
308 320
309 ret = eina_list_append(ret, eina_stringshare_add(devname)); 321 ret = eina_list_append(ret, eina_stringshare_add(devname));
310out: 322out:
@@ -326,7 +338,8 @@ out:
326 * Requires at least one filter. 338 * Requires at least one filter.
327 */ 339 */
328EAPI Eina_List * 340EAPI Eina_List *
329eeze_udev_find_by_filter(const char *subsystem, const char *type, 341eeze_udev_find_by_filter(const char *subsystem,
342 const char *type,
330 const char *name) 343 const char *name)
331{ 344{
332 _udev_enumerate *en; 345 _udev_enumerate *en;
@@ -373,11 +386,12 @@ out:
373 * @param value Optional: the value that the attribute should have 386 * @param value Optional: the value that the attribute should have
374 * 387 *
375 * @return A stringshared list of the devices found with the attribute 388 * @return A stringshared list of the devices found with the attribute
376 * 389 *
377 * @ingroup find 390 * @ingroup find
378 */ 391 */
379EAPI Eina_List * 392EAPI Eina_List *
380eeze_udev_find_by_sysattr(const char *sysattr, const char *value) 393eeze_udev_find_by_sysattr(const char *sysattr,
394 const char *value)
381{ 395{
382 _udev_enumerate *en; 396 _udev_enumerate *en;
383 _udev_list_entry *devs, *cur; 397 _udev_list_entry *devs, *cur;
diff --git a/legacy/eeze/src/lib/eeze_udev_private.c b/legacy/eeze/src/lib/eeze_udev_private.c
index 3492fae2e0..c94e4a35f4 100644
--- a/legacy/eeze/src/lib/eeze_udev_private.c
+++ b/legacy/eeze/src/lib/eeze_udev_private.c
@@ -32,7 +32,7 @@ _new_device(const char *syspath)
32 * copies a device 32 * copies a device
33 */ 33 */
34_udev_device * 34_udev_device *
35_copy_device(_udev_device * device) 35_copy_device(_udev_device *device)
36{ 36{
37 const char *syspath; 37 const char *syspath;
38 38
@@ -48,8 +48,9 @@ _copy_device(_udev_device * device)
48 * with value $value 48 * with value $value
49 */ 49 */
50Eina_Bool 50Eina_Bool
51_walk_parents_test_attr(_udev_device * device, const char *sysattr, 51_walk_parents_test_attr(_udev_device *device,
52 const char *value) 52 const char *sysattr,
53 const char *value)
53{ 54{
54 _udev_device *parent, *child = device; 55 _udev_device *parent, *child = device;
55 const char *test; 56 const char *test;
@@ -67,15 +68,16 @@ _walk_parents_test_attr(_udev_device * device, const char *sysattr,
67 if (!value) 68 if (!value)
68 return EINA_TRUE; 69 return EINA_TRUE;
69 else 70 else
70 if (!strcmp(test, value)) 71 if (!strcmp(test, value))
71 return EINA_TRUE; 72 return EINA_TRUE;
72 } 73 }
73 74
74 return EINA_TRUE; 75 return EINA_TRUE;
75} 76}
76 77
77const char * 78const char *
78_walk_parents_get_attr(_udev_device * device, const char *sysattr) 79_walk_parents_get_attr(_udev_device *device,
80 const char *sysattr)
79{ 81{
80 _udev_device *parent, *child = device; 82 _udev_device *parent, *child = device;
81 const char *test; 83 const char *test;
@@ -99,7 +101,8 @@ _walk_parents_get_attr(_udev_device * device, const char *sysattr)
99 * stringshare adding all devices that are not in the list 101 * stringshare adding all devices that are not in the list
100 */ 102 */
101Eina_List * 103Eina_List *
102_get_unlisted_parents(Eina_List * list, _udev_device * device) 104_get_unlisted_parents(Eina_List *list,
105 _udev_device *device)
103{ 106{
104 _udev_device *parent, *child = device; 107 _udev_device *parent, *child = device;
105 const char *test, *devname, *vendor, *vendor2, *model, *model2; 108 const char *test, *devname, *vendor, *vendor2, *model, *model2;
@@ -128,9 +131,9 @@ _get_unlisted_parents(Eina_List * list, _udev_device * device)
128 || (vendor2 && !vendor)) 131 || (vendor2 && !vendor))
129 break; 132 break;
130 else 133 else
131 if (((model && model2) && (strcmp(model, model2))) || 134 if (((model && model2) && (strcmp(model, model2))) ||
132 ((vendor && vendor2) && (strcmp(vendor, vendor2)))) 135 ((vendor && vendor2) && (strcmp(vendor, vendor2))))
133 break; 136 break;
134 137
135 devname = udev_device_get_syspath(parent); 138 devname = udev_device_get_syspath(parent);
136 EINA_LIST_FOREACH(list, l, test) 139 EINA_LIST_FOREACH(list, l, test)
@@ -148,3 +151,4 @@ _get_unlisted_parents(Eina_List * list, _udev_device * device)
148 151
149 return list; 152 return list;
150} 153}
154
diff --git a/legacy/eeze/src/lib/eeze_udev_syspath.c b/legacy/eeze/src/lib/eeze_udev_syspath.c
index 45f144e742..6ac8ed728f 100644
--- a/legacy/eeze/src/lib/eeze_udev_syspath.c
+++ b/legacy/eeze/src/lib/eeze_udev_syspath.c
@@ -8,9 +8,9 @@
8/** 8/**
9 * @addtogroup syspath Syspath 9 * @addtogroup syspath Syspath
10 * 10 *
11 * These are functions which interact with the syspath (/sys/$PATH) of 11 * These are functions which interact with the syspath (/sys/$PATH) of
12 * a device. 12 * a device.
13 * 13 *
14 * @ingroup udev 14 * @ingroup udev
15 * 15 *
16 * @{ 16 * @{
@@ -134,7 +134,8 @@ eeze_udev_syspath_get_subsystem(const char *syspath)
134 * @return A stringshared char* with the property or NULL on failure 134 * @return A stringshared char* with the property or NULL on failure
135 */ 135 */
136EAPI const char * 136EAPI const char *
137eeze_udev_syspath_get_property(const char *syspath, const char *property) 137eeze_udev_syspath_get_property(const char *syspath,
138 const char *property)
138{ 139{
139 _udev_device *device; 140 _udev_device *device;
140 const char *value = NULL, *test; 141 const char *value = NULL, *test;
@@ -159,7 +160,8 @@ eeze_udev_syspath_get_property(const char *syspath, const char *property)
159 * @return A stringshared char* with the sysattr or NULL on failure 160 * @return A stringshared char* with the sysattr or NULL on failure
160 */ 161 */
161EAPI const char * 162EAPI const char *
162eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr) 163eeze_udev_syspath_get_sysattr(const char *syspath,
164 const char *sysattr)
163{ 165{
164 _udev_device *device; 166 _udev_device *device;
165 const char *value = NULL, *test; 167 const char *value = NULL, *test;
@@ -317,7 +319,7 @@ eeze_udev_devpath_get_syspath(const char *devpath)
317 udev_list_entry_foreach(cur, devs) 319 udev_list_entry_foreach(cur, devs)
318 { 320 {
319 ret = eina_stringshare_add(udev_list_entry_get_name(cur)); 321 ret = eina_stringshare_add(udev_list_entry_get_name(cur));
320 break; /*just in case there's more than one somehow */ 322 break; /*just in case there's more than one somehow */
321 } 323 }
322 udev_enumerate_unref(en); 324 udev_enumerate_unref(en);
323 return ret; 325 return ret;
diff --git a/legacy/eeze/src/lib/eeze_udev_walk.c b/legacy/eeze/src/lib/eeze_udev_walk.c
index a46aeac169..40ca82dded 100644
--- a/legacy/eeze/src/lib/eeze_udev_walk.c
+++ b/legacy/eeze/src/lib/eeze_udev_walk.c
@@ -9,7 +9,7 @@
9 * @addtogroup walks Walks 9 * @addtogroup walks Walks
10 * 10 *
11 * These are functions which walk up the device chain. 11 * These are functions which walk up the device chain.
12 * 12 *
13 * @ingroup udev 13 * @ingroup udev
14 * 14 *
15 * @{ 15 * @{
@@ -26,7 +26,8 @@
26 * @return If the sysattr (with value) is found, returns TRUE. Else, false. 26 * @return If the sysattr (with value) is found, returns TRUE. Else, false.
27 */ 27 */
28EAPI Eina_Bool 28EAPI Eina_Bool
29eeze_udev_walk_check_sysattr(const char *syspath, const char *sysattr, 29eeze_udev_walk_check_sysattr(const char *syspath,
30 const char *sysattr,
30 const char *value) 31 const char *value)
31{ 32{
32 _udev_device *device, *child, *parent; 33 _udev_device *device, *child, *parent;
@@ -40,7 +41,7 @@ eeze_udev_walk_check_sysattr(const char *syspath, const char *sysattr,
40 return EINA_FALSE; 41 return EINA_FALSE;
41 42
42 for (parent = device; parent; 43 for (parent = device; parent;
43 child = parent, parent = udev_device_get_parent(child)) 44 child = parent, parent = udev_device_get_parent(child))
44 { 45 {
45 if (!(test = udev_device_get_sysattr_value(parent, sysattr))) 46 if (!(test = udev_device_get_sysattr_value(parent, sysattr)))
46 continue; 47 continue;
@@ -65,7 +66,8 @@ eeze_udev_walk_check_sysattr(const char *syspath, const char *sysattr,
65 * @return The stringshared value of @p sysattr if found, or NULL 66 * @return The stringshared value of @p sysattr if found, or NULL
66 */ 67 */
67EAPI const char * 68EAPI const char *
68eeze_udev_walk_get_sysattr(const char *syspath, const char *sysattr) 69eeze_udev_walk_get_sysattr(const char *syspath,
70 const char *sysattr)
69{ 71{
70 _udev_device *device, *child, *parent; 72 _udev_device *device, *child, *parent;
71 const char *test = NULL; 73 const char *test = NULL;
@@ -75,9 +77,9 @@ eeze_udev_walk_get_sysattr(const char *syspath, const char *sysattr)
75 77
76 if (!(device = _new_device(syspath))) 78 if (!(device = _new_device(syspath)))
77 return NULL; 79 return NULL;
78 80
79 for (parent = device; parent; 81 for (parent = device; parent;
80 child = parent, parent = udev_device_get_parent(child)) 82 child = parent, parent = udev_device_get_parent(child))
81 { 83 {
82 if ((test = udev_device_get_sysattr_value(parent, sysattr))) 84 if ((test = udev_device_get_sysattr_value(parent, sysattr)))
83 { 85 {
diff --git a/legacy/eeze/src/lib/eeze_udev_watch.c b/legacy/eeze/src/lib/eeze_udev_watch.c
index a3c2634ebc..0b013479d1 100644
--- a/legacy/eeze/src/lib/eeze_udev_watch.c
+++ b/legacy/eeze/src/lib/eeze_udev_watch.c
@@ -14,20 +14,23 @@
14/* opaque */ 14/* opaque */
15struct Eeze_Udev_Watch 15struct Eeze_Udev_Watch
16{ 16{
17 _udev_monitor *mon; 17 _udev_monitor *mon;
18 Ecore_Fd_Handler *handler; 18 Ecore_Fd_Handler *handler;
19 Eeze_Udev_Type type; 19 Eeze_Udev_Type type;
20 void *data; 20 void *data;
21}; 21};
22 22
23/* private */ 23/* private */
24struct _store_data 24struct _store_data
25{ 25{
26 void (*func)(const char *, Eeze_Udev_Event, void *, Eeze_Udev_Watch *); 26 void (*func)(const char *,
27 void *data; 27 Eeze_Udev_Event,
28 int event; 28 void *,
29 _udev_monitor *mon; 29 Eeze_Udev_Watch *);
30 Eeze_Udev_Type type; 30 void *data;
31 int event;
32 _udev_monitor *mon;
33 Eeze_Udev_Type type;
31 Eeze_Udev_Watch *watch; 34 Eeze_Udev_Watch *watch;
32}; 35};
33 36
@@ -42,7 +45,7 @@ struct _store_data
42 * the watch object itself in case you want to stop the watch easily in a callback. 45 * the watch object itself in case you want to stop the watch easily in a callback.
43 * 46 *
44 * @ingroup udev 47 * @ingroup udev
45 * 48 *
46 * @{ 49 * @{
47 */ 50 */
48 51
@@ -50,8 +53,9 @@ struct _store_data
50 * specified; helpful for new udev versions, but absolutely required for 53 * specified; helpful for new udev versions, but absolutely required for
51 * old udev, which does not implement filtering in device monitors. 54 * old udev, which does not implement filtering in device monitors.
52 */ 55 */
53static Eina_Bool 56static Eina_Bool
54_get_syspath_from_watch(void *data, Ecore_Fd_Handler * fd_handler) 57_get_syspath_from_watch(void *data,
58 Ecore_Fd_Handler *fd_handler)
55{ 59{
56 struct _store_data *store = data; 60 struct _store_data *store = data;
57 _udev_device *device = NULL, *parent, *tmpdev; 61 _udev_device *device = NULL, *parent, *tmpdev;
@@ -71,170 +75,180 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler * fd_handler)
71 75
72 switch (store->type) 76 switch (store->type)
73 { 77 {
74 case EEZE_UDEV_TYPE_KEYBOARD: 78 case EEZE_UDEV_TYPE_KEYBOARD:
75#ifdef OLD_UDEV_RRRRRRRRRRRRRR 79#ifdef OLD_UDEV_RRRRRRRRRRRRRR
76 if ((!(test = udev_device_get_subsystem(device))) 80 if ((!(test = udev_device_get_subsystem(device)))
77 || (strcmp(test, "input"))) 81 || (strcmp(test, "input")))
78 goto error; 82 goto error;
79 83
80 test = udev_device_get_property_value(device, "ID_CLASS"); 84 test = udev_device_get_property_value(device, "ID_CLASS");
81 85
82 if ((_walk_parents_test_attr(device, "bInterfaceProtocol", "01")) 86 if ((_walk_parents_test_attr(device, "bInterfaceProtocol", "01"))
83 || ((test) && (!strcmp(test, "kbd")))) 87 || ((test) && (!strcmp(test, "kbd"))))
84 break; 88 break;
85 89
86 goto error; 90 goto error;
87#endif 91#endif
88 if ((!udev_device_get_property_value(device, "ID_INPUT_KEYBOARD")) && 92 if ((!udev_device_get_property_value(device, "ID_INPUT_KEYBOARD")) &&
89 (!udev_device_get_property_value(device, "ID_INPUT_KEY"))) 93 (!udev_device_get_property_value(device, "ID_INPUT_KEY")))
90 goto error; 94 goto error;
91 95
92 break; 96 break;
93 case EEZE_UDEV_TYPE_MOUSE: 97
98 case EEZE_UDEV_TYPE_MOUSE:
94#ifdef OLD_UDEV_RRRRRRRRRRRRRR 99#ifdef OLD_UDEV_RRRRRRRRRRRRRR
95 if ((!(test = udev_device_get_subsystem(device))) 100 if ((!(test = udev_device_get_subsystem(device)))
96 || (strcmp(test, "input"))) 101 || (strcmp(test, "input")))
97 goto error; 102 goto error;
98 103
99 test = udev_device_get_property_value(device, "ID_CLASS"); 104 test = udev_device_get_property_value(device, "ID_CLASS");
100 105
101 if ((_walk_parents_test_attr(device, "bInterfaceProtocol", "02")) 106 if ((_walk_parents_test_attr(device, "bInterfaceProtocol", "02"))
102 || ((test) && (!strcmp(test, "mouse")))) 107 || ((test) && (!strcmp(test, "mouse"))))
103 break; 108 break;
104 109
105 goto error; 110 goto error;
106#endif 111#endif
107 112
108 if (!udev_device_get_property_value(device, "ID_INPUT_MOUSE")) 113 if (!udev_device_get_property_value(device, "ID_INPUT_MOUSE"))
109 goto error; 114 goto error;
110 115
111 break; 116 break;
112 case EEZE_UDEV_TYPE_TOUCHPAD: 117
118 case EEZE_UDEV_TYPE_TOUCHPAD:
113#ifdef OLD_UDEV_RRRRRRRRRRRRRR 119#ifdef OLD_UDEV_RRRRRRRRRRRRRR
114 if ((!(test = udev_device_get_subsystem(device))) 120 if ((!(test = udev_device_get_subsystem(device)))
115 || (strcmp(test, "input"))) 121 || (strcmp(test, "input")))
116 goto error; 122 goto error;
117 123
118 if (_walk_parents_test_attr(device, "resolution", NULL)) 124 if (_walk_parents_test_attr(device, "resolution", NULL))
119 break; 125 break;
120 126
121 goto error; 127 goto error;
122#endif 128#endif
123 if (!udev_device_get_property_value(device, "ID_INPUT_TOUCHPAD")) 129 if (!udev_device_get_property_value(device, "ID_INPUT_TOUCHPAD"))
124 goto error; 130 goto error;
125 131
126 break; 132 break;
127 case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE: 133
134 case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
128#ifdef OLD_UDEV_RRRRRRRRRRRRRR 135#ifdef OLD_UDEV_RRRRRRRRRRRRRR
129 if ((!(test = udev_device_get_subsystem(device))) 136 if ((!(test = udev_device_get_subsystem(device)))
130 || (strcmp(test, "block"))) 137 || (strcmp(test, "block")))
131 goto error; 138 goto error;
132#endif 139#endif
133 test = udev_device_get_sysattr_value(device, "capability"); 140 test = udev_device_get_sysattr_value(device, "capability");
134 141
135 if (test) 142 if (test)
136 cap = strtol(test, NULL, 10); 143 cap = strtol(test, NULL, 10);
137 144
138 if (!(test = (udev_device_get_property_value(device, "ID_FS_USAGE"))) || 145 if (!(test = (udev_device_get_property_value(device, "ID_FS_USAGE"))) ||
139 (strcmp("filesystem", test)) || (cap == 50)) 146 (strcmp("filesystem", test)) || (cap == 50))
140 goto error; 147 goto error;
141 { 148 {
142 int devcheck; 149 int devcheck;
143 150
144 devcheck = open(udev_device_get_devnode(device), O_RDONLY | O_EXCL); 151 devcheck = open(udev_device_get_devnode(device), O_RDONLY | O_EXCL);
145 if ((devcheck < 0) || errno) goto error; 152 if ((devcheck < 0) || errno) goto error;
146 close(devcheck); 153 close(devcheck);
147 } 154 }
148 155
149 break; 156 break;
150 case EEZE_UDEV_TYPE_DRIVE_INTERNAL: 157
158 case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
151#ifdef OLD_UDEV_RRRRRRRRRRRRRR 159#ifdef OLD_UDEV_RRRRRRRRRRRRRR
152 if ((!(test = udev_device_get_subsystem(device))) 160 if ((!(test = udev_device_get_subsystem(device)))
153 || (strcmp(test, "block"))) 161 || (strcmp(test, "block")))
154 goto error; 162 goto error;
155#endif 163#endif
156 if (!(test = udev_device_get_property_value(device, "ID_BUS")) 164 if (!(test = udev_device_get_property_value(device, "ID_BUS"))
157 || (strcmp("ata", test)) 165 || (strcmp("ata", test))
158 || !(test = udev_device_get_sysattr_value(device, "removable")) 166 || !(test = udev_device_get_sysattr_value(device, "removable"))
159 || (strtol(test, NULL, 10))) 167 || (strtol(test, NULL, 10)))
160 goto error; 168 goto error;
161 169
162 break; 170 break;
163 case EEZE_UDEV_TYPE_DRIVE_REMOVABLE: 171
172 case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
164#ifdef OLD_UDEV_RRRRRRRRRRRRRR 173#ifdef OLD_UDEV_RRRRRRRRRRRRRR
165 if ((!(test = udev_device_get_subsystem(device))) 174 if ((!(test = udev_device_get_subsystem(device)))
166 || (strcmp(test, "block"))) 175 || (strcmp(test, "block")))
167 goto error; 176 goto error;
168#endif 177#endif
169 if ((!(test = udev_device_get_sysattr_value(device, "removable")) 178 if ((!(test = udev_device_get_sysattr_value(device, "removable"))
170 || (!strtol(test, NULL, 10))) 179 || (!strtol(test, NULL, 10)))
171 && (!(test = udev_device_get_sysattr_value(device, "capability")) 180 && (!(test = udev_device_get_sysattr_value(device, "capability"))
172 || (strtol(test, NULL, 10) != 10))) 181 || (strtol(test, NULL, 10) != 10)))
173 goto error; 182 goto error;
174 183
175 break; 184 break;
176 case EEZE_UDEV_TYPE_DRIVE_CDROM: 185
186 case EEZE_UDEV_TYPE_DRIVE_CDROM:
177#ifdef OLD_UDEV_RRRRRRRRRRRRRR 187#ifdef OLD_UDEV_RRRRRRRRRRRRRR
178 if ((!(test = udev_device_get_subsystem(device))) 188 if ((!(test = udev_device_get_subsystem(device)))
179 || (strcmp(test, "block"))) 189 || (strcmp(test, "block")))
180 goto error; 190 goto error;
181#endif 191#endif
182 if (!udev_device_get_property_value(device, "ID_CDROM")) 192 if (!udev_device_get_property_value(device, "ID_CDROM"))
183 goto error; 193 goto error;
184 194
185 break; 195 break;
186 case EEZE_UDEV_TYPE_POWER_AC: 196
197 case EEZE_UDEV_TYPE_POWER_AC:
187#ifdef OLD_UDEV_RRRRRRRRRRRRRR 198#ifdef OLD_UDEV_RRRRRRRRRRRRRR
188 if ((!(test = udev_device_get_subsystem(device))) 199 if ((!(test = udev_device_get_subsystem(device)))
189 || (strcmp(test, "power_supply"))) 200 || (strcmp(test, "power_supply")))
190 goto error; 201 goto error;
191#endif 202#endif
192 if (!(test = udev_device_get_property_value(device, "POWER_SUPPLY_TYPE")) 203 if (!(test = udev_device_get_property_value(device, "POWER_SUPPLY_TYPE"))
193 || (strcmp("Mains", test))) 204 || (strcmp("Mains", test)))
194 goto error; 205 goto error;
195 break; 206 break;
196 case EEZE_UDEV_TYPE_POWER_BAT: 207
208 case EEZE_UDEV_TYPE_POWER_BAT:
197#ifdef OLD_UDEV_RRRRRRRRRRRRRR 209#ifdef OLD_UDEV_RRRRRRRRRRRRRR
198 if ((!(test = udev_device_get_subsystem(device))) 210 if ((!(test = udev_device_get_subsystem(device)))
199 || (strcmp(test, "power_supply"))) 211 || (strcmp(test, "power_supply")))
200 goto error; 212 goto error;
201#endif 213#endif
202 if (!(test = udev_device_get_property_value(device, "POWER_SUPPLY_TYPE")) 214 if (!(test = udev_device_get_property_value(device, "POWER_SUPPLY_TYPE"))
203 || (strcmp("Battery", test))) 215 || (strcmp("Battery", test)))
204 goto error; 216 goto error;
205 break; 217 break;
206 case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR: 218
219 case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR:
207#ifdef OLD_UDEV_RRRRRRRRRRRRRR 220#ifdef OLD_UDEV_RRRRRRRRRRRRRR
208 if ((!(test = udev_device_get_subsystem(device))) 221 if ((!(test = udev_device_get_subsystem(device)))
209 || (strcmp(test, "hwmon"))) 222 || (strcmp(test, "hwmon")))
210 goto error; 223 goto error;
211#endif /* have to do stuff up here since we need info from the parent */ 224#endif /* have to do stuff up here since we need info from the parent */
212 if (!_walk_parents_test_attr(device, "temp1_input", NULL)) 225 if (!_walk_parents_test_attr(device, "temp1_input", NULL))
213 goto error; 226 goto error;
214 227
215 /* if device is not the one which has the temp input, we must go up the chain */ 228 /* if device is not the one which has the temp input, we must go up the chain */
216 if (!udev_device_get_sysattr_value(device, "temp1_input")) 229 if (!udev_device_get_sysattr_value(device, "temp1_input"))
217 { 230 {
218 for (parent = udev_device_get_parent(device); parent; parent = udev_device_get_parent(parent)) /*check for parent */ 231 for (parent = udev_device_get_parent(device); parent; parent = udev_device_get_parent(parent)) /*check for parent */
219 if (udev_device_get_sysattr_value(parent, "temp1_input")) 232 if (udev_device_get_sysattr_value(parent, "temp1_input"))
220 { 233 {
221 tmpdev = device; 234 tmpdev = device;
222 235
223 if (!(device = _copy_device(parent))) 236 if (!(device = _copy_device(parent)))
224 goto error; 237 goto error;
225 238
226 udev_device_unref(tmpdev); 239 udev_device_unref(tmpdev);
227 break; 240 break;
228 } 241 }
229 } 242 }
230 243
231 break; 244 break;
232 default: 245
233 break; 246 default:
247 break;
234 } 248 }
235 249
236 if ((!(test = udev_device_get_action(device))) 250 if ((!(test = udev_device_get_action(device)))
237 || (!(ret = udev_device_get_syspath(device)))) 251 || (!(ret = udev_device_get_syspath(device))))
238 goto error; 252 goto error;
239 253
240 if (store->event) 254 if (store->event)
@@ -247,48 +261,49 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler * fd_handler)
247 event |= EEZE_UDEV_EVENT_ADD; 261 event |= EEZE_UDEV_EVENT_ADD;
248 } 262 }
249 else 263 else
250 if (!strcmp(test, "remove")) 264 if (!strcmp(test, "remove"))
251 { 265 {
252 if ((store->event & EEZE_UDEV_EVENT_REMOVE) != 266 if ((store->event & EEZE_UDEV_EVENT_REMOVE) !=
253 EEZE_UDEV_EVENT_REMOVE) 267 EEZE_UDEV_EVENT_REMOVE)
254 goto error; 268 goto error;
255 269
256 event |= EEZE_UDEV_EVENT_REMOVE; 270 event |= EEZE_UDEV_EVENT_REMOVE;
257 } 271 }
258 else 272 else
259 if (!strcmp(test, "change")) 273 if (!strcmp(test, "change"))
260 { 274 {
261 if ((store->event & EEZE_UDEV_EVENT_CHANGE) != 275 if ((store->event & EEZE_UDEV_EVENT_CHANGE) !=
262 EEZE_UDEV_EVENT_CHANGE) 276 EEZE_UDEV_EVENT_CHANGE)
263 goto error; 277 goto error;
264 278
265 event |= EEZE_UDEV_EVENT_CHANGE; 279 event |= EEZE_UDEV_EVENT_CHANGE;
266 } 280 }
267 else 281 else
268 if (!strcmp(test, "online")) 282 if (!strcmp(test, "online"))
269 { 283 {
270 if ((store->event & EEZE_UDEV_EVENT_ONLINE) != 284 if ((store->event & EEZE_UDEV_EVENT_ONLINE) !=
271 EEZE_UDEV_EVENT_ONLINE) 285 EEZE_UDEV_EVENT_ONLINE)
272 goto error; 286 goto error;
273 287
274 event |= EEZE_UDEV_EVENT_ONLINE; 288 event |= EEZE_UDEV_EVENT_ONLINE;
275 } 289 }
276 else 290 else
277 { 291 {
278 if ((store->event & EEZE_UDEV_EVENT_OFFLINE) != 292 if ((store->event & EEZE_UDEV_EVENT_OFFLINE) !=
279 EEZE_UDEV_EVENT_OFFLINE) 293 EEZE_UDEV_EVENT_OFFLINE)
280 goto error; 294 goto error;
281 295
282 event |= EEZE_UDEV_EVENT_OFFLINE; 296 event |= EEZE_UDEV_EVENT_OFFLINE;
283 } 297 }
284 } 298 }
285 299
286 (*func)(eina_stringshare_add(ret), event, sdata, watch); 300 (*func)(eina_stringshare_add(ret), event, sdata, watch);
287error: 301error:
288 if (device) 302 if (device)
289 udev_device_unref(device); 303 udev_device_unref(device);
290 return EINA_TRUE; 304 return EINA_TRUE;
291} 305}
306
292/** 307/**
293 * Add a watch for a device type 308 * Add a watch for a device type
294 * 309 *
@@ -304,8 +319,10 @@ error:
304 * binary &. 319 * binary &.
305 */ 320 */
306EAPI Eeze_Udev_Watch * 321EAPI Eeze_Udev_Watch *
307eeze_udev_watch_add(Eeze_Udev_Type type, int event, 322eeze_udev_watch_add(Eeze_Udev_Type type,
308 Eeze_Udev_Watch_Cb cb, void *user_data) 323 int event,
324 Eeze_Udev_Watch_Cb cb,
325 void *user_data)
309{ 326{
310 _udev_monitor *mon = NULL; 327 _udev_monitor *mon = NULL;
311 int fd; 328 int fd;
@@ -326,42 +343,51 @@ eeze_udev_watch_add(Eeze_Udev_Type type, int event,
326 343
327 switch (type) 344 switch (type)
328 { 345 {
329 case EEZE_UDEV_TYPE_KEYBOARD: 346 case EEZE_UDEV_TYPE_KEYBOARD:
330 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL); 347 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
331 break; 348 break;
332 case EEZE_UDEV_TYPE_MOUSE: 349
333 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL); 350 case EEZE_UDEV_TYPE_MOUSE:
334 break; 351 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
335 case EEZE_UDEV_TYPE_TOUCHPAD: 352 break;
336 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL); 353
337 break; 354 case EEZE_UDEV_TYPE_TOUCHPAD:
338 case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE: 355 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
339 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL); 356 break;
340 break; 357
341 case EEZE_UDEV_TYPE_DRIVE_INTERNAL: 358 case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
342 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL); 359 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
343 break; 360 break;
344 case EEZE_UDEV_TYPE_DRIVE_REMOVABLE: 361
345 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL); 362 case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
346 break; 363 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
347 case EEZE_UDEV_TYPE_DRIVE_CDROM: 364 break;
348 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL); 365
349 break; 366 case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
350 case EEZE_UDEV_TYPE_POWER_AC: 367 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
351 case EEZE_UDEV_TYPE_POWER_BAT: 368 break;
352 udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", 369
353 NULL); 370 case EEZE_UDEV_TYPE_DRIVE_CDROM:
354 break; 371 udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
355 case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR: 372 break;
356 udev_monitor_filter_add_match_subsystem_devtype(mon, "hwmon", NULL); 373
357 break; 374 case EEZE_UDEV_TYPE_POWER_AC:
358 /* 375 case EEZE_UDEV_TYPE_POWER_BAT:
359 case EEZE_UDEV_TYPE_ANDROID: 376 udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply",
360 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface"); 377 NULL);
361 break; 378 break;
362 */ 379
363 default: 380 case EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR:
364 break; 381 udev_monitor_filter_add_match_subsystem_devtype(mon, "hwmon", NULL);
382 break;
383
384 /*
385 case EEZE_UDEV_TYPE_ANDROID:
386 udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
387 break;
388 */
389 default:
390 break;
365 } 391 }
366 392
367#endif 393#endif
@@ -377,8 +403,8 @@ eeze_udev_watch_add(Eeze_Udev_Type type, int event,
377 store->watch = watch; 403 store->watch = watch;
378 store->event = event; 404 store->event = event;
379 405
380 if (!(handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, 406 if (!(handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ,
381 _get_syspath_from_watch, store, NULL, NULL))) 407 _get_syspath_from_watch, store, NULL, NULL)))
382 goto error; 408 goto error;
383 409
384 watch->mon = mon; 410 watch->mon = mon;
@@ -404,7 +430,7 @@ error:
404 * Deletes a watch, closing file descriptors and freeing related udev memory. 430 * Deletes a watch, closing file descriptors and freeing related udev memory.
405 */ 431 */
406EAPI void * 432EAPI void *
407eeze_udev_watch_del(Eeze_Udev_Watch * watch) 433eeze_udev_watch_del(Eeze_Udev_Watch *watch)
408{ 434{
409 struct _store_data *sdata; 435 struct _store_data *sdata;
410 void *ret = NULL; 436 void *ret = NULL;