os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/SoftwareConnectTimer.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/SoftwareConnectTimer.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,109 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// @file softwareconnecttimer.cpp
    1.18 +// @internalComponent
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "softwareconnecttimer.h"
    1.23 +
    1.24 +namespace NUnitTesting_USBDI
    1.25 +	{
    1.26 +	
    1.27 +const TInt KOneSecond(1000000);
    1.28 +	
    1.29 +CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
    1.30 +	{
    1.31 +	CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
    1.32 +	CleanupStack::PushL(self);
    1.33 +	self->ConstructL();
    1.34 +	CleanupStack::Pop(self);
    1.35 +	return self;
    1.36 +	}
    1.37 +	
    1.38 +	
    1.39 +CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
    1.40 +:	CTimer(EPriorityStandard),
    1.41 +	iTestDevice(aTestDevice),
    1.42 +	iConnectType(EUnknown)
    1.43 +	{
    1.44 +	CActiveScheduler::Add(this);
    1.45 +	}
    1.46 +	
    1.47 +	
    1.48 +CSoftwareConnectTimer::~CSoftwareConnectTimer()
    1.49 +	{
    1.50 +	LOG_FUNC
    1.51 +	}
    1.52 +	
    1.53 +	
    1.54 +void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
    1.55 +	{
    1.56 +	LOG_FUNC
    1.57 +	iConnectType = EConnect;
    1.58 +	After(aInterval*KOneSecond);
    1.59 +	}
    1.60 +	
    1.61 +
    1.62 +void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
    1.63 +	{
    1.64 +	LOG_FUNC
    1.65 +	iConnectType = EDisconnect;
    1.66 +	After(aInterval*KOneSecond);
    1.67 +	}
    1.68 +	
    1.69 +	
    1.70 +void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
    1.71 +	{
    1.72 +	LOG_FUNC
    1.73 +	iTestDevice.SoftwareDisconnect();
    1.74 +	SoftwareConnect(aInterval);
    1.75 +	}
    1.76 +
    1.77 +
    1.78 +void CSoftwareConnectTimer::RunL()
    1.79 +	{
    1.80 +	LOG_FUNC
    1.81 +	TInt completionCode(iStatus.Int());
    1.82 +	
    1.83 +	if(completionCode != KErrNone)
    1.84 +		{
    1.85 +		RDebug::Printf("<Error %d> software connect/disconnect timer error",completionCode);
    1.86 +		iTestDevice.ReportError(completionCode);
    1.87 +		}
    1.88 +	else
    1.89 +		{
    1.90 +		switch(iConnectType)
    1.91 +			{
    1.92 +			case EConnect:
    1.93 +				iTestDevice.SoftwareConnect();
    1.94 +				break;
    1.95 +				
    1.96 +			case EDisconnect:
    1.97 +				iTestDevice.SoftwareDisconnect();
    1.98 +				break;
    1.99 +				
   1.100 +			case EUnknown:
   1.101 +				RDebug::Printf("<Error> Unknown state for software connect timer");
   1.102 +				break;
   1.103 +			
   1.104 +			default:
   1.105 +				break;
   1.106 +			}			
   1.107 +		}	
   1.108 +	}
   1.109 +
   1.110 +
   1.111 +	}
   1.112 +