applayerprotocols/httptransportfw/Test/t_utils/t_detectkey.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:43:01 +0300
branchRCL_3
changeset 11 8f055b80aa5b
parent 0 b16258d2340f
permissions -rw-r--r--
Revision: 201017 Kit: 201019

// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

#include "t_detectkey.h"
#include <e32cons.h>

CDetectKeyPress* CDetectKeyPress::NewLC(CConsoleBase& aConsole, MTestInteractionObserver& aObserver)
	{
	CDetectKeyPress* self = new (ELeave) CDetectKeyPress(aConsole,aObserver);
	CleanupStack::PushL(self);
	self->RequestKey();
	return self;
	}


CDetectKeyPress::CDetectKeyPress(CConsoleBase& aConsole, MTestInteractionObserver& aObserver):
	CActive(CActive::EPriorityUserInput), iConsole(aConsole), iObserver(aObserver)
	{
	CActiveScheduler::Add(this);
	}


CDetectKeyPress::~CDetectKeyPress()
	{
	Cancel();
	}

void CDetectKeyPress::DoCancel()
	{
	iConsole.ReadCancel();
	}

void  CDetectKeyPress::RunL()
	{
	TChar key = iConsole.KeyCode();
	TUint modifiers = iConsole.KeyModifiers();

	if (modifiers & EModifierCtrl)
		{
		key += 64;
		if (key == 'n' || key == 'N')
			iObserver.TestInteractionDetectedL(MTestInteractionObserver::EStopCurrentTest);
		}

	
	iConsole.Read(iStatus);
	SetActive();
	}

void CDetectKeyPress::RequestKey()
	{
	iConsole.Read(iStatus);
	SetActive();
	}