Merge lp:~cjcurran/indicator-session/udev-beginnings into lp:indicator-session/0.1
- udev-beginnings
- Merge into trunk
Proposed by
Conor Curran
Status: | Superseded |
---|---|
Proposed branch: | lp:~cjcurran/indicator-session/udev-beginnings |
Merge into: | lp:indicator-session/0.1 |
Diff against target: |
1490 lines (+1286/-28) 7 files modified
configure.ac (+2/-0) src/Makefile.am (+2/-1) src/device-menu-mgr.c (+57/-13) src/sane-rules.h (+778/-0) src/udev-mgr.c (+416/-6) src/udev-mgr.h (+15/-4) src/user-menu-mgr.c (+16/-4) |
To merge this branch: | bzr merge lp:~cjcurran/indicator-session/udev-beginnings |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil J. Patel (community) | Needs Fixing | ||
Review via email: mp+70534@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-08-09.
Commit message
Description of the change
backend for scanners and webcams in place
To post a comment you must log in.
- 189. By Conor Curran
-
fixed memory leaks
- 190. By Conor Curran
-
segfault found and fixed
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2011-07-22 17:15:55 +0000 |
3 | +++ configure.ac 2011-08-09 11:36:39 +0000 |
4 | @@ -58,12 +58,14 @@ |
5 | [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION |
6 | dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION |
7 | dbus-glib-1 |
8 | + gudev-1.0 |
9 | gio-unix-2.0 |
10 | indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) |
11 | ], |
12 | [test "x$with_gtk" = x2], |
13 | [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION |
14 | dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION |
15 | + gudev-1.0 |
16 | dbus-glib-1 |
17 | gio-unix-2.0 |
18 | indicator-0.4 >= $INDICATOR_REQUIRED_VERSION) |
19 | |
20 | === modified file 'src/Makefile.am' |
21 | --- src/Makefile.am 2011-07-21 15:38:44 +0000 |
22 | +++ src/Makefile.am 2011-08-09 11:36:39 +0000 |
23 | @@ -101,7 +101,8 @@ |
24 | apt-transaction.h \ |
25 | apt-transaction.c \ |
26 | udev-mgr.h \ |
27 | - udev-mgr.c |
28 | + udev-mgr.c \ |
29 | + sane-rules.h |
30 | indicator_session_service_CFLAGS = \ |
31 | $(SESSIONSERVICE_CFLAGS) \ |
32 | $(GCONF_CFLAGS) \ |
33 | |
34 | === modified file 'src/device-menu-mgr.c' |
35 | --- src/device-menu-mgr.c 2011-07-22 14:36:59 +0000 |
36 | +++ src/device-menu-mgr.c 2011-08-09 11:36:39 +0000 |
37 | @@ -27,7 +27,7 @@ |
38 | #include "lock-helper.h" |
39 | #include "upower-client.h" |
40 | #include "apt-watcher.h" |
41 | - |
42 | +#include "udev-mgr.h" |
43 | |
44 | #define UP_ADDRESS "org.freedesktop.UPower" |
45 | #define UP_OBJECT "/org/freedesktop/UPower" |
46 | @@ -41,6 +41,7 @@ |
47 | DbusmenuMenuitem* root_item; |
48 | SessionDbus* session_dbus_interface; |
49 | AptWatcher* apt_watcher; |
50 | + UdevMgr* udev_mgr; |
51 | }; |
52 | |
53 | static GConfClient *gconf_client = NULL; |
54 | @@ -80,8 +81,15 @@ |
55 | gchar* type); |
56 | static void show_system_settings_with_context (DbusmenuMenuitem * mi, |
57 | guint timestamp, |
58 | - gchar * type); |
59 | - |
60 | + gchar * type); |
61 | + |
62 | +static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, |
63 | + guint timestamp, |
64 | + gchar * type); |
65 | +static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, |
66 | + guint timestamp, |
67 | + gchar * type); |
68 | + |
69 | static void |
70 | machine_sleep_from_hibernate (DbusmenuMenuitem * mi, |
71 | guint timestamp, |
72 | @@ -214,7 +222,6 @@ |
73 | |
74 | screensaver_throttle(type); |
75 | lock_if_possible (self); |
76 | - |
77 | dbus_g_proxy_begin_call(up_main_proxy, |
78 | type, |
79 | sleep_response, |
80 | @@ -460,6 +467,43 @@ |
81 | g_free(control_centre_command); |
82 | } |
83 | |
84 | +// TODO: refactor both of these down to the one method. |
85 | +static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, |
86 | + guint timestamp, |
87 | + gchar * type) |
88 | +{ |
89 | + GError * error = NULL; |
90 | + if (!g_spawn_command_line_async("simple-scan", &error)) |
91 | + { |
92 | + g_warning("Unable to launch simple-scan: %s", error->message); |
93 | + g_error_free(error); |
94 | + if (!g_spawn_command_line_async("software-center simple-scan", &error)) |
95 | + { |
96 | + g_warning ("Unable to launch software-centre simple-scan: %s", |
97 | + error->message); |
98 | + g_error_free(error); |
99 | + } |
100 | + } |
101 | +} |
102 | + |
103 | +static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, |
104 | + guint timestamp, |
105 | + gchar * type) |
106 | +{ |
107 | + GError * error = NULL; |
108 | + if (!g_spawn_command_line_async("cheese", &error)) |
109 | + { |
110 | + g_warning("Unable to launch cheese: %s", error->message); |
111 | + g_error_free(error); |
112 | + if (!g_spawn_command_line_async("software-center cheese", &error)) |
113 | + { |
114 | + g_warning ("Unable to launch software-centre cheese: %s", |
115 | + error->message); |
116 | + g_error_free(error); |
117 | + } |
118 | + } |
119 | +} |
120 | + |
121 | static void |
122 | device_menu_mgr_build_static_items (DeviceMenuMgr* self) |
123 | { |
124 | @@ -547,15 +591,14 @@ |
125 | scanners_menuitem = dbusmenu_menuitem_new(); |
126 | dbusmenu_menuitem_property_set (scanners_menuitem, |
127 | DBUSMENU_MENUITEM_PROP_LABEL, |
128 | - _("HP Scanners")); |
129 | + _("Scanners")); |
130 | g_signal_connect (G_OBJECT(scanners_menuitem), |
131 | DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
132 | - G_CALLBACK(show_system_settings_with_context), |
133 | - "scanners"); |
134 | + G_CALLBACK(device_menu_mgr_show_simple_scan), |
135 | + NULL); |
136 | dbusmenu_menuitem_child_add_position (self->root_item, |
137 | scanners_menuitem, |
138 | 8); |
139 | - //tmp |
140 | dbusmenu_menuitem_property_set_bool (scanners_menuitem, |
141 | DBUSMENU_MENUITEM_PROP_VISIBLE, |
142 | FALSE); |
143 | @@ -563,15 +606,14 @@ |
144 | webcam_menuitem = dbusmenu_menuitem_new(); |
145 | dbusmenu_menuitem_property_set (webcam_menuitem, |
146 | DBUSMENU_MENUITEM_PROP_LABEL, |
147 | - _("HP Webcam")); |
148 | + _("Webcam")); |
149 | g_signal_connect (G_OBJECT(webcam_menuitem), |
150 | DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
151 | - G_CALLBACK(show_system_settings_with_context), |
152 | - "HP Webcam"); |
153 | + G_CALLBACK(device_menu_mgr_show_cheese), |
154 | + NULL); |
155 | dbusmenu_menuitem_child_add_position (self->root_item, |
156 | webcam_menuitem, |
157 | 10); |
158 | - //tmp |
159 | dbusmenu_menuitem_property_set_bool (webcam_menuitem, |
160 | DBUSMENU_MENUITEM_PROP_VISIBLE, |
161 | FALSE); |
162 | @@ -681,7 +723,9 @@ |
163 | restart_shutdown_logout_mi->logout_mi = logout_mi; |
164 | restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; |
165 | |
166 | - update_menu_entries(restart_shutdown_logout_mi); |
167 | + update_menu_entries(restart_shutdown_logout_mi); |
168 | + // Time to create the udev mgr and hand it the static relevant items. |
169 | + self->udev_mgr = udev_mgr_new (scanners_menuitem, webcam_menuitem); |
170 | } |
171 | |
172 | |
173 | |
174 | === added file 'src/sane-rules.h' |
175 | --- src/sane-rules.h 1970-01-01 00:00:00 +0000 |
176 | +++ src/sane-rules.h 2011-08-09 11:36:39 +0000 |
177 | @@ -0,0 +1,778 @@ |
178 | +void populate_scsi_scanners (GHashTable* scanners) |
179 | +{ |
180 | + GList* epson = NULL; |
181 | + epson = g_list_append (epson, g_strdup ("GT-9700")); |
182 | + epson = g_list_append (epson, g_strdup ("GT-9800")); |
183 | + epson = g_list_append (epson, g_strdup ("Perfection1200")); |
184 | + epson = g_list_append (epson, g_strdup ("Perfection636")); |
185 | + epson = g_list_append (epson, g_strdup ("SCANNER GT-7000")); |
186 | + g_hash_table_insert (scanners, |
187 | + g_strdup("EPSON"), |
188 | + epson); |
189 | + |
190 | + |
191 | + GList* hp = NULL; |
192 | + hp = g_list_append (hp, g_strdup ("C1130A")); |
193 | + hp = g_list_append (hp, g_strdup ("C1750A")); |
194 | + hp = g_list_append (hp, g_strdup ("C1790A")); |
195 | + hp = g_list_append (hp, g_strdup ("C2500A")); |
196 | + hp = g_list_append (hp, g_strdup ("C2520A")); |
197 | + hp = g_list_append (hp, g_strdup ("C5110A")); |
198 | + hp = g_list_append (hp, g_strdup ("C6270A")); |
199 | + hp = g_list_append (hp, g_strdup ("C7670A")); |
200 | + g_hash_table_insert (scanners, |
201 | + g_strdup("HP"), |
202 | + hp); |
203 | +} |
204 | + |
205 | + |
206 | + |
207 | +void populate_usb_scanners (GHashTable* scanners) |
208 | +{ |
209 | + GList* hp = NULL; |
210 | + |
211 | + hp = g_list_append (hp, g_strdup ("0101")); |
212 | + hp = g_list_append (hp, g_strdup ("0105")); |
213 | + hp = g_list_append (hp, g_strdup ("0201")); |
214 | + hp = g_list_append (hp, g_strdup ("0205")); |
215 | + hp = g_list_append (hp, g_strdup ("0305")); |
216 | + hp = g_list_append (hp, g_strdup ("0401")); |
217 | + hp = g_list_append (hp, g_strdup ("0405")); |
218 | + hp = g_list_append (hp, g_strdup ("0505")); |
219 | + hp = g_list_append (hp, g_strdup ("0601")); |
220 | + hp = g_list_append (hp, g_strdup ("0605")); |
221 | + hp = g_list_append (hp, g_strdup ("0701")); |
222 | + hp = g_list_append (hp, g_strdup ("0705")); |
223 | + hp = g_list_append (hp, g_strdup ("0801")); |
224 | + hp = g_list_append (hp, g_strdup ("0805")); |
225 | + hp = g_list_append (hp, g_strdup ("0901")); |
226 | + hp = g_list_append (hp, g_strdup ("0a01")); |
227 | + hp = g_list_append (hp, g_strdup ("0b01")); |
228 | + hp = g_list_append (hp, g_strdup ("1005")); |
229 | + hp = g_list_append (hp, g_strdup ("1105")); |
230 | + hp = g_list_append (hp, g_strdup ("1205")); |
231 | + hp = g_list_append (hp, g_strdup ("1305")); |
232 | + hp = g_list_append (hp, g_strdup ("1405")); |
233 | + hp = g_list_append (hp, g_strdup ("1705")); |
234 | + hp = g_list_append (hp, g_strdup ("1805")); |
235 | + hp = g_list_append (hp, g_strdup ("2005")); |
236 | + hp = g_list_append (hp, g_strdup ("2205")); |
237 | + hp = g_list_append (hp, g_strdup ("2305")); |
238 | + hp = g_list_append (hp, g_strdup ("2405")); |
239 | + hp = g_list_append (hp, g_strdup ("2605")); |
240 | + hp = g_list_append (hp, g_strdup ("2805")); |
241 | + hp = g_list_append (hp, g_strdup ("3805")); |
242 | + hp = g_list_append (hp, g_strdup ("3905")); |
243 | + hp = g_list_append (hp, g_strdup ("3B17")); |
244 | + hp = g_list_append (hp, g_strdup ("4105")); |
245 | + hp = g_list_append (hp, g_strdup ("4205")); |
246 | + hp = g_list_append (hp, g_strdup ("4305")); |
247 | + hp = g_list_append (hp, g_strdup ("4505")); |
248 | + hp = g_list_append (hp, g_strdup ("4605")); |
249 | + hp = g_list_append (hp, g_strdup ("5617")); |
250 | + hp = g_list_append (hp, g_strdup ("5717")); |
251 | + |
252 | + g_hash_table_insert (scanners, |
253 | + g_strdup("03f0"), |
254 | + hp); |
255 | + |
256 | + GList* mustek_2 = NULL; |
257 | + mustek_2 = g_list_append (mustek_2, g_strdup ("1000")); |
258 | + mustek_2 = g_list_append (mustek_2, g_strdup ("1001")); |
259 | + g_hash_table_insert (scanners, |
260 | + g_strdup("0400"), |
261 | + mustek_2); |
262 | + |
263 | + GList* kodak = NULL; |
264 | + kodak = g_list_append (kodak, g_strdup ("6001")); |
265 | + kodak = g_list_append (kodak, g_strdup ("6002")); |
266 | + kodak = g_list_append (kodak, g_strdup ("6003")); |
267 | + kodak = g_list_append (kodak, g_strdup ("6004")); |
268 | + kodak = g_list_append (kodak, g_strdup ("6005")); |
269 | + g_hash_table_insert (scanners, |
270 | + g_strdup("040a"), |
271 | + kodak); |
272 | + |
273 | + GList* creative = NULL; |
274 | + |
275 | + creative = g_list_append (creative, g_strdup ("4007")); |
276 | + |
277 | + g_hash_table_insert (scanners, |
278 | + g_strdup("041e"), |
279 | + creative); |
280 | + |
281 | + GList* lexmark = NULL; |
282 | + |
283 | + lexmark = g_list_append (lexmark, g_strdup("002d")); |
284 | + lexmark = g_list_append (lexmark, g_strdup("0060")); |
285 | + lexmark = g_list_append (lexmark, g_strdup("007c")); |
286 | + lexmark = g_list_append (lexmark, g_strdup("007d")); |
287 | + |
288 | + g_hash_table_insert (scanners, |
289 | + g_strdup("043d"), |
290 | + lexmark); |
291 | + |
292 | + |
293 | + GList* genius = NULL; |
294 | + genius = g_list_append (genius, g_strdup("2004")); |
295 | + genius = g_list_append (genius, g_strdup("2007")); |
296 | + genius = g_list_append (genius, g_strdup("2008")); |
297 | + genius = g_list_append (genius, g_strdup("2009")); |
298 | + genius = g_list_append (genius, g_strdup("2011")); |
299 | + genius = g_list_append (genius, g_strdup("2013")); |
300 | + genius = g_list_append (genius, g_strdup("2014")); |
301 | + genius = g_list_append (genius, g_strdup("2015")); |
302 | + genius = g_list_append (genius, g_strdup("2016")); |
303 | + genius = g_list_append (genius, g_strdup("2017")); |
304 | + genius = g_list_append (genius, g_strdup("201a")); |
305 | + genius = g_list_append (genius, g_strdup("201b")); |
306 | + genius = g_list_append (genius, g_strdup("201d")); |
307 | + genius = g_list_append (genius, g_strdup("201e")); |
308 | + genius = g_list_append (genius, g_strdup("201f")); |
309 | + genius = g_list_append (genius, g_strdup("20c1")); |
310 | + g_hash_table_insert (scanners, |
311 | + g_strdup("0458"), |
312 | + genius); |
313 | + |
314 | + GList* medion = NULL; |
315 | + medion = g_list_append (medion, g_strdup("0377")); |
316 | + g_hash_table_insert (scanners, |
317 | + g_strdup("0461"), |
318 | + medion); |
319 | + |
320 | + GList* trust = NULL; |
321 | + trust = g_list_append (trust, g_strdup("1000")); |
322 | + trust = g_list_append (trust, g_strdup("1002")); |
323 | + g_hash_table_insert (scanners, |
324 | + g_strdup("047b"), |
325 | + trust); |
326 | + |
327 | + GList* kyocera = NULL; |
328 | + kyocera = g_list_append (kyocera, g_strdup("0335")); |
329 | + g_hash_table_insert (scanners, |
330 | + g_strdup("0482"), |
331 | + kyocera); |
332 | + |
333 | + GList* compaq = NULL; |
334 | + compaq = g_list_append (compaq, g_strdup("001a")); |
335 | + g_hash_table_insert (scanners, |
336 | + g_strdup("049f"), |
337 | + compaq); |
338 | + GList* benq = NULL; |
339 | + benq = g_list_append (benq, g_strdup("1a20")); |
340 | + benq = g_list_append (benq, g_strdup("1a2a")); |
341 | + benq = g_list_append (benq, g_strdup("2022")); |
342 | + benq = g_list_append (benq, g_strdup("2040")); |
343 | + benq = g_list_append (benq, g_strdup("2060")); |
344 | + benq = g_list_append (benq, g_strdup("207e")); |
345 | + benq = g_list_append (benq, g_strdup("20b0")); |
346 | + benq = g_list_append (benq, g_strdup("20be")); |
347 | + benq = g_list_append (benq, g_strdup("20c0")); |
348 | + benq = g_list_append (benq, g_strdup("20de")); |
349 | + benq = g_list_append (benq, g_strdup("20f8")); |
350 | + benq = g_list_append (benq, g_strdup("20fc")); |
351 | + benq = g_list_append (benq, g_strdup("20fe")); |
352 | + benq = g_list_append (benq, g_strdup("2137")); |
353 | + benq = g_list_append (benq, g_strdup("2211")); |
354 | + g_hash_table_insert (scanners, |
355 | + g_strdup("04a5"), |
356 | + benq); |
357 | + |
358 | + GList* visioneer = NULL; |
359 | + visioneer = g_list_append (visioneer, g_strdup("0229")); |
360 | + visioneer = g_list_append (visioneer, g_strdup("0390")); |
361 | + visioneer = g_list_append (visioneer, g_strdup("0420")); |
362 | + visioneer = g_list_append (visioneer, g_strdup("0421")); |
363 | + visioneer = g_list_append (visioneer, g_strdup("0422")); |
364 | + visioneer = g_list_append (visioneer, g_strdup("0423")); |
365 | + visioneer = g_list_append (visioneer, g_strdup("0424")); |
366 | + visioneer = g_list_append (visioneer, g_strdup("0426")); |
367 | + visioneer = g_list_append (visioneer, g_strdup("0427")); |
368 | + visioneer = g_list_append (visioneer, g_strdup("0444")); |
369 | + visioneer = g_list_append (visioneer, g_strdup("0446")); |
370 | + visioneer = g_list_append (visioneer, g_strdup("0447")); |
371 | + visioneer = g_list_append (visioneer, g_strdup("0448")); |
372 | + visioneer = g_list_append (visioneer, g_strdup("0449")); |
373 | + visioneer = g_list_append (visioneer, g_strdup("044c")); |
374 | + visioneer = g_list_append (visioneer, g_strdup("0474")); |
375 | + visioneer = g_list_append (visioneer, g_strdup("0475")); |
376 | + visioneer = g_list_append (visioneer, g_strdup("0477")); |
377 | + visioneer = g_list_append (visioneer, g_strdup("0478")); |
378 | + visioneer = g_list_append (visioneer, g_strdup("0479")); |
379 | + visioneer = g_list_append (visioneer, g_strdup("047a")); |
380 | + visioneer = g_list_append (visioneer, g_strdup("047b")); |
381 | + visioneer = g_list_append (visioneer, g_strdup("047c")); |
382 | + visioneer = g_list_append (visioneer, g_strdup("048c")); |
383 | + visioneer = g_list_append (visioneer, g_strdup("048d")); |
384 | + visioneer = g_list_append (visioneer, g_strdup("048e")); |
385 | + visioneer = g_list_append (visioneer, g_strdup("048f")); |
386 | + visioneer = g_list_append (visioneer, g_strdup("0490")); |
387 | + visioneer = g_list_append (visioneer, g_strdup("0491")); |
388 | + visioneer = g_list_append (visioneer, g_strdup("0492")); |
389 | + visioneer = g_list_append (visioneer, g_strdup("0493")); |
390 | + visioneer = g_list_append (visioneer, g_strdup("0494")); |
391 | + visioneer = g_list_append (visioneer, g_strdup("0495")); |
392 | + visioneer = g_list_append (visioneer, g_strdup("0497")); |
393 | + visioneer = g_list_append (visioneer, g_strdup("0498")); |
394 | + visioneer = g_list_append (visioneer, g_strdup("0499")); |
395 | + visioneer = g_list_append (visioneer, g_strdup("049a")); |
396 | + visioneer = g_list_append (visioneer, g_strdup("049b")); |
397 | + visioneer = g_list_append (visioneer, g_strdup("049c")); |
398 | + visioneer = g_list_append (visioneer, g_strdup("049d")); |
399 | + visioneer = g_list_append (visioneer, g_strdup("04a7")); |
400 | + visioneer = g_list_append (visioneer, g_strdup("04ac")); |
401 | + g_hash_table_insert (scanners, |
402 | + g_strdup("04a7"), |
403 | + visioneer); |
404 | + GList* canon = NULL; |
405 | + canon = g_list_append (canon, g_strdup("1601")); |
406 | + canon = g_list_append (canon, g_strdup("1602")); |
407 | + canon = g_list_append (canon, g_strdup("1603")); |
408 | + canon = g_list_append (canon, g_strdup("1604")); |
409 | + canon = g_list_append (canon, g_strdup("1606")); |
410 | + canon = g_list_append (canon, g_strdup("1607")); |
411 | + canon = g_list_append (canon, g_strdup("1608")); |
412 | + canon = g_list_append (canon, g_strdup("1609")); |
413 | + canon = g_list_append (canon, g_strdup("160a")); |
414 | + canon = g_list_append (canon, g_strdup("160b")); |
415 | + canon = g_list_append (canon, g_strdup("1706")); |
416 | + canon = g_list_append (canon, g_strdup("1707")); |
417 | + canon = g_list_append (canon, g_strdup("1708")); |
418 | + canon = g_list_append (canon, g_strdup("1709")); |
419 | + canon = g_list_append (canon, g_strdup("170a")); |
420 | + canon = g_list_append (canon, g_strdup("170b")); |
421 | + canon = g_list_append (canon, g_strdup("170c")); |
422 | + canon = g_list_append (canon, g_strdup("170d")); |
423 | + canon = g_list_append (canon, g_strdup("170e")); |
424 | + canon = g_list_append (canon, g_strdup("1712")); |
425 | + canon = g_list_append (canon, g_strdup("1713")); |
426 | + canon = g_list_append (canon, g_strdup("1714")); |
427 | + canon = g_list_append (canon, g_strdup("1715")); |
428 | + canon = g_list_append (canon, g_strdup("1716")); |
429 | + canon = g_list_append (canon, g_strdup("1717")); |
430 | + canon = g_list_append (canon, g_strdup("1718")); |
431 | + canon = g_list_append (canon, g_strdup("1719")); |
432 | + canon = g_list_append (canon, g_strdup("171a")); |
433 | + canon = g_list_append (canon, g_strdup("171b")); |
434 | + canon = g_list_append (canon, g_strdup("171c")); |
435 | + canon = g_list_append (canon, g_strdup("1721")); |
436 | + canon = g_list_append (canon, g_strdup("1722")); |
437 | + canon = g_list_append (canon, g_strdup("1723")); |
438 | + canon = g_list_append (canon, g_strdup("1724")); |
439 | + canon = g_list_append (canon, g_strdup("1725")); |
440 | + canon = g_list_append (canon, g_strdup("1726")); |
441 | + canon = g_list_append (canon, g_strdup("1727")); |
442 | + canon = g_list_append (canon, g_strdup("1728")); |
443 | + canon = g_list_append (canon, g_strdup("1729")); |
444 | + canon = g_list_append (canon, g_strdup("172b")); |
445 | + canon = g_list_append (canon, g_strdup("172c")); |
446 | + canon = g_list_append (canon, g_strdup("172d")); |
447 | + canon = g_list_append (canon, g_strdup("172e")); |
448 | + canon = g_list_append (canon, g_strdup("172f")); |
449 | + canon = g_list_append (canon, g_strdup("1730")); |
450 | + canon = g_list_append (canon, g_strdup("1731")); |
451 | + canon = g_list_append (canon, g_strdup("1732")); |
452 | + canon = g_list_append (canon, g_strdup("1733")); |
453 | + canon = g_list_append (canon, g_strdup("1734")); |
454 | + canon = g_list_append (canon, g_strdup("1735")); |
455 | + canon = g_list_append (canon, g_strdup("1736")); |
456 | + canon = g_list_append (canon, g_strdup("173a")); |
457 | + canon = g_list_append (canon, g_strdup("173b")); |
458 | + canon = g_list_append (canon, g_strdup("173c")); |
459 | + canon = g_list_append (canon, g_strdup("173d")); |
460 | + canon = g_list_append (canon, g_strdup("173e")); |
461 | + canon = g_list_append (canon, g_strdup("173f")); |
462 | + canon = g_list_append (canon, g_strdup("1740")); |
463 | + canon = g_list_append (canon, g_strdup("1741")); |
464 | + canon = g_list_append (canon, g_strdup("1742")); |
465 | + canon = g_list_append (canon, g_strdup("1901")); |
466 | + canon = g_list_append (canon, g_strdup("1904")); |
467 | + canon = g_list_append (canon, g_strdup("1905")); |
468 | + canon = g_list_append (canon, g_strdup("1909")); |
469 | + canon = g_list_append (canon, g_strdup("190a")); |
470 | + canon = g_list_append (canon, g_strdup("2204")); |
471 | + canon = g_list_append (canon, g_strdup("2206")); |
472 | + canon = g_list_append (canon, g_strdup("2207")); |
473 | + canon = g_list_append (canon, g_strdup("2208")); |
474 | + canon = g_list_append (canon, g_strdup("220d")); |
475 | + canon = g_list_append (canon, g_strdup("220e")); |
476 | + canon = g_list_append (canon, g_strdup("2213")); |
477 | + canon = g_list_append (canon, g_strdup("221c")); |
478 | + canon = g_list_append (canon, g_strdup("2220")); |
479 | + canon = g_list_append (canon, g_strdup("2222")); |
480 | + canon = g_list_append (canon, g_strdup("262f")); |
481 | + canon = g_list_append (canon, g_strdup("2630")); |
482 | + canon = g_list_append (canon, g_strdup("263c")); |
483 | + canon = g_list_append (canon, g_strdup("263d")); |
484 | + canon = g_list_append (canon, g_strdup("263e")); |
485 | + canon = g_list_append (canon, g_strdup("263f")); |
486 | + canon = g_list_append (canon, g_strdup("264c")); |
487 | + canon = g_list_append (canon, g_strdup("264d")); |
488 | + canon = g_list_append (canon, g_strdup("264e")); |
489 | + canon = g_list_append (canon, g_strdup("264f")); |
490 | + canon = g_list_append (canon, g_strdup("2659")); |
491 | + canon = g_list_append (canon, g_strdup("265d")); |
492 | + canon = g_list_append (canon, g_strdup("265e")); |
493 | + canon = g_list_append (canon, g_strdup("265f")); |
494 | + canon = g_list_append (canon, g_strdup("2660")); |
495 | + canon = g_list_append (canon, g_strdup("2684")); |
496 | + canon = g_list_append (canon, g_strdup("2686")); |
497 | + canon = g_list_append (canon, g_strdup("26a3")); |
498 | + canon = g_list_append (canon, g_strdup("26b0")); |
499 | + canon = g_list_append (canon, g_strdup("26b4")); |
500 | + canon = g_list_append (canon, g_strdup("26b5")); |
501 | + canon = g_list_append (canon, g_strdup("26ec")); |
502 | + canon = g_list_append (canon, g_strdup("26ed")); |
503 | + canon = g_list_append (canon, g_strdup("26ee")); |
504 | + g_hash_table_insert (scanners, |
505 | + g_strdup("04a9"), |
506 | + canon); |
507 | + |
508 | + GList* nikon = NULL; |
509 | + nikon = g_list_append (nikon, g_strdup ("4000")); |
510 | + nikon = g_list_append (nikon, g_strdup ("4001")); |
511 | + nikon = g_list_append (nikon, g_strdup ("4002")); |
512 | + g_hash_table_insert (scanners, |
513 | + g_strdup("04b0"), |
514 | + nikon); |
515 | + |
516 | + GList* epson = NULL; |
517 | + |
518 | + // for testing (its a printer not a scanner!) |
519 | + //epson = g_list_append (epson, g_strdup ("0001")); |
520 | + |
521 | + epson = g_list_append (epson, g_strdup("0101")); |
522 | + epson = g_list_append (epson, g_strdup("0103")); |
523 | + epson = g_list_append (epson, g_strdup("0104")); |
524 | + epson = g_list_append (epson, g_strdup("0105")); |
525 | + epson = g_list_append (epson, g_strdup("0106")); |
526 | + epson = g_list_append (epson, g_strdup("0107")); |
527 | + epson = g_list_append (epson, g_strdup("0109")); |
528 | + epson = g_list_append (epson, g_strdup("010a")); |
529 | + epson = g_list_append (epson, g_strdup("010b")); |
530 | + epson = g_list_append (epson, g_strdup("010c")); |
531 | + epson = g_list_append (epson, g_strdup("010e")); |
532 | + epson = g_list_append (epson, g_strdup("010f")); |
533 | + epson = g_list_append (epson, g_strdup("0110")); |
534 | + epson = g_list_append (epson, g_strdup("0112")); |
535 | + epson = g_list_append (epson, g_strdup("0114")); |
536 | + epson = g_list_append (epson, g_strdup("011b")); |
537 | + epson = g_list_append (epson, g_strdup("011c")); |
538 | + epson = g_list_append (epson, g_strdup("011d")); |
539 | + epson = g_list_append (epson, g_strdup("011e")); |
540 | + epson = g_list_append (epson, g_strdup("011f")); |
541 | + epson = g_list_append (epson, g_strdup("0120")); |
542 | + epson = g_list_append (epson, g_strdup("0121")); |
543 | + epson = g_list_append (epson, g_strdup("0122")); |
544 | + epson = g_list_append (epson, g_strdup("0126")); |
545 | + epson = g_list_append (epson, g_strdup("0128")); |
546 | + epson = g_list_append (epson, g_strdup("0129")); |
547 | + epson = g_list_append (epson, g_strdup("012a")); |
548 | + epson = g_list_append (epson, g_strdup("012b")); |
549 | + epson = g_list_append (epson, g_strdup("012c")); |
550 | + epson = g_list_append (epson, g_strdup("0135")); |
551 | + epson = g_list_append (epson, g_strdup("0801")); |
552 | + epson = g_list_append (epson, g_strdup("0802")); |
553 | + epson = g_list_append (epson, g_strdup("0805")); |
554 | + epson = g_list_append (epson, g_strdup("0806")); |
555 | + epson = g_list_append (epson, g_strdup("0807")); |
556 | + epson = g_list_append (epson, g_strdup("0808")); |
557 | + epson = g_list_append (epson, g_strdup("080c")); |
558 | + epson = g_list_append (epson, g_strdup("080d")); |
559 | + epson = g_list_append (epson, g_strdup("080e")); |
560 | + epson = g_list_append (epson, g_strdup("080f")); |
561 | + epson = g_list_append (epson, g_strdup("0810")); |
562 | + epson = g_list_append (epson, g_strdup("0811")); |
563 | + epson = g_list_append (epson, g_strdup("0813")); |
564 | + epson = g_list_append (epson, g_strdup("0814")); |
565 | + epson = g_list_append (epson, g_strdup("0815")); |
566 | + epson = g_list_append (epson, g_strdup("0817")); |
567 | + epson = g_list_append (epson, g_strdup("0818")); |
568 | + epson = g_list_append (epson, g_strdup("0819")); |
569 | + epson = g_list_append (epson, g_strdup("081a")); |
570 | + epson = g_list_append (epson, g_strdup("081c")); |
571 | + epson = g_list_append (epson, g_strdup("081d")); |
572 | + epson = g_list_append (epson, g_strdup("081f")); |
573 | + epson = g_list_append (epson, g_strdup("0820")); |
574 | + epson = g_list_append (epson, g_strdup("0827")); |
575 | + epson = g_list_append (epson, g_strdup("0828")); |
576 | + epson = g_list_append (epson, g_strdup("0829")); |
577 | + epson = g_list_append (epson, g_strdup("082a")); |
578 | + epson = g_list_append (epson, g_strdup("082b")); |
579 | + epson = g_list_append (epson, g_strdup("082e")); |
580 | + epson = g_list_append (epson, g_strdup("082f")); |
581 | + epson = g_list_append (epson, g_strdup("0830")); |
582 | + epson = g_list_append (epson, g_strdup("0833")); |
583 | + epson = g_list_append (epson, g_strdup("0834")); |
584 | + epson = g_list_append (epson, g_strdup("0835")); |
585 | + epson = g_list_append (epson, g_strdup("0836")); |
586 | + epson = g_list_append (epson, g_strdup("0837")); |
587 | + epson = g_list_append (epson, g_strdup("0838")); |
588 | + epson = g_list_append (epson, g_strdup("0839")); |
589 | + epson = g_list_append (epson, g_strdup("083a")); |
590 | + epson = g_list_append (epson, g_strdup("083c")); |
591 | + epson = g_list_append (epson, g_strdup("0841")); |
592 | + epson = g_list_append (epson, g_strdup("0843")); |
593 | + epson = g_list_append (epson, g_strdup("0844")); |
594 | + epson = g_list_append (epson, g_strdup("0846")); |
595 | + epson = g_list_append (epson, g_strdup("0847")); |
596 | + epson = g_list_append (epson, g_strdup("0848")); |
597 | + epson = g_list_append (epson, g_strdup("0849")); |
598 | + epson = g_list_append (epson, g_strdup("084a")); |
599 | + epson = g_list_append (epson, g_strdup("084c")); |
600 | + epson = g_list_append (epson, g_strdup("084d")); |
601 | + epson = g_list_append (epson, g_strdup("084f")); |
602 | + epson = g_list_append (epson, g_strdup("0851")); |
603 | + epson = g_list_append (epson, g_strdup("0854")); |
604 | + epson = g_list_append (epson, g_strdup("0856")); |
605 | + g_hash_table_insert (scanners, |
606 | + g_strdup("04b8"), |
607 | + epson); |
608 | + |
609 | + GList* fujitsu = NULL; |
610 | + fujitsu = g_list_append (fujitsu, g_strdup ("1029")); |
611 | + fujitsu = g_list_append (fujitsu, g_strdup ("1041")); |
612 | + fujitsu = g_list_append (fujitsu, g_strdup ("1042")); |
613 | + fujitsu = g_list_append (fujitsu, g_strdup ("1078")); |
614 | + fujitsu = g_list_append (fujitsu, g_strdup ("1095")); |
615 | + fujitsu = g_list_append (fujitsu, g_strdup ("1096")); |
616 | + fujitsu = g_list_append (fujitsu, g_strdup ("1097")); |
617 | + fujitsu = g_list_append (fujitsu, g_strdup ("10ad")); |
618 | + fujitsu = g_list_append (fujitsu, g_strdup ("10ae")); |
619 | + fujitsu = g_list_append (fujitsu, g_strdup ("10af")); |
620 | + fujitsu = g_list_append (fujitsu, g_strdup ("10c7")); |
621 | + fujitsu = g_list_append (fujitsu, g_strdup ("10cf")); |
622 | + fujitsu = g_list_append (fujitsu, g_strdup ("10e0")); |
623 | + fujitsu = g_list_append (fujitsu, g_strdup ("10e1")); |
624 | + fujitsu = g_list_append (fujitsu, g_strdup ("10e2")); |
625 | + fujitsu = g_list_append (fujitsu, g_strdup ("10e6")); |
626 | + fujitsu = g_list_append (fujitsu, g_strdup ("10e7")); |
627 | + fujitsu = g_list_append (fujitsu, g_strdup ("10ef")); |
628 | + fujitsu = g_list_append (fujitsu, g_strdup ("10f2")); |
629 | + fujitsu = g_list_append (fujitsu, g_strdup ("10fe")); |
630 | + fujitsu = g_list_append (fujitsu, g_strdup ("1135")); |
631 | + fujitsu = g_list_append (fujitsu, g_strdup ("114a")); |
632 | + fujitsu = g_list_append (fujitsu, g_strdup ("114d")); |
633 | + fujitsu = g_list_append (fujitsu, g_strdup ("114e")); |
634 | + fujitsu = g_list_append (fujitsu, g_strdup ("114f")); |
635 | + fujitsu = g_list_append (fujitsu, g_strdup ("1150")); |
636 | + fujitsu = g_list_append (fujitsu, g_strdup ("1155")); |
637 | + fujitsu = g_list_append (fujitsu, g_strdup ("1156")); |
638 | + fujitsu = g_list_append (fujitsu, g_strdup ("116f")); |
639 | + fujitsu = g_list_append (fujitsu, g_strdup ("1174")); |
640 | + fujitsu = g_list_append (fujitsu, g_strdup ("1175")); |
641 | + fujitsu = g_list_append (fujitsu, g_strdup ("1176")); |
642 | + fujitsu = g_list_append (fujitsu, g_strdup ("1177")); |
643 | + fujitsu = g_list_append (fujitsu, g_strdup ("1178")); |
644 | + fujitsu = g_list_append (fujitsu, g_strdup ("117f")); |
645 | + fujitsu = g_list_append (fujitsu, g_strdup ("119d")); |
646 | + fujitsu = g_list_append (fujitsu, g_strdup ("119e")); |
647 | + fujitsu = g_list_append (fujitsu, g_strdup ("119f")); |
648 | + fujitsu = g_list_append (fujitsu, g_strdup ("11a0")); |
649 | + fujitsu = g_list_append (fujitsu, g_strdup ("11a2")); |
650 | + fujitsu = g_list_append (fujitsu, g_strdup ("11ed")); |
651 | + fujitsu = g_list_append (fujitsu, g_strdup ("11ee")); |
652 | + fujitsu = g_list_append (fujitsu, g_strdup ("11ef")); |
653 | + fujitsu = g_list_append (fujitsu, g_strdup ("11f1")); |
654 | + fujitsu = g_list_append (fujitsu, g_strdup ("11f2")); |
655 | + fujitsu = g_list_append (fujitsu, g_strdup ("11f3")); |
656 | + fujitsu = g_list_append (fujitsu, g_strdup ("11f4")); |
657 | + fujitsu = g_list_append (fujitsu, g_strdup ("11fc")); |
658 | + g_hash_table_insert (scanners, |
659 | + g_strdup("04c5"), |
660 | + fujitsu); |
661 | + GList* konica = NULL; |
662 | + konica = g_list_append (konica, g_strdup ("0722")); |
663 | + g_hash_table_insert (scanners, |
664 | + g_strdup("04c8"), |
665 | + konica); |
666 | + GList* panasonic = NULL; |
667 | + panasonic = g_list_append (panasonic, g_strdup ("1000")); |
668 | + panasonic = g_list_append (panasonic, g_strdup ("1001")); |
669 | + panasonic = g_list_append (panasonic, g_strdup ("1006")); |
670 | + panasonic = g_list_append (panasonic, g_strdup ("1007")); |
671 | + panasonic = g_list_append (panasonic, g_strdup ("1009")); |
672 | + panasonic = g_list_append (panasonic, g_strdup ("100a")); |
673 | + panasonic = g_list_append (panasonic, g_strdup ("100f")); |
674 | + panasonic = g_list_append (panasonic, g_strdup ("1010")); |
675 | + g_hash_table_insert (scanners, |
676 | + g_strdup("04da"), |
677 | + panasonic); |
678 | + |
679 | + GList* samsung = NULL; |
680 | + |
681 | + samsung = g_list_append (samsung, g_strdup ("341b")); |
682 | + samsung = g_list_append (samsung, g_strdup ("341f")); |
683 | + samsung = g_list_append (samsung, g_strdup ("3426")); |
684 | + samsung = g_list_append (samsung, g_strdup ("342a")); |
685 | + samsung = g_list_append (samsung, g_strdup ("342b")); |
686 | + samsung = g_list_append (samsung, g_strdup ("342c")); |
687 | + samsung = g_list_append (samsung, g_strdup ("3433")); |
688 | + samsung = g_list_append (samsung, g_strdup ("3434")); |
689 | + samsung = g_list_append (samsung, g_strdup ("343c")); |
690 | + samsung = g_list_append (samsung, g_strdup ("3434")); |
691 | + g_hash_table_insert (scanners, |
692 | + g_strdup("04e8"), |
693 | + samsung); |
694 | + |
695 | + GList* pentax = NULL; |
696 | + pentax = g_list_append (pentax, g_strdup ("2038")); |
697 | + g_hash_table_insert (scanners, |
698 | + g_strdup("04f9"), |
699 | + pentax); |
700 | + |
701 | + GList* apitek = NULL; |
702 | + apitek = g_list_append (apitek, g_strdup ("0202")); |
703 | + g_hash_table_insert (scanners, |
704 | + g_strdup("0553"), |
705 | + apitek); |
706 | + |
707 | + GList* mustek = NULL; |
708 | + mustek = g_list_append (mustek, g_strdup ("0001")); |
709 | + mustek = g_list_append (mustek, g_strdup ("0002")); |
710 | + mustek = g_list_append (mustek, g_strdup ("0006")); |
711 | + mustek = g_list_append (mustek, g_strdup ("0008")); |
712 | + mustek = g_list_append (mustek, g_strdup ("0010")); |
713 | + mustek = g_list_append (mustek, g_strdup ("0210")); |
714 | + mustek = g_list_append (mustek, g_strdup ("0218")); |
715 | + mustek = g_list_append (mustek, g_strdup ("0219")); |
716 | + mustek = g_list_append (mustek, g_strdup ("021a")); |
717 | + mustek = g_list_append (mustek, g_strdup ("021b")); |
718 | + mustek = g_list_append (mustek, g_strdup ("021c")); |
719 | + mustek = g_list_append (mustek, g_strdup ("021d")); |
720 | + mustek = g_list_append (mustek, g_strdup ("021e")); |
721 | + mustek = g_list_append (mustek, g_strdup ("021f")); |
722 | + mustek = g_list_append (mustek, g_strdup ("0409")); |
723 | + g_hash_table_insert (scanners, |
724 | + g_strdup("055f"), |
725 | + mustek); |
726 | + GList* artec = NULL; |
727 | + artec = g_list_append (artec, g_strdup ("4002")); |
728 | + artec = g_list_append (artec, g_strdup ("4003")); |
729 | + artec = g_list_append (artec, g_strdup ("4004")); |
730 | + artec = g_list_append (artec, g_strdup ("4005")); |
731 | + artec = g_list_append (artec, g_strdup ("4006")); |
732 | + artec = g_list_append (artec, g_strdup ("4007")); |
733 | + artec = g_list_append (artec, g_strdup ("4009")); |
734 | + artec = g_list_append (artec, g_strdup ("4010")); |
735 | + artec = g_list_append (artec, g_strdup ("4011")); |
736 | + g_hash_table_insert (scanners, |
737 | + g_strdup("05d8"), |
738 | + artec); |
739 | + |
740 | + GList* microtek = NULL; |
741 | + microtek = g_list_append (microtek, g_strdup ("0099")); |
742 | + microtek = g_list_append (microtek, g_strdup ("009a")); |
743 | + microtek = g_list_append (microtek, g_strdup ("00a3")); |
744 | + microtek = g_list_append (microtek, g_strdup ("00b6")); |
745 | + microtek = g_list_append (microtek, g_strdup ("30cf")); |
746 | + microtek = g_list_append (microtek, g_strdup ("30d4")); |
747 | + microtek = g_list_append (microtek, g_strdup ("40b3")); |
748 | + microtek = g_list_append (microtek, g_strdup ("40b8")); |
749 | + microtek = g_list_append (microtek, g_strdup ("40ca")); |
750 | + microtek = g_list_append (microtek, g_strdup ("40cb")); |
751 | + microtek = g_list_append (microtek, g_strdup ("40dd")); |
752 | + microtek = g_list_append (microtek, g_strdup ("40ff")); |
753 | + microtek = g_list_append (microtek, g_strdup ("80a3")); |
754 | + g_hash_table_insert (scanners, |
755 | + g_strdup("05da"), |
756 | + microtek); |
757 | + |
758 | + GList* avision = NULL; |
759 | + avision = g_list_append (avision, g_strdup ("0268")); |
760 | + avision = g_list_append (avision, g_strdup ("026a")); |
761 | + avision = g_list_append (avision, g_strdup ("0a13")); |
762 | + avision = g_list_append (avision, g_strdup ("0a15")); |
763 | + avision = g_list_append (avision, g_strdup ("0a16")); |
764 | + avision = g_list_append (avision, g_strdup ("0a18")); |
765 | + avision = g_list_append (avision, g_strdup ("0a19")); |
766 | + avision = g_list_append (avision, g_strdup ("0a23")); |
767 | + avision = g_list_append (avision, g_strdup ("0a24")); |
768 | + avision = g_list_append (avision, g_strdup ("0a25")); |
769 | + avision = g_list_append (avision, g_strdup ("0a27")); |
770 | + avision = g_list_append (avision, g_strdup ("0a2a")); |
771 | + avision = g_list_append (avision, g_strdup ("0a2b")); |
772 | + avision = g_list_append (avision, g_strdup ("0a2c")); |
773 | + avision = g_list_append (avision, g_strdup ("0a2d")); |
774 | + avision = g_list_append (avision, g_strdup ("0a2e")); |
775 | + avision = g_list_append (avision, g_strdup ("0a2f")); |
776 | + avision = g_list_append (avision, g_strdup ("0a33")); |
777 | + avision = g_list_append (avision, g_strdup ("0a3a")); |
778 | + avision = g_list_append (avision, g_strdup ("0a3c")); |
779 | + avision = g_list_append (avision, g_strdup ("0a40")); |
780 | + avision = g_list_append (avision, g_strdup ("0a41")); |
781 | + avision = g_list_append (avision, g_strdup ("0a45")); |
782 | + avision = g_list_append (avision, g_strdup ("0a4d")); |
783 | + avision = g_list_append (avision, g_strdup ("0a4e")); |
784 | + avision = g_list_append (avision, g_strdup ("0a4f")); |
785 | + avision = g_list_append (avision, g_strdup ("0a5e")); |
786 | + avision = g_list_append (avision, g_strdup ("0a61")); |
787 | + avision = g_list_append (avision, g_strdup ("0a65")); |
788 | + avision = g_list_append (avision, g_strdup ("0a66")); |
789 | + avision = g_list_append (avision, g_strdup ("0a68")); |
790 | + avision = g_list_append (avision, g_strdup ("0a82")); |
791 | + avision = g_list_append (avision, g_strdup ("0a84")); |
792 | + avision = g_list_append (avision, g_strdup ("0a93")); |
793 | + avision = g_list_append (avision, g_strdup ("0a94")); |
794 | + avision = g_list_append (avision, g_strdup ("0aa1")); |
795 | + avision = g_list_append (avision, g_strdup ("1a35")); |
796 | + g_hash_table_insert (scanners, |
797 | + g_strdup("0638"), |
798 | + avision); |
799 | + GList* minolta = NULL; |
800 | + minolta = g_list_append (minolta, g_strdup ("4004")); |
801 | + minolta = g_list_append (minolta, g_strdup ("400d")); |
802 | + minolta = g_list_append (minolta, g_strdup ("400e")); |
803 | + g_hash_table_insert (scanners, |
804 | + g_strdup("0686"), |
805 | + minolta); |
806 | + |
807 | + GList* agfa = NULL; |
808 | + agfa = g_list_append (agfa, g_strdup ("0001")); |
809 | + agfa = g_list_append (agfa, g_strdup ("0002")); |
810 | + agfa = g_list_append (agfa, g_strdup ("0100")); |
811 | + agfa = g_list_append (agfa, g_strdup ("2061")); |
812 | + agfa = g_list_append (agfa, g_strdup ("208d")); |
813 | + agfa = g_list_append (agfa, g_strdup ("208f")); |
814 | + agfa = g_list_append (agfa, g_strdup ("2091")); |
815 | + agfa = g_list_append (agfa, g_strdup ("2093")); |
816 | + agfa = g_list_append (agfa, g_strdup ("2095")); |
817 | + agfa = g_list_append (agfa, g_strdup ("2097")); |
818 | + agfa = g_list_append (agfa, g_strdup ("20fd")); |
819 | + agfa = g_list_append (agfa, g_strdup ("20ff")); |
820 | + g_hash_table_insert (scanners, |
821 | + g_strdup("06bd"), |
822 | + minolta); |
823 | + |
824 | + GList* umax_2 = NULL; |
825 | + umax_2 = g_list_append (umax_2, g_strdup ("0020")); |
826 | + g_hash_table_insert (scanners, |
827 | + g_strdup("06dc"), |
828 | + umax_2); |
829 | + |
830 | + GList* plustek = NULL; |
831 | + |
832 | + plustek = g_list_append (plustek, g_strdup ("0001")); |
833 | + plustek = g_list_append (plustek, g_strdup ("0010")); |
834 | + plustek = g_list_append (plustek, g_strdup ("0011")); |
835 | + plustek = g_list_append (plustek, g_strdup ("0013")); |
836 | + plustek = g_list_append (plustek, g_strdup ("0015")); |
837 | + plustek = g_list_append (plustek, g_strdup ("0017")); |
838 | + plustek = g_list_append (plustek, g_strdup ("0400")); |
839 | + plustek = g_list_append (plustek, g_strdup ("0401")); |
840 | + plustek = g_list_append (plustek, g_strdup ("0402")); |
841 | + plustek = g_list_append (plustek, g_strdup ("0403")); |
842 | + plustek = g_list_append (plustek, g_strdup ("040b")); |
843 | + plustek = g_list_append (plustek, g_strdup ("040e")); |
844 | + plustek = g_list_append (plustek, g_strdup ("0412")); |
845 | + plustek = g_list_append (plustek, g_strdup ("0413")); |
846 | + plustek = g_list_append (plustek, g_strdup ("0422")); |
847 | + plustek = g_list_append (plustek, g_strdup ("0454")); |
848 | + plustek = g_list_append (plustek, g_strdup ("045f")); |
849 | + plustek = g_list_append (plustek, g_strdup ("0462")); |
850 | + plustek = g_list_append (plustek, g_strdup ("0900")); |
851 | + g_hash_table_insert (scanners, |
852 | + g_strdup("07b3"), |
853 | + plustek); |
854 | + |
855 | + GList* corex = NULL; |
856 | + corex = g_list_append (corex, g_strdup ("0002")); |
857 | + corex = g_list_append (corex, g_strdup ("0005")); |
858 | + g_hash_table_insert (scanners, |
859 | + g_strdup("08f0"), |
860 | + corex); |
861 | + |
862 | + GList* xerox = NULL; |
863 | + xerox = g_list_append (xerox, g_strdup ("3d5d")); |
864 | + xerox = g_list_append (xerox, g_strdup ("3da4")); |
865 | + xerox = g_list_append (xerox, g_strdup ("420c")); |
866 | + xerox = g_list_append (xerox, g_strdup ("4265")); |
867 | + xerox = g_list_append (xerox, g_strdup ("4293")); |
868 | + xerox = g_list_append (xerox, g_strdup ("4294")); |
869 | + g_hash_table_insert (scanners, |
870 | + g_strdup("0924"), |
871 | + xerox); |
872 | + |
873 | + GList* pentax_2 = NULL; |
874 | + pentax_2 = g_list_append (pentax_2, g_strdup ("3210")); |
875 | + g_hash_table_insert (scanners, |
876 | + g_strdup("0a17"), |
877 | + pentax_2); |
878 | + |
879 | + GList* portable = NULL; |
880 | + portable = g_list_append (portable, g_strdup ("1000")); |
881 | + g_hash_table_insert (scanners, |
882 | + g_strdup("0a53"), |
883 | + portable); |
884 | + |
885 | + GList* syscan = NULL; |
886 | + syscan = g_list_append (syscan, g_strdup ("4600")); |
887 | + syscan = g_list_append (syscan, g_strdup ("4802")); |
888 | + syscan = g_list_append (syscan, g_strdup ("4803")); |
889 | + syscan = g_list_append (syscan, g_strdup ("480c")); |
890 | + syscan = g_list_append (syscan, g_strdup ("4810")); |
891 | + syscan = g_list_append (syscan, g_strdup ("6620")); |
892 | + g_hash_table_insert (scanners, |
893 | + g_strdup("0a82"), |
894 | + syscan); |
895 | + |
896 | + GList* canon_2 = NULL; |
897 | + canon_2 = g_list_append (canon_2, g_strdup ("160c")); |
898 | + canon_2 = g_list_append (canon_2, g_strdup ("160f")); |
899 | + canon_2 = g_list_append (canon_2, g_strdup ("1614")); |
900 | + canon_2 = g_list_append (canon_2, g_strdup ("1617")); |
901 | + canon_2 = g_list_append (canon_2, g_strdup ("1618")); |
902 | + canon_2 = g_list_append (canon_2, g_strdup ("161a")); |
903 | + canon_2 = g_list_append (canon_2, g_strdup ("161b")); |
904 | + canon_2 = g_list_append (canon_2, g_strdup ("161d")); |
905 | + canon_2 = g_list_append (canon_2, g_strdup ("1620")); |
906 | + canon_2 = g_list_append (canon_2, g_strdup ("1622")); |
907 | + canon_2 = g_list_append (canon_2, g_strdup ("1623")); |
908 | + canon_2 = g_list_append (canon_2, g_strdup ("1624")); |
909 | + canon_2 = g_list_append (canon_2, g_strdup ("1626")); |
910 | + canon_2 = g_list_append (canon_2, g_strdup ("162b")); |
911 | + canon_2 = g_list_append (canon_2, g_strdup ("1638")); |
912 | + canon_2 = g_list_append (canon_2, g_strdup ("1639")); |
913 | + g_hash_table_insert (scanners, |
914 | + g_strdup("1083"), |
915 | + canon_2); |
916 | + |
917 | + GList* digital = NULL; |
918 | + digital = g_list_append (digital, g_strdup ("0001")); |
919 | + g_hash_table_insert (scanners, |
920 | + g_strdup("1183"), |
921 | + digital); |
922 | + |
923 | + GList* konica_2 = NULL; |
924 | + konica_2 = g_list_append (konica_2, g_strdup ("2089")); |
925 | + g_hash_table_insert (scanners, |
926 | + g_strdup("132b"), |
927 | + konica_2); |
928 | + |
929 | + GList* umax = NULL; |
930 | + umax = g_list_append (umax, g_strdup ("0010")); |
931 | + umax = g_list_append (umax, g_strdup ("0030")); |
932 | + umax = g_list_append (umax, g_strdup ("0050")); |
933 | + umax = g_list_append (umax, g_strdup ("0060")); |
934 | + umax = g_list_append (umax, g_strdup ("0070")); |
935 | + umax = g_list_append (umax, g_strdup ("0130")); |
936 | + umax = g_list_append (umax, g_strdup ("0160")); |
937 | + umax = g_list_append (umax, g_strdup ("0230")); |
938 | + g_hash_table_insert (scanners, |
939 | + g_strdup("1606"), |
940 | + umax); |
941 | + |
942 | + GList* docketport = NULL; |
943 | + docketport = g_list_append (docketport, g_strdup ("4810")); |
944 | + g_hash_table_insert (scanners, |
945 | + g_strdup("1dcc"), |
946 | + docketport); |
947 | + |
948 | + GList* dell = NULL; |
949 | + dell = g_list_append (dell, g_strdup ("5105")); |
950 | + dell = g_list_append (dell, g_strdup ("5124")); |
951 | + dell = g_list_append (dell, g_strdup ("5250")); |
952 | + g_hash_table_insert (scanners, |
953 | + g_strdup("413c"), |
954 | + dell); |
955 | +} |
956 | |
957 | === modified file 'src/udev-mgr.c' |
958 | --- src/udev-mgr.c 2011-07-19 18:53:15 +0000 |
959 | +++ src/udev-mgr.c 2011-08-09 11:36:39 +0000 |
960 | @@ -17,22 +17,120 @@ |
961 | with this program. If not, see <http://www.gnu.org/licenses/>. |
962 | */ |
963 | |
964 | +#include <gudev/gudev.h> |
965 | + |
966 | +// TEMP |
967 | +#include <stdio.h> |
968 | +#include <string.h> |
969 | +#include <stdlib.h> |
970 | +#include <stdarg.h> |
971 | + |
972 | #include "udev-mgr.h" |
973 | +#include "sane-rules.h" |
974 | + |
975 | +static void udevice_mgr_device_list_iterator (gpointer data, |
976 | + gpointer userdata); |
977 | +static void udev_mgr_uevent_cb (GUdevClient *client, |
978 | + gchar *action, |
979 | + GUdevDevice *device, |
980 | + gpointer user_data); |
981 | +static void udev_mgr_update_menuitems (UdevMgr* self); |
982 | +static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, |
983 | + GUdevDevice *device, |
984 | + UdevMgrDeviceAction action); |
985 | +static void udev_mgr_handle_webcam (UdevMgr* self, |
986 | + GUdevDevice* device, |
987 | + UdevMgrDeviceAction action); |
988 | +static void udev_mgr_handle_scsi_device (UdevMgr* self, |
989 | + GUdevDevice* device, |
990 | + UdevMgrDeviceAction action); |
991 | + |
992 | +static void udev_mgr_cleanup_lists(gpointer data, gpointer self); |
993 | +static void udev_mgr_cleanup_entries(gpointer data, gpointer self); |
994 | + |
995 | + |
996 | +static void debug_device (UdevMgr* self, |
997 | + GUdevDevice* device, |
998 | + UdevMgrDeviceAction action); |
999 | + |
1000 | + |
1001 | +struct _UdevMgr |
1002 | +{ |
1003 | + GObject parent_instance; |
1004 | + DbusmenuMenuitem* scanner_item; |
1005 | + DbusmenuMenuitem* webcam_item; |
1006 | + GUdevClient* client; |
1007 | + GHashTable* supported_usb_scanners; |
1008 | + GHashTable* supported_scsi_scanners; |
1009 | + GHashTable* scanners_present; |
1010 | + GHashTable* webcams_present; |
1011 | +}; |
1012 | + |
1013 | +const char *subsystems[3] = {"usb", "scsi", "video4linux"}; |
1014 | +const gchar* usb_subsystem = "usb"; |
1015 | +const gchar* scsi_subsystem = "scsi"; |
1016 | +const gchar* video4linux_subsystem = "video4linux"; |
1017 | |
1018 | |
1019 | G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); |
1020 | |
1021 | static void |
1022 | -udev_mgr_init (UdevMgr *object) |
1023 | -{ |
1024 | - /* TODO: Add initialization code here */ |
1025 | +udev_mgr_init (UdevMgr* self) |
1026 | +{ |
1027 | + self->client = NULL; |
1028 | + self->supported_usb_scanners = NULL; |
1029 | + self->scanners_present = NULL; |
1030 | + self->webcams_present = NULL; |
1031 | + self->client = g_udev_client_new (subsystems); |
1032 | + self->supported_usb_scanners = g_hash_table_new_full (g_str_hash, |
1033 | + g_str_equal, |
1034 | + g_free, |
1035 | + (GDestroyNotify)udev_mgr_cleanup_lists); |
1036 | + self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash, |
1037 | + g_str_equal, |
1038 | + g_free, |
1039 | + (GDestroyNotify)udev_mgr_cleanup_lists); |
1040 | + self->scanners_present = g_hash_table_new_full (g_str_hash, |
1041 | + g_str_equal, |
1042 | + g_free, |
1043 | + g_free); |
1044 | + self->webcams_present = g_hash_table_new_full (g_str_hash, |
1045 | + g_str_equal, |
1046 | + g_free, |
1047 | + g_free); |
1048 | + |
1049 | + // load into memory all supported scanners ... |
1050 | + populate_usb_scanners (self->supported_usb_scanners); |
1051 | + populate_scsi_scanners (self->supported_scsi_scanners); |
1052 | + g_signal_connect (G_OBJECT (self->client), |
1053 | + "uevent", |
1054 | + G_CALLBACK (udev_mgr_uevent_cb), |
1055 | + self); |
1056 | +} |
1057 | + |
1058 | +static void |
1059 | +udev_mgr_cleanup_lists(gpointer data, gpointer self) |
1060 | +{ |
1061 | + GList* scanners = (GList*)data; |
1062 | + g_list_foreach (scanners, udev_mgr_cleanup_entries, NULL); |
1063 | + g_list_free(scanners); |
1064 | +} |
1065 | + |
1066 | +static void |
1067 | +udev_mgr_cleanup_entries(gpointer data, gpointer self) |
1068 | +{ |
1069 | + gchar* entry = (gchar*)data; |
1070 | + g_free(entry); |
1071 | } |
1072 | |
1073 | static void |
1074 | udev_mgr_finalize (GObject *object) |
1075 | { |
1076 | - /* TODO: Add deinitalization code here */ |
1077 | - |
1078 | + UdevMgr* self = UDEV_MGR (object); |
1079 | + g_hash_table_destroy (self->supported_scsi_scanners); |
1080 | + g_hash_table_destroy (self->supported_usb_scanners); |
1081 | + g_hash_table_destroy (self->scanners_present); |
1082 | + g_hash_table_destroy (self->webcams_present); |
1083 | G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object); |
1084 | } |
1085 | |
1086 | @@ -40,7 +138,319 @@ |
1087 | udev_mgr_class_init (UdevMgrClass *klass) |
1088 | { |
1089 | GObjectClass* object_class = G_OBJECT_CLASS (klass); |
1090 | - |
1091 | object_class->finalize = udev_mgr_finalize; |
1092 | } |
1093 | |
1094 | +static void |
1095 | +udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) |
1096 | +{ |
1097 | + g_return_if_fail (G_UDEV_IS_DEVICE (data)); |
1098 | + g_return_if_fail (UDEV_IS_MGR (userdata)); |
1099 | + |
1100 | + UdevMgr* self = UDEV_MGR (userdata); |
1101 | + |
1102 | + GUdevDevice* device = G_UDEV_DEVICE (data); |
1103 | + |
1104 | + const gchar* subsystem = NULL; |
1105 | + subsystem = g_udev_device_get_subsystem (device); |
1106 | + |
1107 | + if (g_strcmp0 (subsystem, "usb") == 0){ |
1108 | + udev_mgr_check_if_usb_device_is_supported (self, device, ADD); |
1109 | + } |
1110 | + else if (g_strcmp0 (subsystem, "video4linux") == 0){ |
1111 | + udev_mgr_handle_webcam (self, device, ADD); |
1112 | + } |
1113 | + else if (g_strcmp0 (subsystem, "scsi") == 0){ |
1114 | + udev_mgr_handle_scsi_device (self, device, ADD); |
1115 | + } |
1116 | + |
1117 | + g_object_unref (device); |
1118 | +} |
1119 | + |
1120 | + |
1121 | +static void udev_mgr_update_menuitems (UdevMgr* self) |
1122 | +{ |
1123 | + dbusmenu_menuitem_property_set_bool (self->scanner_item, |
1124 | + DBUSMENU_MENUITEM_PROP_VISIBLE, |
1125 | + g_hash_table_size (self->scanners_present) > 0); |
1126 | + |
1127 | + dbusmenu_menuitem_property_set_bool (self->webcam_item, |
1128 | + DBUSMENU_MENUITEM_PROP_VISIBLE, |
1129 | + g_hash_table_size (self->webcams_present) > 0); |
1130 | + |
1131 | +} |
1132 | + |
1133 | +static void udev_mgr_uevent_cb (GUdevClient *client, |
1134 | + gchar *action, |
1135 | + GUdevDevice *device, |
1136 | + gpointer user_data) |
1137 | +{ |
1138 | + g_return_if_fail (UDEV_IS_MGR (user_data)); |
1139 | + UdevMgr* self = UDEV_MGR (user_data); |
1140 | + g_return_if_fail (device != NULL); |
1141 | + |
1142 | + g_debug ("just received a UEVENT with an action : %s", action); |
1143 | + |
1144 | + UdevMgrDeviceAction udev_mgr_action = ADD; |
1145 | + |
1146 | + if (g_strcmp0 (action, "remove") == 0){ |
1147 | + udev_mgr_action = REMOVE; |
1148 | + } |
1149 | + |
1150 | + const gchar* subsystem = NULL; |
1151 | + subsystem = g_udev_device_get_subsystem (device); |
1152 | + |
1153 | + if (g_strcmp0 (subsystem, "usb") == 0){ |
1154 | + udev_mgr_check_if_usb_device_is_supported (self, |
1155 | + device, |
1156 | + udev_mgr_action); |
1157 | + } |
1158 | + else if (g_strcmp0 (subsystem, "video4linux") == 0){ |
1159 | + udev_mgr_handle_webcam (self, device, udev_mgr_action); |
1160 | + } |
1161 | + else if (g_strcmp0 (subsystem, "scsi") == 0){ |
1162 | + udev_mgr_handle_scsi_device (self, device, udev_mgr_action); |
1163 | + } |
1164 | +} |
1165 | + |
1166 | + |
1167 | +static void |
1168 | +udev_mgr_handle_webcam (UdevMgr* self, |
1169 | + GUdevDevice* device, |
1170 | + UdevMgrDeviceAction action) |
1171 | +{ |
1172 | + if (FALSE) |
1173 | + debug_device (self, device, action); |
1174 | + |
1175 | + const gchar* vendor; |
1176 | + const gchar* product; |
1177 | + |
1178 | + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); |
1179 | + product = g_udev_device_get_property (device, "ID_MODEL_ID"); |
1180 | + |
1181 | + if (action == REMOVE){ |
1182 | + if (g_hash_table_lookup (self->webcams_present, product) == NULL){ |
1183 | + g_warning ("Got a remove event on a webcam device but we don't have that device in our webcam cache"); |
1184 | + return; |
1185 | + } |
1186 | + g_hash_table_remove (self->webcams_present, |
1187 | + product); |
1188 | + |
1189 | + } |
1190 | + else { |
1191 | + if (g_hash_table_lookup (self->webcams_present, product) != NULL){ |
1192 | + g_warning ("Got an ADD event on a webcam device but we already have that device in our webcam cache"); |
1193 | + return; |
1194 | + } |
1195 | + g_hash_table_insert (self->webcams_present, |
1196 | + g_strdup (product), |
1197 | + g_strdup (vendor)); |
1198 | + } |
1199 | + udev_mgr_update_menuitems (self); |
1200 | +} |
1201 | + |
1202 | +static void |
1203 | +debug_device (UdevMgr* self, |
1204 | + GUdevDevice* device, |
1205 | + UdevMgrDeviceAction action) |
1206 | +{ |
1207 | + const gchar* vendor; |
1208 | + const gchar* product; |
1209 | + const gchar* number; |
1210 | + const gchar* name; |
1211 | + |
1212 | + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); |
1213 | + product = g_udev_device_get_property (device, "ID_MODEL_ID"); |
1214 | + number = g_udev_device_get_number (device); |
1215 | + name = g_udev_device_get_name (device); |
1216 | + |
1217 | + g_debug ("device vendor id %s , product id of %s , number of %s and name of %s", |
1218 | + g_strdup(vendor), |
1219 | + g_strdup(product), |
1220 | + g_strdup(number), |
1221 | + g_strdup(name)); |
1222 | + |
1223 | + const gchar *const *list; |
1224 | + const gchar *const *iter; |
1225 | + char propstr[500]; |
1226 | + guint32 namelen = 0, i; |
1227 | + |
1228 | + list = g_udev_device_get_property_keys(device); |
1229 | + |
1230 | + for (iter = list; iter && *iter; iter++) { |
1231 | + if (strlen(*iter) > namelen) |
1232 | + namelen = strlen(*iter); |
1233 | + } |
1234 | + namelen++; |
1235 | + |
1236 | + for (iter = list; iter && *iter; iter++) { |
1237 | + strcpy(propstr, *iter); |
1238 | + strcat(propstr, ":"); |
1239 | + for (i = 0; i < namelen - strlen(*iter); i++) |
1240 | + strcat(propstr, " "); |
1241 | + strcat(propstr, g_udev_device_get_property(device, *iter)); |
1242 | + g_debug("%s", propstr); |
1243 | + } |
1244 | +} |
1245 | + |
1246 | +static void udev_mgr_handle_scsi_device (UdevMgr* self, |
1247 | + GUdevDevice* device, |
1248 | + UdevMgrDeviceAction action) |
1249 | +{ |
1250 | + const gchar* type = NULL; |
1251 | + type = g_udev_device_get_property (device, "TYPE"); |
1252 | + // apparently anything thats type 3 and SCSI is a Scanner |
1253 | + if (g_strcmp0 (type, "6") == 0){ |
1254 | + gchar* random_scanner_name = g_strdup_printf("%p--scanner", self); |
1255 | + g_hash_table_insert (self->scanners_present, |
1256 | + random_scanner_name, |
1257 | + g_strdup("Scanner")); |
1258 | + udev_mgr_update_menuitems (self); |
1259 | + return; |
1260 | + } |
1261 | + |
1262 | + // We only care about type 3 for the special cases below |
1263 | + if (g_strcmp0 (type, "3") != 0){ |
1264 | + return; |
1265 | + } |
1266 | + |
1267 | + const gchar* vendor = NULL; |
1268 | + vendor = g_udev_device_get_property (device, "VENDOR"); |
1269 | + |
1270 | + if (vendor == NULL) |
1271 | + return; |
1272 | + |
1273 | + GList* vendor_list = NULL; |
1274 | + vendor_list = g_hash_table_lookup (self->supported_scsi_scanners, |
1275 | + (gpointer)vendor); |
1276 | + if (vendor_list == NULL) |
1277 | + return; |
1278 | + |
1279 | + const gchar* model_id = NULL; |
1280 | + model_id = g_udev_device_get_property (device, "MODEL"); |
1281 | + |
1282 | + if (model_id == NULL) |
1283 | + return; |
1284 | + |
1285 | + GList* model_entry = NULL; |
1286 | + model_entry = g_list_find_custom (vendor_list, |
1287 | + model_id, |
1288 | + (GCompareFunc)g_strcmp0); |
1289 | + |
1290 | + if (model_entry != NULL){ |
1291 | + if (action == REMOVE){ |
1292 | + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){ |
1293 | + g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); |
1294 | + } |
1295 | + else{ |
1296 | + g_hash_table_remove (self->scanners_present, vendor); |
1297 | + } |
1298 | + } |
1299 | + else{ |
1300 | + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){ |
1301 | + g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); |
1302 | + } |
1303 | + else{ |
1304 | + g_hash_table_insert (self->scanners_present, |
1305 | + g_strdup(vendor), |
1306 | + g_strdup(model_id)); |
1307 | + } |
1308 | + } |
1309 | + udev_mgr_update_menuitems (self); |
1310 | + } |
1311 | +} |
1312 | + |
1313 | +static void |
1314 | +udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, |
1315 | + GUdevDevice *device, |
1316 | + UdevMgrDeviceAction action) |
1317 | +{ |
1318 | + const gchar* vendor = NULL; |
1319 | + debug_device (self, device, action); |
1320 | + |
1321 | + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); |
1322 | + |
1323 | + if (vendor == NULL) |
1324 | + return; |
1325 | + |
1326 | + //g_debug ("vendor = %s", vendor); |
1327 | + |
1328 | + GList* vendor_list = NULL; |
1329 | + vendor_list = g_hash_table_lookup (self->supported_usb_scanners, |
1330 | + (gpointer)vendor); |
1331 | + if (vendor_list == NULL) |
1332 | + return; |
1333 | + |
1334 | + const gchar* model_id = NULL; |
1335 | + model_id = g_udev_device_get_property (device, "ID_MODEL_ID"); |
1336 | + |
1337 | + if (model_id == NULL) |
1338 | + return; |
1339 | + |
1340 | + GList* model_entry = NULL; |
1341 | + model_entry = g_list_find_custom(vendor_list, model_id, (GCompareFunc)g_strcmp0); |
1342 | + |
1343 | + if (model_entry != NULL){ |
1344 | + if (action == REMOVE){ |
1345 | + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){ |
1346 | + g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); |
1347 | + } |
1348 | + else{ |
1349 | + g_hash_table_remove (self->scanners_present, vendor); |
1350 | + } |
1351 | + } |
1352 | + else{ |
1353 | + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){ |
1354 | + g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); |
1355 | + } |
1356 | + else{ |
1357 | + g_hash_table_insert (self->scanners_present, |
1358 | + g_strdup(vendor), |
1359 | + g_strdup(model_id)); |
1360 | + } |
1361 | + } |
1362 | + udev_mgr_update_menuitems (self); |
1363 | + } |
1364 | +} |
1365 | + |
1366 | +UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, |
1367 | + DbusmenuMenuitem* webcam) |
1368 | +{ |
1369 | + UdevMgr* mgr = g_object_new (UDEV_TYPE_MGR, NULL); |
1370 | + mgr->scanner_item = scanner; |
1371 | + mgr->webcam_item = webcam; |
1372 | + |
1373 | + // Check for USB devices |
1374 | + GList* usb_devices_available = NULL; |
1375 | + usb_devices_available = g_udev_client_query_by_subsystem (mgr->client, |
1376 | + usb_subsystem); |
1377 | + if (usb_devices_available != NULL){ |
1378 | + g_list_foreach (usb_devices_available, |
1379 | + udevice_mgr_device_list_iterator, |
1380 | + mgr); |
1381 | + |
1382 | + g_list_free (usb_devices_available); |
1383 | + } |
1384 | + // Check for webcams |
1385 | + GList* video_devices_available = NULL; |
1386 | + video_devices_available = g_udev_client_query_by_subsystem (mgr->client, |
1387 | + video4linux_subsystem); |
1388 | + if (video_devices_available != NULL){ |
1389 | + g_list_foreach (video_devices_available, |
1390 | + udevice_mgr_device_list_iterator, |
1391 | + mgr); |
1392 | + |
1393 | + g_list_free (video_devices_available); |
1394 | + } |
1395 | + // Check for SCSI devices |
1396 | + GList* scsi_devices_available = NULL; |
1397 | + scsi_devices_available = g_udev_client_query_by_subsystem (mgr->client, |
1398 | + scsi_subsystem); |
1399 | + if (scsi_devices_available != NULL){ |
1400 | + g_list_foreach (scsi_devices_available, |
1401 | + udevice_mgr_device_list_iterator, |
1402 | + mgr); |
1403 | + g_list_free (scsi_devices_available); |
1404 | + } |
1405 | + return mgr; |
1406 | +} |
1407 | |
1408 | === modified file 'src/udev-mgr.h' |
1409 | --- src/udev-mgr.h 2011-07-19 12:18:54 +0000 |
1410 | +++ src/udev-mgr.h 2011-08-09 11:36:39 +0000 |
1411 | @@ -21,6 +21,14 @@ |
1412 | #define _UDEV_MGR_H_ |
1413 | |
1414 | #include <glib-object.h> |
1415 | +#include <libdbusmenu-glib/client.h> |
1416 | + |
1417 | +#include <gtk/gtk.h> |
1418 | +#if GTK_CHECK_VERSION(3, 0, 0) |
1419 | +#include <libdbusmenu-gtk3/menuitem.h> |
1420 | +#else |
1421 | +#include <libdbusmenu-gtk/menuitem.h> |
1422 | +#endif |
1423 | |
1424 | G_BEGIN_DECLS |
1425 | |
1426 | @@ -39,12 +47,15 @@ |
1427 | GObjectClass parent_class; |
1428 | }; |
1429 | |
1430 | -struct _UdevMgr |
1431 | -{ |
1432 | - GObject parent_instance; |
1433 | -}; |
1434 | |
1435 | GType udev_mgr_get_type (void) G_GNUC_CONST; |
1436 | +UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner_item, |
1437 | + DbusmenuMenuitem* webcam_item); |
1438 | + |
1439 | +typedef enum { |
1440 | + ADD, |
1441 | + REMOVE |
1442 | +}UdevMgrDeviceAction; |
1443 | |
1444 | G_END_DECLS |
1445 | |
1446 | |
1447 | === modified file 'src/user-menu-mgr.c' |
1448 | --- src/user-menu-mgr.c 2011-07-18 11:19:38 +0000 |
1449 | +++ src/user-menu-mgr.c 2011-08-09 11:36:39 +0000 |
1450 | @@ -149,10 +149,9 @@ |
1451 | |
1452 | for (u = users; u != NULL; u = g_list_next (u)) { |
1453 | user = u->data; |
1454 | + g_debug ("%p: %s", user, user->real_name); |
1455 | user->service = self->users_dbus_interface; |
1456 | |
1457 | - g_debug ("%i %s", (gint)user->uid, user->user_name); |
1458 | - |
1459 | if (g_strcmp0(user->user_name, "guest") == 0) { |
1460 | /* Check to see if the guest has sessions and so therefore should |
1461 | get a check mark. */ |
1462 | @@ -171,13 +170,26 @@ |
1463 | |
1464 | if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { |
1465 | mi = dbusmenu_menuitem_new (); |
1466 | - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); |
1467 | + dbusmenu_menuitem_property_set (mi, |
1468 | + DBUSMENU_MENUITEM_PROP_TYPE, |
1469 | + USER_ITEM_TYPE); |
1470 | if (user->real_name_conflict) { |
1471 | gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); |
1472 | dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); |
1473 | g_free(conflictedname); |
1474 | } else { |
1475 | - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); |
1476 | + //g_debug ("%i %s", (gint)user->uid, user->real_name); |
1477 | + //g_debug ("users uid = %i", (gint)user->uid); |
1478 | + //g_debug ("users real name = %s", user->real_name); |
1479 | + if (user == NULL){ |
1480 | + g_debug ("USER pointer is NULL"); |
1481 | + return; |
1482 | + } |
1483 | + g_debug ("%p: %s", user, user->real_name); |
1484 | + |
1485 | + dbusmenu_menuitem_property_set (mi, |
1486 | + USER_ITEM_PROP_NAME, |
1487 | + user->real_name); |
1488 | } |
1489 | dbusmenu_menuitem_property_set_bool (mi, |
1490 | USER_ITEM_PROP_LOGGED_IN, |
- Your leaking all the contents of the lists you add to the hash tables as g_list_free isn't going to do anything to the data the list points too. I think you need to initially do something like iterate the hash table, which then calls g_list_foreach on every value with g_free.
- gchar* random_scanner_name = g_strdup_ printf( "%p--scanner" , self); table_insert (self-> scanners_ present,
g_strdup( random_ scanner_ name),
g_strdup( "Scanner" )); scanner_ name);
g_hash_
g_free (random_
just don't free random_scanner_name and send it in without g_strdup?
Apart from that, nothing jumps out at me. However, I can't mark as approved as it crashes every time on my system with the same backtrace as we spoke about (when trying to register the DBus Service). I tried lp:indicator-session and it runs fine, so it's definitely something in this branch :/
I'll have another look at the diff tomorrow morning, but if your around it would be good to maybe go through on Mumble or something to see if there's something we've missed?