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

(-)kdebase-3.4.1/kioslave/media/configure.in.in (-43 / +43 lines)
Lines 12-111 Link Here
12
AC_ARG_WITH(hal,AC_HELP_STRING([--with-hal],[Enable HAL support  [default=check]]),[hal_test="$withval"],[hal_test="yes"])
12
AC_ARG_WITH(hal,AC_HELP_STRING([--with-hal],[Enable HAL support  [default=check]]),[hal_test="$withval"],[hal_test="yes"])
13
13
14
if test "x$hal_test" = "xyes" ; then
14
if test "x$hal_test" = "xyes" ; then
15
  
15
16
########### Check for the HAL, version 0.4.x
16
########### Check for the HAL
17
  
17
18
  AC_MSG_CHECKING(for the HAL 0.4)
18
  AC_MSG_CHECKING(for the HAL)
19
  
19
20
  hal_inc=NOTFOUND
20
  hal_inc=NOTFOUND
21
  hal_lib=NOTFOUND
21
  hal_lib=NOTFOUND
22
  hal=NOTFOUND
22
  hal=NOTFOUND
23
  
23
24
  search_incs="$kde_includes /usr/include /usr/local/include /usr/include/hal /usr/local/include/hal"
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)
25
  AC_FIND_FILE(libhal.h libhal-storage.h, $search_incs, hal_incdir)
26
  
26
27
  if [test -r $hal_incdir/libhal.h] && [test -r $hal_incdir/libhal-storage.h] ; then
27
  if [test -r $hal_incdir/libhal.h] && [test -r $hal_incdir/libhal-storage.h] ; then
28
    HAL_INCS="-I$hal_incdir"
28
    HAL_INCS="-I$hal_incdir"
29
    hal_inc=FOUND
29
    hal_inc=FOUND
30
  fi
30
  fi
31
  
31
32
  if test -r $hal_incdir/libhal-storage.h ; then
33
    hal_storage_version=4
34
    grep LibHalVolume $hal_incdir/libhal-storage.h \
35
    > /dev/null 2>&1 && hal_storage_version=5
36
    if test $hal_storage_version = 4 ; then
37
      AC_DEFINE(HAL_0_4, , [HAL API version 0.4])
38
    fi
39
  fi
40
32
  search_libs="$kde_libraries /usr/lib /usr/local/lib"
41
  search_libs="$kde_libraries /usr/lib /usr/local/lib"
33
  AC_FIND_FILE(libhal.so libhal-storage.so, $search_libs, hal_libdir)
42
  AC_FIND_FILE(libhal.so libhal-storage.so, $search_libs, hal_libdir)
34
  
43
35
  if [test -r $hal_libdir/libhal.so] && [test -r $hal_libdir/libhal-storage.so] ; then
44
  if [test -r $hal_libdir/libhal.so] && [test -r $hal_libdir/libhal-storage.so] ; then
36
    HAL_LIBS="-L$hal_libdir -lhal -lhal-storage"
45
    HAL_LIBS="-L$hal_libdir -lhal -lhal-storage"
37
    hal_lib=FOUND
46
    hal_lib=FOUND
38
  fi
47
  fi
39
  
48
40
  if test -r $hal_incdir/libhal.h ; then
49
41
    hal_version=5
42
    grep LibHalFunctions $hal_incdir/libhal.h \
43
    > /dev/null 2>&1 && hal_version=4
44
    if test $hal_version = 5 ; then
45
      hal_lib=NOT_FOUND
46
    fi
47
  fi
48
				
49
  
50
  if [test $hal_inc = FOUND] && [test $hal_lib = FOUND] ; then
50
  if [test $hal_inc = FOUND] && [test $hal_lib = FOUND] ; then
51
      AC_MSG_RESULT(headers $hal_incdir  libraries $hal_libdir)
51
      AC_MSG_RESULT(headers $hal_incdir  libraries $hal_libdir)
52
  	hal=FOUND
52
  	hal=FOUND
53
  else
