Bug 108229 - half broken k3b hal+dbus support in FC4
Summary: half broken k3b hal+dbus support in FC4
Status: RESOLVED FIXED
Alias: None
Product: k3b
Classification: Applications
Component: general (show other bugs)
Version: 0.12.x
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Trueg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-27 17:40 UTC by Paul Ionescu
Modified: 2005-07-01 15:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Ionescu 2005-06-27 17:40:20 UTC
Version:           0.12.1 (using KDE KDE 3.4.1)
Installed from:    Fedora RPMs
OS:                Linux

Hi,

I installed k3b from Rex Dieter kde-redhat repo in my FC4 box.

Then I tried to test the dbus and hal features. I started k3b and then I
plugged an USB DVD recorder, and it correctly appeared in the k3b. (happy
exclamations !!!)
Then I disconnected the USB burner, but it did not disappeared from k3b.
Even more, if I tried to actually use this not existing device, k3b did
not realized it is gone, but asked to insert a blank disk in it.

As an additional info, I checked in hal-device-manager and lshal, and the
USB burner disappeared from hal database, so it seems hal and dbus is
fine.
Comment 1 Rex Dieter 2005-06-27 23:00:17 UTC
For the record, fc4 includes dbus-0.33 and hal-0.5.2
Comment 2 Sebastian Trueg 2005-07-01 15:29:13 UTC
SVN commit 430473 by trueg:

Fixed HAL device removing.

BUG: 108229


 M  +2 -0      ChangeLog  
 M  +17 -20    libk3bdevice/k3bhalconnection.cpp  
 M  +2 -0      libk3bdevice/k3bhalconnection.h  


--- branches/stable/extragear/multimedia/k3b/ChangeLog #430472:430473
@@ -14,6 +14,8 @@
  * Improved session import dialog.
  * Properly default to DVD size in Video DVD project.
  * Fixed automatic multisession handling for DVD+RW media
+ * Fixed handbook installation
+ * Fixed HAL backend: devices are properly removed now.
 
 0.12.1
 Fixed compilation problems with older musepack library version.
--- branches/stable/extragear/multimedia/k3b/libk3bdevice/k3bhalconnection.cpp #430472:430473
@@ -100,9 +100,10 @@
   s_contextMap[m_halContext] = this;
 
   // report all already detected devices
-  QStringList devs = devices();
-  for( QStringList::iterator it = devs.begin(); it != devs.end(); ++it )
-    emit deviceAdded( *it );
+  int numDevices;
+  char** halDeviceList = libhal_get_all_devices( m_halContext, &numDevices, 0 );
+  for( int i = 0; i < numDevices; ++i )
+    addDevice( halDeviceList[i] );
 
   return true;
 }
@@ -133,17 +134,7 @@
 
 QStringList K3bDevice::HalConnection::devices() const
 {
-  QStringList devs;
-  if( m_halContext ) {
-    int numDevices;
-    char** halDeviceList = libhal_get_all_devices( m_halContext, &numDevices, 0 );
-    for( int i = 0; i < numDevices; ++i ) {
-      QString dev = getSystemDeviceForCdrom( halDeviceList[i] );
-      if( !dev.isEmpty() )
-	devs.append( dev );
-    }
-  }
-  return devs;
+  return QStringList( m_udiDeviceMap.values() );
 }
 
 
@@ -169,16 +160,22 @@
 void K3bDevice::HalConnection::addDevice( const char* udi )
 {
   QString s = getSystemDeviceForCdrom( udi );
-  if( !s.isEmpty() )
+  if( !s.isEmpty() ) {
+    //    kdDebug() << "Mapping udi " << udi << " to device " << s << endl;
+    m_udiDeviceMap[udi] = s;
     emit deviceAdded( s );
+  }
 }
 
 
 void K3bDevice::HalConnection::removeDevice( const char* udi )
 {
-  QString s = getSystemDeviceForCdrom( udi );
-  if( !s.isEmpty() )
-    emit deviceRemoved( s );
+  QMapIterator<QCString, QString> it = m_udiDeviceMap.find( udi );
+  if( it != m_udiDeviceMap.end() ) {
+    //    kdDebug() << "Unmapping udi " << udi << " from device " << it.data() << endl;
+    emit deviceRemoved( it.data() );
+    m_udiDeviceMap.erase( it );
+  }
 }
 
 
@@ -192,7 +189,7 @@
 // CALLBACKS
 void K3bDevice::HalConnection::halDeviceAdded( LibHalContext* ctx, const char* udi )
 {
-  //  kdDebug() << k_funcinfo << endl;
+  //  kdDebug() << "adding udi   " << udi << endl;
   HalConnection* con = s_contextMap[ctx];
   con->addDevice( udi );
 }
@@ -200,7 +197,7 @@
 
 void K3bDevice::HalConnection::halDeviceRemoved( LibHalContext* ctx, const char* udi )
 {
-  //  kdDebug() << k_funcinfo << endl;
+  //  kdDebug() << "removing udi " << udi << endl;
   HalConnection* con = s_contextMap[ctx];
   con->removeDevice( udi );
 }
--- branches/stable/extragear/multimedia/k3b/libk3bdevice/k3bhalconnection.h #430472:430473
@@ -85,6 +85,8 @@
       LibHalFunctions m_halFunctions;
 #endif
 
+      QMap<QCString, QString> m_udiDeviceMap;
+
       /**
        * \return the system device for cdrom devices and an empty string for all other devices.
        */