Magellan Linux

Contents of /trunk/kdebase/kdebase-3.4.1-hal-0.5.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (show annotations) (download)
Sun Jun 26 15:30:03 2005 UTC (18 years, 10 months ago) by niro
File size: 29587 byte(s)
new

1 This patch adds hal-0.5.x support to kdebase-3.4.1
2 Niels Rogalla, <niro@magellan-linux.net>
3
4 --- kdebase-3.4.1/kioslave/media/configure.in.in.orig 2005-05-23 12:14:18.000000000 +0000
5 +++ kdebase-3.4.1/kioslave/media/configure.in.in 2005-06-12 15:20:57.000000000 +0000
6 @@ -12,100 +12,100 @@
7 AC_ARG_WITH(hal,AC_HELP_STRING([--with-hal],[Enable HAL support [default=check]]),[hal_test="$withval"],[hal_test="yes"])
8
9 if test "x$hal_test" = "xyes" ; then
10 -
11 -########### Check for the HAL, version 0.4.x
12 -
13 - AC_MSG_CHECKING(for the HAL 0.4)
14 -
15 +
16 +########### Check for the HAL
17 +
18 + AC_MSG_CHECKING(for the HAL)
19 +
20 hal_inc=NOTFOUND
21 hal_lib=NOTFOUND
22 hal=NOTFOUND
23 -
24 - search_incs="$kde_includes /usr/include /usr/local/include /usr/include/hal /usr/local/include/hal"
25 +
26 + search_incs="$kde_includes /usr/include /usr/include/hal /usr/local/include /usr/local/include/hal"
27 AC_FIND_FILE(libhal.h libhal-storage.h, $search_incs, hal_incdir)
28 -
29 +
30 if [test -r $hal_incdir/libhal.h] && [test -r $hal_incdir/libhal-storage.h] ; then
31 HAL_INCS="-I$hal_incdir"
32 hal_inc=FOUND
33 fi
34 -
35 +
36 + if test -r $hal_incdir/libhal-storage.h ; then
37 + hal_storage_version=4
38 + grep LibHalVolume $hal_incdir/libhal-storage.h \
39 + > /dev/null 2>&1 && hal_storage_version=5
40 + if test $hal_storage_version = 4 ; then
41 + AC_DEFINE(HAL_0_4, , [HAL API version 0.4])
42 + fi
43 + fi
44 +
45 search_libs="$kde_libraries /usr/lib /usr/local/lib"
46 AC_FIND_FILE(libhal.so libhal-storage.so, $search_libs, hal_libdir)
47 -
48 +
49 if [test -r $hal_libdir/libhal.so] && [test -r $hal_libdir/libhal-storage.so] ; then
50 HAL_LIBS="-L$hal_libdir -lhal -lhal-storage"
51 hal_lib=FOUND
52 fi
53 -
54 - if test -r $hal_incdir/libhal.h ; then
55 - hal_version=5
56 - grep LibHalFunctions $hal_incdir/libhal.h \
57 - > /dev/null 2>&1 && hal_version=4
58 - if test $hal_version = 5 ; then
59 - hal_lib=NOT_FOUND
60 - fi
61 - fi
62 -
63 -
64 +
65 +
66 if [test $hal_inc = FOUND] && [test $hal_lib = FOUND] ; then
67 AC_MSG_RESULT(headers $hal_incdir libraries $hal_libdir)
68 hal=FOUND
69 else
70 AC_MSG_RESULT(searched but not found)
71 fi
72 -
73 +
74 AC_SUBST(HAL_INCS)
75 AC_SUBST(HAL_LIBS)
76 -
77 -
78 +
79 +
80 ########### Check for DBus
81 -
82 +
83 AC_MSG_CHECKING(for DBus)
84 -
85 +
86 dbus_inc=NOTFOUND
87 dbus_lib=NOTFOUND
88 dbus=NOTFOUND
89 -
90 - search_incs="$kde_includes /usr/include /usr/local/include /usr/include/dbus-1.0 /usr/local/include/dbus-1.0"
91 +
92 + search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
93 AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir)
94 -
95 +
96 search_incs_arch_deps="$kde_includes /usr/lib/dbus-1.0/include /usr/local/lib/dbus-1.0/include"
97 AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps)
98 -
99 +
100 if [test -r $dbus_incdir/dbus/dbus.h] && [test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h] ; then
101 DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps"
102 dbus_inc=FOUND
103 fi
104 -
105 +
106 search_libs="$kde_libraries /usr/lib /usr/local/lib"
107 AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir)
108 -
109 +
110 if test -r $dbus_libdir/libdbus-1.so ; then
111 DBUS_LIBS="-L$dbus_libdir -ldbus-1"
112 dbus_lib=FOUND
113 fi
114 -
115 +
116 if [test $dbus_inc = FOUND] && [test $dbus_lib = FOUND] ; then
117 AC_MSG_RESULT(headers $dbus_incdir $dbus_incdir_arch_deps libraries $dbus_libdir)
118 dbus=FOUND
119 else
120 AC_MSG_RESULT(searched but not found)
121 fi
122 -
123 +
124 AC_SUBST(DBUS_INCS)
125 AC_SUBST(DBUS_LIBS)
126 -
127 +
128 ########### Check for DBus-Qt bindings
129 -
130 +
131 AC_MSG_CHECKING(for DBus-Qt bindings)
132 -
133 +
134 dbusqt_inc=NOTFOUND
135 dbusqt_lib=NOTFOUND
136 dbusqt=NOTFOUND
137 -
138 - search_incs="$kde_includes /usr/include /usr/local/include /usr/include/dbus-1.0 /usr/local/include/dbus-1.0"
139 +
140 + search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
141 AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir)
142 -
143 +
144 if test -r $dbusqt_incdir/dbus/connection.h ; then
145 have_qt_patch=0
146 grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \
147 @@ -115,15 +115,15 @@
148 dbusqt_inc=FOUND
149 fi
150 fi
151 -
152 +
153 search_libs="$kde_libraries /usr/lib /usr/local/lib"
154 AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir)
155 -
156 +
157 if test -r $dbusqt_libdir/libdbus-qt-1.so ; then
158 DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1"
159 dbusqt_lib=FOUND
160 fi
161 -
162 +
163 if [test $dbusqt_inc = FOUND] && [test $dbusqt_lib = FOUND] ; then
164 AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir)
165 dbusqt=FOUND
166 --- kdebase-3.4.1/kioslave/media/kdedmodule/halbackend.h.orig 2005-05-23 12:14:18.000000000 +0000
167 +++ kdebase-3.4.1/kioslave/media/kdedmodule/halbackend.h 2005-06-12 15:16:27.000000000 +0000
168 @@ -35,6 +35,8 @@
169 #include <qstringlist.h>
170 #include <qstring.h>
171
172 +#include <config.h>
173 +
174 /* We acknowledge the the dbus API is unstable */
175 #define DBUS_API_SUBJECT_TO_CHANGE
176 /* DBus-Qt bindings */
177 @@ -43,6 +45,65 @@
178 #include <libhal.h>
179 #include <libhal-storage.h>
180
181 +/* The HAL API changed between 0.4 and 0.5 series.
182 +These defines enable backward compatibility */
183 +#ifdef HAL_0_4
184 + // libhal-storage 0.4 API
185 + #define LibHalStoragePolicy HalStoragePolicy
186 + #define LibHalDrive HalDrive
187 + #define LibHalVolume HalVolume
188 + #define LibHalVolumeDiscType HalVolumeDiscType
189 + #define libhal_storage_policy_free hal_storage_policy_free
190 + #define libhal_storage_policy_new hal_storage_policy_new
191 + #define libhal_drive_from_udi hal_drive_from_udi
192 + #define libhal_drive_find_all_volumes hal_drive_find_all_volumes
193 + #define libhal_drive_get_type hal_drive_get_type
194 + #define libhal_drive_get_device_file hal_drive_get_device_file
195 + #define libhal_drive_free hal_drive_free
196 + #define libhal_drive_policy_compute_display_name hal_drive_policy_compute_display_name
197 + #define libhal_drive_is_hotpluggable hal_drive_is_hotpluggable
198 + #define libhal_volume_from_udi hal_volume_from_udi
199 + #define libhal_volume_get_device_file hal_volume_get_device_file
200 + #define libhal_volume_get_mount_point hal_volume_get_mount_point
201 + #define libhal_volume_get_fstype hal_volume_get_fstype
202 + #define libhal_volume_is_mounted hal_volume_is_mounted
203 + #define libhal_volume_get_disc_type hal_volume_get_disc_type
204 + #define libhal_volume_free hal_volume_free
205 + #define libhal_volume_policy_compute_display_name hal_volume_policy_compute_display_name
206 + #define libhal_volume_disc_has_data hal_volume_disc_has_data
207 + #define libhal_volume_disc_has_audio hal_volume_disc_has_audio
208 + #define libhal_volume_disc_is_blank hal_volume_disc_is_blank
209 + #define libhal_volume_is_disc hal_volume_is_disc
210 + #define libhal_volume_get_storage_device_udi hal_volume_get_storage_device_udi
211 + #define LIBHAL_VOLUME_DISC_TYPE_CDROM HAL_VOLUME_DISC_TYPE_CDROM
212 + #define LIBHAL_VOLUME_DISC_TYPE_CDR HAL_VOLUME_DISC_TYPE_CDR
213 + #define LIBHAL_VOLUME_DISC_TYPE_CDRW HAL_VOLUME_DISC_TYPE_CDRW
214 + #define LIBHAL_VOLUME_DISC_TYPE_DVDROM HAL_VOLUME_DISC_TYPE_DVDROM
215 + #define LIBHAL_VOLUME_DISC_TYPE_DVDRAM HAL_VOLUME_DISC_TYPE_DVDRAM
216 + #define LIBHAL_VOLUME_DISC_TYPE_DVDR HAL_VOLUME_DISC_TYPE_DVDR
217 + #define LIBHAL_VOLUME_DISC_TYPE_DVDRW HAL_VOLUME_DISC_TYPE_DVDRW
218 + #define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR HAL_VOLUME_DISC_TYPE_DVDPLUSR
219 + #define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW HAL_VOLUME_DISC_TYPE_DVDPLUSRW
220 + #define LIBHAL_DRIVE_TYPE_COMPACT_FLASH HAL_DRIVE_TYPE_COMPACT_FLASH
221 + #define LIBHAL_DRIVE_TYPE_MEMORY_STICK HAL_DRIVE_TYPE_MEMORY_STICK
222 + #define LIBHAL_DRIVE_TYPE_SMART_MEDIA HAL_DRIVE_TYPE_SMART_MEDIA
223 + #define LIBHAL_DRIVE_TYPE_SD_MMC HAL_DRIVE_TYPE_SD_MMC
224 + #define LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER
225 + #define LIBHAL_DRIVE_TYPE_CAMERA HAL_DRIVE_TYPE_CAMERA
226 + #define LIBHAL_DRIVE_TYPE_TAPE HAL_DRIVE_TYPE_TAPE
227 +
228 + // libhal 0.4 API
229 + #define libhal_free_string hal_free_string
230 + #define libhal_device_exists(ctx, udi, error) hal_device_exists(ctx, udi)
231 + #define libhal_device_property_watch_all(ctx, error) hal_device_property_watch_all(ctx)
232 + #define libhal_get_all_devices(ctx, num_devices, error) hal_get_all_devices(ctx, num_devices)
233 + #define libhal_device_property_exists(ctx, udi, key, error) hal_device_property_exists(ctx, udi, key)
234 + #define libhal_device_get_property_bool(ctx, udi, key, error) hal_device_get_property_bool(ctx, udi, key)
235 + #define libhal_device_get_property_string(ctx, udi, key, error) hal_device_get_property_string(ctx, udi, key)
236 + #define libhal_device_query_capability(ctx, udi, capability, error) hal_device_query_capability(ctx, udi, capability)
237 +#endif
238 +
239 +
240 /**
241 * A handy function to query a hal string
242 *
243 @@ -137,12 +198,14 @@
244
245 /* Hal call-backs -- from gvm*/
246 public:
247 +#ifdef HAL_0_4
248 /** Invoked by libhal for integration with our mainloop.
249 *
250 * @param ctx LibHal context
251 * @param dbus_connection D-BUS connection to integrate
252 */
253 static void hal_main_loop_integration(LibHalContext *ctx, DBusConnection *dbus_connection);
254 +#endif
255
256 /** Invoked when a device is added to the Global Device List.
257 *
258 @@ -175,7 +238,13 @@
259 * @param message D-BUS message with variable parameters depending on condition
260 */
261 static void hal_device_condition(LibHalContext *ctx, const char *udi,
262 - const char *condition_name, DBusMessage *message);
263 + const char *condition_name,
264 + #ifdef HAL_0_4
265 + DBusMessage *message
266 + #else
267 + const char* message
268 + #endif
269 + );
270
271 /* HAL and DBus structures */
272 private:
273 @@ -184,15 +253,17 @@
274 */
275 LibHalContext* m_halContext;
276
277 +#ifdef HAL_0_4
278 /**
279 * Structure defining the hal callback function for devices events
280 */
281 LibHalFunctions m_halFunctions;
282 +#endif
283
284 /**
285 * libhal-storage HAL policy, e.g. for icon names
286 */
287 - HalStoragePolicy* m_halStoragePolicy;
288 + LibHalStoragePolicy* m_halStoragePolicy;
289
290 /**
291 * The DBus-Qt bindings connection for mainloop integration
292 --- kdebase-3.4.1/kioslave/media/kdedmodule/halbackend.cpp.orig 2005-05-23 12:14:18.000000000 +0000
293 +++ kdebase-3.4.1/kioslave/media/kdedmodule/halbackend.cpp 2005-06-12 15:16:27.000000000 +0000
294 @@ -19,11 +19,13 @@
295 #include "halbackend.h"
296 #include "linuxcdpolling.h"
297
298 +#include <stdlib.h>
299 +
300 #include <klocale.h>
301 #include <kurl.h>
302 #include <kdebug.h>
303
304 -#define MOUNT_SUFFIX (hal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted"))
305 +#define MOUNT_SUFFIX (libhal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted"))
306
307 /* Static instance of this class, for static HAL callbacks */
308 static HALBackend* s_HALBackend;
309 @@ -33,9 +35,9 @@
310 {
311 char* _ppt_string;
312 QString _ppt_QString;
313 - _ppt_string = hal_device_get_property_string(ctx, udi, key);
314 + _ppt_string = libhal_device_get_property_string(ctx, udi, key, NULL);
315 _ppt_QString = QString(_ppt_string ? _ppt_string : "");
316 - hal_free_string(_ppt_string);
317 + libhal_free_string(_ppt_string);
318 return _ppt_QString;
319 }
320
321 @@ -55,14 +57,24 @@
322 {
323 /* Close HAL connection */
324 if (m_halContext)
325 + {
326 + #ifdef HAL_0_4
327 hal_shutdown(m_halContext);
328 + #else
329 + libhal_ctx_shutdown(m_halContext, NULL);
330 + libhal_ctx_free(m_halContext);
331 + #endif
332 + }
333 if (m_halStoragePolicy)
334 - hal_storage_policy_free(m_halStoragePolicy);
335 + libhal_storage_policy_free(m_halStoragePolicy);
336 +
337 + /** @todo empty media list ? */
338 }
339
340 /* Connect to the HAL */
341 bool HALBackend::InitHal()
342 {
343 +#ifdef HAL_0_4 /* HAL API 0.4 */
344 /* libhal initialization */
345 m_halFunctions.main_loop_integration = HALBackend::hal_main_loop_integration;
346 m_halFunctions.device_added = HALBackend::hal_device_added;
347 @@ -75,19 +87,57 @@
348 m_halContext = hal_initialize(&m_halFunctions, FALSE);
349 if (!m_halContext)
350 {
351 - kdDebug()<<"Failed to initialize HAL!"<<endl;
352 + kdDebug(1219) << "Failed to initialize HAL!" << endl;
353 + return false;
354 + }
355 +
356 +#else /* HAL API >= 0.5 */
357 + kdDebug(1219) << "Context new" << endl;
358 + m_halContext = libhal_ctx_new();
359 + if (!m_halContext)
360 + {
361 + kdDebug(1219) << "Failed to initialize HAL!" << endl;
362 + return false;
363 + }
364 +
365 + // Main loop integration
366 + kdDebug(1219) << "Main loop integration" << endl;
367 + DBusError error;
368 + dbus_error_init(&error);
369 + DBusConnection *dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
370 + if (dbus_error_is_set(&error))
371 + return false;
372 + MainLoopIntegration(dbus_connection);
373 + libhal_ctx_set_dbus_connection(m_halContext, dbus_connection);
374 +
375 + // HAL callback functions
376 + kdDebug(1219) << "Callback functions" << endl;
377 + libhal_ctx_set_device_added(m_halContext, HALBackend::hal_device_added);
378 + libhal_ctx_set_device_removed(m_halContext, HALBackend::hal_device_removed);
379 + libhal_ctx_set_device_new_capability (m_halContext, NULL);
380 + libhal_ctx_set_device_lost_capability (m_halContext, NULL);
381 + libhal_ctx_set_device_property_modified (m_halContext, HALBackend::hal_device_property_modified);
382 + libhal_ctx_set_device_condition(m_halContext, HALBackend::hal_device_condition);
383 +
384 + kdDebug(1219) << "Context Init" << endl;
385 + if (!libhal_ctx_init(m_halContext, NULL))
386 + {
387 + kdDebug(1219) << "Failed to init HAL context!" << endl;
388 return false;
389 }
390 +#endif
391
392 /** @todo customize watch policy */
393 - if (hal_device_property_watch_all(m_halContext))
394 + kdDebug(1219) << "Watch properties" << endl;
395 + if (libhal_device_property_watch_all(m_halContext, NULL))
396 {
397 - kdDebug()<<"Failed to watch HAL properties!"<<endl;
398 + kdDebug(1219) << "Failed to watch HAL properties!" << endl;
399 return false;
400 }
401
402 /* libhal-storage initialization */
403 - m_halStoragePolicy = hal_storage_policy_new();
404 + kdDebug(1219) << "Storage Policy" << endl;
405 + m_halStoragePolicy = libhal_storage_policy_new();
406 /** @todo define libhal-storage icon policy */
407
408 /* List devices at startup */
409 @@ -97,13 +147,15 @@
410 /* List devices (at startup)*/
411 bool HALBackend::ListDevices()
412 {
413 + kdDebug(1219) << "ListDevices" << endl;
414 +
415 int numDevices;
416 - char** halDeviceList = hal_get_all_devices(m_halContext, &numDevices);
417 + char** halDeviceList = libhal_get_all_devices(m_halContext, &numDevices, NULL);
418
419 if (!halDeviceList)
420 return false;
421
422 - kdDebug() << "HALBackend::ListDevices : " << numDevices << " devices found" << endl;
423 + kdDebug(1219) << "HALBackend::ListDevices : " << numDevices << " devices found" << endl;
424 for (int i = 0; i < numDevices; i++)
425 AddDevice(halDeviceList[i]);
426
427 @@ -116,7 +168,7 @@
428 {
429 /* We don't deal with devices that do not expose their capabilities.
430 If we don't check this, we will get a lot of warning messages from libhal */
431 - if (!hal_device_property_exists(m_halContext, udi, "info.capabilities"))
432 + if (!libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL))
433 return;
434
435 /* If the device is already listed, do not process.
436 @@ -126,11 +178,11 @@
437 return;
438
439 /* Add volume block devices */
440 - if (hal_device_query_capability(m_halContext, udi, "volume"))
441 + if (libhal_device_query_capability(m_halContext, udi, "volume", NULL))
442 {
443 /* We only list volume that have a filesystem or volume that have an audio track*/
444 if ( (hal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "filesystem") &&
445 - (!hal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio")) )
446 + (!libhal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio", NULL)) )
447 return;
448 /* Query drive udi */
449 QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device");
450 @@ -150,7 +202,7 @@
451 }
452
453 /* Floppy & zip drives */
454 - if (hal_device_query_capability(m_halContext, udi, "storage"))
455 + if (libhal_device_query_capability(m_halContext, udi, "storage", NULL))
456 if ((hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "floppy") ||
457 (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip"))
458 {
459 @@ -162,7 +214,7 @@
460 }
461
462 /* Camera handled by gphoto2*/
463 - if (hal_device_query_capability(m_halContext, udi, "camera"))
464 + if (libhal_device_query_capability(m_halContext, udi, "camera", NULL))
465
466 {
467 /* Create medium */
468 @@ -194,7 +246,7 @@
469 return;
470
471 QString conditionName = QString(condition);
472 - kdDebug() << "Processing device condition " << conditionName << " for " << udi << endl;
473 + kdDebug(1219) << "Processing device condition " << conditionName << " for " << udi << endl;
474
475 /* TODO: Warn the user that (s)he should unmount devices before unplugging */
476 if (conditionName == "VolumeUnmountForced")
477 @@ -229,8 +281,8 @@
478 return medium->id().ascii();
479
480 /* Hard part : this is a volume whose drive is registered */
481 - if (hal_device_property_exists(m_halContext, udi, "info.capabilities"))
482 - if (hal_device_query_capability(m_halContext, udi, "volume"))
483 + if (libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL))
484 + if (libhal_device_query_capability(m_halContext, udi, "volume", NULL))
485 {
486 QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device");
487 return findMediumUdiFromUdi(driveUdi.ascii());
488 @@ -241,14 +293,14 @@
489
490 void HALBackend::ResetProperties(const char* mediumUdi)
491 {
492 - kdDebug() << "HALBackend::setProperties" << endl;
493 + kdDebug(1219) << "HALBackend::setProperties" << endl;
494
495 Medium* m = new Medium(mediumUdi, "");
496 - if (hal_device_query_capability(m_halContext, mediumUdi, "volume"))
497 + if (libhal_device_query_capability(m_halContext, mediumUdi, "volume", NULL))
498 setVolumeProperties(m);
499 - if (hal_device_query_capability(m_halContext, mediumUdi, "storage"))
500 + if (libhal_device_query_capability(m_halContext, mediumUdi, "storage", NULL))
501 setFloppyProperties(m);
502 - if (hal_device_query_capability(m_halContext, mediumUdi, "camera"))
503 + if (libhal_device_query_capability(m_halContext, mediumUdi, "camera", NULL))
504 setCameraProperties(m);
505
506 m_mediaList.changeMediumState(*m);
507 @@ -258,38 +310,39 @@
508
509 void HALBackend::setVolumeProperties(Medium* medium)
510 {
511 - kdDebug() << "HALBackend::setVolumeProperties for " << medium->id() << endl;
512 + kdDebug(1219) << "HALBackend::setVolumeProperties for " << medium->id() << endl;
513
514 const char* udi = medium->id().ascii();
515 /* Check if the device still exists */
516 - if (!hal_device_exists(m_halContext, udi))
517 + if (!libhal_device_exists(m_halContext, udi, NULL))
518 return;
519
520 /* Get device information from libhal-storage */
521 - HalVolume* halVolume = hal_volume_from_udi(m_halContext, udi);
522 + LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi);
523 if (!halVolume)
524 return;
525 -
526 - QString driveUdi = hal_volume_get_storage_device_udi(halVolume);
527 - HalDrive* halDrive = hal_drive_from_udi(m_halContext, driveUdi.ascii());
528 + QString driveUdi = libhal_volume_get_storage_device_udi(halVolume);
529 + LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, driveUdi.ascii());
530
531 medium->setName(
532 - generateName(hal_volume_get_device_file(halVolume)) );
533 + generateName(libhal_volume_get_device_file(halVolume)) );
534
535 medium->mountableState(
536 - hal_volume_get_device_file(halVolume), /* Device node */
537 - hal_volume_get_mount_point(halVolume), /* Mount point */
538 - hal_volume_get_fstype(halVolume), /* Filesystem type */
539 - hal_volume_is_mounted(halVolume) ); /* Mounted ? */
540 + libhal_volume_get_device_file(halVolume), /* Device node */
541 + libhal_volume_get_mount_point(halVolume), /* Mount point */
542 + libhal_volume_get_fstype(halVolume), /* Filesystem type */
543 + libhal_volume_is_mounted(halVolume) ); /* Mounted ? */
544
545 QString mimeType;
546 - if (hal_volume_is_disc(halVolume))
547 + if (libhal_volume_is_disc(halVolume))
548 {
549 mimeType = "media/cdrom" + MOUNT_SUFFIX;
550
551 - HalVolumeDiscType discType = hal_volume_get_disc_type(halVolume);
552 - if ((discType == HAL_VOLUME_DISC_TYPE_CDR) || (discType == HAL_VOLUME_DISC_TYPE_CDRW))
553 - if (hal_volume_disc_is_blank(halVolume))
554 + LibHalVolumeDiscType discType = libhal_volume_get_disc_type(halVolume);
555 + if ((discType == LIBHAL_VOLUME_DISC_TYPE_CDROM) ||
556 + (discType == LIBHAL_VOLUME_DISC_TYPE_CDR) ||
557 + (discType == LIBHAL_VOLUME_DISC_TYPE_CDRW))
558 + if (libhal_volume_disc_is_blank(halVolume))
559 {
560 mimeType = "media/blankcd";
561 medium->unmountableState("");
562 @@ -297,10 +350,10 @@
563 else
564 mimeType = "media/cdwriter" + MOUNT_SUFFIX;
565
566 - if ((discType == HAL_VOLUME_DISC_TYPE_DVDROM) || (discType == HAL_VOLUME_DISC_TYPE_DVDRAM) ||
567 - (discType == HAL_VOLUME_DISC_TYPE_DVDR) || (discType == HAL_VOLUME_DISC_TYPE_DVDRW) ||
568 - (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSRW) )
569 - if (hal_volume_disc_is_blank(halVolume))
570 + if ((discType == LIBHAL_VOLUME_DISC_TYPE_DVDROM) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRAM) ||
571 + (discType == LIBHAL_VOLUME_DISC_TYPE_DVDR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRW) ||
572 + (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW) )
573 + if (libhal_volume_disc_is_blank(halVolume))
574 {
575 mimeType = "media/blankdvd";
576 medium->unmountableState("");
577 @@ -308,16 +361,16 @@
578 else
579 mimeType = "media/dvd" + MOUNT_SUFFIX;
580
581 - if (hal_volume_disc_has_audio(halVolume) && !hal_volume_disc_has_data(halVolume))
582 + if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume))
583 {
584 mimeType = "media/audiocd";
585 - medium->unmountableState( "audiocd:/?device=" + QString(hal_volume_get_device_file(halVolume)) );
586 + medium->unmountableState( "audiocd:/?device=" + QString(libhal_volume_get_device_file(halVolume)) );
587 }
588
589 medium->setIconName(QString::null);
590 -
591 +
592 /* check if the disc id a vcd or a video dvd */
593 - DiscType type = LinuxCDPolling::identifyDiscType(hal_volume_get_device_file(halVolume));
594 + DiscType type = LinuxCDPolling::identifyDiscType(libhal_volume_get_device_file(halVolume));
595 switch (type)
596 {
597 case DiscType::VCD:
598 @@ -334,81 +387,85 @@
599 else
600 {
601 mimeType = "media/hdd" + MOUNT_SUFFIX;
602 - if (hal_drive_is_hotpluggable(halDrive))
603 - {
604 + if (libhal_drive_is_hotpluggable(halDrive))
605 + {
606 mimeType = "media/removable" + MOUNT_SUFFIX;
607 medium->needMounting();
608 - switch (hal_drive_get_type(halDrive)) {
609 - case HAL_DRIVE_TYPE_COMPACT_FLASH:
610 + switch (libhal_drive_get_type(halDrive)) {
611 + case LIBHAL_DRIVE_TYPE_COMPACT_FLASH:
612 medium->setIconName("compact_flash" + MOUNT_SUFFIX);
613 break;
614 - case HAL_DRIVE_TYPE_MEMORY_STICK:
615 + case LIBHAL_DRIVE_TYPE_MEMORY_STICK:
616 medium->setIconName("memory_stick" + MOUNT_SUFFIX);
617 break;
618 - case HAL_DRIVE_TYPE_SMART_MEDIA:
619 + case LIBHAL_DRIVE_TYPE_SMART_MEDIA:
620 medium->setIconName("smart_media" + MOUNT_SUFFIX);
621 break;
622 - case HAL_DRIVE_TYPE_SD_MMC:
623 + case LIBHAL_DRIVE_TYPE_SD_MMC:
624 medium->setIconName("sd_mmc" + MOUNT_SUFFIX);
625 break;
626 - case HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
627 + case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
628 medium->setIconName(QString::null); //FIXME need icon
629 break;
630 - case HAL_DRIVE_TYPE_CAMERA:
631 + case LIBHAL_DRIVE_TYPE_CAMERA:
632 medium->setIconName("camera" + MOUNT_SUFFIX);
633 - break;
634 - case HAL_DRIVE_TYPE_TAPE:
635 + break;
636 + case LIBHAL_DRIVE_TYPE_TAPE:
637 medium->setIconName(QString::null); //FIXME need icon
638 - break;
639 - default:
640 + break;
641 + default:
642 medium->setIconName(QString::null);
643 };
644 };
645 }
646 medium->setMimeType(mimeType);
647
648 - medium->setLabel(QString::fromUtf8( hal_volume_policy_compute_display_name(halDrive,
649 - halVolume, m_halStoragePolicy) ) );
650 + char* name = libhal_volume_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy);
651 + //char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy);
652 + QString volume_name = QString::fromUtf8(name);
653 + QString media_name = volume_name;
654 + medium->setLabel(media_name);
655 + free(name);
656
657 - hal_drive_free(halDrive);
658 - hal_volume_free(halVolume);
659 + libhal_drive_free(halDrive);
660 + libhal_volume_free(halVolume);
661 }
662
663 // Handle floppies and zip drives
664 void HALBackend::setFloppyProperties(Medium* medium)
665 {
666 - kdDebug() << "HALBackend::setFloppyProperties for " << medium->id() << endl;
667 + kdDebug(1219) << "HALBackend::setFloppyProperties for " << medium->id() << endl;
668
669 const char* udi = medium->id().ascii();
670 /* Check if the device still exists */
671 - if (!hal_device_exists(m_halContext, udi))
672 + if (!libhal_device_exists(m_halContext, udi, NULL))
673 return;
674
675 - HalDrive* halDrive = hal_drive_from_udi(m_halContext, udi);
676 + LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, udi);
677 if (!halDrive)
678 return;
679 int numVolumes;
680 - char** volumes = hal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
681 - HalVolume* halVolume = NULL;
682 - kdDebug() << " found " << numVolumes << " volumes" << endl;
683 + char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
684 + LibHalVolume* halVolume = NULL;
685 + kdDebug(1219) << " found " << numVolumes << " volumes" << endl;
686 if (numVolumes)
687 - halVolume = hal_volume_from_udi(m_halContext, volumes[0]);
688 + halVolume = libhal_volume_from_udi(m_halContext, volumes[0]);
689
690 medium->setName(
691 - generateName(hal_drive_get_device_file(halDrive)) );
692 + generateName(libhal_drive_get_device_file(halDrive)) );
693
694 if (halVolume)
695 {
696 medium->mountableState(
697 - hal_volume_get_device_file(halVolume), /* Device node */
698 - hal_volume_get_mount_point(halVolume), /* Mount point */
699 - hal_volume_get_fstype(halVolume), /* Filesystem type */
700 - hal_volume_is_mounted(halVolume) ); /* Mounted ? */
701 + libhal_volume_get_device_file(halVolume), /* Device node */
702 + libhal_volume_get_mount_point(halVolume), /* Mount point */
703 + libhal_volume_get_fstype(halVolume), /* Filesystem type */
704 + libhal_volume_is_mounted(halVolume) ); /* Mounted ? */
705 }
706 else
707 {
708 medium->mountableState(
709 - hal_drive_get_device_file(halDrive), /* Device node */
710 + libhal_drive_get_device_file(halDrive), /* Device node */
711 "", /* Mount point */
712 "", /* Filesystem type */
713 false ); /* Mounted ? */
714 @@ -421,7 +478,7 @@
715 else
716 medium->setMimeType("media/floppy_unmounted");
717 }
718 -
719 +
720 if (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip")
721 {
722 if (halVolume)
723 @@ -429,23 +486,38 @@
724 else
725 medium->setMimeType("media/zip_unmounted");
726 }
727 -
728 +
729 medium->setIconName(QString::null);
730
731 - medium->setLabel(QString::fromUtf8( hal_drive_policy_compute_display_name(halDrive,
732 - halVolume, m_halStoragePolicy) ) );
733 + QString media_name;
734 + if (halVolume)
735 + {
736 + char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy);
737 + QString volume_name = QString::fromUtf8(name);
738 + media_name = volume_name;
739 + free(name);
740 + }
741 + else
742 + {
743 + char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy);
744 + QString drive_name = QString::fromUtf8(name);
745 + media_name = drive_name;
746 + free(name);
747 + }
748 + medium->setLabel(media_name);
749
750 - hal_drive_free(halDrive);
751 - hal_volume_free(halVolume);
752 + free(volumes);
753 + libhal_drive_free(halDrive);
754 + libhal_volume_free(halVolume);
755 }
756
757 void HALBackend::setCameraProperties(Medium* medium)
758 {
759 - kdDebug() << "HALBackend::setCameraProperties for " << medium->id() << endl;
760 + kdDebug(1219) << "HALBackend::setCameraProperties for " << medium->id() << endl;
761
762 const char* udi = medium->id().ascii();
763 /* Check if the device still exists */
764 - if (!hal_device_exists(m_halContext, udi))
765 + if (!libhal_device_exists(m_halContext, udi, NULL))
766 return;
767
768 /** @todo find name */
769 @@ -467,24 +539,26 @@
770 ** HAL CALL-BACKS **
771 ******************************************/
772
773 +#ifdef HAL_0_4
774 void HALBackend::hal_main_loop_integration(LibHalContext *ctx,
775 DBusConnection *dbus_connection)
776 {
777 - kdDebug() << "HALBackend::hal_main_loop_integration" << endl;
778 + kdDebug(1219) << "HALBackend::hal_main_loop_integration" << endl;
779 Q_UNUSED(ctx);
780 s_HALBackend->MainLoopIntegration(dbus_connection);
781 }
782 +#endif
783
784 void HALBackend::hal_device_added(LibHalContext *ctx, const char *udi)
785 {
786 - kdDebug() << "HALBackend::hal_device_added " << udi << endl;
787 + kdDebug(1219) << "HALBackend::hal_device_added " << udi << endl;
788 Q_UNUSED(ctx);
789 s_HALBackend->AddDevice(udi);
790 }
791
792 void HALBackend::hal_device_removed(LibHalContext *ctx, const char *udi)
793 {
794 - kdDebug() << "HALBackend::hal_device_removed " << udi << endl;
795 + kdDebug(1219) << "HALBackend::hal_device_removed " << udi << endl;
796 Q_UNUSED(ctx);
797 s_HALBackend->RemoveDevice(udi);
798 }
799 @@ -492,16 +566,23 @@
800 void HALBackend::hal_device_property_modified(LibHalContext *ctx, const char *udi,
801 const char *key, dbus_bool_t is_removed, dbus_bool_t is_added)
802 {
803 - kdDebug() << "HALBackend::hal_property_modified " << udi << " -- " << key << endl;
804 + kdDebug(1219) << "HALBackend::hal_property_modified " << udi << " -- " << key << endl;
805 Q_UNUSED(ctx);
806 Q_UNUSED(is_removed);
807 Q_UNUSED(is_added);
808 s_HALBackend->ModifyDevice(udi, key);
809 }
810 +
811 void HALBackend::hal_device_condition(LibHalContext *ctx, const char *udi,
812 - const char *condition_name, DBusMessage *message)
813 + const char *condition_name,
814 + #ifdef HAL_0_4
815 + DBusMessage *message
816 + #else
817 + const char* message
818 + #endif
819 + )
820 {
821 - kdDebug() << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl;
822 + kdDebug(1219) << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl;
823 Q_UNUSED(ctx);
824 Q_UNUSED(message);
825 s_HALBackend->DeviceCondition(udi, condition_name);

Properties

Name Value
svn:executable *