devicediagnostics/devdiagapp/inc/devdiagruntimereqsinfo.h
changeset 0 3ce708148e4d
child 54 9360ca28b668
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2007 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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DEVDIAGRUNTIMEREQSINFO_H
       
    20 #define DEVDIAGRUNTIMEREQSINFO_H
       
    21 
       
    22 // System Include Files
       
    23 #include <e32base.h>                // CActive
       
    24 #include <e32def.h>                 // TInt, TUint, TInt64
       
    25 #include <e32std.h>                 // TTime, TCallBack
       
    26 #include <etel.h>                   // RTelServer
       
    27 #include <etel3rdparty.h>           // CTelephony Packages
       
    28 #include <etelmm.h>                 // RMobilePhone
       
    29 
       
    30 // Forward Declarations
       
    31 class RFs;
       
    32 class RDiagResultsDatabase;
       
    33 
       
    34 /**
       
    35  *  Phone Doctor Application Runtime Requirements Information
       
    36  *  This class checks the current status of diagnostics requirements,
       
    37  *  which must be satisfied before the Phone Doctor Application may run tests.
       
    38  *
       
    39  *  @lib euser.lib
       
    40  *  @lib centralrepository.lib
       
    41  */
       
    42 class CDevDiagRuntimeReqsInfo : public CActive
       
    43     {
       
    44 
       
    45 public: // Data Types
       
    46 
       
    47     /**
       
    48      * Error codes indicating the results of the runtime requirements checks.
       
    49      */
       
    50      enum TResult
       
    51         {
       
    52         EResultOk = 0,       
       
    53         EResultErrLowDisk,
       
    54         EResultErrLowBattery,        
       
    55         };
       
    56 
       
    57 
       
    58 public: // New Functions
       
    59 
       
    60     /**
       
    61      * Two-phased constructor.
       
    62      *
       
    63      * @param aFs A reference to a connected file system object.
       
    64      * @param aDb A reference to a connection results database session.
       
    65      * @param aCallback A general callback that indicates when checking the
       
    66      *                  runtime requirements has finished.
       
    67      * @return A pointer to a new instance of CDevDiagRuntimeReqsInfo.
       
    68      */
       
    69     static CDevDiagRuntimeReqsInfo* NewL( RFs& aFs,
       
    70                                      RDiagResultsDatabase& aDb,
       
    71                                      TCallBack aCallback );
       
    72 
       
    73     /**
       
    74     * Destructor.
       
    75     */
       
    76     virtual ~CDevDiagRuntimeReqsInfo();
       
    77 
       
    78     /**
       
    79      * Checks if the diagnostics runtime requirements are satisfied.  This
       
    80      * is an asynchronous request which will complete with a callback.
       
    81      *
       
    82      * @param aResumingTests If ETrue, then runtime checks which do not apply
       
    83      *                       to resumed test execution will be skipped.
       
    84      */
       
    85     void CheckRuntimeRequirementsL( TBool aResumingTests );
       
    86 
       
    87     /**
       
    88      * Returns the runtime requirements result, which indicates if the runtime
       
    89      * requirements were satisfied.
       
    90      *
       
    91      * @return The runtime requirements result.
       
    92      */
       
    93     TResult Result() const;
       
    94 
       
    95     /**
       
    96      * Displays the dialog associated with the result of the runtime checks.
       
    97      *
       
    98      * @return The command the dialog is dismissed with.
       
    99      */
       
   100     TInt DisplayDialogL() const;
       
   101 
       
   102 
       
   103 private: // Data Types
       
   104 
       
   105     /**
       
   106      * The state of the runtime requirements.  This is used to handle
       
   107      * completion of the asynchronous requests.
       
   108      */
       
   109     enum TState
       
   110         {
       
   111         EStateInitial = 0,
       
   112         EStateCheckingBattery,   
       
   113         EStateComplete
       
   114         };
       
   115 
       
   116 
       
   117 private: // New Functions
       
   118 
       
   119     /**
       
   120      * C++ constructor.
       
   121      *
       
   122      * @param aFs A reference to a connected file system object.
       
   123      * @param aDb A reference to a connection results database session.
       
   124      * @param aCallback A general callback that indicates when checking the
       
   125      *                  runtime requirements has finished.
       
   126      */
       
   127     CDevDiagRuntimeReqsInfo( RFs& aFs,
       
   128                         RDiagResultsDatabase& aDb,
       
   129                         TCallBack aCallback );
       
   130 
       
   131     /**
       
   132      * Two-phased constructor.
       
   133      */
       
   134     void ConstructL();
       
   135 
       
   136     /**
       
   137      * Reads the runtime requirements values from the central repository and
       
   138      * stores them to the object.
       
   139      */
       
   140     void ReadCentralRepositoryValuesL();
       
   141 
       
   142    
       
   143     /**
       
   144      * Checks if there is enough free estimated disk space to log test
       
   145      * results.  Updates the member data with the disk space information.
       
   146      */
       
   147     void CheckDiskSpaceL();
       
   148 
       
   149     /**
       
   150      * Checks if the phone's battery level is adequate to run tests.  Updates
       
   151      * the member data with the battery level information.
       
   152      */
       
   153     void CheckBatteryLevelL();
       
   154     
       
   155     /**
       
   156      * This is a utility function to handle the common checking for completion
       
   157      * of the runtime requirements checks.  If a runtime check failed, this
       
   158      * will set the object active so that the runtime checking completes.
       
   159      *
       
   160      * @return ETrue if checking is done, EFalse if checking should continue.
       
   161      */
       
   162     TBool CheckCompletion();
       
   163 
       
   164     /**
       
   165      * Utility function to display a message dialog associated with the
       
   166      * specified resource.
       
   167      *
       
   168      * @param aResource The resource of the message query dialog to display.
       
   169      * @return The button pressed to dismiss the dialog.
       
   170      */
       
   171     static TInt DisplayMessageQueryDialogL( TInt aResource );
       
   172 
       
   173     
       
   174 private: // From base class CActive
       
   175 
       
   176     /**
       
   177      * From CActive.
       
   178      * This function is called when an active request completes.
       
   179      */
       
   180     virtual void RunL();
       
   181 
       
   182     /**
       
   183      * From CActive.
       
   184      * This function is called to cancel any outstanding asynchronous
       
   185      * requests.
       
   186      */
       
   187     virtual void DoCancel();
       
   188 
       
   189 
       
   190 private: // Data
       
   191 
       
   192     /**
       
   193      * A reference to a connected file server session, used to check the disk
       
   194      * space.
       
   195      */
       
   196     RFs& iFs;
       
   197 
       
   198     /**
       
   199      * A reference to a connected results database session, used to get
       
   200      * information about the maximum executions.
       
   201      */
       
   202     RDiagResultsDatabase& iDb;
       
   203 
       
   204     /**
       
   205      * A general callback that indicates when checking the runtime
       
   206      * requirements has finished.
       
   207      */
       
   208     TCallBack iCallback;
       
   209     
       
   210      /**
       
   211      * A telephony object used to check some of the runtime requirements
       
   212      * checks.
       
   213      * Own.
       
   214      */
       
   215     CTelephony* iTelephony;
       
   216 
       
   217     /**
       
   218      * A battery info object used to satisfy the runtime requirement check for
       
   219      * minimum battery level.
       
   220      */
       
   221     CTelephony::TBatteryInfoV1 iBatteryInfo;
       
   222 
       
   223     /**
       
   224      * A package object for the battery information.
       
   225      */
       
   226     CTelephony::TBatteryInfoV1Pckg iBatteryInfoPackage;
       
   227 
       
   228     /**
       
   229      * Indicates if the runtime requirements are being checked for resumed
       
   230      * test execution.  If ETrue, then runtime checks which do not apply to
       
   231      * resumed test execution will be skipped.
       
   232      */
       
   233     TBool iResumingTests;
       
   234 
       
   235     /**
       
   236      * The runtime requirements status, which will contain error code values
       
   237      * to indicate if the runtime requirements are satisfied.
       
   238      */
       
   239     TResult iResult;
       
   240 
       
   241     /**
       
   242      * The state, which is used when handling asynchronous requests.
       
   243      */
       
   244     TState iState;
       
   245 
       
   246     /**
       
   247      * The current battery level.
       
   248      */
       
   249     TInt iBatteryLevel;
       
   250 
       
   251     /**
       
   252      * The minimum required battery level.
       
   253      */
       
   254     TInt iMinBatteryLevel;
       
   255 
       
   256     /**
       
   257      * The current amount of free disk space (in bytes).
       
   258      */
       
   259     TInt64 iDiskSpaceFree;
       
   260 
       
   261     /**
       
   262      * The minimum required free disk space (in bytes).
       
   263      */
       
   264     TInt64 iMinDiskSpaceFree;
       
   265 
       
   266     
       
   267     };
       
   268 
       
   269 #endif // DEVDIAGRUNTIMEREQSINFO_H