author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// @file softwareconnecttimer.cpp |
sl@0 | 15 |
// @internalComponent |
sl@0 | 16 |
// |
sl@0 | 17 |
// |
sl@0 | 18 |
|
sl@0 | 19 |
#include "softwareconnecttimer.h" |
sl@0 | 20 |
|
sl@0 | 21 |
namespace NUnitTesting_USBDI |
sl@0 | 22 |
{ |
sl@0 | 23 |
|
sl@0 | 24 |
const TInt KOneSecond(1000000); |
sl@0 | 25 |
|
sl@0 | 26 |
CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice) |
sl@0 | 27 |
{ |
sl@0 | 28 |
CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice); |
sl@0 | 29 |
CleanupStack::PushL(self); |
sl@0 | 30 |
self->ConstructL(); |
sl@0 | 31 |
CleanupStack::Pop(self); |
sl@0 | 32 |
return self; |
sl@0 | 33 |
} |
sl@0 | 34 |
|
sl@0 | 35 |
|
sl@0 | 36 |
CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice) |
sl@0 | 37 |
: CTimer(EPriorityStandard), |
sl@0 | 38 |
iTestDevice(aTestDevice), |
sl@0 | 39 |
iConnectType(EUnknown) |
sl@0 | 40 |
{ |
sl@0 | 41 |
CActiveScheduler::Add(this); |
sl@0 | 42 |
} |
sl@0 | 43 |
|
sl@0 | 44 |
|
sl@0 | 45 |
CSoftwareConnectTimer::~CSoftwareConnectTimer() |
sl@0 | 46 |
{ |
sl@0 | 47 |
LOG_FUNC |
sl@0 | 48 |
} |
sl@0 | 49 |
|
sl@0 | 50 |
|
sl@0 | 51 |
void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval) |
sl@0 | 52 |
{ |
sl@0 | 53 |
LOG_FUNC |
sl@0 | 54 |
iConnectType = EConnect; |
sl@0 | 55 |
After(aInterval*KOneSecond); |
sl@0 | 56 |
} |
sl@0 | 57 |
|
sl@0 | 58 |
|
sl@0 | 59 |
void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval) |
sl@0 | 60 |
{ |
sl@0 | 61 |
LOG_FUNC |
sl@0 | 62 |
iConnectType = EDisconnect; |
sl@0 | 63 |
After(aInterval*KOneSecond); |
sl@0 | 64 |
} |
sl@0 | 65 |
|
sl@0 | 66 |
|
sl@0 | 67 |
void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval) |
sl@0 | 68 |
{ |
sl@0 | 69 |
LOG_FUNC |
sl@0 | 70 |
iTestDevice.SoftwareDisconnect(); |
sl@0 | 71 |
SoftwareConnect(aInterval); |
sl@0 | 72 |
} |
sl@0 | 73 |
|
sl@0 | 74 |
|
sl@0 | 75 |
void CSoftwareConnectTimer::RunL() |
sl@0 | 76 |
{ |
sl@0 | 77 |
LOG_FUNC |
sl@0 | 78 |
TInt completionCode(iStatus.Int()); |
sl@0 | 79 |
|
sl@0 | 80 |
if(completionCode != KErrNone) |
sl@0 | 81 |
{ |
sl@0 | 82 |
RDebug::Printf("<Error %d> software connect/disconnect timer error",completionCode); |
sl@0 | 83 |
iTestDevice.ReportError(completionCode); |
sl@0 | 84 |
} |
sl@0 | 85 |
else |
sl@0 | 86 |
{ |
sl@0 | 87 |
switch(iConnectType) |
sl@0 | 88 |
{ |
sl@0 | 89 |
case EConnect: |
sl@0 | 90 |
iTestDevice.SoftwareConnect(); |
sl@0 | 91 |
break; |
sl@0 | 92 |
|
sl@0 | 93 |
case EDisconnect: |
sl@0 | 94 |
iTestDevice.SoftwareDisconnect(); |
sl@0 | 95 |
break; |
sl@0 | 96 |
|
sl@0 | 97 |
case EUnknown: |
sl@0 | 98 |
RDebug::Printf("<Error> Unknown state for software connect timer"); |
sl@0 | 99 |
break; |
sl@0 | 100 |
|
sl@0 | 101 |
default: |
sl@0 | 102 |
break; |
sl@0 | 103 |
} |
sl@0 | 104 |
} |
sl@0 | 105 |
} |
sl@0 | 106 |
|
sl@0 | 107 |
|
sl@0 | 108 |
} |
sl@0 | 109 |