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

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/collection/mtpcollection/handler
From:       Alejandro Daniel Wainzinger <aikawarazuni () gmail ! com>
Date:       2009-07-17 11:59:23
Message-ID: 1247831963.139769.16502.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 998310 by awainzinger:

Cache Mtp capacity, like with Ipods.

 M  +14 -11    MtpHandler.cpp  
 M  +2 -0      MtpHandler.h  


--- trunk/extragear/multimedia/amarok/src/collection/mtpcollection/handler/MtpHandler.cpp #998309:998310
@@ -290,8 +290,20 @@
     else
         debug() << "Unknown battery level";
 
+    if( LIBMTP_Get_Storage( m_device, LIBMTP_STORAGE_SORTBY_NOTSORTED ) != 0 )
+    {
+        debug() << "Failed to get storage properties, cannot get capacity";
+        m_capacity = 0.0;
+    }
 
+    else
+    {
+        m_capacity =  m_device->storage->FreeSpaceInBytes;
+        m_capacity = m_device->storage->MaxCapacity;
+    }
 
+
+
     QString modelname = QString( LIBMTP_Get_Modelname( m_device ) );
 
     // NOTE: on next libmtp bump, may reintroduce owner name
@@ -1026,16 +1038,7 @@
 MtpHandler::usedCapacity() const
 {
     DEBUG_BLOCK
-    if( LIBMTP_Get_Storage( m_device, LIBMTP_STORAGE_SORTBY_NOTSORTED ) != 0 )
-    {
-        debug() << "Failed to get storage properties, cannot get capacity";
-        return 0.0;
-    }
-
-    else
-    {
-        return m_device->storage->FreeSpaceInBytes;
-    }
+    return m_capacity;
 }
 
 float
@@ -1050,7 +1053,7 @@
 
     else
     {
-        return m_device->storage->MaxCapacity;
+        return m_device->storage->FreeSpaceInBytes;
     }
 
 }
--- trunk/extragear/multimedia/amarok/src/collection/mtpcollection/handler/MtpHandler.h #998309:998310
@@ -212,6 +212,8 @@
 
     LIBMTP_mtpdevice_t      *m_device;
 
+    float                    m_capacity;
+
     QMap<int, QString>       mtpFileTypes;
 
     uint32_t                m_default_parent_folder;
[prev in list] [next in list] [prev in thread] [next in thread] 

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