voicerecorder/UtilsInc/VRUSBStateHanlder.h
branchRCL_3
changeset 17 4e5b531d23cb
child 19 487b46c8e1a4
equal deleted inserted replaced
15:a2fdc35b8f46 17:4e5b531d23cb
       
     1 /*
       
     2  ============================================================================
       
     3  Name		: VRUSBStateHanlder.h
       
     4  Author	  : Junhua Xu
       
     5  Version	 : 1.0
       
     6  Copyright   : Your copyright notice
       
     7  Description : CVRUSBStateHanlder declaration
       
     8  ============================================================================
       
     9  */
       
    10 
       
    11 #ifndef VRUSBSTATEHANLDER_H
       
    12 #define VRUSBSTATEHANLDER_H
       
    13 
       
    14 #include <e32base.h>	// For CActive, link against: euser.lib
       
    15 #include <e32std.h>		// For RTimer, link against: euser.lib
       
    16 #include <e32property.h> 
       
    17 
       
    18 //#include "DummyUSBState.h" // for dummy testing
       
    19 
       
    20 class MVRUSBStateObserver
       
    21     {
       
    22 public:
       
    23     // Constructors and destructor
       
    24 
       
    25     virtual TInt HandleUsbPlugInL() = 0;
       
    26     virtual TInt HandleUsbPlugOutL() = 0;
       
    27 
       
    28     };
       
    29 
       
    30 class CVRUSBStateHanlder : public CActive
       
    31     {
       
    32 public:
       
    33     // Cancel and destroy
       
    34     ~CVRUSBStateHanlder();
       
    35 
       
    36     IMPORT_C static CVRUSBStateHanlder* NewL(MVRUSBStateObserver* aObserver);
       
    37 
       
    38 public:
       
    39 
       
    40     IMPORT_C static TBool IsUsbActive();
       
    41 
       
    42 private:
       
    43     // C++ constructor
       
    44     CVRUSBStateHanlder(MVRUSBStateObserver* aObserver);
       
    45 
       
    46     // Second-phase constructor
       
    47     void ConstructL();
       
    48 
       
    49 private:
       
    50     // From CActive
       
    51     // Handle completion
       
    52     void RunL();
       
    53 
       
    54     // How to cancel me
       
    55     void DoCancel();
       
    56 
       
    57     // Override to handle leaves from RunL(). Default implementation causes
       
    58     // the active scheduler to panic.
       
    59     TInt RunError(TInt aError);
       
    60 
       
    61     void StartL();
       
    62 
       
    63 private:
       
    64 #ifdef DUMMY_USB_TESTING
       
    65     RTimer iTimer; // Provides async timing service, for dummy testing
       
    66     TInt isUSBActive;
       
    67 #else
       
    68     RProperty iProperty;
       
    69 #endif
       
    70     MVRUSBStateObserver* iObserver;    
       
    71     };
       
    72 
       
    73 #endif // VRUSBSTATEHANLDER_H