usbmgmt/usbmgrtest/t_ncm/inc/devicewatcher.h
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     1 /*
       
     2 * Copyright (c) 2002-2009 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 /** @file
       
    19  @internalComponent
       
    20  @test
       
    21  */
       
    22 
       
    23 #ifndef DEVICEWATCHER_H
       
    24 #define DEVICEWATCHER_H
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <d32usbc.h>
       
    28 
       
    29 class CUsbNcmConsole;
       
    30 
       
    31 //The mode of CDeviceWatcher
       
    32 enum TDeviceWatchMode
       
    33 	{
       
    34 	EWatchMode,				//Only monitor the device state
       
    35 	EWatchAndStartMode		//monitor the device state and start/stop NCM and NCM control app 
       
    36 							//when usb cable plugin/unplug
       
    37 	};
       
    38 
       
    39 NONSHARABLE_CLASS(CDeviceWatcher) : public CActive
       
    40 /**
       
    41 Monitor the USB device state.
       
    42 */
       
    43 	{	
       
    44 public:
       
    45 	
       
    46 	static CDeviceWatcher* NewL(CUsbNcmConsole& aUsb);
       
    47 	~CDeviceWatcher();
       
    48 
       
    49 	void SetWatchMode(TDeviceWatchMode aWatchMode);
       
    50 	TDeviceWatchMode GetWatchMode() const;
       
    51 
       
    52 private:
       
    53 	CDeviceWatcher(CUsbNcmConsole& aUsb);
       
    54 	void ConstructL();
       
    55 	
       
    56 private:
       
    57 	//From CActive
       
    58 	void DoCancel();
       
    59 	void RunL();
       
    60 	TInt RunError(TInt aError);
       
    61 
       
    62 private:
       
    63 	void DisplayDeviceState(TUint aDeviceState);
       
    64 
       
    65 private:
       
    66 	//Main console
       
    67 	CUsbNcmConsole&  iTestConsole;
       
    68 	RDevUsbcClient iLdd;
       
    69 
       
    70 	//Usb device state
       
    71 	TUint		iDeviceState;
       
    72 	//Usb old device state
       
    73 	TUint		iOldDeviceState;
       
    74 	//Indicate whether start/stop behavior are used. ETrue means start/stop is needed.
       
    75 	TBool				iStartNcm;	
       
    76 	TDeviceWatchMode	iWatchMode;
       
    77 	};
       
    78 
       
    79 
       
    80 #endif //DEVICEWATCHER_H