Contents of /trunk/kdebase/patches/kdebase-3.4.3-hal-0.5.patch
Parent Directory | Revision Log
Revision 144 -
(show annotations)
(download)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 37362 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 37362 byte(s)
-import
1 | diff -Nur kdebase-3.4.3.orig/kioslave/media/configure.in.in kdebase-3.4.3/kioslave/media/configure.in.in |
2 | --- kdebase-3.4.3.orig/kioslave/media/configure.in.in 2005-10-05 15:38:19.000000000 +0200 |
3 | +++ kdebase-3.4.3/kioslave/media/configure.in.in 2005-10-09 11:50:50.000000000 +0200 |
4 | @@ -12,100 +12,100 @@ |
5 | AC_ARG_WITH(hal,AC_HELP_STRING([--with-hal],[Enable HAL support [default=check]]),[hal_test="$withval"],[hal_test="yes"]) |
6 | |
7 | if test "x$hal_test" = "xyes" ; then |
8 | - |
9 | -########### Check for the HAL, version 0.4.x |
10 | - |
11 | - AC_MSG_CHECKING(for the HAL 0.4) |
12 | - |
13 | + |
14 | +########### Check for the HAL |
15 | + |
16 | + AC_MSG_CHECKING(for the HAL) |
17 | + |
18 | hal_inc=NOTFOUND |
19 | hal_lib=NOTFOUND |
20 | hal=NOTFOUND |
21 | - |
22 | - search_incs="$kde_includes /usr/include /usr/local/include /usr/include/hal /usr/local/include/hal" |
23 | + |
24 | + search_incs="$kde_includes /usr/include /usr/include/hal /usr/local/include /usr/local/include/hal" |
25 | AC_FIND_FILE(libhal.h libhal-storage.h, $search_incs, hal_incdir) |
26 | - |
27 | + |
28 | if test -r $hal_incdir/libhal.h && test -r $hal_incdir/libhal-storage.h ; then |
29 | HAL_INCS="-I$hal_incdir" |
30 | hal_inc=FOUND |
31 | fi |
32 | - |
33 | + |
34 | + if test -r $hal_incdir/libhal-storage.h ; then |
35 | + hal_storage_version=4 |
36 | + grep LibHalVolume $hal_incdir/libhal-storage.h \ |
37 | + > /dev/null 2>&1 && hal_storage_version=5 |
38 | + if test $hal_storage_version = 4 ; then |
39 | + AC_DEFINE(HAL_0_4, , [HAL API version 0.4]) |
40 | + fi |
41 | + fi |
42 | + |
43 | search_libs="$kde_libraries /usr/lib /usr/local/lib" |
44 | AC_FIND_FILE(libhal.so libhal-storage.so, $search_libs, hal_libdir) |
45 | - |
46 | - if [test -r $hal_libdir/libhal.so] && test -r $hal_libdir/libhal-storage.so ; then |
47 | + |
48 | + if test -r $hal_libdir/libhal.so && test -r $hal_libdir/libhal-storage.so ; then |
49 | HAL_LIBS="-L$hal_libdir -lhal -lhal-storage" |
50 | hal_lib=FOUND |
51 | fi |
52 | - |
53 | - if test -r $hal_incdir/libhal.h ; then |
54 | - hal_version=5 |
55 | - grep LibHalFunctions $hal_incdir/libhal.h \ |
56 | - > /dev/null 2>&1 && hal_version=4 |
57 | - if test $hal_version = 5 ; then |
58 | - hal_lib=NOT_FOUND |
59 | - fi |
60 | - fi |
61 | - |
62 | - |
63 | - if test "$hal_inc" = "FOUND" && test "$hal_lib" = "FOUND" ; then |
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 | + hal=FOUND |
70 | else |
71 | AC_MSG_RESULT(searched but not found) |
72 | fi |
73 | - |
74 | + |
75 | AC_SUBST(HAL_INCS) |
76 | AC_SUBST(HAL_LIBS) |
77 | - |
78 | - |
79 | + |
80 | + |
81 | ########### Check for DBus |
82 | - |
83 | + |
84 | AC_MSG_CHECKING(for DBus) |
85 | - |
86 | + |
87 | dbus_inc=NOTFOUND |
88 | dbus_lib=NOTFOUND |
89 | dbus=NOTFOUND |
90 | - |
91 | - search_incs="$kde_includes /usr/include /usr/local/include /usr/include/dbus-1.0 /usr/local/include/dbus-1.0" |
92 | + |
93 | + search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0" |
94 | AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir) |
95 | - |
96 | + |
97 | search_incs_arch_deps="$kde_includes /usr/lib/dbus-1.0/include /usr/local/lib/dbus-1.0/include" |
98 | AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps) |
99 | - |
100 | + |
101 | if test -r $dbus_incdir/dbus/dbus.h && test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h ; then |
102 | DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps" |
103 | dbus_inc=FOUND |
104 | fi |
105 | - |
106 | + |
107 | search_libs="$kde_libraries /usr/lib /usr/local/lib" |
108 | AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir) |
109 | - |
110 | + |
111 | if test -r $dbus_libdir/libdbus-1.so ; then |
112 | DBUS_LIBS="-L$dbus_libdir -ldbus-1" |
113 | dbus_lib=FOUND |
114 | fi |
115 | - |
116 | + |
117 | if test "$dbus_inc" = FOUND && test "$dbus_lib" = FOUND ; then |
118 | AC_MSG_RESULT(headers $dbus_incdir $dbus_incdir_arch_deps libraries $dbus_libdir) |
119 | dbus=FOUND |
120 | else |
121 | AC_MSG_RESULT(searched but not found) |
122 | fi |
123 | - |
124 | + |
125 | AC_SUBST(DBUS_INCS) |
126 | AC_SUBST(DBUS_LIBS) |
127 | - |
128 | + |
129 | ########### Check for DBus-Qt bindings |
130 | - |
131 | + |
132 | AC_MSG_CHECKING(for DBus-Qt bindings) |
133 | - |
134 | + |
135 | dbusqt_inc=NOTFOUND |
136 | dbusqt_lib=NOTFOUND |
137 | dbusqt=NOTFOUND |
138 | - |
139 | - search_incs="$kde_includes /usr/include /usr/local/include /usr/include/dbus-1.0 /usr/local/include/dbus-1.0" |
140 | + |
141 | + search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0" |
142 | AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir) |
143 | - |
144 | + |
145 | if test -r $dbusqt_incdir/dbus/connection.h ; then |
146 | have_qt_patch=0 |
147 | grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \ |
148 | @@ -115,15 +115,15 @@ |
149 | dbusqt_inc=FOUND |
150 | fi |
151 | fi |
152 | - |
153 | + |
154 | search_libs="$kde_libraries /usr/lib /usr/local/lib" |
155 | AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir) |
156 | - |
157 | + |
158 | if test -r $dbusqt_libdir/libdbus-qt-1.so ; then |
159 | DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1" |
160 | dbusqt_lib=FOUND |
161 | fi |
162 | - |
163 | + |
164 | if test "$dbusqt_inc" = FOUND && test "$dbusqt_lib" = FOUND ; then |
165 | AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir) |
166 | dbusqt=FOUND |
167 | diff -Nur kdebase-3.4.3.orig/kioslave/media/kdedmodule/Makefile.am kdebase-3.4.3/kioslave/media/kdedmodule/Makefile.am |
168 | --- kdebase-3.4.3.orig/kioslave/media/kdedmodule/Makefile.am 2005-10-05 15:38:19.000000000 +0200 |
169 | +++ kdebase-3.4.3/kioslave/media/kdedmodule/Makefile.am 2005-10-09 11:24:34.000000000 +0200 |
170 | @@ -22,7 +22,7 @@ |
171 | |
172 | noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB) $(HALBACKEND_LIB) |
173 | |
174 | -kded_mediamanager_la_SOURCES = mediamanager.cpp mediamanager.skel medialist.cpp backendbase.cpp fstabbackend.cpp removablebackend.cpp mediadirnotify.cpp mediadirnotify.skel |
175 | +kded_mediamanager_la_SOURCES = mediamanager.cpp mediamanager.skel medialist.cpp backendbase.cpp fstabbackend.cpp haladdition.cpp removablebackend.cpp mediadirnotify.cpp mediadirnotify.skel |
176 | kded_mediamanager_la_LDFLAGS = $(all_libraries) -module -avoid-version |
177 | kded_mediamanager_la_LIBADD = $(LIB_KSYCOCA) ../libmediacommon/libmediacommon.la $(HALBACKEND_LIB) $(LINUXCDPOLLING_LIB) |
178 | |
179 | diff -Nur kdebase-3.4.3.orig/kioslave/media/kdedmodule/haladdition.cpp kdebase-3.4.3/kioslave/media/kdedmodule/haladdition.cpp |
180 | --- kdebase-3.4.3.orig/kioslave/media/kdedmodule/haladdition.cpp 1970-01-01 01:00:00.000000000 +0100 |
181 | +++ kdebase-3.4.3/kioslave/media/kdedmodule/haladdition.cpp 2005-10-09 11:24:34.000000000 +0200 |
182 | @@ -0,0 +1,155 @@ |
183 | +/* This file is part of the KDE Project |
184 | + Copyright (c) 2004 Kévin Ottens <ervin ipsquad net> |
185 | + |
186 | + This library is free software; you can redistribute it and/or |
187 | + modify it under the terms of the GNU Library General Public |
188 | + License version 2 as published by the Free Software Foundation. |
189 | + |
190 | + This library is distributed in the hope that it will be useful, |
191 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
192 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
193 | + Library General Public License for more details. |
194 | + |
195 | + You should have received a copy of the GNU Library General Public License |
196 | + along with this library; see the file COPYING.LIB. If not, write to |
197 | + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
198 | + Boston, MA 02111-1307, USA. |
199 | +*/ |
200 | + |
201 | +#include "haladdition.h" |
202 | + |
203 | +#include <klocale.h> |
204 | +#include <kdirwatch.h> |
205 | +#include <kurl.h> |
206 | +#include <kstandarddirs.h> |
207 | + |
208 | +#ifdef _OS_SOLARIS_ |
209 | +#define MTAB "/etc/mnttab" |
210 | +#else |
211 | +#define MTAB "/etc/mtab" |
212 | +#endif |
213 | + |
214 | + |
215 | +HalAddition::HalAddition(MediaList &list) |
216 | + : QObject(), BackendBase(list) |
217 | +{ |
218 | + KDirWatch::self()->addFile(MTAB); |
219 | + |
220 | + connect( KDirWatch::self(), SIGNAL( dirty(const QString&) ), |
221 | + this, SLOT( slotDirty(const QString&) ) ); |
222 | + |
223 | + handleMtabChange(); |
224 | + |
225 | + KDirWatch::self()->startScan(); |
226 | +} |
227 | + |
228 | +void HalAddition::slotDirty(const QString &path) |
229 | +{ |
230 | + if (path==MTAB) |
231 | + { |
232 | + handleMtabChange(); |
233 | + } |
234 | +} |
235 | + |
236 | +void HalAddition::handleMtabChange() |
237 | +{ |
238 | + QStringList new_mtabIds; |
239 | + KMountPoint::List mtab = KMountPoint::currentMountPoints(); |
240 | + |
241 | + KMountPoint::List::iterator it = mtab.begin(); |
242 | + KMountPoint::List::iterator end = mtab.end(); |
243 | + |
244 | + for (; it!=end; ++it) |
245 | + { |
246 | + QString dev = (*it)->mountedFrom(); |
247 | + QString mp = (*it)->mountPoint(); |
248 | + QString fs = (*it)->mountType(); |
249 | + |
250 | + if ( mp == "/" |
251 | + || mp.find("/media/floppy") != -1 |
252 | + || mp.find("/media/zip") != -1 |
253 | + || mp.find("/media/jaz") != -1 |
254 | + ) |
255 | + { |
256 | + QString device; |
257 | + const Medium *medium; |
258 | + |
259 | + device = dev; |
260 | + device.replace("/dev/", ""); |
261 | + |
262 | + if (medium = m_mediaList.findByName(device)) |
263 | + { |
264 | + QString mime, icon, label; |
265 | + guess(dev, mp, fs, true, mime, icon, label); |
266 | + m_mediaList.changeMediumState(medium->id(), dev, mp, fs, true, mime, icon, medium->label()); |
267 | + new_mtabIds += device; |
268 | + } |
269 | + } |
270 | + } |
271 | + |
272 | + QStringList::iterator it2 = m_mtabIds.begin(); |
273 | + QStringList::iterator end2 = m_mtabIds.end(); |
274 | + |
275 | + for (; it2!=end2; ++it2) |
276 | + { |
277 | + if ( !new_mtabIds.contains(*it2) ) |
278 | + { |
279 | + const Medium *medium; |
280 | + |
281 | + if (medium = m_mediaList.findByName(*it2)) |
282 | + { |
283 | + QString dev = medium->deviceNode(); |
284 | + QString mp = medium->mountPoint(); |
285 | + QString fs = medium->fsType(); |
286 | + QString mime, icon, label; |
287 | + |
288 | + guess(dev, mp, fs, false, mime, icon, label); |
289 | + m_mediaList.changeMediumState(medium->id(), false, mime, icon, medium->label()); |
290 | + } |
291 | + } |
292 | + } |
293 | + m_mtabIds = new_mtabIds; |
294 | +} |
295 | + |
296 | +void HalAddition::guess(const QString &devNode, const QString &mountPoint, |
297 | + const QString &fsType, bool mounted, |
298 | + QString &mimeType, QString &iconName, QString &label) |
299 | +{ |
300 | + if ( devNode.find("fd")!=-1 ) |
301 | + { |
302 | + if ( devNode.find("360")!=-1 || devNode.find("1200")!=-1 ) |
303 | + { |
304 | + mimeType = "media/floppy5"; |
305 | + } |
306 | + else |
307 | + { |
308 | + mimeType = "media/floppy"; |
309 | + } |
310 | + label = i18n("Floppy"); |
311 | + } |
312 | + else if ( mountPoint.find("zip")!=-1 |
313 | + || mountPoint.find("jaz")!=-1 |
314 | + // FREEBSD SPECIFIC |
315 | + || devNode.find("/afd")!=-1 |
316 | + ) |
317 | + { |
318 | + mimeType = "media/zip"; |
319 | + label = i18n("Zip Disk"); |
320 | + } |
321 | + else |
322 | + { |
323 | + mimeType = "media/hdd"; |
324 | + label = i18n("Harddisk"); |
325 | + } |
326 | + |
327 | + QString tmp = devNode; |
328 | + if ( tmp.startsWith("/dev/") ) |
329 | + { |
330 | + tmp = tmp.mid(5); |
331 | + } |
332 | + label+= " (" + tmp + ")"; |
333 | + mimeType+= (mounted ? "_mounted" : "_unmounted"); |
334 | + iconName = QString::null; |
335 | +} |
336 | + |
337 | +#include "haladdition.moc" |
338 | diff -Nur kdebase-3.4.3.orig/kioslave/media/kdedmodule/haladdition.h kdebase-3.4.3/kioslave/media/kdedmodule/haladdition.h |
339 | --- kdebase-3.4.3.orig/kioslave/media/kdedmodule/haladdition.h 1970-01-01 01:00:00.000000000 +0100 |
340 | +++ kdebase-3.4.3/kioslave/media/kdedmodule/haladdition.h 2005-10-09 11:24:34.000000000 +0200 |
341 | @@ -0,0 +1,49 @@ |
342 | +/* This file is part of the KDE Project |
343 | + Copyright (c) 2004 Kévin Ottens <ervin ipsquad net> |
344 | + |
345 | + This library is free software; you can redistribute it and/or |
346 | + modify it under the terms of the GNU Library General Public |
347 | + License version 2 as published by the Free Software Foundation. |
348 | + |
349 | + This library is distributed in the hope that it will be useful, |
350 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
351 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
352 | + Library General Public License for more details. |
353 | + |
354 | + You should have received a copy of the GNU Library General Public License |
355 | + along with this library; see the file COPYING.LIB. If not, write to |
356 | + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
357 | + Boston, MA 02111-1307, USA. |
358 | +*/ |
359 | + |
360 | +#ifndef _HALADDITION_H_ |
361 | +#define _HALADDITION_H_ |
362 | + |
363 | +#include "backendbase.h" |
364 | + |
365 | +#include <qobject.h> |
366 | +#include <qstringlist.h> |
367 | +#include <kmountpoint.h> |
368 | + |
369 | +class HalAddition : public QObject, public BackendBase |
370 | +{ |
371 | +Q_OBJECT |
372 | + |
373 | +public: |
374 | + HalAddition(MediaList &list); |
375 | + virtual ~HalAddition() {}; |
376 | + |
377 | + static void guess(const QString &devNode, const QString &mountPoint, |
378 | + const QString &fsType, bool mounted, |
379 | + QString &mimeType, QString &iconName, |
380 | + QString &label); |
381 | +private slots: |
382 | + void slotDirty(const QString &path); |
383 | + |
384 | +private: |
385 | + void handleMtabChange(); |
386 | + QStringList m_mtabIds; |
387 | + |
388 | +}; |
389 | + |
390 | +#endif |
391 | diff -Nur kdebase-3.4.3.orig/kioslave/media/kdedmodule/halbackend.cpp kdebase-3.4.3/kioslave/media/kdedmodule/halbackend.cpp |
392 | --- kdebase-3.4.3.orig/kioslave/media/kdedmodule/halbackend.cpp 2005-10-05 15:38:19.000000000 +0200 |
393 | +++ kdebase-3.4.3/kioslave/media/kdedmodule/halbackend.cpp 2005-10-09 13:54:26.000000000 +0200 |
394 | @@ -1,5 +1,5 @@ |
395 | /* This file is part of the KDE Project |
396 | - Copyright (c) 2004 Jérôme Lodewyck <lodewyck@clipper.ens.fr> |
397 | + Copyright (c) 2004 - 2005 Jérôme Lodewyck <lodewyck@clipper.ens.fr> |
398 | |
399 | This library is free software; you can redistribute it and/or |
400 | modify it under the terms of the GNU Library General Public |
401 | @@ -19,12 +19,14 @@ |
402 | #include "halbackend.h" |
403 | #include "linuxcdpolling.h" |
404 | |
405 | +#include <stdlib.h> |
406 | + |
407 | #include <klocale.h> |
408 | #include <kurl.h> |
409 | #include <kdebug.h> |
410 | |
411 | -#define MOUNT_SUFFIX (hal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted")) |
412 | -#define MOUNT_ICON_SUFFIX (hal_volume_is_mounted(halVolume) ? QString("_mount") : QString("_unmount")) |
413 | +#define MOUNT_SUFFIX (libhal_volume_is_mounted(halVolume) ? QString("_mounted") : QString("_unmounted")) |
414 | +#define MOUNT_ICON_SUFFIX (libhal_volume_is_mounted(halVolume) ? QString("_mount") : QString("_unmount")) |
415 | |
416 | /* Static instance of this class, for static HAL callbacks */ |
417 | static HALBackend* s_HALBackend; |
418 | @@ -34,9 +36,9 @@ |
419 | { |
420 | char* _ppt_string; |
421 | QString _ppt_QString; |
422 | - _ppt_string = hal_device_get_property_string(ctx, udi, key); |
423 | + _ppt_string = libhal_device_get_property_string(ctx, udi, key, NULL); |
424 | _ppt_QString = QString(_ppt_string ? _ppt_string : ""); |
425 | - hal_free_string(_ppt_string); |
426 | + libhal_free_string(_ppt_string); |
427 | return _ppt_QString; |
428 | } |
429 | |
430 | @@ -56,14 +58,24 @@ |
431 | { |
432 | /* Close HAL connection */ |
433 | if (m_halContext) |
434 | + { |
435 | + #ifdef HAL_0_4 |
436 | hal_shutdown(m_halContext); |
437 | + #else |
438 | + libhal_ctx_shutdown(m_halContext, NULL); |
439 | + libhal_ctx_free(m_halContext); |
440 | + #endif |
441 | + } |
442 | if (m_halStoragePolicy) |
443 | - hal_storage_policy_free(m_halStoragePolicy); |
444 | + libhal_storage_policy_free(m_halStoragePolicy); |
445 | + |
446 | + /** @todo empty media list ? */ |
447 | } |
448 | |
449 | /* Connect to the HAL */ |
450 | bool HALBackend::InitHal() |
451 | { |
452 | +#ifdef HAL_0_4 /* HAL API 0.4 */ |
453 | /* libhal initialization */ |
454 | m_halFunctions.main_loop_integration = HALBackend::hal_main_loop_integration; |
455 | m_halFunctions.device_added = HALBackend::hal_device_added; |
456 | @@ -76,19 +88,72 @@ |
457 | m_halContext = hal_initialize(&m_halFunctions, FALSE); |
458 | if (!m_halContext) |
459 | { |
460 | - kdDebug()<<"Failed to initialize HAL!"<<endl; |
461 | + kdDebug() << "Failed to initialize HAL!" << endl; |
462 | + return false; |
463 | + } |
464 | + |
465 | + /** @todo customize watch policy */ |
466 | + kdDebug() << "Watch properties" << endl; |
467 | + if (libhal_device_property_watch_all(m_halContext, NULL)) |
468 | + { |
469 | + kdDebug() << "Failed to watch HAL properties!" << endl; |
470 | + return false; |
471 | + } |
472 | +#else /* HAL API >= 0.5 */ |
473 | + kdDebug() << "Context new" << endl; |
474 | + m_halContext = libhal_ctx_new(); |
475 | + if (!m_halContext) |
476 | + { |
477 | + kdDebug() << "Failed to initialize HAL!" << endl; |
478 | + return false; |
479 | + } |
480 | + |
481 | + // Main loop integration |
482 | + kdDebug() << "Main loop integration" << endl; |
483 | + DBusError error; |
484 | + dbus_error_init(&error); |
485 | + DBusConnection *dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); |
486 | + if (dbus_error_is_set(&error)) { |
487 | + dbus_error_free(&error); |
488 | + libhal_ctx_free(m_halContext); |
489 | + m_halContext = NULL; |
490 | + return false; |
491 | + } |
492 | + MainLoopIntegration(dbus_connection); |
493 | + libhal_ctx_set_dbus_connection(m_halContext, dbus_connection); |
494 | + |
495 | + // HAL callback functions |
496 | + kdDebug() << "Callback functions" << endl; |
497 | + libhal_ctx_set_device_added(m_halContext, HALBackend::hal_device_added); |
498 | + libhal_ctx_set_device_removed(m_halContext, HALBackend::hal_device_removed); |
499 | + libhal_ctx_set_device_new_capability (m_halContext, NULL); |
500 | + libhal_ctx_set_device_lost_capability (m_halContext, NULL); |
501 | + libhal_ctx_set_device_property_modified (m_halContext, HALBackend::hal_device_property_modified); |
502 | + libhal_ctx_set_device_condition(m_halContext, HALBackend::hal_device_condition); |
503 | + |
504 | + kdDebug() << "Context Init" << endl; |
505 | + if (!libhal_ctx_init(m_halContext, &error)) |
506 | + { |
507 | + if (dbus_error_is_set(&error)) |
508 | + dbus_error_free(&error); |
509 | + libhal_ctx_free(m_halContext); |
510 | + m_halContext = NULL; |
511 | + kdDebug() << "Failed to init HAL context!" << endl; |
512 | return false; |
513 | } |
514 | |
515 | /** @todo customize watch policy */ |
516 | - if (hal_device_property_watch_all(m_halContext)) |
517 | + kdDebug() << "Watch properties" << endl; |
518 | + if (!libhal_device_property_watch_all(m_halContext, &error)) |
519 | { |
520 | - kdDebug()<<"Failed to watch HAL properties!"<<endl; |
521 | + kdDebug() << "Failed to watch HAL properties!" << endl; |
522 | return false; |
523 | } |
524 | +#endif |
525 | |
526 | /* libhal-storage initialization */ |
527 | - m_halStoragePolicy = hal_storage_policy_new(); |
528 | + kdDebug() << "Storage Policy" << endl; |
529 | + m_halStoragePolicy = libhal_storage_policy_new(); |
530 | /** @todo define libhal-storage icon policy */ |
531 | |
532 | /* List devices at startup */ |
533 | @@ -98,8 +163,10 @@ |
534 | /* List devices (at startup)*/ |
535 | bool HALBackend::ListDevices() |
536 | { |
537 | + kdDebug() << "ListDevices" << endl; |
538 | + |
539 | int numDevices; |
540 | - char** halDeviceList = hal_get_all_devices(m_halContext, &numDevices); |
541 | + char** halDeviceList = libhal_get_all_devices(m_halContext, &numDevices, NULL); |
542 | |
543 | if (!halDeviceList) |
544 | return false; |
545 | @@ -117,7 +184,7 @@ |
546 | { |
547 | /* We don't deal with devices that do not expose their capabilities. |
548 | If we don't check this, we will get a lot of warning messages from libhal */ |
549 | - if (!hal_device_property_exists(m_halContext, udi, "info.capabilities")) |
550 | + if (!libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL)) |
551 | return; |
552 | |
553 | /* If the device is already listed, do not process. |
554 | @@ -127,17 +194,18 @@ |
555 | return; |
556 | |
557 | /* Add volume block devices */ |
558 | - if (hal_device_query_capability(m_halContext, udi, "volume")) |
559 | + if (libhal_device_query_capability(m_halContext, udi, "volume", NULL)) |
560 | { |
561 | /* We only list volume that have a filesystem or volume that have an audio track*/ |
562 | if ( (hal_device_get_property_QString(m_halContext, udi, "volume.fsusage") != "filesystem") && |
563 | - (!hal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio")) ) |
564 | + (!libhal_device_get_property_bool(m_halContext, udi, "volume.disc.has_audio", NULL)) ) |
565 | return; |
566 | /* Query drive udi */ |
567 | QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device"); |
568 | /* We don't list floppy volumes because we list floppy drives */ |
569 | if ((hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "floppy") || |
570 | - (hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "zip")) |
571 | + (hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "zip") || |
572 | + (hal_device_get_property_QString(m_halContext, driveUdi.ascii(), "storage.drive_type") == "jaz")) |
573 | return; |
574 | |
575 | /** @todo check exclusion list **/ |
576 | @@ -149,11 +217,12 @@ |
577 | |
578 | return; |
579 | } |
580 | - |
581 | + |
582 | /* Floppy & zip drives */ |
583 | - if (hal_device_query_capability(m_halContext, udi, "storage")) |
584 | + if (libhal_device_query_capability(m_halContext, udi, "storage", NULL)) |
585 | if ((hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "floppy") || |
586 | - (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip")) |
587 | + (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip") || |
588 | + (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "jaz")) |
589 | { |
590 | /* Create medium */ |
591 | Medium* medium = new Medium(udi, ""); |
592 | @@ -163,7 +232,7 @@ |
593 | } |
594 | |
595 | /* Camera handled by gphoto2*/ |
596 | - if (hal_device_query_capability(m_halContext, udi, "camera")) |
597 | + if (libhal_device_query_capability(m_halContext, udi, "camera", NULL)) |
598 | |
599 | { |
600 | /* Create medium */ |
601 | @@ -181,9 +250,14 @@ |
602 | |
603 | void HALBackend::ModifyDevice(const char *udi, const char* key) |
604 | { |
605 | - Q_UNUSED(udi); |
606 | + const char* mediumUdi = findMediumUdiFromUdi(udi); |
607 | + if (!mediumUdi) |
608 | + return; |
609 | + ResetProperties(mediumUdi); |
610 | + |
611 | Q_UNUSED(key); |
612 | /* |
613 | + Q_UNUSED(udi); |
614 | TODO: enable this when the watch policy is written |
615 | */ |
616 | } |
617 | @@ -230,8 +304,8 @@ |
618 | return medium->id().ascii(); |
619 | |
620 | /* Hard part : this is a volume whose drive is registered */ |
621 | - if (hal_device_property_exists(m_halContext, udi, "info.capabilities")) |
622 | - if (hal_device_query_capability(m_halContext, udi, "volume")) |
623 | + if (libhal_device_property_exists(m_halContext, udi, "info.capabilities", NULL)) |
624 | + if (libhal_device_query_capability(m_halContext, udi, "volume", NULL)) |
625 | { |
626 | QString driveUdi = hal_device_get_property_QString(m_halContext, udi, "block.storage_device"); |
627 | return findMediumUdiFromUdi(driveUdi.ascii()); |
628 | @@ -245,11 +319,11 @@ |
629 | kdDebug() << "HALBackend::setProperties" << endl; |
630 | |
631 | Medium* m = new Medium(mediumUdi, ""); |
632 | - if (hal_device_query_capability(m_halContext, mediumUdi, "volume")) |
633 | + if (libhal_device_query_capability(m_halContext, mediumUdi, "volume", NULL)) |
634 | setVolumeProperties(m); |
635 | - if (hal_device_query_capability(m_halContext, mediumUdi, "storage")) |
636 | + if (libhal_device_query_capability(m_halContext, mediumUdi, "storage", NULL)) |
637 | setFloppyProperties(m); |
638 | - if (hal_device_query_capability(m_halContext, mediumUdi, "camera")) |
639 | + if (libhal_device_query_capability(m_halContext, mediumUdi, "camera", NULL)) |
640 | setCameraProperties(m); |
641 | |
642 | m_mediaList.changeMediumState(*m); |
643 | @@ -263,34 +337,35 @@ |
644 | |
645 | const char* udi = medium->id().ascii(); |
646 | /* Check if the device still exists */ |
647 | - if (!hal_device_exists(m_halContext, udi)) |
648 | + if (!libhal_device_exists(m_halContext, udi, NULL)) |
649 | return; |
650 | |
651 | /* Get device information from libhal-storage */ |
652 | - HalVolume* halVolume = hal_volume_from_udi(m_halContext, udi); |
653 | + LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, udi); |
654 | if (!halVolume) |
655 | return; |
656 | - |
657 | - QString driveUdi = hal_volume_get_storage_device_udi(halVolume); |
658 | - HalDrive* halDrive = hal_drive_from_udi(m_halContext, driveUdi.ascii()); |
659 | + QString driveUdi = libhal_volume_get_storage_device_udi(halVolume); |
660 | + LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, driveUdi.ascii()); |
661 | |
662 | medium->setName( |
663 | - generateName(hal_volume_get_device_file(halVolume)) ); |
664 | + generateName(libhal_volume_get_device_file(halVolume)) ); |
665 | |
666 | medium->mountableState( |
667 | - hal_volume_get_device_file(halVolume), /* Device node */ |
668 | - hal_volume_get_mount_point(halVolume), /* Mount point */ |
669 | - hal_volume_get_fstype(halVolume), /* Filesystem type */ |
670 | - hal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
671 | + libhal_volume_get_device_file(halVolume), /* Device node */ |
672 | + libhal_volume_get_mount_point(halVolume), /* Mount point */ |
673 | + libhal_volume_get_fstype(halVolume), /* Filesystem type */ |
674 | + libhal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
675 | |
676 | QString mimeType; |
677 | - if (hal_volume_is_disc(halVolume)) |
678 | + if (libhal_volume_is_disc(halVolume)) |
679 | { |
680 | mimeType = "media/cdrom" + MOUNT_SUFFIX; |
681 | |
682 | - HalVolumeDiscType discType = hal_volume_get_disc_type(halVolume); |
683 | - if ((discType == HAL_VOLUME_DISC_TYPE_CDR) || (discType == HAL_VOLUME_DISC_TYPE_CDRW)) |
684 | - if (hal_volume_disc_is_blank(halVolume)) |
685 | + LibHalVolumeDiscType discType = libhal_volume_get_disc_type(halVolume); |
686 | + if ((discType == LIBHAL_VOLUME_DISC_TYPE_CDROM) || |
687 | + (discType == LIBHAL_VOLUME_DISC_TYPE_CDR) || |
688 | + (discType == LIBHAL_VOLUME_DISC_TYPE_CDRW)) |
689 | + if (libhal_volume_disc_is_blank(halVolume)) |
690 | { |
691 | mimeType = "media/blankcd"; |
692 | medium->unmountableState(""); |
693 | @@ -298,10 +373,10 @@ |
694 | else |
695 | mimeType = "media/cdwriter" + MOUNT_SUFFIX; |
696 | |
697 | - if ((discType == HAL_VOLUME_DISC_TYPE_DVDROM) || (discType == HAL_VOLUME_DISC_TYPE_DVDRAM) || |
698 | - (discType == HAL_VOLUME_DISC_TYPE_DVDR) || (discType == HAL_VOLUME_DISC_TYPE_DVDRW) || |
699 | - (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == HAL_VOLUME_DISC_TYPE_DVDPLUSRW) ) |
700 | - if (hal_volume_disc_is_blank(halVolume)) |
701 | + if ((discType == LIBHAL_VOLUME_DISC_TYPE_DVDROM) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRAM) || |
702 | + (discType == LIBHAL_VOLUME_DISC_TYPE_DVDR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDRW) || |
703 | + (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR) || (discType == LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW) ) |
704 | + if (libhal_volume_disc_is_blank(halVolume)) |
705 | { |
706 | mimeType = "media/blankdvd"; |
707 | medium->unmountableState(""); |
708 | @@ -309,16 +384,16 @@ |
709 | else |
710 | mimeType = "media/dvd" + MOUNT_SUFFIX; |
711 | |
712 | - if (hal_volume_disc_has_audio(halVolume) && !hal_volume_disc_has_data(halVolume)) |
713 | + if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume)) |
714 | { |
715 | mimeType = "media/audiocd"; |
716 | - medium->unmountableState( "audiocd:/?device=" + QString(hal_volume_get_device_file(halVolume)) ); |
717 | + medium->unmountableState( "audiocd:/?device=" + QString(libhal_volume_get_device_file(halVolume)) ); |
718 | } |
719 | |
720 | medium->setIconName(QString::null); |
721 | - |
722 | + |
723 | /* check if the disc id a vcd or a video dvd */ |
724 | - DiscType type = LinuxCDPolling::identifyDiscType(hal_volume_get_device_file(halVolume)); |
725 | + DiscType type = LinuxCDPolling::identifyDiscType(libhal_volume_get_device_file(halVolume)); |
726 | switch (type) |
727 | { |
728 | case DiscType::VCD: |
729 | @@ -335,30 +410,30 @@ |
730 | else |
731 | { |
732 | mimeType = "media/hdd" + MOUNT_SUFFIX; |
733 | - if (hal_drive_is_hotpluggable(halDrive)) |
734 | + if (libhal_drive_is_hotpluggable(halDrive)) |
735 | { |
736 | mimeType = "media/removable" + MOUNT_SUFFIX; |
737 | medium->needMounting(); |
738 | - switch (hal_drive_get_type(halDrive)) { |
739 | - case HAL_DRIVE_TYPE_COMPACT_FLASH: |
740 | + switch (libhal_drive_get_type(halDrive)) { |
741 | + case LIBHAL_DRIVE_TYPE_COMPACT_FLASH: |
742 | medium->setIconName("compact_flash" + MOUNT_ICON_SUFFIX); |
743 | break; |
744 | - case HAL_DRIVE_TYPE_MEMORY_STICK: |
745 | + case LIBHAL_DRIVE_TYPE_MEMORY_STICK: |
746 | medium->setIconName("memory_stick" + MOUNT_ICON_SUFFIX); |
747 | break; |
748 | - case HAL_DRIVE_TYPE_SMART_MEDIA: |
749 | + case LIBHAL_DRIVE_TYPE_SMART_MEDIA: |
750 | medium->setIconName("smart_media" + MOUNT_ICON_SUFFIX); |
751 | break; |
752 | - case HAL_DRIVE_TYPE_SD_MMC: |
753 | + case LIBHAL_DRIVE_TYPE_SD_MMC: |
754 | medium->setIconName("sd_mmc" + MOUNT_ICON_SUFFIX); |
755 | break; |
756 | - case HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER: |
757 | + case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER: |
758 | medium->setIconName(QString::null); //FIXME need icon |
759 | break; |
760 | - case HAL_DRIVE_TYPE_CAMERA: |
761 | + case LIBHAL_DRIVE_TYPE_CAMERA: |
762 | medium->setIconName("camera" + MOUNT_ICON_SUFFIX); |
763 | break; |
764 | - case HAL_DRIVE_TYPE_TAPE: |
765 | + case LIBHAL_DRIVE_TYPE_TAPE: |
766 | medium->setIconName(QString::null); //FIXME need icon |
767 | break; |
768 | default: |
769 | @@ -368,11 +443,15 @@ |
770 | } |
771 | medium->setMimeType(mimeType); |
772 | |
773 | - medium->setLabel(QString::fromUtf8( hal_volume_policy_compute_display_name(halDrive, |
774 | - halVolume, m_halStoragePolicy) ) ); |
775 | + char* name = libhal_volume_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
776 | + //char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
777 | + QString volume_name = QString::fromUtf8(name); |
778 | + QString media_name = volume_name; |
779 | + medium->setLabel(media_name); |
780 | + free(name); |
781 | |
782 | - hal_drive_free(halDrive); |
783 | - hal_volume_free(halVolume); |
784 | + libhal_drive_free(halDrive); |
785 | + libhal_volume_free(halVolume); |
786 | } |
787 | |
788 | // Handle floppies and zip drives |
789 | @@ -382,34 +461,34 @@ |
790 | |
791 | const char* udi = medium->id().ascii(); |
792 | /* Check if the device still exists */ |
793 | - if (!hal_device_exists(m_halContext, udi)) |
794 | + if (!libhal_device_exists(m_halContext, udi, NULL)) |
795 | return; |
796 | |
797 | - HalDrive* halDrive = hal_drive_from_udi(m_halContext, udi); |
798 | + LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, udi); |
799 | if (!halDrive) |
800 | return; |
801 | int numVolumes; |
802 | - char** volumes = hal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes); |
803 | - HalVolume* halVolume = NULL; |
804 | + char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes); |
805 | + LibHalVolume* halVolume = NULL; |
806 | kdDebug() << " found " << numVolumes << " volumes" << endl; |
807 | if (numVolumes) |
808 | - halVolume = hal_volume_from_udi(m_halContext, volumes[0]); |
809 | + halVolume = libhal_volume_from_udi(m_halContext, volumes[0]); |
810 | |
811 | medium->setName( |
812 | - generateName(hal_drive_get_device_file(halDrive)) ); |
813 | + generateName(libhal_drive_get_device_file(halDrive)) ); |
814 | |
815 | if (halVolume) |
816 | { |
817 | medium->mountableState( |
818 | - hal_volume_get_device_file(halVolume), /* Device node */ |
819 | - hal_volume_get_mount_point(halVolume), /* Mount point */ |
820 | - hal_volume_get_fstype(halVolume), /* Filesystem type */ |
821 | - hal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
822 | + libhal_volume_get_device_file(halVolume), /* Device node */ |
823 | + libhal_volume_get_mount_point(halVolume), /* Mount point */ |
824 | + libhal_volume_get_fstype(halVolume), /* Filesystem type */ |
825 | + libhal_volume_is_mounted(halVolume) ); /* Mounted ? */ |
826 | } |
827 | else |
828 | { |
829 | medium->mountableState( |
830 | - hal_drive_get_device_file(halDrive), /* Device node */ |
831 | + libhal_drive_get_device_file(halDrive), /* Device node */ |
832 | "", /* Mount point */ |
833 | "", /* Filesystem type */ |
834 | false ); /* Mounted ? */ |
835 | @@ -422,7 +501,7 @@ |
836 | else |
837 | medium->setMimeType("media/floppy_unmounted"); |
838 | } |
839 | - |
840 | + |
841 | if (hal_device_get_property_QString(m_halContext, udi, "storage.drive_type") == "zip") |
842 | { |
843 | if (halVolume) |
844 | @@ -430,14 +509,29 @@ |
845 | else |
846 | medium->setMimeType("media/zip_unmounted"); |
847 | } |
848 | - |
849 | + |
850 | medium->setIconName(QString::null); |
851 | |
852 | - medium->setLabel(QString::fromUtf8( hal_drive_policy_compute_display_name(halDrive, |
853 | - halVolume, m_halStoragePolicy) ) ); |
854 | + QString media_name; |
855 | + if (halVolume) |
856 | + { |
857 | + char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
858 | + QString volume_name = QString::fromUtf8(name); |
859 | + media_name = volume_name; |
860 | + free(name); |
861 | + } |
862 | + else |
863 | + { |
864 | + char* name = libhal_drive_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); |
865 | + QString drive_name = QString::fromUtf8(name); |
866 | + media_name = drive_name; |
867 | + free(name); |
868 | + } |
869 | + medium->setLabel(media_name); |
870 | |
871 | - hal_drive_free(halDrive); |
872 | - hal_volume_free(halVolume); |
873 | + free(volumes); |
874 | + libhal_drive_free(halDrive); |
875 | + libhal_volume_free(halVolume); |
876 | } |
877 | |
878 | void HALBackend::setCameraProperties(Medium* medium) |
879 | @@ -446,7 +540,7 @@ |
880 | |
881 | const char* udi = medium->id().ascii(); |
882 | /* Check if the device still exists */ |
883 | - if (!hal_device_exists(m_halContext, udi)) |
884 | + if (!libhal_device_exists(m_halContext, udi, NULL)) |
885 | return; |
886 | |
887 | /** @todo find name */ |
888 | @@ -468,6 +562,7 @@ |
889 | ** HAL CALL-BACKS ** |
890 | ******************************************/ |
891 | |
892 | +#ifdef HAL_0_4 |
893 | void HALBackend::hal_main_loop_integration(LibHalContext *ctx, |
894 | DBusConnection *dbus_connection) |
895 | { |
896 | @@ -475,6 +570,7 @@ |
897 | Q_UNUSED(ctx); |
898 | s_HALBackend->MainLoopIntegration(dbus_connection); |
899 | } |
900 | +#endif |
901 | |
902 | void HALBackend::hal_device_added(LibHalContext *ctx, const char *udi) |
903 | { |
904 | @@ -499,8 +595,15 @@ |
905 | Q_UNUSED(is_added); |
906 | s_HALBackend->ModifyDevice(udi, key); |
907 | } |
908 | + |
909 | void HALBackend::hal_device_condition(LibHalContext *ctx, const char *udi, |
910 | - const char *condition_name, DBusMessage *message) |
911 | + const char *condition_name, |
912 | + #ifdef HAL_0_4 |
913 | + DBusMessage *message |
914 | + #else |
915 | + const char* message |
916 | + #endif |
917 | + ) |
918 | { |
919 | kdDebug() << "HALBackend::hal_device_condition " << udi << " -- " << condition_name << endl; |
920 | Q_UNUSED(ctx); |
921 | diff -Nur kdebase-3.4.3.orig/kioslave/media/kdedmodule/halbackend.h kdebase-3.4.3/kioslave/media/kdedmodule/halbackend.h |
922 | --- kdebase-3.4.3.orig/kioslave/media/kdedmodule/halbackend.h 2005-10-05 15:38:19.000000000 +0200 |
923 | +++ kdebase-3.4.3/kioslave/media/kdedmodule/halbackend.h 2005-10-09 11:24:34.000000000 +0200 |
924 | @@ -35,6 +35,8 @@ |
925 | #include <qstringlist.h> |
926 | #include <qstring.h> |
927 | |
928 | +#include <config.h> |
929 | + |
930 | /* We acknowledge the the dbus API is unstable */ |
931 | #define DBUS_API_SUBJECT_TO_CHANGE |
932 | /* DBus-Qt bindings */ |
933 | @@ -43,6 +45,65 @@ |
934 | #include <libhal.h> |
935 | #include <libhal-storage.h> |
936 | |
937 | +/* The HAL API changed between 0.4 and 0.5 series. |
938 | +These defines enable backward compatibility */ |
939 | +#ifdef HAL_0_4 |
940 | + // libhal-storage 0.4 API |
941 | + #define LibHalStoragePolicy HalStoragePolicy |
942 | + #define LibHalDrive HalDrive |
943 | + #define LibHalVolume HalVolume |
944 | + #define LibHalVolumeDiscType HalVolumeDiscType |
945 | + #define libhal_storage_policy_free hal_storage_policy_free |
946 | + #define libhal_storage_policy_new hal_storage_policy_new |
947 | + #define libhal_drive_from_udi hal_drive_from_udi |
948 | + #define libhal_drive_find_all_volumes hal_drive_find_all_volumes |
949 | + #define libhal_drive_get_type hal_drive_get_type |
950 | + #define libhal_drive_get_device_file hal_drive_get_device_file |
951 | + #define libhal_drive_free hal_drive_free |
952 | + #define libhal_drive_policy_compute_display_name hal_drive_policy_compute_display_name |
953 | + #define libhal_drive_is_hotpluggable hal_drive_is_hotpluggable |
954 | + #define libhal_volume_from_udi hal_volume_from_udi |
955 | + #define libhal_volume_get_device_file hal_volume_get_device_file |
956 | + #define libhal_volume_get_mount_point hal_volume_get_mount_point |
957 | + #define libhal_volume_get_fstype hal_volume_get_fstype |
958 | + #define libhal_volume_is_mounted hal_volume_is_mounted |
959 | + #define libhal_volume_get_disc_type hal_volume_get_disc_type |
960 | + #define libhal_volume_free hal_volume_free |
961 | + #define libhal_volume_policy_compute_display_name hal_volume_policy_compute_display_name |
962 | + #define libhal_volume_disc_has_data hal_volume_disc_has_data |
963 | + #define libhal_volume_disc_has_audio hal_volume_disc_has_audio |
964 | + #define libhal_volume_disc_is_blank hal_volume_disc_is_blank |
965 | + #define libhal_volume_is_disc hal_volume_is_disc |
966 | + #define libhal_volume_get_storage_device_udi hal_volume_get_storage_device_udi |
967 | + #define LIBHAL_VOLUME_DISC_TYPE_CDROM HAL_VOLUME_DISC_TYPE_CDROM |
968 | + #define LIBHAL_VOLUME_DISC_TYPE_CDR HAL_VOLUME_DISC_TYPE_CDR |
969 | + #define LIBHAL_VOLUME_DISC_TYPE_CDRW HAL_VOLUME_DISC_TYPE_CDRW |
970 | + #define LIBHAL_VOLUME_DISC_TYPE_DVDROM HAL_VOLUME_DISC_TYPE_DVDROM |
971 | + #define LIBHAL_VOLUME_DISC_TYPE_DVDRAM HAL_VOLUME_DISC_TYPE_DVDRAM |
972 | + #define LIBHAL_VOLUME_DISC_TYPE_DVDR HAL_VOLUME_DISC_TYPE_DVDR |
973 | + #define LIBHAL_VOLUME_DISC_TYPE_DVDRW HAL_VOLUME_DISC_TYPE_DVDRW |
974 | + #define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR HAL_VOLUME_DISC_TYPE_DVDPLUSR |
975 | + #define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW HAL_VOLUME_DISC_TYPE_DVDPLUSRW |
976 | + #define LIBHAL_DRIVE_TYPE_COMPACT_FLASH HAL_DRIVE_TYPE_COMPACT_FLASH |
977 | + #define LIBHAL_DRIVE_TYPE_MEMORY_STICK HAL_DRIVE_TYPE_MEMORY_STICK |
978 | + #define LIBHAL_DRIVE_TYPE_SMART_MEDIA HAL_DRIVE_TYPE_SMART_MEDIA |
979 | + #define LIBHAL_DRIVE_TYPE_SD_MMC HAL_DRIVE_TYPE_SD_MMC |
980 | + #define LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER |
981 | + #define LIBHAL_DRIVE_TYPE_CAMERA HAL_DRIVE_TYPE_CAMERA |
982 | + #define LIBHAL_DRIVE_TYPE_TAPE HAL_DRIVE_TYPE_TAPE |
983 | + |
984 | + // libhal 0.4 API |
985 | + #define libhal_free_string hal_free_string |
986 | + #define libhal_device_exists(ctx, udi, error) hal_device_exists(ctx, udi) |
987 | + #define libhal_device_property_watch_all(ctx, error) hal_device_property_watch_all(ctx) |
988 | + #define libhal_get_all_devices(ctx, num_devices, error) hal_get_all_devices(ctx, num_devices) |
989 | + #define libhal_device_property_exists(ctx, udi, key, error) hal_device_property_exists(ctx, udi, key) |
990 | + #define libhal_device_get_property_bool(ctx, udi, key, error) hal_device_get_property_bool(ctx, udi, key) |
991 | + #define libhal_device_get_property_string(ctx, udi, key, error) hal_device_get_property_string(ctx, udi, key) |
992 | + #define libhal_device_query_capability(ctx, udi, capability, error) hal_device_query_capability(ctx, udi, capability) |
993 | +#endif |
994 | + |
995 | + |
996 | /** |
997 | * A handy function to query a hal string |
998 | * |
999 | @@ -137,12 +198,14 @@ |
1000 | |
1001 | /* Hal call-backs -- from gvm*/ |
1002 | public: |
1003 | +#ifdef HAL_0_4 |
1004 | /** Invoked by libhal for integration with our mainloop. |
1005 | * |
1006 | * @param ctx LibHal context |
1007 | * @param dbus_connection D-BUS connection to integrate |
1008 | */ |
1009 | static void hal_main_loop_integration(LibHalContext *ctx, DBusConnection *dbus_connection); |
1010 | +#endif |
1011 | |
1012 | /** Invoked when a device is added to the Global Device List. |
1013 | * |
1014 | @@ -175,7 +238,13 @@ |
1015 | * @param message D-BUS message with variable parameters depending on condition |
1016 | */ |
1017 | static void hal_device_condition(LibHalContext *ctx, const char *udi, |
1018 | - const char *condition_name, DBusMessage *message); |
1019 | + const char *condition_name, |
1020 | + #ifdef HAL_0_4 |
1021 | + DBusMessage *message |
1022 | + #else |
1023 | + const char* message |
1024 | + #endif |
1025 | + ); |
1026 | |
1027 | /* HAL and DBus structures */ |
1028 | private: |
1029 | @@ -184,15 +253,17 @@ |
1030 | */ |
1031 | LibHalContext* m_halContext; |
1032 | |
1033 | +#ifdef HAL_0_4 |
1034 | /** |
1035 | * Structure defining the hal callback function for devices events |
1036 | */ |
1037 | LibHalFunctions m_halFunctions; |
1038 | +#endif |
1039 | |
1040 | /** |
1041 | * libhal-storage HAL policy, e.g. for icon names |
1042 | */ |
1043 | - HalStoragePolicy* m_halStoragePolicy; |
1044 | + LibHalStoragePolicy* m_halStoragePolicy; |
1045 | |
1046 | /** |
1047 | * The DBus-Qt bindings connection for mainloop integration |
1048 | diff -Nur kdebase-3.4.3.orig/kioslave/media/kdedmodule/mediamanager.cpp kdebase-3.4.3/kioslave/media/kdedmodule/mediamanager.cpp |
1049 | --- kdebase-3.4.3.orig/kioslave/media/kdedmodule/mediamanager.cpp 2005-10-05 15:38:19.000000000 +0200 |
1050 | +++ kdebase-3.4.3/kioslave/media/kdedmodule/mediamanager.cpp 2005-10-09 11:24:34.000000000 +0200 |
1051 | @@ -31,6 +31,7 @@ |
1052 | |
1053 | #ifdef COMPILE_HALBACKEND |
1054 | #include "halbackend.h" |
1055 | +#include "haladdition.h" |
1056 | #endif //COMPILE_HALBACKEND |
1057 | |
1058 | #ifdef COMPILE_LINUXCDPOLLING |
1059 | @@ -60,8 +61,10 @@ |
1060 | |
1061 | #ifdef COMPILE_HALBACKEND |
1062 | HALBackend* halBackend = new HALBackend(m_mediaList, this); |
1063 | - if (halBackend->InitHal()) |
1064 | + if (halBackend->InitHal()) { |
1065 | m_backends.append( halBackend ); |
1066 | + m_backends.append( new HalAddition(m_mediaList) ); |
1067 | + } |
1068 | else |
1069 | { |
1070 | delete halBackend; |