voicerecorder/UtilsInc/VRUSBStateHanlder.h
branchRCL_3
changeset 20 072a5fa0c63b
parent 19 2f5c9ee7098c
child 21 c6bafb5162d8
equal deleted inserted replaced
19:2f5c9ee7098c 20:072a5fa0c63b
     1 /*
       
     2 * Copyright (c) 2002-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 *     CVRUSBStateHanlder declaration
       
    16 *     
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef VRUSBSTATEHANLDER_H
       
    22 #define VRUSBSTATEHANLDER_H
       
    23 
       
    24 #include <e32base.h>	// For CActive, link against: euser.lib
       
    25 #include <e32std.h>		// For RTimer, link against: euser.lib
       
    26 #include <e32property.h> 
       
    27 
       
    28 //#include "DummyUSBState.h" // for dummy testing
       
    29 
       
    30 class MVRUSBStateObserver
       
    31     {
       
    32 public:
       
    33     // Constructors and destructor
       
    34 
       
    35     virtual TInt HandleUsbPlugInL() = 0;
       
    36     virtual TInt HandleUsbPlugOutL() = 0;
       
    37 
       
    38     };
       
    39 
       
    40 class CVRUSBStateHanlder : public CActive
       
    41     {
       
    42 public:
       
    43     // Cancel and destroy
       
    44     ~CVRUSBStateHanlder();
       
    45 
       
    46     IMPORT_C static CVRUSBStateHanlder* NewL(MVRUSBStateObserver* aObserver);
       
    47 
       
    48 public:
       
    49 
       
    50     IMPORT_C static TBool IsUsbActive();
       
    51 
       
    52 private:
       
    53     // C++ constructor
       
    54     CVRUSBStateHanlder(MVRUSBStateObserver* aObserver);
       
    55 
       
    56     // Second-phase constructor
       
    57     void ConstructL();
       
    58 
       
    59 private:
       
    60     // From CActive
       
    61     // Handle completion
       
    62     void RunL();
       
    63 
       
    64     // How to cancel me
       
    65     void DoCancel();
       
    66 
       
    67     // Override to handle leaves from RunL(). Default implementation causes
       
    68     // the active scheduler to panic.
       
    69     TInt RunError(TInt aError);
       
    70 
       
    71     void StartL();
       
    72 
       
    73 private:
       
    74 #ifdef DUMMY_USB_TESTING
       
    75     RTimer iTimer; // Provides async timing service, for dummy testing
       
    76     TInt isUSBActive;
       
    77 #else
       
    78     RProperty iProperty;
       
    79 #endif
       
    80     MVRUSBStateObserver* iObserver;    
       
    81     enum TUSBConnectionStatus 
       
    82         { 
       
    83         EStateUninitialized, 
       
    84         EStateConnected, 
       
    85         EStateDisConnected
       
    86         }; 
       
    87     TUSBConnectionStatus iConnectionStatus;
       
    88     };
       
    89 
       
    90 #endif // VRUSBSTATEHANLDER_H