os/kernelhwsrv/baseapitest/basesvs/prompt/src/t_prompt.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <e32base.h>
sl@0
    20
#include <e32cons.h>
sl@0
    21
#include <e32std.h>
sl@0
    22
sl@0
    23
/*@{*/
sl@0
    24
const TInt KDefaultInterval			= 5000000;
sl@0
    25
_LIT(KPromptPressAnyKey,			"And press any key to continue...");
sl@0
    26
_LIT(KPromptConsole,				"TEF");
sl@0
    27
_LIT(KPromptMMCMessage,				"After hitting a key to continue, eject and insert the MMC card (press F5 and release on the emulator).\n");
sl@0
    28
/*@}*/
sl@0
    29
sl@0
    30
sl@0
    31
LOCAL_C void MainL()
sl@0
    32
/**
sl@0
    33
 * Secure variant, contain the prompt console
sl@0
    34
 */
sl@0
    35
	{
sl@0
    36
	CConsoleBase 	*console = Console::NewL(KPromptConsole, 
sl@0
    37
		TSize(KConsFullScreen,KConsFullScreen));
sl@0
    38
	CleanupStack::PushL(console);
sl@0
    39
sl@0
    40
    console->Printf(KPromptMMCMessage);
sl@0
    41
	console->Printf(KPromptPressAnyKey);
sl@0
    42
sl@0
    43
	TRequestStatus	timerStatus;
sl@0
    44
	RTimer			timer;
sl@0
    45
	CleanupClosePushL(timer);
sl@0
    46
	timer.CreateLocal();
sl@0
    47
	timer.After(timerStatus, TTimeIntervalMicroSeconds32(KDefaultInterval));
sl@0
    48
sl@0
    49
	TRequestStatus	readStatus;
sl@0
    50
	console->Read(readStatus);
sl@0
    51
sl@0
    52
	User::WaitForRequest(timerStatus, readStatus);
sl@0
    53
	if ( timerStatus!=KErrNone )
sl@0
    54
		{
sl@0
    55
		timer.Cancel();
sl@0
    56
		User::WaitForRequest(timerStatus);
sl@0
    57
		}
sl@0
    58
	if ( readStatus==KRequestPending )
sl@0
    59
		{
sl@0
    60
		console->ReadCancel();
sl@0
    61
		User::WaitForRequest(readStatus);
sl@0
    62
		}
sl@0
    63
sl@0
    64
	CleanupStack::PopAndDestroy(2, console);
sl@0
    65
	}
sl@0
    66
sl@0
    67
sl@0
    68
GLDEF_C TInt E32Main()
sl@0
    69
/**
sl@0
    70
 * @return - Standard Epoc error code on process exit
sl@0
    71
 * Secure variant only
sl@0
    72
 * Process entry point. Called by client using RProcess API
sl@0
    73
 */
sl@0
    74
	{
sl@0
    75
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
    76
	if(cleanup == NULL)
sl@0
    77
		{
sl@0
    78
		RProcess::Rendezvous(KErrNoMemory);
sl@0
    79
		return KErrNoMemory;
sl@0
    80
		}
sl@0
    81
#if (defined TRAP_IGNORE)
sl@0
    82
	TRAP_IGNORE(MainL());
sl@0
    83
	RProcess::Rendezvous(KErrNone);
sl@0
    84
#else
sl@0
    85
	TRAPD(err,MainL());
sl@0
    86
	RProcess::Rendezvous(err);
sl@0
    87
#endif
sl@0
    88
sl@0
    89
	delete cleanup;
sl@0
    90
	return KErrNone;
sl@0
    91
    }