[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/stable/extragear/multimedia/k3b
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2005-07-01 13:29:09
Message-ID: 1120224549.308030.27703.nullmailer () svn ! kde ! org
[Download RAW message or body]

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.
        */
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic