applayerprotocols/httptransportfw/Test/t_utils/t_detectkey.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2001-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 "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 //
       
    15 
       
    16 #include "t_detectkey.h"
       
    17 #include <e32cons.h>
       
    18 
       
    19 CDetectKeyPress* CDetectKeyPress::NewLC(CConsoleBase& aConsole, MTestInteractionObserver& aObserver)
       
    20 	{
       
    21 	CDetectKeyPress* self = new (ELeave) CDetectKeyPress(aConsole,aObserver);
       
    22 	CleanupStack::PushL(self);
       
    23 	self->RequestKey();
       
    24 	return self;
       
    25 	}
       
    26 
       
    27 
       
    28 CDetectKeyPress::CDetectKeyPress(CConsoleBase& aConsole, MTestInteractionObserver& aObserver):
       
    29 	CActive(CActive::EPriorityUserInput), iConsole(aConsole), iObserver(aObserver)
       
    30 	{
       
    31 	CActiveScheduler::Add(this);
       
    32 	}
       
    33 
       
    34 
       
    35 CDetectKeyPress::~CDetectKeyPress()
       
    36 	{
       
    37 	Cancel();
       
    38 	}
       
    39 
       
    40 void CDetectKeyPress::DoCancel()
       
    41 	{
       
    42 	iConsole.ReadCancel();
       
    43 	}
       
    44 
       
    45 void  CDetectKeyPress::RunL()
       
    46 	{
       
    47 	TChar key = iConsole.KeyCode();
       
    48 	TUint modifiers = iConsole.KeyModifiers();
       
    49 
       
    50 	if (modifiers & EModifierCtrl)
       
    51 		{
       
    52 		key += 64;
       
    53 		if (key == 'n' || key == 'N')
       
    54 			iObserver.TestInteractionDetectedL(MTestInteractionObserver::EStopCurrentTest);
       
    55 		}
       
    56 
       
    57 	
       
    58 	iConsole.Read(iStatus);
       
    59 	SetActive();
       
    60 	}
       
    61 
       
    62 void CDetectKeyPress::RequestKey()
       
    63 	{
       
    64 	iConsole.Read(iStatus);
       
    65 	SetActive();
       
    66 	} 
       
    67