Lines 1-5
Link Here
|
1 |
/* This file is part of the KDE Project |
1 |
/* This file is part of the KDE Project |
2 |
Copyright (c) 2004 Jérôme Lodewyck <lodewyck@clipper.ens.fr> |
2 |
Copyright (c) 2004 - 2005 Jérôme Lodewyck <lodewyck@clipper.ens.fr> |
3 |
|
3 |
|
4 |
This library is free software; you can redistribute it and/or |
4 |
This library is free software; you can redistribute it and/or |
5 |
modify it under the terms of the GNU Library General Public |
5 |
modify it under the terms of the GNU Library General Public |
Lines 19-29
Link Here
|
19 |
#include "halbackend.h" |
19 |
#include "halbackend.h" |
20 |
#include "linuxcdpolling.h" |
20 |
#include "linuxcdpolling.h" |
21 |
|
21 |
|
|
|
22 |
#include <stdlib.h> |
23 |
|
22 |
#include <klocale.h> |
24 |
#include <klocale.h> |
23 |
#include <kurl.h> |
25 |
#include <kurl.h> |
24 |
#include <kdebug.h> |
26 |
#include <kdebug.h> |
25 |
|
27 |
|
26 |
#define MOUNT_SUFFIX (hal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted")) |
28 |
#define MOUNT_SUFFIX (libhal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted")) |
27 |
|
29 |
|
28 |
/* Static instance of this class, for static HAL callbacks */ |
30 |
/* Static instance of this class, for static HAL callbacks */ |
29 |
static HALBackend* s_HALBackend; |
31 |
static HALBackend* s_HALBackend; |
Lines 33-41
Link Here
|
33 |
{ |
35 |
{ |
34 |
char* _ppt_string; |
36 |
char* _ppt_string; |
35 |
QString _ppt_QString; |
37 |
QString _ppt_QString; |
36 |
_ppt_string = hal_device_get_property_string(ctx, udi, key); |
38 |
_ppt_string = libhal_device_get_property_string(ctx, udi, key, NULL); |
37 |
_ppt_QString = QString(_ppt_string ? _ppt_string : ""); |
39 |
_ppt_QString = QString(_ppt_string ? _ppt_string : ""); |
38 |
hal_free_string(_ppt_string); |
40 |
libhal_free_string(_ppt_string); |
39 |
return _ppt_QString; |
41 |
return _ppt_QString; |
40 |
} |
42 |
} |
41 |
|
43 |
|
Lines 55-68
Link Here
|
55 |
{ |
57 |
{ |
56 |
/* Close HAL connection */ |
58 |
/* Close HAL connection */ |
57 |
if (m_halContext) |
59 |
if (m_halContext) |
|
|
60 |
{ |
61 |
#ifdef HAL_0_4 |
58 |
hal_shutdown(m_halContext); |
62 |
hal_shutdown(m_halContext); |
|
|
63 |
#else |
64 |
libhal_ctx_shutdown(m_halContext, NULL); |
65 |
libhal_ctx_free(m_halContext); |
66 |
#endif |
67 |
} |
59 |
if (m_halStoragePolicy) |
68 |
if (m_halStoragePolicy) |
60 |
hal_storage_policy_free(m_halStoragePolicy); |
69 |
libhal_storage_policy_free(m_halStoragePolicy); |
|
|
70 |
|
71 |
/** @todo empty media list ? */ |
61 |
} |
72 |
} |
62 |
|
73 |
|
63 |
/* Connect to the HAL */ |
74 |
/* Connect to the HAL */ |
64 |
bool HALBackend::InitHal() |
75 |
bool HALBackend::InitHal() |
65 |
{ |
76 |
{ |
|
|
77 |
#ifdef HAL_0_4 /* HAL API 0.4 */ |
66 |
/* libhal initialization */ |
78 |
/* libhal initialization */ |
67 |
m_halFunctions.main_loop_integration = HALBackend::hal_main_loop_integration; |
79 |
m_halFunctions.main_loop_integration = HALBackend::hal_main_loop_integration; |
68 |
m_halFunctions.device_added = HALBackend::hal_device_added; |
80 |
m_halFunctions.device_added = HALBackend::hal_device_added; |
Lines 75-93
Link Here
|
75 |
m_halContext = hal_initialize(&m_halFunctions, FALSE); |
87 |
m_halContext = hal_initialize(&m_halFunctions, FALSE); |
76 |
if (!m_halContext) |
88 |
if (!m_halContext) |
77 |
{ |
89 |
{ |
78 |
kdDebug()<<"Failed to initialize HAL!"<<endl; |
90 |
kdDebug() << "Failed to initialize HAL!" << endl; |
79 |
return false; |
91 |
return false; |
80 |
} |
92 |
} |
81 |
|
93 |
|
82 |
/** @todo customize watch policy */ |
94 |
/** @todo customize watch policy */ |
83 |
if (hal_device_property_watch_all(m_halContext)) |
95 |
kdDebug() << "Watch properties" << endl; |
|
|
96 |
if (libhal_device_property_watch_all(m_halContext, NULL)) |
97 |
{ |
98 |
kdDebug() << "Failed to watch HAL properties!" << endl; |
99 |
return false; |
100 |
} |
101 |
#else /* HAL API >= 0.5 */ |
102 |
kdDebug() << "Context new" << endl; |
103 |
m_halContext = libhal_ctx_new(); |
104 |
if (!m_halContext) |
84 |
{ |
105 |
{ |
85 |
kdDebug()<<"Failed to watch HAL properties!"<<endl; |
106 |
kdDebug() << "Failed to initialize HAL!" << endl; |
|
|
107 |
return false; |
108 |
} |
109 |
|
110 |
// Main loop integration |
111 |
kdDebug() << "Main loop integration" << endl; |
112 |
DBusError error; |
113 |
dbus_error_init(&error); |
114 |
DBusConnection *dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); |
115 |
if (dbus_error_is_set(&error)) { |
116 |
dbus_error_free(&error); |
117 |
libhal_ctx_free(m_halContext); |
118 |
m_halContext = NULL; |
86 |
return false; |
119 |
return false; |
87 |
} |
120 |
} |
|
|
121 |
MainLoopIntegration(dbus_connection); |
122 |
libhal_ctx_set_dbus_connection(m_halContext, dbus_connection); |
123 |
|
124 |
// HAL callback functions |
125 |
kdDebug() << "Callback functions" << endl; |
126 |
libhal_ctx_set_device_added(m_halContext, HALBackend::hal_device_added); |
127 |
libhal_ctx_set_device_removed(m_halContext, HALBackend::hal_device_removed); |
128 |
libhal_ctx_set_device_new_capability (m_halContext, NULL); |
129 |
libhal_ctx_set_device_lost_capability (m_halContext, NULL); |
130 |
libhal_ctx_set_device_property_modified (m_halContext, HALBackend::hal_device_property_modified); |
131 |
libhal_ctx_set_device_condition(m_halContext, HALBackend::hal_device_condition); |
132 |
|
133 |
kdDebug() << "Context Init" << endl; |
134 |
if (!libhal_ctx_init(m_halContext, &error)) |
135 |
{ |
136 |
if (dbus_error_is_set(&error)) |
137 |
dbus_error_free(&error); |
138 |
libhal_ctx_free(m_halContext); |
139 |
m_halContext = NULL; |
140 |
kdDebug() << "Failed to init HAL context!" << endl; |
141 |
return false; |
142 |
} |
143 |
|
144 |
/** @todo customize watch policy */ |
145 |
kdDebug() << "Watch properties" << endl; |
146 |
if (!libhal_device_property_watch_all(m_halContext, &error)) |
147 |
{ |
148 |
kdDebug() << "Failed to watch HAL properties!" << endl; |
149 |
return false; |
150 |
} |
151 |
#endif |
88 |
|
152 |
|
89 |
/* libhal-storage initialization */ |
153 |
/* libhal-storage initialization */ |
90 |
m_halStoragePolicy = hal_storage_policy_new(); |
154 |
kdDebug() << "Storage Policy" << endl; |
|
|
155 |
m_halStoragePolicy = libhal_storage_policy_new(); |
91 |
/** @todo define libhal-storage icon policy */ |
156 |
/** @todo define libhal-storage icon policy */ |
92 |
|
157 |
|
93 |
/* List devices at startup */ |
158 |
/* List devices at startup */ |
Lines 97-104
Link Here
|
97 |
/* List devices (at startup)*/ |
162 |
/* List devices (at startup)*/ |
98 |
bool HALBackend::ListDevices() |
163 |
bool HALBackend::ListDevices() |
99 |
{ |
164 |
{ |
|
|
165 |
kdDebug() << "ListDevices" << endl; |
166 |
|
100 |
int numDevices; |
167 |
int numDevices; |
101 |
char** halDeviceList = hal_get_all_devices(m_halContext, &numDevices); |
168 |
char** halDeviceList = libhal_get_all_devices(m_halContext, &numDevices, NULL); |
102 |
|
169 |
|
103 |
if (!halDeviceList) |
170 |
if (!halDeviceList) |
104 |
return false; |
171 |
return false; |
Lines 116-122
Link Here
|
116 |
{ |
183 |
{ |
117 |
/* We don't deal with devices that do not expose their capabilities. |
184 |
/* We don't deal with devices that do not expose their capabilities. |
118 |
If we don't check this, we will get a lot of warning messages from libhal */ |
185 |
If we don't check this, we will get a lot of warning messages from libhal */ |
119 |
if (!hal_device_property_exists(m_halContext, udi, "info.capabilities")) |
186 |
if (!libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL)) |
120 |
return; |
187 |
return; |
121 |
|
188 |
|
122 |
/* If the device is already listed, do not process. |
189 |
/* If the device is already listed, do not process. |
Lines 126-142
Link Here
|
126 |
return; |
193 |
return; |
127 |
|
194 |
|
128 |
/* Add volume block devices */ |
195 |
/* Add volume block devices */ |
129 |
if (hal_device_query_capability(m_halContext, udi, "volume")) |
196 |
if (libhal_device_query_capability(m_halContext, udi, "volume", NULL)) |
130 |
{ |
197 |
{ |
131 |
/* We only list volume that have a filesystem or volume that have an audio track*/ |
198 |
/* We only list volume that have a filesystem or volume that have an audio track*/ |
132 |
if ( (hal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "filesystem") && |
199 |
if ( (hal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "filesystem") && |
133 |
(!hal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio")) ) |
200 |
(!libhal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio", NULL)) ) |
134 |
return; |
201 |
return; |
135 |
/* Query drive udi */ |
202 |
/* Query drive udi */ |
136 |
QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device"); |
203 |
QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device"); |
137 |
/* We don't list floppy volumes because we list floppy drives */ |
204 |
/* We don't list floppy volumes because we list floppy drives */ |
138 |
if ((hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "floppy") || |
205 |
if ((hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "floppy") || |
139 |
(hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "zip")) |
206 |
(hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "zip") || |
|
|
207 |
(hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "jaz")) |
140 |
return; |
208 |
return; |
141 |
|
209 |
|
142 |
/** @todo check exclusion list **/ |
210 |
/** @todo check exclusion list **/ |
Lines 148-158
Link Here
|
148 |
|
216 |
|
149 |
return; |
217 |
return; |
150 |
} |
218 |
} |
151 |
|
219 |
|
152 |
/* Floppy & zip drives */ |
220 |
/* Floppy & zip drives */ |
153 |
if (hal_device_query_capability(m_halContext, udi, "storage")) |
221 |
if (libhal_device_query_capability(m_halContext, udi, "storage", NULL)) |
154 |
if ((hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "floppy") || |
222 |
if ((hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "floppy") || |
155 |
(hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip")) |
223 |
(hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip") || |
|
|
224 |
(hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "jaz")) |
156 |
{ |
225 |
{ |
157 |
/* Create medium */ |
226 |
/* Create medium */ |
158 |
Medium* medium = new Medium(udi, ""); |
227 |
Medium* medium = new Medium(udi, ""); |
Lines 162-168
Link Here
|
162 |
} |
231 |
} |
163 |
|
232 |
|
164 |
/* Camera handled by gphoto2*/ |
233 |
/* Camera handled by gphoto2*/ |
165 |
if (hal_device_query_capability(m_halContext, udi, "camera")) |
234 |
if (libhal_device_query_capability(m_halContext, udi, "camera", NULL)) |
166 |
|
235 |
|
167 |
{ |
236 |
{ |
168 |
/* Create medium */ |
237 |
/* Create medium */ |
Lines 180-188
Link Here
|
180 |
|
249 |
|
181 |
void HALBackend::ModifyDevice(const char *udi, const char* key) |
250 |
void HALBackend::ModifyDevice(const char *udi, const char* key) |
182 |
{ |
251 |
{ |
183 |
Q_UNUSED(udi); |
252 |
const char* mediumUdi = findMediumUdiFromUdi(udi); |
|
|
253 |
if (!mediumUdi) |
254 |
return; |
255 |
ResetProperties(mediumUdi); |
256 |
|
184 |
Q_UNUSED(key); |
257 |
Q_UNUSED(key); |
185 |
/* |
258 |
/* |
|
|
259 |
Q_UNUSED(udi); |
186 |
TODO: enable this when the watch policy is written |
260 |
TODO: enable this when the watch policy is written |
187 |
*/ |
261 |
*/ |
188 |
} |
262 |
} |
Lines 229-236
Link Here
|
229 |
return medium->id().ascii(); |
303 |
return medium->id().ascii(); |
230 |
|
304 |
|
231 |
/* Hard part : this is a volume whose drive is registered */ |
305 |
/* Hard part : this is a volume whose drive is registered */ |
232 |
if (hal_device_property_exists(m_halContext, udi, "info.capabilities")) |
306 |
if (libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL)) |
233 |
if (hal_device_query_capability(m_halContext, udi, "volume")) |
307 |
if (libhal_device_query_capability(m_halContext, udi, "volume", NULL)) |
234 |
{ |
308 |
{ |
235 |
QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device"); |
309 |
QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device"); |
236 |
return findMediumUdiFromUdi(driveUdi.ascii()); |
310 |
return findMediumUdiFromUdi(driveUdi.ascii()); |
Lines 244-254
Link Here
|
244 |
kdDebug() << "HALBackend::setProperties" << endl; |
318 |
kdDebug() << "HALBackend::setProperties" << endl; |
245 |
|
319 |
|
246 |
Medium* m = new Medium(mediumUdi, ""); |
320 |
Medium* m = new Medium(mediumUdi, ""); |
247 |
if (hal_device_query_capability(m_halContext, mediumUdi, "volume")) |
321 |
if (libhal_device_query_capability(m_halContext, mediumUdi, "volume", NULL)) |
248 |
setVolumeProperties(m); |
322 |
setVolumeProperties(m); |
249 |
if (hal_device_query_capability(m_halContext, mediumUdi, "storage")) |
323 |
if (libhal_device_query_capability(m_halContext, mediumUdi, "storage", NULL)) |
250 |
setFloppyProperties(m); |
324 |
setFloppyProperties(m); |
251 |
if (hal_device_query_capability(m_halContext, mediumUdi, "camera")) |
325 |
if (libhal_device_query_capability(m_halContext, mediumUdi, "camera", NULL)) |
252 |
setCameraProperties(m); |
326 |
setCameraProperties(m); |
253 |
|
327 |
|
254 |
m_mediaList.changeMediumState(*m); |
328 |
m_mediaList.changeMediumState(*m); |
Lines 262-295
Link Here
|
262 |
|
336 |
|
263 |
const char* udi = medium->id().ascii(); |
337 |
const char* udi = medium->id().ascii(); |
264 |
/* Check if the device still exists */ |
338 |
/* Check if the device still exists */ |
265 |
if (!hal_device_exists(m_halContext, udi)) |
339 |
if (!libhal_device_exists(m_halContext, udi, NULL)) |
266 |
return; |
340 |
return; |
267 |
|
341 |
|
268 |
/* Get device information from libhal-storage */ |
342 |
/* Get device information from libhal-storage */ |
269 |
HalVolume* halVolume = hal_volume_from_udi(m_halContext, udi); |
343 |
LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi); |
270 |
if (!halVolume) |
344 |
if (!halVolume) |
271 |
return; |
345 |
return; |
272 |
|
346 |
QString driveUdi = libhal_volume_get_storage_device_udi(halVolume); |
273 |
QString driveUdi = hal_volume_get_storage_device_udi(halVolume); |
347 |
LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, driveUdi.ascii()); |
274 |
HalDrive* halDrive = hal_drive_from_udi(m_halContext, driveUdi.ascii()); |
|
|
275 |
|
348 |
|
276 |
medium->setName( |
349 |
medium->setName( |
277 |
generateName(hal_volume_get_device_file(halVolume)) ); |
350 |
generateName(libhal_volume_get_device_file(halVolume)) ); |
278 |
|
351 |
|
279 |
medium->mountableState( |
352 |
medium->mountableState( |
280 |
hal_volume_get_device_file(halVolume), /* Device node */ |
353 |
libhal_volume_get_device_file(halVolume), /* Device node */ |
281 |
hal_volume_get_mount_point(halVolume), /* Mount point */ |
354 |
libhal_volume_get_mount_point(halVolume), /* Mount point */ |
282 |
hal_volume_get_fstype(halVolume), /* Filesystem type */ |
355 |
libhal_volume_get_fstype(halVolume), /* Filesystem type */ |
283 |
hal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
356 |
libhal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
284 |
|
357 |
|
285 |
QString mimeType; |
358 |
QString mimeType; |
286 |
if (hal_volume_is_disc(halVolume)) |
359 |
if (libhal_volume_is_disc(halVolume)) |
287 |
{ |
360 |
{ |
288 |
mimeType = "media/cdrom" + MOUNT_SUFFIX; |
361 |
mimeType = "media/cdrom" + MOUNT_SUFFIX; |
289 |
|
362 |
|
290 |
HalVolumeDiscType discType = hal_volume_get_disc_type(halVolume); |
363 |
LibHalVolumeDiscType discType = libhal_volume_get_disc_type(halVolume); |
291 |
if ((discType == HAL_VOLUME_DISC_TYPE_CDR) || (discType == HAL_VOLUME_DISC_TYPE_CDRW)) |
364 |
if ((discType == LIBHAL_VOLUME_DISC_TYPE_CDROM) || |
292 |
if (hal_volume_disc_is_blank(halVolume)) |
365 |
(discType == LIBHAL_VOLUME_DISC_TYPE_CDR) || |
|
|
366 |
(discType == LIBHAL_VOLUME_DISC_TYPE_CDRW)) |
367 |
if (libhal_volume_disc_is_blank(halVolume)) |
293 |
{ |
368 |
{ |
294 |
mimeType = "media/blankcd"; |
369 |
mimeType = "media/blankcd"; |
295 |
medium->unmountableState(""); |
370 |
medium->unmountableState(""); |
Lines 297-306
Link Here
|
297 |
else |
372 |
else |
298 |
mimeType = "media/cdwriter" + MOUNT_SUFFIX; |
373 |
mimeType = "media/cdwriter" + MOUNT_SUFFIX; |
299 |
|
374 |
|
300 |
if ((discType == HAL_VOLUME_DISC_TYPE_DVDROM) || (discType == HAL_VOLUME_DISC_TYPE_DVDRAM) || |
375 |
if ((discType == LIBHAL_VOLUME_DISC_TYPE_DVDROM) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRAM) || |
301 |
(discType == HAL_VOLUME_DISC_TYPE_DVDR) || (discType == HAL_VOLUME_DISC_TYPE_DVDRW) || |
376 |
(discType == LIBHAL_VOLUME_DISC_TYPE_DVDR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRW) || |
302 |
(discType == HAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSRW) ) |
377 |
(discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW) ) |
303 |
if (hal_volume_disc_is_blank(halVolume)) |
378 |
if (libhal_volume_disc_is_blank(halVolume)) |
304 |
{ |
379 |
{ |
305 |
mimeType = "media/blankdvd"; |
380 |
mimeType = "media/blankdvd"; |
306 |
medium->unmountableState(""); |
381 |
medium->unmountableState(""); |
Lines 308-323
Link Here
|
308 |
else |
383 |
else |
309 |
mimeType = "media/dvd" + MOUNT_SUFFIX; |
384 |
mimeType = "media/dvd" + MOUNT_SUFFIX; |
310 |
|
385 |
|
311 |
if (hal_volume_disc_has_audio(halVolume) && !hal_volume_disc_has_data(halVolume)) |
386 |
if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume)) |
312 |
{ |
387 |
{ |
313 |
mimeType = "media/audiocd"; |
388 |
mimeType = "media/audiocd"; |
314 |
medium->unmountableState( "audiocd:/?device=" + QString(hal_volume_get_device_file(halVolume)) ); |
389 |
medium->unmountableState( "audiocd:/?device=" + QString(libhal_volume_get_device_file(halVolume)) ); |
315 |
} |
390 |
} |
316 |
|
391 |
|
317 |
medium->setIconName(QString::null); |
392 |
medium->setIconName(QString::null); |
318 |
|
393 |
|
319 |
/* check if the disc id a vcd or a video dvd */ |
394 |
/* check if the disc id a vcd or a video dvd */ |
320 |
DiscType type = LinuxCDPolling::identifyDiscType(hal_volume_get_device_file(halVolume)); |
395 |
DiscType type = LinuxCDPolling::identifyDiscType(libhal_volume_get_device_file(halVolume)); |
321 |
switch (type) |
396 |
switch (type) |
322 |
{ |
397 |
{ |
323 |
case DiscType::VCD: |
398 |
case DiscType::VCD: |
Lines 334-377
Link Here
|
334 |
else |
409 |
else |
335 |
{ |
410 |
{ |
336 |
mimeType = "media/hdd" + MOUNT_SUFFIX; |
411 |
mimeType = "media/hdd" + MOUNT_SUFFIX; |
337 |
if (hal_drive_is_hotpluggable(halDrive)) |
412 |
if (libhal_drive_is_hotpluggable(halDrive)) |
338 |
{ |
413 |
{ |
339 |
mimeType = "media/removable" + MOUNT_SUFFIX; |
414 |
mimeType = "media/removable" + MOUNT_SUFFIX; |
340 |
medium->needMounting(); |
415 |
medium->needMounting(); |
341 |
switch (hal_drive_get_type(halDrive)) { |
416 |
switch (libhal_drive_get_type(halDrive)) { |
342 |
case HAL_DRIVE_TYPE_COMPACT_FLASH: |
417 |
case LIBHAL_DRIVE_TYPE_COMPACT_FLASH: |
343 |
medium->setIconName("compact_flash" + MOUNT_SUFFIX); |
418 |
medium->setIconName("compact_flash" + MOUNT_SUFFIX); |
344 |
break; |
419 |
break; |
345 |
case HAL_DRIVE_TYPE_MEMORY_STICK: |
420 |
case LIBHAL_DRIVE_TYPE_MEMORY_STICK: |
346 |
medium->setIconName("memory_stick" + MOUNT_SUFFIX); |
421 |
medium->setIconName("memory_stick" + MOUNT_SUFFIX); |
347 |
break; |
422 |
break; |
348 |
case HAL_DRIVE_TYPE_SMART_MEDIA: |
423 |
case LIBHAL_DRIVE_TYPE_SMART_MEDIA: |
349 |
medium->setIconName("smart_media" + MOUNT_SUFFIX); |
424 |
medium->setIconName("smart_media" + MOUNT_SUFFIX); |
350 |
break; |
425 |
break; |
351 |
case HAL_DRIVE_TYPE_SD_MMC: |
426 |
case LIBHAL_DRIVE_TYPE_SD_MMC: |
352 |
medium->setIconName("sd_mmc" + MOUNT_SUFFIX); |
427 |
medium->setIconName("sd_mmc" + MOUNT_SUFFIX); |
353 |
break; |
428 |
break; |
354 |
case HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER: |
429 |
case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER: |
355 |
medium->setIconName(QString::null); //FIXME need icon |
430 |
medium->setIconName(QString::null); //FIXME need icon |
356 |
break; |
431 |
break; |
357 |
case HAL_DRIVE_TYPE_CAMERA: |
432 |
case LIBHAL_DRIVE_TYPE_CAMERA: |
358 |
medium->setIconName("camera" + MOUNT_SUFFIX); |
433 |
medium->setIconName("camera" + MOUNT_SUFFIX); |
359 |
break; |
434 |
break; |
360 |
case HAL_DRIVE_TYPE_TAPE: |
435 |
case LIBHAL_DRIVE_TYPE_TAPE: |
361 |
medium->setIconName(QString::null); //FIXME need icon |
436 |
medium->setIconName(QString::null); //FIXME need icon |
362 |
break; |
437 |
break; |
363 |
default: |
438 |
default: |
364 |
medium->setIconName(QString::null); |
439 |
medium->setIconName(QString::null); |
365 |
}; |
440 |
}; |
366 |
}; |
441 |
}; |
367 |
} |
442 |
} |
368 |
medium->setMimeType(mimeType); |
443 |
medium->setMimeType(mimeType); |
369 |
|
444 |
|
370 |
medium->setLabel(QString::fromUtf8( hal_volume_policy_compute_display_name(halDrive, |
445 |
char* name = libhal_volume_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
371 |
halVolume, m_halStoragePolicy) ) ); |
446 |
//char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
|
|
447 |
QString volume_name = QString::fromUtf8(name); |
448 |
QString media_name = volume_name; |
449 |
medium->setLabel(media_name); |
450 |
free(name); |
372 |
|
451 |
|
373 |
hal_drive_free(halDrive); |
452 |
libhal_drive_free(halDrive); |
374 |
hal_volume_free(halVolume); |
453 |
libhal_volume_free(halVolume); |
375 |
} |
454 |
} |
376 |
|
455 |
|
377 |
// Handle floppies and zip drives |
456 |
// Handle floppies and zip drives |
Lines 381-414
Link Here
|
381 |
|
460 |
|
382 |
const char* udi = medium->id().ascii(); |
461 |
const char* udi = medium->id().ascii(); |
383 |
/* Check if the device still exists */ |
462 |
/* Check if the device still exists */ |
384 |
if (!hal_device_exists(m_halContext, udi)) |
463 |
if (!libhal_device_exists(m_halContext, udi, NULL)) |
385 |
return; |
464 |
return; |
386 |
|
465 |
|
387 |
HalDrive* halDrive = hal_drive_from_udi(m_halContext, udi); |
466 |
LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, udi); |
388 |
if (!halDrive) |
467 |
if (!halDrive) |
389 |
return; |
468 |
return; |
390 |
int numVolumes; |
469 |
int numVolumes; |
391 |
char** volumes = hal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes); |
470 |
char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes); |
392 |
HalVolume* halVolume = NULL; |
471 |
LibHalVolume* halVolume = NULL; |
393 |
kdDebug() << " found " << numVolumes << " volumes" << endl; |
472 |
kdDebug() << " found " << numVolumes << " volumes" << endl; |
394 |
if (numVolumes) |
473 |
if (numVolumes) |
395 |
halVolume = hal_volume_from_udi(m_halContext, volumes[0]); |
474 |
halVolume = libhal_volume_from_udi(m_halContext, volumes[0]); |
396 |
|
475 |
|
397 |
medium->setName( |
476 |
medium->setName( |
398 |
generateName(hal_drive_get_device_file(halDrive)) ); |
477 |
generateName(libhal_drive_get_device_file(halDrive)) ); |
399 |
|
478 |
|
400 |
if (halVolume) |
479 |
if (halVolume) |
401 |
{ |
480 |
{ |
402 |
medium->mountableState( |
481 |
medium->mountableState( |
403 |
hal_volume_get_device_file(halVolume), /* Device node */ |
482 |
libhal_volume_get_device_file(halVolume), /* Device node */ |
404 |
hal_volume_get_mount_point(halVolume), /* Mount point */ |
483 |
libhal_volume_get_mount_point(halVolume), /* Mount point */ |
405 |
hal_volume_get_fstype(halVolume), /* Filesystem type */ |
484 |
libhal_volume_get_fstype(halVolume), /* Filesystem type */ |
406 |
hal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
485 |
libhal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
407 |
} |
486 |
} |
408 |
else |
487 |
else |
409 |
{ |
488 |
{ |
410 |
medium->mountableState( |
489 |
medium->mountableState( |
411 |
hal_drive_get_device_file(halDrive), /* Device node */ |
490 |
libhal_drive_get_device_file(halDrive), /* Device node */ |
412 |
"", /* Mount point */ |
491 |
"", /* Mount point */ |
413 |
"", /* Filesystem type */ |
492 |
"", /* Filesystem type */ |
414 |
false ); /* Mounted ? */ |
493 |
false ); /* Mounted ? */ |
Lines 421-427
Link Here
|
421 |
else |
500 |
else |
422 |
medium->setMimeType("media/floppy_unmounted"); |
501 |
medium->setMimeType("media/floppy_unmounted"); |
423 |
} |
502 |
} |
424 |
|
503 |
|
425 |
if (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip") |
504 |
if (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip") |
426 |
{ |
505 |
{ |
427 |
if (halVolume) |
506 |
if (halVolume) |
Lines 429-442
Link Here
|
429 |
else |
508 |
else |
430 |
medium->setMimeType("media/zip_unmounted"); |
509 |
medium->setMimeType("media/zip_unmounted"); |
431 |
} |
510 |
} |
432 |
|
511 |
|
433 |
medium->setIconName(QString::null); |
512 |
medium->setIconName(QString::null); |
434 |
|
513 |
|
435 |
medium->setLabel(QString::fromUtf8( hal_drive_policy_compute_display_name(halDrive, |
514 |
QString media_name; |
436 |
halVolume, m_halStoragePolicy) ) ); |
515 |
if (halVolume) |
|
|
516 |
{ |
517 |
char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
518 |
QString volume_name = QString::fromUtf8(name); |
519 |
media_name = volume_name; |
520 |
free(name); |
521 |
} |
522 |
else |
523 |
{ |
524 |
char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
525 |
QString drive_name = QString::fromUtf8(name); |
526 |
media_name = drive_name; |
527 |
free(name); |
528 |
} |
529 |
medium->setLabel(media_name); |
437 |
|
530 |
|
438 |
hal_drive_free(halDrive); |
531 |
free(volumes); |
439 |
hal_volume_free(halVolume); |
532 |
libhal_drive_free(halDrive); |
|
|
533 |
libhal_volume_free(halVolume); |
440 |
} |
534 |
} |
441 |
|
535 |
|
442 |
void HALBackend::setCameraProperties(Medium* medium) |
536 |
void HALBackend::setCameraProperties(Medium* medium) |
Lines 445-451
Link Here
|
445 |
|
539 |
|
446 |
const char* udi = medium->id().ascii(); |
540 |
const char* udi = medium->id().ascii(); |
447 |
/* Check if the device still exists */ |
541 |
/* Check if the device still exists */ |
448 |
if (!hal_device_exists(m_halContext, udi)) |
542 |
if (!libhal_device_exists(m_halContext, udi, NULL)) |
449 |
return; |
543 |
return; |
450 |
|
544 |
|
451 |
/** @todo find name */ |
545 |
/** @todo find name */ |
Lines 467-472
Link Here
|
467 |
** HAL CALL-BACKS ** |
561 |
** HAL CALL-BACKS ** |
468 |
******************************************/ |
562 |
******************************************/ |
469 |
|
563 |
|
|
|
564 |
#ifdef HAL_0_4 |
470 |
void HALBackend::hal_main_loop_integration(LibHalContext *ctx, |
565 |
void HALBackend::hal_main_loop_integration(LibHalContext *ctx, |
471 |
DBusConnection *dbus_connection) |
566 |
DBusConnection *dbus_connection) |
472 |
{ |
567 |
{ |
Lines 474-479
Link Here
|
474 |
Q_UNUSED(ctx); |
569 |
Q_UNUSED(ctx); |
475 |
s_HALBackend->MainLoopIntegration(dbus_connection); |
570 |
s_HALBackend->MainLoopIntegration(dbus_connection); |
476 |
} |
571 |
} |
|
|
572 |
#endif |
477 |
|
573 |
|
478 |
void HALBackend::hal_device_added(LibHalContext *ctx, const char *udi) |
574 |
void HALBackend::hal_device_added(LibHalContext *ctx, const char *udi) |
479 |
{ |
575 |
{ |
Lines 498-505
Link Here
|
498 |
Q_UNUSED(is_added); |
594 |
Q_UNUSED(is_added); |
499 |
s_HALBackend->ModifyDevice(udi, key); |
595 |
s_HALBackend->ModifyDevice(udi, key); |
500 |
} |
596 |
} |
|
|
597 |
|
501 |
void HALBackend::hal_device_condition(LibHalContext *ctx, const char *udi, |
598 |
void HALBackend::hal_device_condition(LibHalContext *ctx, const char *udi, |
502 |
const char *condition_name, DBusMessage *message) |
599 |
const char *condition_name, |
|
|
600 |
#ifdef HAL_0_4 |
601 |
DBusMessage *message |
602 |
#else |
603 |
const char* message |
604 |
#endif |
605 |
) |
503 |
{ |
606 |
{ |
504 |
kdDebug() << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl; |
607 |
kdDebug() << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl; |
505 |
Q_UNUSED(ctx); |
608 |
Q_UNUSED(ctx); |