Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Oct 2006 01:37:06 +0400 (MSD)
From:      Maxim Samsonov <xors@sendmail.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/104552: [PATCH]: x11/kdebase3 Enable HAL backend support
Message-ID:  <200610182137.k9ILb6gH007243@xors.pg.org>
Resent-Message-ID: <200610182140.k9ILeIpa053955@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         104552
>Category:       ports
>Synopsis:       [PATCH]: x11/kdebase3 Enable HAL backend support
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 18 21:40:18 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Maxim Samsonov
>Release:        FreeBSD 6.2-PRERELEASE i386
>Organization:
>Environment:
>Description:
This patch enables HAL backend support for KDE media manager
and adds the dependencies on sysutils/hal, devel/dbus-qt3(pr: ports/104547).
>How-To-Repeat:
>Fix:
--- kdebase3.diff begins here ---
diff -rubdBN kdebase3.orig/Makefile kdebase3/Makefile
--- kdebase3.orig/Makefile	Wed Oct 18 14:24:45 2006
+++ kdebase3/Makefile	Thu Oct 19 01:06:30 2006
@@ -22,6 +22,8 @@
 		xmkmf:${X_IMAKE_PORT}
 LIB_DEPENDS=	sasl2:${PORTSDIR}/security/cyrus-sasl2 \
 		smbclient:${PORTSDIR}/net/samba-libsmbclient \
+		dbus-qt-1.1:${PORTSDIR}/devel/dbus-qt3 \
+		hal.1:${PORTSDIR}/sysutils/hal \
 		usb-0.1:${PORTSDIR}/devel/libusb
 
 CONFLICTS=	kdeartwork-3.[2-3]* kdelibs-3.[0-4]* kdeutils-3.[0-2]*
@@ -46,7 +48,7 @@
 LDCONFIG_DIRS+=	%%PREFIX%%/lib %%PREFIX%%/lib/kde3
 
 CONFIGURE_ENV+=	RUN_KAPPFINDER=no kde_cv_utmp_file=/var/run/utmp
-CONFIGURE_ARGS+=--without-hal \
+CONFIGURE_ARGS+=--with-hal \
 		--without-java			\
 		--with-qt-dir=${X11BASE}	\
 		--with-xdmdir=${X11BASE}/lib/X11/xdm \