53
  else
54
      AC_MSG_RESULT(searched but not found)
54
      AC_MSG_RESULT(searched but not found)
55
  fi
55
  fi
56
  
56
57
  AC_SUBST(HAL_INCS)
57
  AC_SUBST(HAL_INCS)
58
  AC_SUBST(HAL_LIBS)
58
  AC_SUBST(HAL_LIBS)
59
  
59
60
  
60
61
########### Check for DBus
61
########### Check for DBus
62
  
62
63
  AC_MSG_CHECKING(for DBus)
63
  AC_MSG_CHECKING(for DBus)
64
  
64
65
  dbus_inc=NOTFOUND
65
  dbus_inc=NOTFOUND
66
  dbus_lib=NOTFOUND
66
  dbus_lib=NOTFOUND
67
  dbus=NOTFOUND
67
  dbus=NOTFOUND
68
  
68
69
  search_incs="$kde_includes /usr/include /usr/local/include /usr/include/dbus-1.0 /usr/local/include/dbus-1.0"
69
  search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
70
  AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir)
70
  AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir)
71
  
71
72
  search_incs_arch_deps="$kde_includes /usr/lib/dbus-1.0/include /usr/local/lib/dbus-1.0/include"
72
  search_incs_arch_deps="$kde_includes /usr/lib/dbus-1.0/include /usr/local/lib/dbus-1.0/include"
73
  AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps)
73
  AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps)
74
  
74
75
  if [test -r $dbus_incdir/dbus/dbus.h] && [test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h] ; then
75
  if [test -r $dbus_incdir/dbus/dbus.h] && [test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h] ; then
76
    DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps"
76
    DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps"
77
    dbus_inc=FOUND
77
    dbus_inc=FOUND
78
  fi
78
  fi
79
  
79
80
  search_libs="$kde_libraries /usr/lib /usr/local/lib"
80
  search_libs="$kde_libraries /usr/lib /usr/local/lib"
81
  AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir)
81
  AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir)
82
  
82
83
  if test -r $dbus_libdir/libdbus-1.so ; then
83
  if test -r $dbus_libdir/libdbus-1.so ; then
84
    DBUS_LIBS="-L$dbus_libdir -ldbus-1"
84
    DBUS_LIBS="-L$dbus_libdir -ldbus-1"
85
    dbus_lib=FOUND
85
    dbus_lib=FOUND
86
  fi
86
  fi
87
  
87
88
  if [test $dbus_inc = FOUND] && [test $dbus_lib = FOUND] ; then
88
  if [test $dbus_inc = FOUND] && [test $dbus_lib = FOUND] ; then
89
    AC_MSG_RESULT(headers $dbus_incdir $dbus_incdir_arch_deps  libraries $dbus_libdir)
89
    AC_MSG_RESULT(headers $dbus_incdir $dbus_incdir_arch_deps  libraries $dbus_libdir)
90
    dbus=FOUND
90
    dbus=FOUND
91
  else
91
  else
92
    AC_MSG_RESULT(searched but not found)
92
    AC_MSG_RESULT(searched but not found)
93
  fi
93
  fi
94
  
94
95
  AC_SUBST(DBUS_INCS)
95
  AC_SUBST(DBUS_INCS)
96
  AC_SUBST(DBUS_LIBS)
96
  AC_SUBST(DBUS_LIBS)
97
  
97
98
########### Check for DBus-Qt bindings
98
########### Check for DBus-Qt bindings
99
  
99
100
  AC_MSG_CHECKING(for DBus-Qt bindings)
100
  AC_MSG_CHECKING(for DBus-Qt bindings)
101
  
101
102
  dbusqt_inc=NOTFOUND
102
  dbusqt_inc=NOTFOUND
103
  dbusqt_lib=NOTFOUND
103
  dbusqt_lib=NOTFOUND
104
  dbusqt=NOTFOUND
104
  dbusqt=NOTFOUND
105
  
