voicerecorder/UtilsInc/VRUSBStateHanlder.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 09:44:44 +0300
branchRCL_3
changeset 15 487b46c8e1a4
parent 13 4e5b531d23cb
child 17 41c99112ff9d
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

/*
 ============================================================================
 Name		: VRUSBStateHanlder.h
 Author	  : Junhua Xu
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CVRUSBStateHanlder declaration
 ============================================================================
 */

#ifndef VRUSBSTATEHANLDER_H
#define VRUSBSTATEHANLDER_H

#include <e32base.h>	// For CActive, link against: euser.lib
#include <e32std.h>		// For RTimer, link against: euser.lib
#include <e32property.h> 

//#include "DummyUSBState.h" // for dummy testing

class MVRUSBStateObserver
    {
public:
    // Constructors and destructor

    virtual TInt HandleUsbPlugInL() = 0;
    virtual TInt HandleUsbPlugOutL() = 0;

    };

class CVRUSBStateHanlder : public CActive
    {
public:
    // Cancel and destroy
    ~CVRUSBStateHanlder();

    IMPORT_C static CVRUSBStateHanlder* NewL(MVRUSBStateObserver* aObserver);

public:

    IMPORT_C static TBool IsUsbActive();

private:
    // C++ constructor
    CVRUSBStateHanlder(MVRUSBStateObserver* aObserver);

    // Second-phase constructor
    void ConstructL();

private:
    // From CActive
    // Handle completion
    void RunL();

    // How to cancel me
    void DoCancel();

    // Override to handle leaves from RunL(). Default implementation causes
    // the active scheduler to panic.
    TInt RunError(TInt aError);

    void StartL();

private:
#ifdef DUMMY_USB_TESTING
    RTimer iTimer; // Provides async timing service, for dummy testing
    TInt isUSBActive;
#else
    RProperty iProperty;
#endif
    MVRUSBStateObserver* iObserver;    
    enum TUSBConnectionStatus 
        { 
        EStateUninitialized, 
        EStateConnected, 
        EStateDisConnected
        }; 
    TUSBConnectionStatus iConnectionStatus;
    };

#endif // VRUSBSTATEHANLDER_H