kerneltest/e32test/usbho/t_usbdi/src/SoftwareConnectTimer.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file softwareconnecttimer.cpp
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "softwareconnecttimer.h"
       
    20 
       
    21 namespace NUnitTesting_USBDI
       
    22 	{
       
    23 	
       
    24 const TInt KOneSecond(1000000);
       
    25 	
       
    26 CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
       
    27 	{
       
    28 	CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 	
       
    35 	
       
    36 CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
       
    37 :	CTimer(EPriorityStandard),
       
    38 	iTestDevice(aTestDevice),
       
    39 	iConnectType(EUnknown)
       
    40 	{
       
    41 	CActiveScheduler::Add(this);
       
    42 	}
       
    43 	
       
    44 	
       
    45 CSoftwareConnectTimer::~CSoftwareConnectTimer()
       
    46 	{
       
    47 	LOG_FUNC
       
    48 	}
       
    49 	
       
    50 	
       
    51 void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
       
    52 	{
       
    53 	LOG_FUNC
       
    54 	iConnectType = EConnect;
       
    55 	After(aInterval*KOneSecond);
       
    56 	}
       
    57 	
       
    58 
       
    59 void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
       
    60 	{
       
    61 	LOG_FUNC
       
    62 	iConnectType = EDisconnect;
       
    63 	After(aInterval*KOneSecond);
       
    64 	}
       
    65 	
       
    66 	
       
    67 void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
       
    68 	{
       
    69 	LOG_FUNC
       
    70 	iTestDevice.SoftwareDisconnect();
       
    71 	SoftwareConnect(aInterval);
       
    72 	}
       
    73 
       
    74 
       
    75 void CSoftwareConnectTimer::RunL()
       
    76 	{
       
    77 	LOG_FUNC
       
    78 	TInt completionCode(iStatus.Int());
       
    79 	
       
    80 	if(completionCode != KErrNone)
       
    81 		{
       
    82 		RDebug::Printf("<Error %d> software connect/disconnect timer error",completionCode);
       
    83 		iTestDevice.ReportError(completionCode);
       
    84 		}
       
    85 	else
       
    86 		{
       
    87 		switch(iConnectType)
       
    88 			{
       
    89 			case EConnect:
       
    90 				iTestDevice.SoftwareConnect();
       
    91 				break;
       
    92 				
       
    93 			case EDisconnect:
       
    94 				iTestDevice.SoftwareDisconnect();
       
    95 				break;
       
    96 				
       
    97 			case EUnknown:
       
    98 				RDebug::Printf("<Error> Unknown state for software connect timer");
       
    99 				break;
       
   100 			
       
   101 			default:
       
   102 				break;
       
   103 			}			
       
   104 		}	
       
   105 	}
       
   106 
       
   107 
       
   108 	}
       
   109