Magellan Linux

Contents of /trunk/kdebase/kdebase-3.4.0-hal-0.5.1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21 - (show annotations) (download)
Tue May 3 19:41:17 2005 UTC (19 years ago) by niro
File size: 22166 byte(s)
fixes compile issues with hal-0.5.1

1 ===================================================================
2 RCS file: /home/kde/kdebase/kioslave/media/kdedmodule/halbackend.h,v
3 retrieving revision 1.1
4 retrieving revision 1.3
5 diff -u -r1.1 -r1.3
6 --- kdebase/kioslave/media/kdedmodule/halbackend.h 2004/10/25 22:35:32 1.1
7 +++ kdebase/kioslave/media/kdedmodule/halbackend.h 2005/03/27 13:24:33 1.3
8 @@ -35,6 +35,8 @@
9 #include <qstringlist.h>
10 #include <qstring.h>
11
12 +#include <config.h>
13 +
14 /* We acknowledge the the dbus API is unstable */
15 #define DBUS_API_SUBJECT_TO_CHANGE
16 /* DBus-Qt bindings */
17 @@ -43,6 +45,65 @@
18 #include <libhal.h>
19 #include <libhal-storage.h>
20
21 +/* The HAL API changed between 0.4 and 0.5 series.
22 +These defines enable backward compatibility */
23 +#ifdef HAL_0_4
24 + // libhal-storage 0.4 API
25 + #define LibHalStoragePolicy HalStoragePolicy
26 + #define LibHalDrive HalDrive
27 + #define LibHalVolume HalVolume
28 + #define LibHalVolumeDiscType HalVolumeDiscType
29 + #define libhal_storage_policy_free hal_storage_policy_free
30 + #define libhal_storage_policy_new hal_storage_policy_new
31 + #define libhal_drive_from_udi hal_drive_from_udi
32 + #define libhal_drive_find_all_volumes hal_drive_find_all_volumes
33 + #define libhal_drive_get_type hal_drive_get_type
34 + #define libhal_drive_get_device_file hal_drive_get_device_file
35 + #define libhal_drive_free hal_drive_free
36 + #define libhal_drive_policy_compute_display_name hal_drive_policy_compute_display_name
37 + #define libhal_drive_is_hotpluggable hal_drive_is_hotpluggable
38 + #define libhal_volume_from_udi hal_volume_from_udi
39 + #define libhal_volume_get_device_file hal_volume_get_device_file
40 + #define libhal_volume_get_mount_point hal_volume_get_mount_point
41 + #define libhal_volume_get_fstype hal_volume_get_fstype
42 + #define libhal_volume_is_mounted hal_volume_is_mounted
43 + #define libhal_volume_get_disc_type hal_volume_get_disc_type
44 + #define libhal_volume_free hal_volume_free
45 + #define libhal_volume_policy_compute_display_name hal_volume_policy_compute_display_name
46 + #define libhal_volume_disc_has_data hal_volume_disc_has_data
47 + #define libhal_volume_disc_has_audio hal_volume_disc_has_audio
48 + #define libhal_volume_disc_is_blank hal_volume_disc_is_blank
49 + #define libhal_volume_is_disc hal_volume_is_disc
50 + #define libhal_volume_get_storage_device_udi hal_volume_get_storage_device_udi
51 + #define LIBHAL_VOLUME_DISC_TYPE_CDROM HAL_VOLUME_DISC_TYPE_CDROM
52 + #define LIBHAL_VOLUME_DISC_TYPE_CDR HAL_VOLUME_DISC_TYPE_CDR
53 + #define LIBHAL_VOLUME_DISC_TYPE_CDRW HAL_VOLUME_DISC_TYPE_CDRW
54 + #define LIBHAL_VOLUME_DISC_TYPE_DVDROM HAL_VOLUME_DISC_TYPE_DVDROM
55 + #define LIBHAL_VOLUME_DISC_TYPE_DVDRAM HAL_VOLUME_DISC_TYPE_DVDRAM
56 + #define LIBHAL_VOLUME_DISC_TYPE_DVDR HAL_VOLUME_DISC_TYPE_DVDR
57 + #define LIBHAL_VOLUME_DISC_TYPE_DVDRW HAL_VOLUME_DISC_TYPE_DVDRW
58 + #define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR HAL_VOLUME_DISC_TYPE_DVDPLUSR
59 + #define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW HAL_VOLUME_DISC_TYPE_DVDPLUSRW
60 + #define LIBHAL_DRIVE_TYPE_COMPACT_FLASH HAL_DRIVE_TYPE_COMPACT_FLASH
61 + #define LIBHAL_DRIVE_TYPE_MEMORY_STICK HAL_DRIVE_TYPE_MEMORY_STICK
62 + #define LIBHAL_DRIVE_TYPE_SMART_MEDIA HAL_DRIVE_TYPE_SMART_MEDIA
63 + #define LIBHAL_DRIVE_TYPE_SD_MMC HAL_DRIVE_TYPE_SD_MMC
64 + #define LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER
65 + #define LIBHAL_DRIVE_TYPE_CAMERA HAL_DRIVE_TYPE_CAMERA
66 + #define LIBHAL_DRIVE_TYPE_TAPE HAL_DRIVE_TYPE_TAPE
67 +
68 + // libhal 0.4 API
69 + #define libhal_free_string hal_free_string
70 + #define libhal_device_exists(ctx, udi, error) hal_device_exists(ctx, udi)
71 + #define libhal_device_property_watch_all(ctx, error) hal_device_property_watch_all(ctx)
72 + #define libhal_get_all_devices(ctx, num_devices, error) hal_get_all_devices(ctx, num_devices)
73 + #define libhal_device_property_exists(ctx, udi, key, error) hal_device_property_exists(ctx, udi, key)
74 + #define libhal_device_get_property_bool(ctx, udi, key, error) hal_device_get_property_bool(ctx, udi, key)
75 + #define libhal_device_get_property_string(ctx, udi, key, error) hal_device_get_property_string(ctx, udi, key)
76 + #define libhal_device_query_capability(ctx, udi, capability, error) hal_device_query_capability(ctx, udi, capability)
77 +#endif
78 +
79 +
80 /**
81 * A handy function to query a hal string
82 *
83 @@ -175,7 +236,13 @@
84 * @param message D-BUS message with variable parameters depending on condition
85 */
86 static void hal_device_condition(LibHalContext *ctx, const char *udi,
87 - const char *condition_name, DBusMessage *message);
88 + const char *condition_name,
89 + #ifdef HAL_0_4
90 + DBusMessage *message
91 + #else
92 + const char* message
93 + #endif
94 + );
95
96 /* HAL and DBus structures */
97 private:
98 @@ -184,15 +251,17 @@
99 */
100 LibHalContext* m_halContext;
101
102 +#ifdef HAL_0_4
103 /**
104 * Structure defining the hal callback function for devices events
105 */
106 LibHalFunctions m_halFunctions;
107 +#endif
108
109 /**
110 * libhal-storage HAL policy, e.g. for icon names
111 */
112 - HalStoragePolicy* m_halStoragePolicy;
113 + LibHalStoragePolicy* m_halStoragePolicy;
114
115 /**
116 * The DBus-Qt bindings connection for mainloop integration
117 ===================================================================
118 RCS file: /home/kde/kdebase/kioslave/media/kdedmodule/halbackend.cpp,v
119 retrieving revision 1.7
120 retrieving revision 1.11
121 diff -u -r1.7 -r1.11
122 --- kdebase/kioslave/media/kdedmodule/halbackend.cpp 2005/02/14 15:47:23 1.7
123 +++ kdebase/kioslave/media/kdedmodule/halbackend.cpp 2005/03/30 21:37:21 1.11
124 @@ -23,7 +23,7 @@
125 #include <kurl.h>
126 #include <kdebug.h>
127
128 -#define MOUNT_SUFFIX (hal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted"))
129 +#define MOUNT_SUFFIX (libhal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted"))
130
131 /* Static instance of this class, for static HAL callbacks */
132 static HALBackend* s_HALBackend;
133 @@ -33,9 +33,9 @@
134 {
135 char* _ppt_string;
136 QString _ppt_QString;
137 - _ppt_string = hal_device_get_property_string(ctx, udi, key);
138 + _ppt_string = libhal_device_get_property_string(ctx, udi, key, NULL);
139 _ppt_QString = QString(_ppt_string ? _ppt_string : "");
140 - hal_free_string(_ppt_string);
141 + libhal_free_string(_ppt_string);
142 return _ppt_QString;
143 }
144
145 @@ -55,14 +55,22 @@
146 {
147 /* Close HAL connection */
148 if (m_halContext)
149 + {
150 + #ifdef HAL_0_4
151 hal_shutdown(m_halContext);
152 + #else
153 + libhal_ctx_shutdown(m_halContext, NULL);
154 + libhal_ctx_free(m_halContext);
155 + #endif
156 + }
157 if (m_halStoragePolicy)
158 - hal_storage_policy_free(m_halStoragePolicy);
159 + libhal_storage_policy_free(m_halStoragePolicy);
160 }
161
162 /* Connect to the HAL */
163 bool HALBackend::InitHal()
164 {
165 +#ifdef HAL_0_4 /* HAL API 0.4 */
166 /* libhal initialization */
167 m_halFunctions.main_loop_integration = HALBackend::hal_main_loop_integration;
168 m_halFunctions.device_added = HALBackend::hal_device_added;
169 @@ -75,19 +83,58 @@
170 m_halContext = hal_initialize(&m_halFunctions, FALSE);
171 if (!m_halContext)
172 {
173 - kdDebug()<<"Failed to initialize HAL!"<<endl;
174 + kdDebug() << "Failed to initialize HAL!" << endl;
175 return false;
176 }
177
178 /** @todo customize watch policy */
179 - if (hal_device_property_watch_all(m_halContext))
180 + /* NOTICE: this code chunk doesn't seem necessary for the .05 API... still, it should */
181 + kdDebug() << "Watch properties" << endl;
182 + if (libhal_device_property_watch_all(m_halContext, NULL))
183 + {
184 + kdDebug() << "Failed to watch HAL properties!" << endl;
185 + return false;
186 + }
187 +
188 +#else /* HAL API >= 0.5 */
189 + kdDebug() << "Context new" << endl;
190 + m_halContext = libhal_ctx_new();
191 + if (!m_halContext)
192 {
193 - kdDebug()<<"Failed to watch HAL properties!"<<endl;
194 + kdDebug() << "Failed to initialize HAL!" << endl;
195 return false;
196 }
197
198 + // Main loop integration
199 + kdDebug() << "Main loop integration" << endl;
200 + DBusError error;
201 + dbus_error_init(&error);
202 + DBusConnection *dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
203 + if (dbus_error_is_set(&error))
204 + return false;
205 + MainLoopIntegration(dbus_connection);
206 + libhal_ctx_set_dbus_connection(m_halContext, dbus_connection);
207 +
208 + // HAL callback functions
209 + kdDebug() << "Callback functions" << endl;
210 + libhal_ctx_set_device_added(m_halContext, HALBackend::hal_device_added);
211 + libhal_ctx_set_device_removed(m_halContext, HALBackend::hal_device_removed);
212 + libhal_ctx_set_device_new_capability (m_halContext, NULL);
213 + libhal_ctx_set_device_lost_capability (m_halContext, NULL);
214 + libhal_ctx_set_device_property_modified (m_halContext, HALBackend::hal_device_property_modified);
215 + libhal_ctx_set_device_condition(m_halContext, HALBackend::hal_device_condition);
216 +
217 + kdDebug() << "Context Init" << endl;
218 + if (!libhal_ctx_init(m_halContext, NULL))
219 + {
220 + kdDebug() << "Failed to init HAL context!" << endl;
221 + return false;
222 + }
223 +#endif
224 +
225 /* libhal-storage initialization */
226 - m_halStoragePolicy = hal_storage_policy_new();
227 + kdDebug() << "Storage Policy" << endl;
228 + m_halStoragePolicy = libhal_storage_policy_new();
229 /** @todo define libhal-storage icon policy */
230
231 /* List devices at startup */
232 @@ -97,8 +144,10 @@
233 /* List devices (at startup)*/
234 bool HALBackend::ListDevices()
235 {
236 + kdDebug() << "ListDevices" << endl;
237 +
238 int numDevices;
239 - char** halDeviceList = hal_get_all_devices(m_halContext, &numDevices);
240 + char** halDeviceList = libhal_get_all_devices(m_halContext, &numDevices, NULL);
241
242 if (!halDeviceList)
243 return false;
244 @@ -116,7 +165,7 @@
245 {
246 /* We don't deal with devices that do not expose their capabilities.
247 If we don't check this, we will get a lot of warning messages from libhal */
248 - if (!hal_device_property_exists(m_halContext, udi, "info.capabilities"))
249 + if (!libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL))
250 return;
251
252 /* If the device is already listed, do not process.
253 @@ -126,11 +175,11 @@
254 return;
255
256 /* Add volume block devices */
257 - if (hal_device_query_capability(m_halContext, udi, "volume"))
258 + if (libhal_device_query_capability(m_halContext, udi, "volume", NULL))
259 {
260 /* We only list volume that have a filesystem or volume that have an audio track*/
261 if ( (hal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "filesystem") &&
262 - (!hal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio")) )
263 + (!libhal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio", NULL)) )
264 return;
265 /* Query drive udi */
266 QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device");
267 @@ -150,7 +199,7 @@
268 }
269
270 /* Floppy & zip drives */
271 - if (hal_device_query_capability(m_halContext, udi, "storage"))
272 + if (libhal_device_query_capability(m_halContext, udi, "storage", NULL))
273 if ((hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "floppy") ||
274 (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip"))
275 {
276 @@ -162,7 +211,7 @@
277 }
278
279 /* Camera handled by gphoto2*/
280 - if (hal_device_query_capability(m_halContext, udi, "camera"))
281 + if (libhal_device_query_capability(m_halContext, udi, "camera", NULL))
282
283 {
284 /* Create medium */
285 @@ -229,8 +278,8 @@
286 return medium->id().ascii();
287
288 /* Hard part : this is a volume whose drive is registered */
289 - if (hal_device_property_exists(m_halContext, udi, "info.capabilities"))
290 - if (hal_device_query_capability(m_halContext, udi, "volume"))
291 + if (libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL))
292 + if (libhal_device_query_capability(m_halContext, udi, "volume", NULL))
293 {
294 QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device");
295 return findMediumUdiFromUdi(driveUdi.ascii());
296 @@ -244,11 +293,11 @@
297 kdDebug() << "HALBackend::setProperties" << endl;
298
299 Medium* m = new Medium(mediumUdi, "");
300 - if (hal_device_query_capability(m_halContext, mediumUdi, "volume"))
301 + if (libhal_device_query_capability(m_halContext, mediumUdi, "volume", NULL))
302 setVolumeProperties(m);
303 - if (hal_device_query_capability(m_halContext, mediumUdi, "storage"))
304 + if (libhal_device_query_capability(m_halContext, mediumUdi, "storage", NULL))
305 setFloppyProperties(m);
306 - if (hal_device_query_capability(m_halContext, mediumUdi, "camera"))
307 + if (libhal_device_query_capability(m_halContext, mediumUdi, "camera", NULL))
308 setCameraProperties(m);
309
310 m_mediaList.changeMediumState(*m);
311 @@ -262,31 +311,35 @@
312
313 const char* udi = medium->id().ascii();
314 /* Check if the device still exists */
315 - if (!hal_device_exists(m_halContext, udi))
316 + if (!libhal_device_exists(m_halContext, udi, NULL))
317 return;
318
319 /* Get device information from libhal-storage */
320 - HalVolume* halVolume = hal_volume_from_udi(m_halContext, udi);
321 - QString driveUdi = hal_volume_get_storage_device_udi(halVolume);
322 - HalDrive* halDrive = hal_drive_from_udi(m_halContext, driveUdi.ascii());
323 + LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi);
324 + if (!halVolume)
325 + return;
326 + QString driveUdi = libhal_volume_get_storage_device_udi(halVolume);
327 + LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, driveUdi.ascii());
328
329 medium->setName(
330 - generateName(hal_volume_get_device_file(halVolume)) );
331 + generateName(libhal_volume_get_device_file(halVolume)) );
332
333 medium->mountableState(
334 - hal_volume_get_device_file(halVolume), /* Device node */
335 - hal_volume_get_mount_point(halVolume), /* Mount point */
336 - hal_volume_get_fstype(halVolume), /* Filesystem type */
337 - hal_volume_is_mounted(halVolume) ); /* Mounted ? */
338 + libhal_volume_get_device_file(halVolume), /* Device node */
339 + libhal_volume_get_mount_point(halVolume), /* Mount point */
340 + libhal_volume_get_fstype(halVolume), /* Filesystem type */
341 + libhal_volume_is_mounted(halVolume) ); /* Mounted ? */
342
343 QString mimeType;
344 - if (hal_volume_is_disc(halVolume))
345 + if (libhal_volume_is_disc(halVolume))
346 {
347 mimeType = "media/cdrom" + MOUNT_SUFFIX;
348
349 - HalVolumeDiscType discType = hal_volume_get_disc_type(halVolume);
350 - if ((discType == HAL_VOLUME_DISC_TYPE_CDR) || (discType == HAL_VOLUME_DISC_TYPE_CDRW))
351 - if (hal_volume_disc_is_blank(halVolume))
352 + LibHalVolumeDiscType discType = libhal_volume_get_disc_type(halVolume);
353 + if ((discType == LIBHAL_VOLUME_DISC_TYPE_CDROM) ||
354 + (discType == LIBHAL_VOLUME_DISC_TYPE_CDR) ||
355 + (discType == LIBHAL_VOLUME_DISC_TYPE_CDRW))
356 + if (libhal_volume_disc_is_blank(halVolume))
357 {
358 mimeType = "media/blankcd";
359 medium->unmountableState("");
360 @@ -294,10 +347,10 @@
361 else
362 mimeType = "media/cdwriter" + MOUNT_SUFFIX;
363
364 - if ((discType == HAL_VOLUME_DISC_TYPE_DVDROM) || (discType == HAL_VOLUME_DISC_TYPE_DVDRAM) ||
365 - (discType == HAL_VOLUME_DISC_TYPE_DVDR) || (discType == HAL_VOLUME_DISC_TYPE_DVDRW) ||
366 - (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSRW) )
367 - if (hal_volume_disc_is_blank(halVolume))
368 + if ((discType == LIBHAL_VOLUME_DISC_TYPE_DVDROM) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRAM) ||
369 + (discType == LIBHAL_VOLUME_DISC_TYPE_DVDR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRW) ||
370 + (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW) )
371 + if (libhal_volume_disc_is_blank(halVolume))
372 {
373 mimeType = "media/blankdvd";
374 medium->unmountableState("");
375 @@ -305,16 +358,16 @@
376 else
377 mimeType = "media/dvd" + MOUNT_SUFFIX;
378
379 - if (hal_volume_disc_has_audio(halVolume) && !hal_volume_disc_has_data(halVolume))
380 + if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume))
381 {
382 mimeType = "media/audiocd";
383 - medium->unmountableState( "audiocd:/?device=" + QString(hal_volume_get_device_file(halVolume)) );
384 + medium->unmountableState( "audiocd:/?device=" + QString(libhal_volume_get_device_file(halVolume)) );
385 }
386
387 medium->setIconName(QString::null);
388 -
389 +
390 /* check if the disc id a vcd or a video dvd */
391 - DiscType type = LinuxCDPolling::identifyDiscType(hal_volume_get_device_file(halVolume));
392 + DiscType type = LinuxCDPolling::identifyDiscType(libhal_volume_get_device_file(halVolume));
393 switch (type)
394 {
395 case DiscType::VCD:
396 @@ -331,44 +384,46 @@
397 else
398 {
399 mimeType = "media/hdd" + MOUNT_SUFFIX;
400 - if (hal_drive_is_hotpluggable(halDrive))
401 - {
402 + if (libhal_drive_is_hotpluggable(halDrive))
403 + {
404 mimeType = "media/removable" + MOUNT_SUFFIX;
405 medium->needMounting();
406 - switch (hal_drive_get_type(halDrive)) {
407 - case HAL_DRIVE_TYPE_COMPACT_FLASH:
408 + switch (libhal_drive_get_type(halDrive)) {
409 + case LIBHAL_DRIVE_TYPE_COMPACT_FLASH:
410 medium->setIconName("compact_flash" + MOUNT_SUFFIX);
411 break;
412 - case HAL_DRIVE_TYPE_MEMORY_STICK:
413 + case LIBHAL_DRIVE_TYPE_MEMORY_STICK:
414 medium->setIconName("memory_stick" + MOUNT_SUFFIX);
415 break;
416 - case HAL_DRIVE_TYPE_SMART_MEDIA:
417 + case LIBHAL_DRIVE_TYPE_SMART_MEDIA:
418 medium->setIconName("smart_media" + MOUNT_SUFFIX);
419 break;
420 - case HAL_DRIVE_TYPE_SD_MMC:
421 + case LIBHAL_DRIVE_TYPE_SD_MMC:
422 medium->setIconName("sd_mmc" + MOUNT_SUFFIX);
423 break;
424 - case HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
425 + case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
426 medium->setIconName(QString::null); //FIXME need icon
427 break;
428 - case HAL_DRIVE_TYPE_CAMERA:
429 + case LIBHAL_DRIVE_TYPE_CAMERA:
430 medium->setIconName("camera" + MOUNT_SUFFIX);
431 - break;
432 - case HAL_DRIVE_TYPE_TAPE:
433 + break;
434 + case LIBHAL_DRIVE_TYPE_TAPE:
435 medium->setIconName(QString::null); //FIXME need icon
436 - break;
437 - default:
438 + break;
439 + default:
440 medium->setIconName(QString::null);
441 };
442 };
443 }
444 medium->setMimeType(mimeType);
445
446 - medium->setLabel(QString::fromUtf8( hal_volume_policy_compute_display_name(halDrive,
447 - halVolume, m_halStoragePolicy) ) );
448 + QString volume_name = QString::fromUtf8(libhal_volume_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy));
449 + //QString drive_name = QString::fromUtf8(libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy));
450 + QString media_name = volume_name;
451 + medium->setLabel(media_name);
452
453 - hal_drive_free(halDrive);
454 - hal_volume_free(halVolume);
455 + libhal_drive_free(halDrive);
456 + libhal_volume_free(halVolume);
457 }
458
459 // Handle floppies and zip drives
460 @@ -378,32 +433,34 @@
461
462 const char* udi = medium->id().ascii();
463 /* Check if the device still exists */
464 - if (!hal_device_exists(m_halContext, udi))
465 + if (!libhal_device_exists(m_halContext, udi, NULL))
466 return;
467
468 - HalDrive* halDrive = hal_drive_from_udi(m_halContext, udi);
469 + LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, udi);
470 + if (!halDrive)
471 + return;
472 int numVolumes;
473 - char** volumes = hal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
474 - HalVolume* halVolume = NULL;
475 + char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
476 + LibHalVolume* halVolume = NULL;
477 kdDebug() << " found " << numVolumes << " volumes" << endl;
478 if (numVolumes)
479 - halVolume = hal_volume_from_udi(m_halContext, volumes[0]);
480 + halVolume = libhal_volume_from_udi(m_halContext, volumes[0]);
481
482 medium->setName(
483 - generateName(hal_drive_get_device_file(halDrive)) );
484 + generateName(libhal_drive_get_device_file(halDrive)) );
485
486 if (halVolume)
487 {
488 medium->mountableState(
489 - hal_volume_get_device_file(halVolume), /* Device node */
490 - hal_volume_get_mount_point(halVolume), /* Mount point */
491 - hal_volume_get_fstype(halVolume), /* Filesystem type */
492 - hal_volume_is_mounted(halVolume) ); /* Mounted ? */
493 + libhal_volume_get_device_file(halVolume), /* Device node */
494 + libhal_volume_get_mount_point(halVolume), /* Mount point */
495 + libhal_volume_get_fstype(halVolume), /* Filesystem type */
496 + libhal_volume_is_mounted(halVolume) ); /* Mounted ? */
497 }
498 else
499 {
500 medium->mountableState(
501 - hal_drive_get_device_file(halDrive), /* Device node */
502 + libhal_drive_get_device_file(halDrive), /* Device node */
503 "", /* Mount point */
504 "", /* Filesystem type */
505 false ); /* Mounted ? */
506 @@ -416,7 +473,7 @@
507 else
508 medium->setMimeType("media/floppy_unmounted");
509 }
510 -
511 +
512 if (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip")
513 {
514 if (halVolume)
515 @@ -424,14 +481,24 @@
516 else
517 medium->setMimeType("media/zip_unmounted");
518 }
519 -
520 +
521 medium->setIconName(QString::null);
522
523 - medium->setLabel(QString::fromUtf8( hal_drive_policy_compute_display_name(halDrive,
524 - halVolume, m_halStoragePolicy) ) );
525 + QString media_name;
526 + if (halVolume)
527 + {
528 + QString volume_name = QString::fromUtf8(libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy));
529 + media_name = volume_name;
530 + }
531 + else
532 + {
533 + QString drive_name = QString::fromUtf8(libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy));
534 + media_name = drive_name;
535 + }
536 + medium->setLabel(media_name);
537
538 - hal_drive_free(halDrive);
539 - hal_volume_free(halVolume);
540 + libhal_drive_free(halDrive);
541 + libhal_volume_free(halVolume);
542 }
543
544 void HALBackend::setCameraProperties(Medium* medium)
545 @@ -440,7 +507,7 @@
546
547 const char* udi = medium->id().ascii();
548 /* Check if the device still exists */
549 - if (!hal_device_exists(m_halContext, udi))
550 + if (!libhal_device_exists(m_halContext, udi, NULL))
551 return;
552
553 /** @todo find name */
554 @@ -462,6 +529,7 @@
555 ** HAL CALL-BACKS **
556 ******************************************/
557
558 +#ifdef HAL_0_4
559 void HALBackend::hal_main_loop_integration(LibHalContext *ctx,
560 DBusConnection *dbus_connection)
561 {
562 @@ -469,6 +537,7 @@
563 Q_UNUSED(ctx);
564 s_HALBackend->MainLoopIntegration(dbus_connection);
565 }
566 +#endif
567
568 void HALBackend::hal_device_added(LibHalContext *ctx, const char *udi)
569 {
570 @@ -493,8 +562,15 @@
571 Q_UNUSED(is_added);
572 s_HALBackend->ModifyDevice(udi, key);
573 }
574 +
575 void HALBackend::hal_device_condition(LibHalContext *ctx, const char *udi,
576 - const char *condition_name, DBusMessage *message)
577 + const char *condition_name,
578 + #ifdef HAL_0_4
579 + DBusMessage *message
580 + #else
581 + const char* message
582 + #endif
583 + )
584 {
585 kdDebug() << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl;
586 Q_UNUSED(ctx);

Properties

Name Value
svn:executable *