Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 80282
Collapse All | Expand All

(-)src/th-device-pool.c (-2 / +99 lines)
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
(-)src/th-device-tracker.c (+19 lines)
Lines 196-201 th_device_tracker_prop_mod (ThDeviceTrac Link Here
196
 *
196
 *
197
 ***************************************************************************/
197
 ***************************************************************************/
198
198
199
#ifndef USE_NEW_DBUS_HAL_API
200
199
void  
201
void  
200
th_device_tracker_dev_condition (ThDeviceTracker *tracker, 
202
th_device_tracker_dev_condition (ThDeviceTracker *tracker, 
201
                                 const gchar     *udi, 
203
                                 const gchar     *udi, 
Lines 211-214 th_device_tracker_dev_condition (ThDevic Link Here
211
		TH_DEVICE_TRACKER_GET_IFACE (tracker)->dev_condition (tracker, udi, cond_name, msg);
213
		TH_DEVICE_TRACKER_GET_IFACE (tracker)->dev_condition (tracker, udi, cond_name, msg);
212
}
214
}
213
215
216
#else
217
218
void  
219
th_device_tracker_dev_condition (ThDeviceTracker *tracker, 
220
                                 const gchar     *udi, 
221
                                 const gchar     *cond_name,
222
                                 const gchar     *cond_detail)
223
{
224
	g_return_if_fail (TH_IS_DEVICE_TRACKER (tracker));
225
	g_return_if_fail (udi != NULL);
226
	g_return_if_fail (cond_name != NULL);
227
228
	if (TH_DEVICE_TRACKER_GET_IFACE (tracker)->dev_condition != NULL)
229
		TH_DEVICE_TRACKER_GET_IFACE (tracker)->dev_condition (tracker, udi, cond_name, cond_detail);
230
}
231
232
#endif /* USE_NEW_DBUS_HAL_API */
214
233
(-)src/th-device-tracker.h (+53 lines)
Lines 21-26 Link Here
21
#include <libhal.h>
21
#include <libhal.h>
22
#include <glib-object.h>
22
#include <glib-object.h>
23
23
24
#include <dbus/dbus-glib-lowlevel.h>
25
/* dbus-glib >= 0.30 */
26
#ifdef DBUS_TYPE_PENDING_CALL
27
# define USE_NEW_DBUS_HAL_API
28
# warning ****************************************************************
29
# warning *
30
# warning *  It seems like you are using dbus >= 0.30 and hal >= 0.5.0
31
# warning *
32
# warning *  Please be advised that this code has not been tested with
33
# warning *   this configuration yet, it has just been fixed to compile.
34
# warning *
35
# warning *  Please let me know whether DVD drive detection works on
36
# warning *   your system, and please do send the log as well (so I
37
# warning *   can see whether the drives were actually detected via
38
# warning *   HAL or using the backup methods). Thanks!
39
# warning *
40
# warning ****************************************************************
41
#endif
42
43
#ifdef USE_NEW_DBUS_HAL_API
44
# define hal_ctx_get_user_data(ctx)                  libhal_ctx_get_user_data(ctx)
45
# define hal_ctx_set_user_data(ctx,user_data)        libhal_ctx_set_user_data(ctx,user_data)
46
# define hal_device_exists(ctx,udi)                  libhal_device_exists(ctx,udi,NULL)
47
# define hal_device_property_exists(ctx,udi,key)     libhal_device_property_exists(ctx,udi,key,NULL)
48
# define hal_device_get_property_string(ctx,udi,key) libhal_device_get_property_string(ctx,udi,key,NULL)
49
# define hal_device_get_property_uint64(ctx,udi,key) libhal_device_get_property_uint64(ctx,udi,key,NULL)
50
# define hal_device_get_property_bool(ctx,udi,key)   libhal_device_get_property_bool(ctx,udi,key,NULL)
51
# define hal_free_string(s)                          libhal_free_string(s)
52
# define hal_free_string_array(str_arr)              libhal_free_string_array(str_arr)
53
# define hal_get_all_devices(ctx,p_num_devices)      libhal_get_all_devices(ctx,p_num_devices,NULL)
54
# define DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL        DBUS_INTERFACE_LOCAL
55
#endif
56
24
#define TH_TYPE_DEVICE_TRACKER            (th_device_tracker_get_type ())
57
#define TH_TYPE_DEVICE_TRACKER            (th_device_tracker_get_type ())
25
#define TH_DEVICE_TRACKER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TH_TYPE_DEVICE_TRACKER, ThDeviceTracker))
58
#define TH_DEVICE_TRACKER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TH_TYPE_DEVICE_TRACKER, ThDeviceTracker))
26
#define TH_IS_DEVICE_TRACKER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TH_TYPE_DEVICE_TRACKER))
59
#define TH_IS_DEVICE_TRACKER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TH_TYPE_DEVICE_TRACKER))
Lines 50-59 struct _ThDeviceTrackerIface Link Here
50
	                                 gboolean         is_removed, 
83
	                                 gboolean         is_removed, 
51
	                                 gboolean         is_added);
84
	                                 gboolean         is_added);
