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

List:       kde-commits
Subject:    Re: extragear/multimedia/amarok/src/collection/ipodcollection/handler
From:       Martin Aumueller <aumuell () reserv ! at>
Date:       2009-07-17 11:42:47
Message-ID: 200907171342.47616.aumuell () reserv ! at
[Download RAW message or body]

Perhaps the caching policy should go into some super class? The cache could be 
updated when a device is connected and when write operations on the device 
have been caused by Amarok. Now, every plugin has to decide on its own when to 
update the cache. And it has to do additional work in order to cache this data 
at all.

On Friday 17 July 2009 13:32:11 Alejandro Daniel Wainzinger wrote:
> SVN commit 998297 by awainzinger:
>
> Cache capacity/used space for iPod.
>
>  M  +19 -24    IpodHandler.cpp
>  M  +10 -0     IpodHandler.h
>
>
> ---
> trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/Ipo
>dHandler.cpp #998296:998297 @@ -72,6 +72,7 @@
>
>      : MediaDeviceHandler( mc )
>
>      //, m_memColl( mc )
>      , m_masterPlaylist( 0 )
> +    , m_capacity( 0.0 )
>      , m_jobcounter( 0 )
>      , m_autoConnect( false )
>      , m_mountPoint( mountPoint )
> @@ -312,6 +313,21 @@
>
>      qsrand( QTime::currentTime().msec() ); // random number used for
> folder number generation
>
> +    // Get storage access for getting device space capacity/usage
> +
> +    Solid::Device device = Solid::Device(  m_memColl->udi() );
> +        if (  device.isValid() )
> +        {
> +            Solid::StorageAccess *storage =
> device.as<Solid::StorageAccess>(); +            m_filepath =
> storage->filePath();
> +            m_capacity = KDiskFreeSpaceInfo::freeSpaceInfo( m_filepath
> ).size(); +        }
> +        else
> +        {
> +            m_filepath = "";
> +            m_capacity = 0.0;
> +        }
> +
>      debug() << "Succeeded: " << m_success;
>
>      m_memColl->slotAttemptConnectionDone( m_success );
> @@ -1343,37 +1359,16 @@
>  float
>  IpodHandler::usedCapacity() const
>  {
> -    Solid::Device device = Solid::Device( m_memColl->udi() );
> -    if( device.isValid() )
> -    {
> -        Solid::StorageAccess *storage = device.as<Solid::StorageAccess>();
> -        KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(
> storage->filePath() ); -        return info.used();
> -
> -    }
> -
> +    if ( !m_filepath.isEmpty() )
> +        return KDiskFreeSpaceInfo::freeSpaceInfo( m_filepath ).used();
>      else
> -    {
>          return 0.0;
> -    }
>  }
>
>  float
>  IpodHandler::totalCapacity() const
>  {
> -    Solid::Device device = Solid::Device( m_memColl->udi() );
> -    if( device.isValid() )
> -    {
> -        Solid::StorageAccess *storage = device.as<Solid::StorageAccess>();
> -        KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(
> storage->filePath() ); -        return info.size();
> -    }
> -
> -    else
> -    {
> -        return 0.0;
> -    }
> -
> +    return m_capacity;
>  }
>
>  /// Sets
> ---
> trunk/extragear/multimedia/amarok/src/collection/ipodcollection/handler/Ipo
>dHandler.h #998296:998297 @@ -39,6 +39,7 @@
>
>  #include "mediadevicecollection_export.h"
>
> +#include <KDiskFreeSpaceInfo>
>  #include <KIO/Job>
>  #include "kjob.h"
>  #include <ctime> // for kjob.h
> @@ -50,6 +51,10 @@
>  #include <QMultiMap>
>  #include <QMutex>
>
> +namespace Solid {
> +    class StorageAccess;
> +}
> +
>  class QString;
>  class QMutex;
>
> @@ -281,6 +286,11 @@
>      GList            *m_currtracklist;
>      Itdb_Track       *m_currtrack;
>
> +    // For space checks
> +
> +    QString               m_filepath;
> +    float                 m_capacity;
> +
>      // for playlist parsing
>
>      GList            *m_currplaylistlist;
[prev in list] [next in list] [prev in thread] [next in thread] 

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