Lines 88-110
static void dp_hal_device_prop
Link Here
|
88 |
dbus_bool_t is_removed, |
88 |
dbus_bool_t is_removed, |
89 |
dbus_bool_t is_added); |
89 |
dbus_bool_t is_added); |
90 |
|
90 |
|
|
|
91 |
#ifndef USE_NEW_DBUS_HAL_API |
92 |
|
91 |
static void dp_hal_device_condition_cb (LibHalContext *ctx, |
93 |
static void dp_hal_device_condition_cb (LibHalContext *ctx, |
92 |
const char *udi, |
94 |
const char *udi, |
93 |
const char *cond_name, |
95 |
const char *cond_name, |
94 |
DBusMessage *msg); |
96 |
DBusMessage *msg); |
|
|
97 |
#else |
98 |
|
99 |
static void dp_hal_device_condition_cb (LibHalContext *ctx, |
100 |
const char *udi, |
101 |
const char *cond_name, |
102 |
const char *cond_detail); |
103 |
|
104 |
#endif |
95 |
|
105 |
|
96 |
/* variables */ |
106 |
/* variables */ |
97 |
|
107 |
|
98 |
static GObjectClass *dp_parent_class; /* NULL */ |
108 |
static GObjectClass *dp_parent_class; /* NULL */ |
99 |
|
109 |
|
100 |
|
110 |
|
101 |
|
|
|
102 |
/*************************************************************************** |
111 |
/*************************************************************************** |
103 |
* |
112 |
* |
104 |
* disc_drive_hal_cb_funcs |
113 |
* disc_drive_hal_cb_funcs |
105 |
* |
114 |
* |
106 |
***************************************************************************/ |
115 |
***************************************************************************/ |
107 |
|
116 |
|
|
|
117 |
#ifndef USE_NEW_DBUS_HAL_API |
108 |
static const LibHalFunctions disc_drive_hal_cb_funcs = |
118 |
static const LibHalFunctions disc_drive_hal_cb_funcs = |
109 |
{ |
119 |
{ |
110 |
dp_hal_main_loop_hook_cb, /* main loop integration */ |
120 |
dp_hal_main_loop_hook_cb, /* main loop integration */ |
Lines 115-120
static const LibHalFunctions disc_drive_
Link Here
|
115 |
dp_hal_device_prop_mod_cb, /* device property modified */ |
125 |
dp_hal_device_prop_mod_cb, /* device property modified */ |
116 |
dp_hal_device_condition_cb /* device condiiton */ |
126 |
dp_hal_device_condition_cb /* device condiiton */ |
117 |
}; |
127 |
}; |
|
|
128 |
#endif /* USE_NEW_DBUS_HAL_API */ |
118 |
|
129 |
|
119 |
/*************************************************************************** |
130 |
/*************************************************************************** |
120 |
* |
131 |
* |
Lines 194-201
device_pool_instance_init (ThDevicePool
Link Here
|
194 |
|
205 |
|
195 |
pool->priv = g_new0 (ThDevicePoolPrivate, 1); |
206 |
pool->priv = g_new0 (ThDevicePoolPrivate, 1); |
196 |
|
207 |
|
|
|
208 |
#ifdef USE_NEW_DBUS_HAL_API |
209 |
new_hal_ctx = libhal_ctx_new(); |
210 |
libhal_ctx_set_cache (new_hal_ctx, TRUE); |
211 |
libhal_ctx_set_device_added (new_hal_ctx, dp_hal_device_added_cb); |
212 |
libhal_ctx_set_device_removed (new_hal_ctx, dp_hal_device_removed_cb); |
213 |
libhal_ctx_set_device_new_capability (new_hal_ctx, dp_hal_device_new_cap_cb); |
214 |
libhal_ctx_set_device_lost_capability (new_hal_ctx, dp_hal_device_lost_cap_cb); |
215 |
libhal_ctx_set_device_property_modified (new_hal_ctx, dp_hal_device_prop_mod_cb); |
216 |
libhal_ctx_set_device_condition (new_hal_ctx, dp_hal_device_condition_cb); |
217 |
|
218 |
{ |
219 |
DBusConnection *conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); |
220 |
if (conn == NULL) |
221 |
{ |
222 |
g_warning ("dbus_bus_get(DBUS_BUS_SYSTEM) failed at %s!\n", G_STRLOC); |
223 |
} |
224 |
else |
225 |
{ |
226 |
libhal_ctx_set_dbus_connection (new_hal_ctx, conn); |
227 |
dp_hal_main_loop_hook_cb (new_hal_ctx, conn); |
228 |
} |
229 |
} |
230 |
|
231 |
if (!libhal_ctx_init (new_hal_ctx, NULL)) |
232 |
g_warning ("libhal_ctx_init() failed at %s!\n", G_STRLOC); |
233 |
|
234 |
#else |
235 |
|
197 |
new_hal_ctx = hal_initialize (&disc_drive_hal_cb_funcs, TRUE); |
236 |
new_hal_ctx = hal_initialize (&disc_drive_hal_cb_funcs, TRUE); |
198 |
|
237 |
|
|
|
238 |
#endif /* USE_NEW_DBUS_HAL_API */ |
239 |
|
199 |
|
240 |
|
200 |
/* we will get a NULL context if libhal cannot connect |
241 |
/* we will get a NULL context if libhal cannot connect |
201 |
* to the dbus message bus. we will get a valid context |
242 |
* to the dbus message bus. we will get a valid context |
Lines 236-243
device_pool_finalize (GObject *object)
Link Here
|
236 |
|
277 |
|
237 |
if (pool->priv->hal_ctx) |
278 |
if (pool->priv->hal_ctx) |
238 |
{ |
279 |
{ |
|
|
280 |
#ifndef USE_NEW_DBUS_HAL_API |
239 |
if (hal_shutdown (pool->priv->hal_ctx) != 0) |
281 |
if (hal_shutdown (pool->priv->hal_ctx) != 0) |
240 |
g_printerr ("ThDevicePool: hal_shutdown() problem!?\n"); |
282 |
g_printerr ("ThDevicePool: hal_shutdown() problem!\n"); |
|
|
283 |
#else |
284 |
if (!libhal_ctx_shutdown (pool->priv->hal_ctx, NULL)) |
285 |
g_printerr ("ThDevicePool: libhal_ctx_shutdown() problem!\n"); |
286 |
libhal_ctx_free (pool->priv->hal_ctx); |
287 |
#endif |
241 |
} |
288 |
} |
242 |
|
289 |
|
243 |
for (l = pool->priv->trackers; l; l = l->next) |
290 |
for (l = pool->priv->trackers; l; l = l->next) |
Lines 312-318
dp_reconnect_to_hal_cb (ThDevicePool *po
Link Here
|
312 |
|
359 |
|
313 |
g_message ("Trying to reconnect to HAL..."); |
360 |
g_message ("Trying to reconnect to HAL..."); |
314 |
|
361 |
|
|
|
362 |
#ifdef USE_NEW_DBUS_HAL_API |
363 |
new_hal_ctx = libhal_ctx_new(); |
364 |
libhal_ctx_set_cache (new_hal_ctx, TRUE); |
365 |
libhal_ctx_set_device_added (new_hal_ctx, dp_hal_device_added_cb); |
366 |
libhal_ctx_set_device_removed (new_hal_ctx, dp_hal_device_removed_cb); |
367 |
libhal_ctx_set_device_new_capability (new_hal_ctx, dp_hal_device_new_cap_cb); |
368 |
libhal_ctx_set_device_lost_capability (new_hal_ctx, dp_hal_device_lost_cap_cb); |
369 |
libhal_ctx_set_device_property_modified (new_hal_ctx, dp_hal_device_prop_mod_cb); |
370 |
libhal_ctx_set_device_condition (new_hal_ctx, dp_hal_device_condition_cb); |
371 |
|
372 |
{ |
373 |
DBusConnection *conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); |
374 |
if (conn == NULL) |
375 |
{ |
376 |
g_warning ("dbus_bus_get(DBUS_BUS_SYSTEM) failed at %s!\n", G_STRLOC); |
377 |
} |
378 |
else |
379 |
{ |
380 |
libhal_ctx_set_dbus_connection (new_hal_ctx, conn); |
381 |
dp_hal_main_loop_hook_cb (new_hal_ctx, conn); |
382 |
} |
383 |
} |
384 |
|
385 |
if (!libhal_ctx_init (new_hal_ctx, NULL)) |
386 |
g_warning ("libhal_ctx_init() failed at %s!\n", G_STRLOC); |
387 |
#else |
315 |
new_hal_ctx = hal_initialize (&disc_drive_hal_cb_funcs, TRUE); |
388 |
new_hal_ctx = hal_initialize (&disc_drive_hal_cb_funcs, TRUE); |
|
|
389 |
#endif |
316 |
|
390 |
|
317 |
if (new_hal_ctx) |
391 |
if (new_hal_ctx) |
318 |
{ |
392 |
{ |
Lines 517-522
dp_hal_device_prop_mod_cb (LibHalContext
Link Here
|
517 |
* |
591 |
* |
518 |
***************************************************************************/ |
592 |
***************************************************************************/ |
519 |
|
593 |
|
|
|
594 |
#ifndef USE_NEW_DBUS_HAL_API |
595 |
|
520 |
static void |
596 |
static void |
521 |
dp_hal_device_condition_cb (LibHalContext *ctx, const char *udi, const char *cond_name, DBusMessage *msg) |
597 |
dp_hal_device_condition_cb (LibHalContext *ctx, const char *udi, const char *cond_name, DBusMessage *msg) |
522 |
{ |
598 |
{ |
Lines 534-539
dp_hal_device_condition_cb (LibHalContex
Link Here
|
534 |
} |
610 |
} |
535 |
} |
611 |
} |
536 |
|
612 |
|
|
|
613 |
#else /* USE_NEW_DBUS_HAL_API */ |
614 |
|
615 |
static void |
616 |
dp_hal_device_condition_cb (LibHalContext *ctx, const char *udi, const char *cond_name, const char *msg_detail) |
617 |
{ |
618 |
ThDevicePool *pool; |
619 |
GList *l; |
620 |
|
621 |
pool = hal_ctx_get_device_pool (ctx); |
622 |
g_return_if_fail (TH_IS_DEVICE_POOL (pool)); |
623 |
|
624 |
for (l = pool->priv->trackers; l; l = l->next) |
625 |
{ |
626 |
ThDeviceTracker *tracker = TH_DEVICE_TRACKER (l->data); |
627 |
|
628 |
th_device_tracker_dev_condition (tracker, udi, cond_name, msg_detail); |
629 |
} |
630 |
} |
631 |
|
632 |
#endif /* USE_NEW_DBUS_HAL_API */ |
633 |
|
537 |
/*************************************************************************** |
634 |
/*************************************************************************** |
538 |
* |
635 |
* |
539 |
* device_pool_device_is_volume |
636 |
* device_pool_device_is_volume |