105
106
  search_incs="$kde_includes /usr/include /usr/local/include /usr/include/dbus-1.0 /usr/local/include/dbus-1.0"
106
  search_incs="$kde_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0"
107
  AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir)
107
  AC_FIND_FILE(dbus/connection.h, $search_incs, dbusqt_incdir)
108
  
108
109
  if test -r $dbusqt_incdir/dbus/connection.h ; then
109
  if test -r $dbusqt_incdir/dbus/connection.h ; then
110
    have_qt_patch=0
110
    have_qt_patch=0
111
    grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \
111
    grep dbus_connection_setup_with_qt_main $dbusqt_incdir/dbus/connection.h \
Lines 115-129 Link Here
115
      dbusqt_inc=FOUND
115
      dbusqt_inc=FOUND
116
    fi
116
    fi
117
  fi
117
  fi
118
  
118
119
  search_libs="$kde_libraries /usr/lib /usr/local/lib"
119
  search_libs="$kde_libraries /usr/lib /usr/local/lib"
120
  AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir)
120
  AC_FIND_FILE(libdbus-qt-1.so, $search_libs, dbusqt_libdir)
121
  
121
122
  if test -r $dbusqt_libdir/libdbus-qt-1.so ; then
122
  if test -r $dbusqt_libdir/libdbus-qt-1.so ; then
123
    DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1"
123
    DBUSQT_LIBS="-L$dbusqt_libdir -ldbus-qt-1"
124
    dbusqt_lib=FOUND
124
    dbusqt_lib=FOUND
125
  fi
125
  fi
126
  
126
127
  if [test $dbusqt_inc = FOUND] && [test $dbusqt_lib = FOUND] ; then
127
  if [test $dbusqt_inc = FOUND] && [test $dbusqt_lib = FOUND] ; then
128
    AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir)
128
    AC_MSG_RESULT(headers $dbusqt_incdir libraries $dbusqt_libdir)
129
    dbusqt=FOUND
129
    dbusqt=FOUND
(-)kdebase-3.4.1/kioslave/media/kdedmodule/Makefile.am (-1 / +1 lines)
Lines 22-28 Link Here
22
22
23
noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB) $(HALBACKEND_LIB)
23
noinst_LTLIBRARIES = $(LINUXCDPOLLING_LIB) $(HALBACKEND_LIB)
24
24
25
kded_mediamanager_la_SOURCES = mediamanager.cpp mediamanager.skel medialist.cpp backendbase.cpp fstabbackend.cpp removablebackend.cpp mediadirnotify.cpp mediadirnotify.skel
25
kded_mediamanager_la_SOURCES = mediamanager.cpp mediamanager.skel medialist.cpp backendbase.cpp fstabbackend.cpp haladdition.cpp removablebackend.cpp mediadirnotify.cpp mediadirnotify.skel
26
kded_mediamanager_la_LDFLAGS = $(all_libraries) -module -avoid-version
26
kded_mediamanager_la_LDFLAGS = $(all_libraries) -module -avoid-version
27
kded_mediamanager_la_LIBADD = $(LIB_KSYCOCA) ../libmediacommon/libmediacommon.la $(HALBACKEND_LIB) $(LINUXCDPOLLING_LIB)
27
kded_mediamanager_la_LIBADD = $(LIB_KSYCOCA) ../libmediacommon/libmediacommon.la $(HALBACKEND_LIB) $(LINUXCDPOLLING_LIB)
28
28
(-)kdebase-3.4.1/kioslave/media/kdedmodule/mediamanager.cpp (-1 / +4 lines)
Lines 31-36 Link Here
31
31
32
#ifdef COMPILE_HALBACKEND
32
#ifdef COMPILE_HALBACKEND
33
#include "halbackend.h"
33
#include "halbackend.h"
34
#include "haladdition.h"
34
#endif //COMPILE_HALBACKEND
35
#endif //COMPILE_HALBACKEND
35
36
36
#ifdef COMPILE_LINUXCDPOLLING
37
#ifdef COMPILE_LINUXCDPOLLING
Lines 60-67 Link Here
60
61
61
#ifdef COMPILE_HALBACKEND
62
#ifdef COMPILE_HALBACKEND
62
	HALBackend* halBackend = new HALBackend(m_mediaList, this);
