internetradio2.0/uiinc/irdiskspacewatcher.h
changeset 3 ee64f059b8e1
parent 2 2e1adbfc62af
child 4 3f2d53f144fe
child 5 0930554dc389
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Header for CIRDiskSpaceWatcher
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CIRDISKSPACEWATCHER_H
       
    19 #define CIRDISKSPACEWATCHER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 
       
    24 #include "irdiskspacewatcherobserver.h"
       
    25 
       
    26 class CIRDiskSpaceSession;
       
    27 
       
    28 // Default drive. Used to save for example settings and cache files.
       
    29 const TDriveNumber KVRDefaultDrive = EDriveC;
       
    30 
       
    31 /**
       
    32  *  CIRDiskSpaceWatcher. Watcher of disk space on defined disks.
       
    33  *
       
    34  *  Observes a disk and notifies the observer if the supplied critical disk 
       
    35  *  space limit is reached. 
       
    36  */
       
    37 NONSHARABLE_CLASS( CIRDiskSpaceWatcher ): public CBase, public MIRDiskSpaceWatcherObserver
       
    38     {
       
    39     
       
    40 public:  // Methods
       
    41 
       
    42     /**
       
    43      * Static constructor.     
       
    44      * 
       
    45      * @param aCriticalLevel, critical disk space level
       
    46      * @param aDiskSpaceWatcherObserver observer of disk space status     
       
    47      */
       
    48     static CIRDiskSpaceWatcher* NewL( const TInt64& aCriticalLevel, 
       
    49         MIRDiskSpaceWatcherObserver& aDiskSpaceWatcherObserver );
       
    50     
       
    51     /**
       
    52      * Destructor.
       
    53      */
       
    54     virtual ~CIRDiskSpaceWatcher();
       
    55 
       
    56     /**
       
    57      * IsBelowCriticalLevel Returns whether or disk defined by parameter 
       
    58      * contains less than the critical level free disk space.
       
    59      * Please note that StartObservingDriveL must have been called 
       
    60      * before calling this. Otherwise method will return EFalse whetever
       
    61      * disk space is below critical level or not.
       
    62      *  
       
    63      * @param aDriveNumber drive which space is checked
       
    64      * @return ETrue if there is less free disk space than the critical 
       
    65      * level, otherwise EFalse.
       
    66      */
       
    67     TBool IsBelowCriticalLevel( const TDriveNumber& aDriveNumber ) const;
       
    68                         
       
    69     /**
       
    70      * Starts observing space of drive which is given as parameter
       
    71      *
       
    72      * @param aDriveNumber drive which will be observed
       
    73      */
       
    74     void StartObservingDriveL( const TDriveNumber& aDriveNumber );            
       
    75             
       
    76     /**
       
    77      * Stops observing space of drive which is given as parameter.
       
    78      * Please note that if drive is observed by some other object 
       
    79      * it will be observed until all objects have asked 
       
    80      * VRDiskSpaceWatcher to stop observing that drive.
       
    81      *
       
    82      * @param aDriveNumber drive which observing will be stopped. 
       
    83      */
       
    84     void StopObservingDrive( const TDriveNumber& aDriveNumber );    
       
    85     
       
    86     // From base class MIRDiskSpaceWatcherObserver
       
    87     /** 
       
    88      * From MIRDiskSpaceWatcherObserver
       
    89      *
       
    90      * @see MIRDiskSpaceWatcherObserver::NotifyLowDiskSpaceL()
       
    91      */
       
    92     
       
    93     void NotifyLowDiskSpaceL();
       
    94             
       
    95 protected:  
       
    96 
       
    97 private: 
       
    98 
       
    99     /**
       
   100      * C++ default constructor.
       
   101      * 
       
   102      * @param aCriticalLevel, critical disk space level
       
   103      * @param aDiskSpaceWatcherObserver observer of disk space status
       
   104      */
       
   105     CIRDiskSpaceWatcher( const TInt64& aCriticalLevel, 
       
   106         MIRDiskSpaceWatcherObserver& aDiskSpaceWatcherObserver );
       
   107 
       
   108     /**
       
   109      * By default Symbian 2nd phase constructor is private.
       
   110      */
       
   111     void ConstructL();
       
   112 
       
   113 private:    // Data
       
   114 
       
   115     /** 
       
   116      * Handle to the file system. 
       
   117      */
       
   118     RFs iFs;
       
   119 
       
   120     /** 
       
   121      * Critical disk space level. 
       
   122      */
       
   123     const TInt64 iCriticalLevel;
       
   124 
       
   125 	/** 
       
   126 	 * The observer to be notified when critical disk space limit is reached.
       
   127 	 */
       
   128     MIRDiskSpaceWatcherObserver& iObserver;
       
   129 
       
   130     /** 
       
   131      * Contains active objects which do the actual disk space checking 
       
   132      */
       
   133     RPointerArray<CIRDiskSpaceSession> iDiskSpaceSessions;
       
   134     };
       
   135 
       
   136 #endif      // IRDISKSPACEWATCHER_H