diff -rubdBN kdebase3.orig/files/patch-kioslave_media_mediamanager-halbackend.cpp kdebase3/files/patch-kioslave_media_mediamanager-halbackend.cpp
--- kdebase3.orig/files/patch-kioslave_media_mediamanager-halbackend.cpp	Thu Jan  1 03:00:00 1970
+++ kdebase3/files/patch-kioslave_media_mediamanager-halbackend.cpp	Thu Oct 19 00:38:15 2006
@@ -0,0 +1,175 @@
+--- kioslave/media/mediamanager/halbackend.cpp.orig	Wed Oct 18 21:11:02 2006
++++ kioslave/media/mediamanager/halbackend.cpp	Thu Oct 19 00:29:42 2006
+@@ -17,8 +17,9 @@
+ */
+ 
+ #include "halbackend.h"
+-#include "linuxcdpolling.h"
+ 
++#include <fcntl.h>
++#include <unistd.h>
+ #include <stdlib.h>
+ 
+ #include <klocale.h>
+@@ -348,6 +349,120 @@
+ 	delete m;
+ }
+ 
++bool HALBackend::hasDirectory(const QCString &devNode, const QCString &dir)
++{
++	bool ret = false; // return value
++	int fd = 0; // file descriptor for drive
++	unsigned short bs; // the discs block size
++	unsigned short bts; // the path table size (in blocks)
++	unsigned short ts; // the path table size (in bytes)
++	unsigned int btl; // the path table location (in blocks)
++	unsigned int tl; // the path table location (in bytes)
++	unsigned char len_di = 0; // length of the directory name in current path table entry
++	unsigned int parent = 0; // the number of the parent directory's path table entry
++	char dirname[256]; // filename for the current path table entry
++	int pos = 0; // our position into the path table
++	QCString fixed_directory = dir.upper(); // the uppercase version of the "directory" parameter
++	unsigned char buf[4096]; // the read buffer
++	unsigned char *sbuf = buf+2048; // the half part of the read buffer pointer
++	unsigned char *ptr; // the read buffer pointer
++	int rts; // the initial read path table size (in bytes)
++
++	// open the drive
++	fd = open(devNode, O_RDONLY | O_NONBLOCK);
++	if (fd == -1) return false;
++
++	// read the info block
++	lseek(fd, 0x8000, SEEK_SET);
++	if (read(fd, buf, 2048) != 2048)
++	{
++		close(fd);
++		return false;
++	}
++	// read the block size
++	bs = *(unsigned short *)(buf+0x80);
++	if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
++		bs = ((bs << 8) & 0xFF00) | ((bs >> 8) & 0xFF);
++
++	// read in size of path table
++	ts = *(unsigned short *)(buf+0x84);
++	if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
++		ts = ((ts << 8) & 0xFF00) | ((ts >> 8) & 0xFF);
++
++	// read in which block path table is in
++	btl = *(unsigned int   *)(buf+0x8C);
++	if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
++		btl = ((btl << 24) & 0xFF000000) | ((btl << 8) & 0xFF0000) |
++		     ((btl >> 8) & 0xFF00) | ((btl >> 24) & 0xFF);
++
++	// seek to the path table
++	tl = btl*bs;
++	lseek(fd, tl&(~0x7FF), SEEK_SET);
++	
++	// read the path table
++	bts = (ts+(tl&0x7FF))/2048;
++	rts = !bts ? 2048 : 4096;
++	if (read(fd, buf, rts) != rts)
++	{
++		close(fd);
++		return false;
++	}
++	if (bts) --bts;
++	ptr = buf+(tl&0x7FF);
++
++	// loop through the path table entries
++	while (pos < ts)
++	{
++		// get the length of the filename of the current entry
++		len_di = *ptr;
++
++		// get the record number of this entry's parent
++		// i'm pretty sure that the 1st entry is always the top directory
++		parent = *(unsigned short *)(ptr+6);
++		if (Q_BYTE_ORDER != Q_LITTLE_ENDIAN)
++			parent = ((parent << 8) & 0xFF00) | ((parent >> 8) & 0xFF);
++
++		// read the name
++		bcopy(ptr+8, dirname, len_di);
++		dirname[len_di] = 0;
++		qstrcpy(dirname, QCString(dirname).upper());
++
++		// if we found a folder that has the root as a parent, and the directory name matches
++		// then return success
++		if ((parent == 1) && (dirname == fixed_directory))
++		{
++			ret = true;
++			break;
++		}
++
++		// all path table entries are padded to be even, so if this is an odd-length table, seek a byte to fix it
++		if (len_di%2 == 1)
++		{
++			++pos;
++			++ptr;
++		}
++
++		// update our position
++		pos += 8 + len_di;
++		ptr += 8 + len_di;
++		if (bts && ptr >= sbuf )
++		{
++			--bts;
++			ptr -= 2048;
++			bcopy(sbuf, buf, 2048);
++			// read the path table
++			if (read(fd, sbuf, 2048) != 2048)
++			{
++				close(fd);
++				return false;
++			}   
++		}
++	}
++
++	close(fd);
++	return ret;
++}
++
+ void HALBackend::setVolumeProperties(Medium* medium)
+ {
+ 	kdDebug(1219) << "HALBackend::setVolumeProperties for " << medium->id() << endl;
+@@ -407,28 +522,24 @@
+ 			else
+ 				mimeType = "media/dvd" + MOUNT_SUFFIX;
+ 
+-		if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume))
++		/* check if the disc id a vcd or a video dvd */
++		if (libhal_volume_disc_has_data(halVolume))
++		{
++			QCString devNode = libhal_volume_get_device_file(halVolume);
++			if (hasDirectory(devNode, "video_ts"))
++				mimeType = "media/dvdvideo";
++			else if (hasDirectory(devNode, "vcd"))
++				mimeType = "media/vcd";
++			else if (hasDirectory(devNode, "svcd"))
++				mimeType = "media/svcd";
++		}
++		else if (libhal_volume_disc_has_audio(halVolume))
+ 		{
+ 			mimeType = "media/audiocd";
+ 			medium->unmountableState( "audiocd:/?device=" + QString(libhal_volume_get_device_file(halVolume)) );
+ 		}
+ 
+ 		medium->setIconName(QString::null);
+-
+-		/* check if the disc id a vcd or a video dvd */
+-		DiscType type = LinuxCDPolling::identifyDiscType(libhal_volume_get_device_file(halVolume));
+-		switch (type)
+-		{
+-		  case DiscType::VCD:
+-		    mimeType = "media/vcd";
+-		    break;
+-		  case DiscType::SVCD:
+-		    mimeType = "media/svcd";
+-		    break;
+-		  case DiscType::DVD:
+-		    mimeType = "media/dvdvideo";
+-		    break;
+-		}
+ 	}
+ 	else
+ 	{
diff -rubdBN kdebase3.orig/files/patch-kioslave_media_mediamanager-halbackend.h kdebase3/files/patch-kioslave_media_mediamanager-halbackend.h
--- kdebase3.orig/files/patch-kioslave_media_mediamanager-halbackend.h	Thu Jan  1 03:00:00 1970
+++ kdebase3/files/patch-kioslave_media_mediamanager-halbackend.h	Wed Oct 18 16:56:09 2006
@@ -0,0 +1,10 @@
+--- kioslave/media/mediamanager/halbackend.h.orig	Sat Oct 14 21:08:31 2006
++++ kioslave/media/mediamanager/halbackend.h	Wed Oct 18 16:41:14 2006
+@@ -197,6 +197,7 @@
+ 	void setFloppyProperties(Medium* medium);
+ 	void setCameraProperties(Medium* medium);
+ 	QString generateName(const QString &devNode);
++	bool hasDirectory(const QCString &devNode, const QCString &dir);
+ 
+ /* Hal call-backs -- from gvm*/
+ public:
--- kdebase3.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610182137.k9ILb6gH007243>