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

List:       kde-commits
Subject:    branches/KDE/3.5/kdebase/kioslave/media/mediamanager
From:       Martin Pley <martin () pley ! de>
Date:       2007-11-22 12:16:40
Message-ID: 1195733800.471233.32717.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 740044 by pley:

- Fixed a small memleak: use libhal_free_string_array(volumes) instead
  of free(volumes)
- USB floppy drives have media-detection enabled. Thus we can react on
  insertion of a floppy disk
- Fixed empty labels for floppy drives


 M  +28 -19    halbackend.cpp  
 M  +1 -1      halbackend.h  


--- branches/KDE/3.5/kdebase/kioslave/media/mediamanager/halbackend.cpp \
#740043:740044 @@ -265,6 +265,8 @@
             (libhal_device_get_property_QString(m_halContext, udi, \
                "storage.drive_type") == "zip") ||
             (libhal_device_get_property_QString(m_halContext, udi, \
"storage.drive_type") == "jaz"))  {
+            if (! libhal_device_get_property_bool(m_halContext, udi, \
"storage.removable.media_available", NULL) ) +                allowNotification = \
false;  /* Create medium */
             Medium* medium = new Medium(udi, "");
             // if the storage has a volume, we ignore it
@@ -298,11 +300,13 @@
 
 void HALBackend::ModifyDevice(const char *udi, const char* key)
 {
-    Q_UNUSED(key);
     const char* mediumUdi = findMediumUdiFromUdi(udi);
     if (!mediumUdi)
         return;
-    ResetProperties(mediumUdi);
+    bool allowNotification = false;
+    if (strcmp(key, "storage.removable.media_available") == 0)
+        allowNotification = libhal_device_get_property_bool(m_halContext, udi, key, \
NULL); +    ResetProperties(mediumUdi, allowNotification);
 }
 
 void HALBackend::DeviceCondition(const char* udi, const char* condition)
@@ -382,7 +386,7 @@
     return NULL;
 }
 
-void HALBackend::ResetProperties(const char* mediumUdi)
+void HALBackend::ResetProperties(const char* mediumUdi, bool allowNotification)
 {
     kdDebug(1219) << "HALBackend::setProperties" << endl;
     if ( QString::fromLatin1( mediumUdi ).startsWith( "/org/kde/" ) )
@@ -393,7 +397,7 @@
             Medium m( *cmedium );
             if ( setFstabProperties( &m ) ) {
                 kdDebug() << "setFstabProperties worked" << endl;
-                m_mediaList.changeMediumState(m, false);
+                m_mediaList.changeMediumState(m, allowNotification);
             }
             return;
        }
@@ -408,7 +412,7 @@
     if (libhal_device_query_capability(m_halContext, mediumUdi, "camera", NULL))
         setCameraProperties(m);
 
-    m_mediaList.changeMediumState(*m, false);
+    m_mediaList.changeMediumState(*m, allowNotification);
 
     delete m;
 }
@@ -615,44 +619,49 @@
     LibHalDrive*  halDrive  = libhal_drive_from_udi(m_halContext, udi);
     if (!halDrive)
         return false;
-    int numVolumes;
-    char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, \
                &numVolumes);
-    kdDebug(1219) << " found " << numVolumes << " volumes" << endl;
-    if (numVolumes)
-    {
-        free(volumes);
-        libhal_drive_free(halDrive);
-        return false;
+
+    QString drive_type = libhal_device_get_property_QString(m_halContext, udi, \
"storage.drive_type"); +
+    if (drive_type == "zip") {
+        int numVolumes;
+        char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, \
&numVolumes); +        libhal_free_string_array(volumes);
+        kdDebug(1219) << " found " << numVolumes << " volumes" << endl;
+        if (numVolumes)
+        {
+            libhal_drive_free(halDrive);
+            return false;
+        }
     }
 
-    medium->setName(
-        generateName(libhal_drive_get_device_file(halDrive)) );
+    medium->setName( generateName(libhal_drive_get_device_file(halDrive)) );
+    medium->setLabel(i18n("Unknown Drive"));
 
     // HAL hates floppies - so we have to do it twice ;(
     medium->mountableState(libhal_drive_get_device_file(halDrive), QString::null, \
QString::null, false);  setFloppyMountState(medium);
 
-    if (libhal_device_get_property_QString(m_halContext, udi, "storage.drive_type") \
== "floppy") +    if (drive_type == "floppy")
     {
         if (medium->isMounted()) // don't use _SUFFIX here as it accesses the volume
             medium->setMimeType("media/floppy_mounted" );
         else
             medium->setMimeType("media/floppy_unmounted");
+        medium->setLabel(i18n("Floppy Drive"));
     }
-
-    if (libhal_device_get_property_QString(m_halContext, udi, "storage.drive_type") \
== "zip") +    else if (drive_type == "zip") 
     {
         if (medium->isMounted())
             medium->setMimeType("media/zip_mounted" );
         else
             medium->setMimeType("media/zip_unmounted");
+        medium->setLabel(i18n("Zip Drive"));
     }
 
     /** @todo And mimtype for JAZ drives ? */
 
     medium->setIconName(QString::null);
 
-    free(volumes);
     libhal_drive_free(halDrive);
 
     return true;
--- branches/KDE/3.5/kdebase/kioslave/media/mediamanager/halbackend.h #740043:740044
@@ -128,7 +128,7 @@
 	/**
 	* Reset properties for the given medium
 	*/
-	void ResetProperties(const char* MediumUdi);
+	void ResetProperties(const char* MediumUdi, bool allowNotification=false);
 
 	/**
 	* Find the medium that is concerned with device udi


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

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