52
	
85
	
86
#ifndef USE_NEW_DBUS_HAL_API
87
53
	void          (*dev_condition)  (ThDeviceTracker *tracker, 
88
	void          (*dev_condition)  (ThDeviceTracker *tracker, 
54
	                                 const gchar     *udi, 
89
	                                 const gchar     *udi, 
55
	                                 const gchar     *cond_name,
90
	                                 const gchar     *cond_name,
56
	                                 DBusMessage     *msg);
91
	                                 DBusMessage     *msg);
92
#else
93
94
	void          (*dev_condition)  (ThDeviceTracker *tracker, 
95
	                                 const gchar     *udi, 
96
	                                 const gchar     *cond_name,
97
	                                 const gchar     *cond_detail);
98
99
#endif /* USE_NEW_DBUS_HAL_API */
57
};
100
};
58
101
59
GType th_device_tracker_get_type       (void) G_GNUC_CONST;
102
GType th_device_tracker_get_type       (void) G_GNUC_CONST;
Lines 81-90 void th_device_tracker_prop_mod ( Link Here
81
	                                      gboolean         is_removed, 
124
	                                      gboolean         is_removed, 
82
	                                      gboolean         is_added);
125
	                                      gboolean         is_added);
83
	
126
	
127
#ifndef USE_NEW_DBUS_HAL_API
128
84
void  th_device_tracker_dev_condition  (ThDeviceTracker *tracker, 
129
void  th_device_tracker_dev_condition  (ThDeviceTracker *tracker, 
85
	                                      const gchar     *udi, 
130
	                                      const gchar     *udi, 
86
	                                      const gchar     *cond_name,
131
	                                      const gchar     *cond_name,
87
	                                      DBusMessage     *msg);
132
	                                      DBusMessage     *msg);
133
#else
134
135
void  th_device_tracker_dev_condition  (ThDeviceTracker *tracker, 
136
	                                      const gchar     *udi, 
137
	                                      const gchar     *cond_name,
138
	                                      const gchar     *cond_detail);
139
140
#endif /* USE_NEW_DBUS_HAL_API */
88
141
89
#endif /* _th_device_tracker_h_included_ */
142
#endif /* _th_device_tracker_h_included_ */
90
143
(-)src/th-disc-drive-pool.c (+14 lines)
Lines 119-129 static void disc_pool_device_p Link Here
119
                                                  gboolean         is_removed, 
119
                                                  gboolean         is_removed, 
120
                                                  gboolean         is_added);
120
                                                  gboolean         is_added);
121
121
122
#ifndef USE_NEW_DBUS_HAL_API
123
122
static void           disc_pool_device_condition (ThDeviceTracker *tracker,
124
static void           disc_pool_device_condition (ThDeviceTracker *tracker,
123
                                                  const char      *udi, 
125
                                                  const char      *udi, 
124
                                                  const char      *cond_name, 
126
                                                  const char      *cond_name, 
125
                                                  DBusMessage     *msg);
127
                                                  DBusMessage     *msg);
126
128
129
#else
130
131
static void           disc_pool_device_condition (ThDeviceTracker *tracker,
132
                                                  const char      *udi, 
133
                                                  const char      *cond_name, 
134
                                                  const gchar     *cond_detail);
135
#endif
136
127
/* variables */
137
/* variables */
128
138
129
static guint          ddp_signals[NUM_SIGNALS];  /* all 0 */
139
static guint          ddp_signals[NUM_SIGNALS];  /* all 0 */
Lines 892-898 static void Link Here
892
disc_pool_device_condition (ThDeviceTracker *tracker, 
902
disc_pool_device_condition (ThDeviceTracker *tracker, 
893
                            const gchar     *udi, 
903
                            const gchar     *udi, 
894
                            const gchar     *cond_name, 
904
                            const gchar     *cond_name, 
905
#ifndef USE_NEW_DBUS_HAL_API
895
                            DBusMessage     *msg)
906
                            DBusMessage     *msg)
907
#else
908
                            const gchar     *cond_detail)
909
#endif
896
{
910
{
897
	ThDiscDrivePool *disc_pool;
911
	ThDiscDrivePool *disc_pool;
898
912

Return to bug 80282