filesystemuis/memscaneng/serverinc/mseng.h
changeset 0 6a9f87576119
child 13 5181328fad28
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     1 /*
       
     2 * Copyright (c) 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: 
       
    15 *     The actual "engine". 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CMSENG_H
       
    21 #define CMSENG_H
       
    22 
       
    23 
       
    24 // SYSTEM INCLUDES
       
    25 #include <data_caging_path_literals.hrh>
       
    26 #include <badesca.h>                        // descriptor arrays
       
    27 #include <f32file.h>                        // enum TDriveNumber
       
    28 #include <stringresourcereader.h>
       
    29 #include <barsc2.h>                         // CResourceFile
       
    30 #include <barsread2.h>                      // RResourceReader
       
    31 
       
    32 
       
    33 // USER INCLUDES
       
    34 #include "msenguihandler.h"
       
    35 
       
    36 
       
    37 // FORWARD DECLARATIOS
       
    38 class CMsengScanner;
       
    39 class RFs;
       
    40 class MMsengUIHandler;
       
    41 
       
    42 
       
    43 // CONSTANTS
       
    44 
       
    45 // Resource file path
       
    46 _LIT(KMsengRscFilePath,"Z:mseng.rsc");
       
    47 
       
    48 
       
    49 // DATA TYPES
       
    50 
       
    51 /**
       
    52 *  Type definition to handle arrays of integers 
       
    53 *  more conveniently
       
    54 */
       
    55 typedef CArrayFixFlat<TInt> CIntArray;
       
    56 
       
    57 
       
    58 // CLASS DECLARATION
       
    59 
       
    60 /**
       
    61 *  The actual "engine".
       
    62 *  This is the class which the UI instantiates.
       
    63 */
       
    64 class CMseng :public CBase
       
    65     {
       
    66     public:  // Constructors and destructor
       
    67         /**
       
    68         * Two-phased constructor.
       
    69         * @param aUIHandler Reference to a class implementing MMsengUIHandler interface
       
    70         */
       
    71         IMPORT_C static CMseng* NewL(MMsengUIHandler& aUIHandler);
       
    72         /**
       
    73         * Destructor.
       
    74         */
       
    75         IMPORT_C ~CMseng();
       
    76 
       
    77     public: // New functions
       
    78         
       
    79         /**
       
    80         * Get the data groups.
       
    81         * @return CDesCArray* containing the names of the data groups.
       
    82         */
       
    83         IMPORT_C CDesCArray* DataGroupsL() const;
       
    84 
       
    85         /**
       
    86         * Get the scan result. This array contains exacly one
       
    87         * integer per data group. 
       
    88         * @return Array of integers. 
       
    89         */
       
    90         IMPORT_C CArrayFix<TInt64>* ScanResultL() const;
       
    91 
       
    92         /**
       
    93         * Is there scanning going on?
       
    94         * @return ETrue if there is scanning going on, otherwise EFalse.
       
    95         */
       
    96         IMPORT_C TBool ScanInProgress() const;
       
    97 
       
    98         /**
       
    99         * Get the amount of total and free space on a disk
       
   100         * @param aTotal Amount of total space in bytes in substituted here.
       
   101         * @param aFree Amount of free space in bytes in substituted here.
       
   102         * @param aVolume Disk identifier, e.g. 'C'
       
   103         */
       
   104         IMPORT_C void DiskInfoL(TInt64& aTotal, TInt64& aFree, const TDriveNumber aVolume) const;
       
   105 
       
   106         /**
       
   107         * Get the amount of total and free RAM.
       
   108         * @param aTotal Amount of total RAM in bytes in substituted here.
       
   109         * @param aTotal Amount of free RAM in bytes in substituted here.
       
   110         */
       
   111         IMPORT_C static void MemInfoL(TInt64& aTotal, TInt64& aFree);
       
   112 
       
   113         /**
       
   114         * Start scanning memory. 
       
   115         * This means starting the actual work of the engine. Starts scanning,
       
   116         * which runs until finished.
       
   117         *
       
   118         * The scanning is only supported for drives C and E, otherwise
       
   119         * leave occurs with error KErrNotSupported.
       
   120         *        
       
   121         * NOTE: the support for scanning E drive is not properly tested.
       
   122         *       It is assumed to have the same directory structure than in C.
       
   123         *
       
   124         * @param aDrive the drive to be scanned
       
   125         */
       
   126         IMPORT_C void ScanL(TDriveNumber aDrive);
       
   127 
       
   128         /**
       
   129         * Cancel ongoing scanning operation.
       
   130         */
       
   131         IMPORT_C void Cancel();
       
   132         
       
   133         /**
       
   134         * Check whether internal drive.
       
   135         * @param aDrv Drive to be chanked.
       
   136         * @return ETrue if internal drive, otherwise EFalse.
       
   137         */
       
   138         static TBool IsInternalDrive( RFs& aFs, const TInt aDrv );
       
   139 
       
   140         /**
       
   141         * Check whether removable drive.
       
   142         * @param aDrv Drive to be chanked.
       
   143         * @return ETrue if internal drive, otherwise EFalse.
       
   144         */
       
   145         static TBool IsRemovableDrive( RFs& aFs, const TInt aDrv );
       
   146 
       
   147     private:
       
   148 
       
   149         /**
       
   150         * C++ default constructor is prohibited.
       
   151         */
       
   152         CMseng(MMsengUIHandler& aUIHandler);
       
   153 
       
   154         /**
       
   155         * By default Symbian OS constructor is private.
       
   156         *
       
   157         * Initialize iResultArray by reading the the data group 
       
   158         *  names from resource file and setting all result values to zero.
       
   159         * Initialize iDataGroupUidArray and iDataGroupExtArray
       
   160         *  from resource file.
       
   161         */
       
   162         void ConstructL();
       
   163         
       
   164 
       
   165         // Prohibit copy constructor if not deriving from CBase.
       
   166         CMseng( const CMseng& );
       
   167         // Prohibit assigment operator if not deriving from CBase.
       
   168         CMseng& operator= ( const CMseng& );
       
   169 
       
   170 
       
   171     private:    // Data members
       
   172     
       
   173         MMsengUIHandler& iUIHandler;
       
   174         CMsengScanner* iScanner;
       
   175 
       
   176         // Number of data groups
       
   177         TInt iNumberOfDataGroups;
       
   178 
       
   179         // These arrays are needed to when calculating the result.
       
   180         // They are indexed using values from enum TDataGroups.
       
   181         // This creates the mapping between data groups and the
       
   182         // UIDs and extensions belonging to a particular data group
       
   183         CArrayPtrFlat<CIntArray>* iDataGroupUidArray;
       
   184         CArrayPtrFlat<CIntArray>* iDataGroupExtArray;        
       
   185         
       
   186         RFs iFsSession;
       
   187         CResourceFile* iResFile;
       
   188         mutable TInt64 iFreeMemory;        
       
   189         
       
   190     };
       
   191 
       
   192 #endif      // CMSENG_H   
       
   193             
       
   194 // End of File