contentpublishingsrv/contentharvester/contentharvesterswiplugin/inc/chswiusbhandler.h
changeset 3 ff572005ac23
equal deleted inserted replaced
2:b7904b40483f 3:ff572005ac23
       
     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 #ifndef C_CCHSWIUSBHANDLER_H
       
    19 #define C_CCHSWIUSBHANDLER_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // FORWARD DECLARATION
       
    30 class MCHSwiMassModeObserver;
       
    31 
       
    32 
       
    33 /*
       
    34  * Inherited CActive, performs a asynchronous checks for mass storage mode
       
    35  *
       
    36  * @since 3.1
       
    37  */
       
    38 class CCHSwiUsbHandler : public CActive
       
    39     {
       
    40 public:
       
    41 	/**
       
    42 	 * Two-phased constructor.
       
    43      * @param aPlugin Owning plugin.
       
    44      * @param aFs File session. 
       
    45 	 */
       
    46     static CCHSwiUsbHandler* NewL( MCHSwiMassModeObserver* aMassModeObserver,
       
    47     		RFs& aFs );
       
    48 
       
    49 	/**
       
    50 	 * Destructor.
       
    51 	 */
       
    52     virtual ~CCHSwiUsbHandler();
       
    53 
       
    54     /**
       
    55      * Performs synchronous drive scan. Checks whether Mass Drive is available.
       
    56      * If it available: observer's Mass Mode flag is set to EFalse.
       
    57      * If it is not available: Mass Mode flag is set to ETrue.
       
    58      * In case of error, the check is postponed to be done again in RunL and Mass 
       
    59      * Mode flag is set to ETrue.
       
    60      */
       
    61     void SynchronousDriveScan();
       
    62 
       
    63     /**
       
    64      * Performs postponed drive scan. Checks whether Mass Drive is available.
       
    65      * If it available: observer's Mass Mode flag is set to EFalse.
       
    66      * If it is not available: Mass Mode flag is set to ETrue.
       
    67      * In case of error, the check is postponed to be done again in RunL and Mass 
       
    68      * Mode flag is set to ETrue.
       
    69      */
       
    70     void PostponedDriveScan();
       
    71     
       
    72 protected:
       
    73 
       
    74 	/**
       
    75 	 * Handles timer events to start drive scan.
       
    76 	 */
       
    77     void RunL();
       
    78 
       
    79     /**
       
    80      * RunL error handling.
       
    81      * @param aError Error.
       
    82      */
       
    83     TInt RunError( TInt aError );
       
    84 
       
    85     /**
       
    86      * Cancels notifications.
       
    87      */
       
    88     void DoCancel();
       
    89 
       
    90 private:
       
    91 
       
    92     /**
       
    93      * no copy constructor
       
    94      */
       
    95     CCHSwiUsbHandler( const CCHSwiUsbHandler& );
       
    96     
       
    97     /**
       
    98      * no assignment
       
    99      */    
       
   100     CCHSwiUsbHandler& operator=( const CCHSwiUsbHandler& );
       
   101 
       
   102     /**
       
   103      * C++ default constructor
       
   104      */
       
   105     CCHSwiUsbHandler( MCHSwiMassModeObserver* aMassModeObserver, RFs& aFs );
       
   106 
       
   107     /**
       
   108      * Symbian default constructor.
       
   109      */
       
   110     void ConstructL();
       
   111 
       
   112     /**
       
   113      * Scans drives to check mass storage mode.
       
   114      */
       
   115     TInt ScanDrives( TInt& aDriveFlags );
       
   116 
       
   117     /**
       
   118      * Handles drive access errors by launching new postponed scan.
       
   119      */
       
   120     void HandleDriveError();
       
   121     
       
   122     /**
       
   123      * Scans drives and updates Mass Mode flag in the observer. 
       
   124      * @param aFlagsValid indicates whether current iDriveFlags are valid 
       
   125      * (they become invalid in case of an error).
       
   126      */
       
   127     TInt ScanDrivesAndUpdateFlag( TBool aFlagsValid );
       
   128     
       
   129     /**
       
   130      * Updates mass mode flag in observer.
       
   131      */
       
   132     TInt UpdateMassModeFlag();
       
   133 
       
   134 private:
       
   135 	/**
       
   136 	 * Error from last drive scan.
       
   137 	 */
       
   138 	TInt iLastDriveScanError;
       
   139 	
       
   140 	/**
       
   141 	 * Observer.
       
   142 	 */
       
   143 	MCHSwiMassModeObserver* iMassModeObserver;
       
   144 	
       
   145 	/**
       
   146 	 * File session. Not owned.
       
   147 	 */
       
   148     RFs iFs;
       
   149     
       
   150     /**
       
   151      * Drive flags obtained in last drive scan. Every bit indicates presence 
       
   152      * of given drive. This member is used for drive access optimalization -
       
   153      * if flags are valid (i.e. no error occured)
       
   154      */
       
   155     TInt iDriveFlags;
       
   156     
       
   157     /**
       
   158      * Timer for postponed drive scan.
       
   159      */
       
   160     RTimer iTimer;
       
   161     };
       
   162 
       
   163 #endif // #ifndef C_CCHSWIUSBHANDLER_H