First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // @file softwareconnecttimer.cpp
19 #include "softwareconnecttimer.h"
21 namespace NUnitTesting_USBDI
24 const TInt KOneSecond(1000000);
26 CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
28 CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
29 CleanupStack::PushL(self);
31 CleanupStack::Pop(self);
36 CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
37 : CTimer(EPriorityStandard),
38 iTestDevice(aTestDevice),
39 iConnectType(EUnknown)
41 CActiveScheduler::Add(this);
45 CSoftwareConnectTimer::~CSoftwareConnectTimer()
51 void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
54 iConnectType = EConnect;
55 After(aInterval*KOneSecond);
59 void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
62 iConnectType = EDisconnect;
63 After(aInterval*KOneSecond);
67 void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
70 iTestDevice.SoftwareDisconnect();
71 SoftwareConnect(aInterval);
75 void CSoftwareConnectTimer::RunL()
78 TInt completionCode(iStatus.Int());
80 if(completionCode != KErrNone)
82 RDebug::Printf("<Error %d> software connect/disconnect timer error",completionCode);
83 iTestDevice.ReportError(completionCode);
90 iTestDevice.SoftwareConnect();
94 iTestDevice.SoftwareDisconnect();
98 RDebug::Printf("<Error> Unknown state for software connect timer");