63
	HALBackend* halBackend = new HALBackend(m_mediaList, this);
63
	if (halBackend->InitHal())
64
	if (halBackend->InitHal()) {
64
		m_backends.append( halBackend );
65
		m_backends.append( halBackend );
66
		m_backends.append( new HalAddition(m_mediaList) );
67
	}
65
	else
68
	else
66
	{
69
	{
67
		delete halBackend;
70
		delete halBackend;
(-) (+49 lines)
Added Link Here
1
/* This file is part of the KDE Project
2
   Copyright (c) 2004 Kévin Ottens <ervin ipsquad net>
3
4
   This library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Library General Public
6
   License version 2 as published by the Free Software Foundation.
7
8
   This library is distributed in the hope that it will be useful,
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
   Library General Public License for more details.
12
13
   You should have received a copy of the GNU Library General Public License
14
   along with this library; see the file COPYING.LIB.  If not, write to
15
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16
   Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef _HALADDITION_H_
20
#define _HALADDITION_H_
21
22
#include "backendbase.h"
23
24
#include <qobject.h>
25
#include <qstringlist.h>
26
#include <kmountpoint.h>
27
28
class HalAddition : public QObject, public BackendBase
29
{
30
Q_OBJECT
31
32
public:
33
	HalAddition(MediaList &list);
34
	virtual ~HalAddition() {};
35
36
	static void guess(const QString &devNode, const QString &mountPoint,
37
                          const QString &fsType, bool mounted,
38
                          QString &mimeType, QString &iconName,
39
	                  QString &label);
40
private slots:
41
	void slotDirty(const QString &path);
42
43
private:
44
	void handleMtabChange();
45
        QStringList m_mtabIds;
46
		
47
};
48
49
#endif
(-) (+155 lines)
Added Link Here
1
/* This file is part of the KDE Project
2
   Copyright (c) 2004 Kévin Ottens <ervin ipsquad net>
3
4
   This library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Library General Public
6
   License version 2 as published by the Free Software Foundation.
7
8
   This library is distributed in the hope that it will be useful,
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
   Library General Public License for more details.
12
13
   You should have received a copy of the GNU Library General Public License
14
   along with this library; see the file COPYING.LIB.  If not, write to
15
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16
   Boston, MA 02111-1307, USA.
17
*/
18
19
#include "haladdition.h"
20
21
#include <klocale.h>
22
#include <kdirwatch.h>
23
#include <kurl.h>
24
#include <kstandarddirs.h>
25
26
#ifdef _OS_SOLARIS_
27
#define MTAB "/etc/mnttab"
28
#else
29
#define MTAB "/etc/mtab"
30
#endif
31
32
33
HalAddition::HalAddition(MediaList &list)
34
	: QObject(), BackendBase(list)
35
{
36
	KDirWatch::self()->addFile(MTAB);
37
38
	connect( KDirWatch::self(), SIGNAL( dirty(const QString&) ),
39
	         this, SLOT( slotDirty(const QString&) ) );
40
41
	handleMtabChange();
42
43
	KDirWatch::self()->startScan();
44
}
45
46
void HalAddition::slotDirty(const QString &path)
47
{
48
	if (path==MTAB)
49
	{
50
		handleMtabChange();
51
	}
52
}
53
54
void HalAddition::handleMtabChange()
55
{
56
	QStringList new_mtabIds;
57
	KMountPoint::List mtab = KMountPoint::currentMountPoints();
58
59
	KMountPoint::List::iterator it = mtab.begin();
60
	KMountPoint::List::iterator end = mtab.end();
61
62
	for (; it!=end; ++it)
63
	{
64
		QString dev = (*it)->mountedFrom();
65
		QString mp = (*it)->mountPoint();
66
		QString fs = (*it)->mountType();
67
68
		if ( mp == "/"
69
		  || mp.find("/media/floppy") != -1
70
	          || mp.find("/media/zip") != -1
71
		  || mp.find("/media/jaz") != -1
72
		   ) 
73
		{
74
			QString device;
75
			const Medium *medium;
76
		     	
77
			device = dev;
78
			device.replace("/dev/", "");
79
80
			if (medium = m_mediaList.findByName(device))
81
			{
82
				QString mime, icon, label;
83
				guess(dev, mp, fs, true, mime, icon, label);
84
				m_mediaList.changeMediumState(medium->id(), dev, mp, fs, true, mime, icon, medium->label());
85
				new_mtabIds += device;
86
			}
87
		}
88
	}
89
        
90
	QStringList::iterator it2 = m_mtabIds.begin();
91
	QStringList::iterator end2 = m_mtabIds.end();
92
93
	for (; it2!=end2; ++it2)
94
	{
95
		if ( !new_mtabIds.contains(*it2) )
96
		{
97
			const Medium *medium;
98
99
			if (medium = m_mediaList.findByName(*it2))
100
			{
101
				QString dev = medium->deviceNode();
102
				QString mp = medium->mountPoint();
103
				QString fs = medium->fsType();
104
				QString mime, icon, label;
105
				
106
		  		guess(dev, mp, fs, false, mime, icon, label);
107
				m_mediaList.changeMediumState(medium->id(), false, mime, icon, medium->label());
108
			}
109
		}
110
	}
111
	m_mtabIds = new_mtabIds;
112
}
113
114
void HalAddition::guess(const QString &devNode, const QString &mountPoint,
115
                         const QString &fsType, bool mounted,
116
                         QString &mimeType, QString &iconName, QString &label)
117
{
118
	if ( devNode.find("fd")!=-1 )
119
	{
120
		if ( devNode.find("360")!=-1 || devNode.find("1200")!=-1 )
121
		{
122
			mimeType = "media/floppy5";
123
		}
124
		else
125
		{
126
			mimeType = "media/floppy";
127
		}
128
		label = i18n("Floppy");
129
	}
130
	else if ( mountPoint.find("zip")!=-1
131
	       || mountPoint.find("jaz")!=-1
132
	       // FREEBSD SPECIFIC
133
	       || devNode.find("/afd")!=-1
134
	        )
135
	{
136
		mimeType = "media/zip";
137
		label = i18n("Zip Disk");
138
	}
139
	else
140
	{
141
		mimeType = "media/hdd";
142
		label = i18n("Harddisk");
143
	}
144
145
	QString tmp = devNode;
146
	if ( tmp.startsWith("/dev/") )
147
	{
148
		tmp = tmp.mid(5);
149
	}
150
	label+= " (" + tmp + ")";
151
	mimeType+= (mounted ? "_mounted" : "_unmounted");
152
	iconName = QString::null;
153
}
154
155
#include "haladdition.moc"
(-)kdebase-3.4.1/kioslave/media/kdedmodule/halbackend.cpp (-82 / +185 lines)
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);
(-)kdebase-3.4.1/kioslave/media/kdedmodule/halbackend.h (-2 / +73 lines)
Lines 35-40 Link Here
35
#include <qstringlist.h>
35
#include <qstringlist.h>
36
#include <qstring.h>
36
#include <qstring.h>
37
37
38
#include <config.h>
39
38
/* We acknowledge the the dbus API is unstable */
40
/* We acknowledge the the dbus API is unstable */
39
#define DBUS_API_SUBJECT_TO_CHANGE
41
#define DBUS_API_SUBJECT_TO_CHANGE
40
/* DBus-Qt bindings */
42
/* DBus-Qt bindings */
Lines 43-48 Link Here
43
#include <libhal.h>
45
#include <libhal.h>
44
#include <libhal-storage.h>
46
#include <libhal-storage.h>
45
47
48
/* The HAL API changed between 0.4 and 0.5 series.
49
These defines enable backward compatibility */
50
#ifdef HAL_0_4
51
	// libhal-storage 0.4 API
52
	#define LibHalStoragePolicy				HalStoragePolicy
53
	#define LibHalDrive						HalDrive
54
	#define LibHalVolume					HalVolume
55
	#define LibHalVolumeDiscType			HalVolumeDiscType
56
	#define libhal_storage_policy_free		hal_storage_policy_free
57
	#define libhal_storage_policy_new		hal_storage_policy_new
58
	#define libhal_drive_from_udi			hal_drive_from_udi
59
	#define libhal_drive_find_all_volumes	hal_drive_find_all_volumes
60
	#define libhal_drive_get_type			hal_drive_get_type
61
	#define libhal_drive_get_device_file	hal_drive_get_device_file
62
	#define libhal_drive_free				hal_drive_free
63
	#define libhal_drive_policy_compute_display_name	hal_drive_policy_compute_display_name
64
	#define libhal_drive_is_hotpluggable	hal_drive_is_hotpluggable
65
	#define libhal_volume_from_udi			hal_volume_from_udi
66
	#define libhal_volume_get_device_file	hal_volume_get_device_file
67
	#define libhal_volume_get_mount_point	hal_volume_get_mount_point
68
	#define libhal_volume_get_fstype		hal_volume_get_fstype
69
	#define libhal_volume_is_mounted		hal_volume_is_mounted
70
	#define libhal_volume_get_disc_type		hal_volume_get_disc_type
71
	#define libhal_volume_free				hal_volume_free
72
	#define libhal_volume_policy_compute_display_name	hal_volume_policy_compute_display_name
73
	#define libhal_volume_disc_has_data		hal_volume_disc_has_data
74
	#define libhal_volume_disc_has_audio	hal_volume_disc_has_audio
75
	#define libhal_volume_disc_is_blank		hal_volume_disc_is_blank
76
	#define libhal_volume_is_disc			hal_volume_is_disc
77
	#define libhal_volume_get_storage_device_udi	hal_volume_get_storage_device_udi
78
	#define LIBHAL_VOLUME_DISC_TYPE_CDROM		HAL_VOLUME_DISC_TYPE_CDROM
79
	#define LIBHAL_VOLUME_DISC_TYPE_CDR			HAL_VOLUME_DISC_TYPE_CDR
80
	#define LIBHAL_VOLUME_DISC_TYPE_CDRW		HAL_VOLUME_DISC_TYPE_CDRW
81
	#define LIBHAL_VOLUME_DISC_TYPE_DVDROM		HAL_VOLUME_DISC_TYPE_DVDROM
82
	#define LIBHAL_VOLUME_DISC_TYPE_DVDRAM		HAL_VOLUME_DISC_TYPE_DVDRAM
83
	#define LIBHAL_VOLUME_DISC_TYPE_DVDR		HAL_VOLUME_DISC_TYPE_DVDR
84
	#define LIBHAL_VOLUME_DISC_TYPE_DVDRW		HAL_VOLUME_DISC_TYPE_DVDRW
85
	#define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR	HAL_VOLUME_DISC_TYPE_DVDPLUSR
86
	#define LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW	HAL_VOLUME_DISC_TYPE_DVDPLUSRW
87
	#define LIBHAL_DRIVE_TYPE_COMPACT_FLASH			HAL_DRIVE_TYPE_COMPACT_FLASH
88
	#define LIBHAL_DRIVE_TYPE_MEMORY_STICK			HAL_DRIVE_TYPE_MEMORY_STICK
89
	#define LIBHAL_DRIVE_TYPE_SMART_MEDIA 			HAL_DRIVE_TYPE_SMART_MEDIA
90
	#define LIBHAL_DRIVE_TYPE_SD_MMC				HAL_DRIVE_TYPE_SD_MMC
91
	#define LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER	HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER
92
	#define LIBHAL_DRIVE_TYPE_CAMERA				HAL_DRIVE_TYPE_CAMERA
93
	#define LIBHAL_DRIVE_TYPE_TAPE					HAL_DRIVE_TYPE_TAPE
94
95
	// libhal 0.4 API
96
	#define libhal_free_string hal_free_string
97
	#define libhal_device_exists(ctx, udi, error) hal_device_exists(ctx, udi)
98
	#define libhal_device_property_watch_all(ctx, error) hal_device_property_watch_all(ctx)
99
	#define libhal_get_all_devices(ctx, num_devices, error) hal_get_all_devices(ctx, num_devices)
100
	#define libhal_device_property_exists(ctx, udi, key, error) hal_device_property_exists(ctx, udi, key)
101
	#define libhal_device_get_property_bool(ctx, udi, key, error) hal_device_get_property_bool(ctx, udi, key)
102
	#define libhal_device_get_property_string(ctx, udi, key, error) hal_device_get_property_string(ctx, udi, key)
103
	#define libhal_device_query_capability(ctx, udi, capability, error) hal_device_query_capability(ctx, udi, capability)
104
#endif
105
106
46
/**
107
/**
47
* A handy function to query a hal string
108
* A handy function to query a hal string
48
*
109
*
Lines 137-148 Link Here
137
198
138
/* Hal call-backs -- from gvm*/
199
/* Hal call-backs -- from gvm*/
139
public:
200
public:
201
#ifdef HAL_0_4
140
	/** Invoked by libhal for integration with our mainloop.
202
	/** Invoked by libhal for integration with our mainloop.
141
	*
203
	*
142
	*  @param  ctx                 LibHal context
204
	*  @param  ctx                 LibHal context
143
	*  @param  dbus_connection     D-BUS connection to integrate
205
	*  @param  dbus_connection     D-BUS connection to integrate
144
	*/
206
	*/
145
	static void hal_main_loop_integration(LibHalContext *ctx, DBusConnection *dbus_connection);
207
	static void hal_main_loop_integration(LibHalContext *ctx, DBusConnection *dbus_connection);
208
#endif
146
209
147
	/** Invoked when a device is added to the Global Device List.
210
	/** Invoked when a device is added to the Global Device List.
148
	*
211
	*
Lines 175-181 Link Here
175
	*  @param  message             D-BUS message with variable parameters depending on condition
238
	*  @param  message             D-BUS message with variable parameters depending on condition
176
	*/
239
	*/
177
	static void hal_device_condition(LibHalContext *ctx, const char *udi,
240
	static void hal_device_condition(LibHalContext *ctx, const char *udi,
178
				const char *condition_name, DBusMessage *message);
241
				const char *condition_name,
242
				#ifdef HAL_0_4
243
				DBusMessage *message
244
				#else
245
				const char* message
246
				#endif
247
				);
179
248
180
/* HAL and DBus structures */
249
/* HAL and DBus structures */
181
private:
250
private:
Lines 184-198 Link Here
184
	*/
253
	*/
185
	LibHalContext*		m_halContext;
254
	LibHalContext*		m_halContext;
186
255
256
#ifdef HAL_0_4
187
	/**
257
	/**
188
	* Structure defining the hal callback function for devices events
258
	* Structure defining the hal callback function for devices events
189
	*/
259
	*/
190
	LibHalFunctions 	m_halFunctions;
260
	LibHalFunctions 	m_halFunctions;
261
#endif
191
262
192
	/**
263
	/**
193
	* libhal-storage HAL policy, e.g. for icon names
264
	* libhal-storage HAL policy, e.g. for icon names
194
	*/
265
	*/
195
	HalStoragePolicy*	m_halStoragePolicy;
266
	LibHalStoragePolicy*	m_halStoragePolicy;
196
267
197
	/**
268
	/**
198
	* The DBus-Qt bindings connection for mainloop integration
269
	* The DBus-Qt bindings connection for mainloop integration

Return to bug 105553