imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h
changeset 1 235a7fc86938
parent 0 2014ca87e772
child 5 82749d516180
child 14 2edacbf5d3f9
equal deleted inserted replaced
0:2014ca87e772 1:235a7fc86938
    18 
    18 
    19 #ifndef THUMBNAILSTORE_H
    19 #ifndef THUMBNAILSTORE_H
    20 #define THUMBNAILSTORE_H
    20 #define THUMBNAILSTORE_H
    21 
    21 
    22 #include <sqldb.h>
    22 #include <sqldb.h>
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
    23 #include "thumbnailcenrep.h"
    25 #include "thumbnailcenrep.h"
    24 #include "thumbnailmanagerconstants.h"
    26 #include "thumbnailmanagerconstants.h"
    25 #include "thumbnaillog.h"
    27 #include "thumbnaillog.h"
    26 #include "thumbnailserver.h"
    28 #include "thumbnailserver.h"
    27 
    29 
    53     TState iState;
    55     TState iState;
    54 };
    56 };
    55 
    57 
    56 
    58 
    57 /**
    59 /**
       
    60 * MMdSDiskSpaceNotifierObserver
       
    61 * Observer interface for a disk space notifier.
       
    62 */
       
    63 class MThumbnailStoreDiskSpaceNotifierObserver
       
    64     {
       
    65     public :
       
    66         /**
       
    67          * Called to notify the observer that disk space has crossed the specified threshold value.
       
    68          *
       
    69          * @param aDiskFull is disk full (freespace under specified threshold level)
       
    70          */
       
    71         virtual void HandleDiskSpaceNotificationL(TBool aDiskFull) = 0;
       
    72         
       
    73         /**
       
    74          * Called to if disk space notifier has an error situation.
       
    75          *
       
    76          * @param aError error code
       
    77          */
       
    78         virtual void HandleDiskSpaceError(TInt aError) = 0;
       
    79 
       
    80     };
       
    81 
       
    82 /**
       
    83 * CMSDiskSpaceNotifierAO.
       
    84 * A disk space notifier class
       
    85 */
       
    86 class CThumbnailStoreDiskSpaceNotifierAO : public CActive
       
    87     {
       
    88     public:
       
    89         enum TDiskSpaceNotifierState
       
    90             {
       
    91             ENormal,
       
    92             EIterate
       
    93             };
       
    94 
       
    95     public : // Constructors and destructors
       
    96         /**
       
    97          * Constructs a disk space notifier implementation.
       
    98          *
       
    99          * @param aThreshold minimum free disk space threshold level in bytes
       
   100          * @param aFilename filename which defines monitored drive's number
       
   101          * @return  implementation
       
   102          */
       
   103         static CThumbnailStoreDiskSpaceNotifierAO* NewL(
       
   104                 MThumbnailStoreDiskSpaceNotifierObserver& aObserver, 
       
   105             TInt64 aThreshold, const TDesC& aFilename);
       
   106         
       
   107         /**
       
   108          * Constructs a disk space notifier implementation and leaves it
       
   109          * in the cleanup stack.
       
   110          *
       
   111          * @param aThreshold minimum free disk space threshold level in bytes
       
   112          * @return implementation
       
   113          */
       
   114         static CThumbnailStoreDiskSpaceNotifierAO* NewLC(        
       
   115                 MThumbnailStoreDiskSpaceNotifierObserver& aObserver, 
       
   116             TInt64 aThreshold, const TDesC& aFilename );
       
   117 
       
   118         /**
       
   119         * Destructor.
       
   120         */
       
   121         virtual ~CThumbnailStoreDiskSpaceNotifierAO();
       
   122 
       
   123         TBool DiskFull() const;
       
   124 
       
   125     protected: // Functions from base classes
       
   126         /**
       
   127          * From CActive
       
   128          * Callback function.
       
   129          * Invoked to handle responses from the server.
       
   130          */
       
   131         void RunL();
       
   132 
       
   133         /**
       
   134          * From CActive
       
   135          * Handles errors that occur during notifying the observer.
       
   136          */
       
   137         TInt RunError(TInt aError);
       
   138 
       
   139         /**
       
   140          * From CActive
       
   141          * Cancels any outstanding operation.
       
   142          */
       
   143         void DoCancel();
       
   144 
       
   145     private: // Constructors and destructors
       
   146 
       
   147         /**
       
   148          * constructor
       
   149          */
       
   150         CThumbnailStoreDiskSpaceNotifierAO(
       
   151                 MThumbnailStoreDiskSpaceNotifierObserver& aObserver,
       
   152             TInt64 aThreshold, TDriveNumber aDrive );
       
   153 
       
   154         /**
       
   155          * 2nd phase constructor
       
   156          * @param aThreshold minimum free disk space threshold level in bytes
       
   157          * @param aDrive monitored drive's number
       
   158          */
       
   159         void ConstructL();
       
   160 
       
   161     private: // New methods
       
   162 
       
   163         void StartNotifier();
       
   164 
       
   165         static TDriveNumber GetDriveNumberL( const TDesC& aFilename );
       
   166 
       
   167     private: // Data
       
   168 
       
   169         MThumbnailStoreDiskSpaceNotifierObserver& iObserver;
       
   170         
       
   171         RFs iFileServerSession;
       
   172         
       
   173         const TInt64 iThreshold;
       
   174         
       
   175         const TDriveNumber iDrive;
       
   176         
       
   177         TDiskSpaceNotifierState iState;
       
   178         
       
   179         TInt iIterationCount;
       
   180         
       
   181         TBool iDiskFull;
       
   182     };
       
   183 
       
   184 
       
   185 /**
    58  *  Store for thumbnails.
   186  *  Store for thumbnails.
    59  *
   187  *
    60  *  @since S60 v5.0
   188  *  @since S60 v5.0
    61  */
   189  */
    62 class CThumbnailStore: public CBase
   190 class CThumbnailStore: public CBase, public MThumbnailStoreDiskSpaceNotifierObserver
    63     {
   191     {
    64     // Bitmasked Flags
   192     // Bitmasked Flags
    65     typedef enum 
   193     typedef enum 
    66     {
   194     {
    67     KThumbnailDbFlagCropped = 1,
   195     KThumbnailDbFlagCropped = 1,
   314      *
   442      *
   315      * @since S60 v5.0
   443      * @since S60 v5.0
   316      */
   444      */
   317     
   445     
   318     TInt CheckRowIDsL();
   446     TInt CheckRowIDsL();
       
   447     
       
   448     TBool IsDiskFull();
   319 
   449 
   320 private:
   450 private:
   321     /**
   451     /**
   322      * C++ default constructor
   452      * C++ default constructor
   323      *
   453      *
   424     * Removes blacklisted flag from all entrys
   554     * Removes blacklisted flag from all entrys
   425     *
   555     *
   426     */
   556     */
   427     void RemoveDbFlagL(TThumbnailDbFlags aFlag);
   557     void RemoveDbFlagL(TThumbnailDbFlags aFlag);
   428     
   558     
       
   559 public : // From MThumbnailStoreDiskSpaceNotifierObserver
       
   560     void HandleDiskSpaceNotificationL(TBool aDiskFull);
       
   561 
       
   562     void HandleDiskSpaceError(TInt aError);
       
   563     
   429 private:
   564 private:
   430     // data
   565     // data
   431 
   566 
   432     /**
   567     /**
   433      * Fileserver.
   568      * Fileserver.
   470 #endif
   605 #endif
   471     /**
   606     /**
   472      * Periodic timer handling automatic flushing of db cache
   607      * Periodic timer handling automatic flushing of db cache
   473      */
   608      */
   474     CPeriodic* iAutoFlushTimer;
   609     CPeriodic* iAutoFlushTimer;
       
   610     
       
   611     /**
       
   612     * Notifier for situations where free disk space runs out.
       
   613     */
       
   614     CThumbnailStoreDiskSpaceNotifierAO* iDiskFullNotifier;
       
   615     
       
   616     TBool iDiskFull;
   475 };
   617 };
       
   618 // End of File
       
   619 
   476 
   620 
   477 #endif // THUMBNAILSTORE_H
   621 #endif // THUMBNAILSTORE_H