1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <e32cons.h> |
|
20 #include <e32std.h> |
|
21 #include <e32property.h> |
|
22 |
|
23 /*@{*/ |
|
24 const TInt KDefaultInterval = 20000000; |
|
25 const TUid KMyPropertyCat = {0x10012345}; |
|
26 |
|
27 _LIT(KPromptConsole, "Manual Check"); |
|
28 /*@}*/ |
|
29 |
|
30 LOCAL_C void MainL() |
|
31 { |
|
32 TInt argLen = User::CommandLineLength(); |
|
33 HBufC* hBuf = HBufC::NewLC(argLen); |
|
34 TPtr tPtr = hBuf->Des(); |
|
35 User::CommandLine(tPtr); |
|
36 CConsoleBase* console = Console::NewL(KPromptConsole, TSize(KConsFullScreen, KConsFullScreen)); |
|
37 CleanupStack::PushL(console); |
|
38 console->Printf(KPromptConsole); |
|
39 console->Printf(_L("\n\n\n\n\n")); |
|
40 console->Printf(tPtr); |
|
41 |
|
42 RTimer timer; |
|
43 CleanupClosePushL(timer); |
|
44 timer.CreateLocal(); |
|
45 TRequestStatus timerStatus; |
|
46 timer.After(timerStatus, TTimeIntervalMicroSeconds32(KDefaultInterval)); |
|
47 TRequestStatus readStatus; |
|
48 console->Read(readStatus); |
|
49 User::WaitForRequest(timerStatus, readStatus); |
|
50 |
|
51 TKeyCode keycode(EKeyNull); |
|
52 if(timerStatus != KErrNone) |
|
53 { |
|
54 if(readStatus == KErrNone) |
|
55 { |
|
56 keycode = console->KeyCode(); |
|
57 } |
|
58 timer.Cancel(); |
|
59 } |
|
60 |
|
61 if(readStatus == KRequestPending) |
|
62 { |
|
63 console->ReadCancel(); |
|
64 } |
|
65 |
|
66 RProperty property; |
|
67 CleanupClosePushL(property); |
|
68 User::LeaveIfError( property.Attach(KMyPropertyCat, 1) ); |
|
69 User::LeaveIfError( property.Set((TInt)keycode) ); |
|
70 //property.Close(); |
|
71 CleanupStack::PopAndDestroy(4, hBuf); // &property, &timer, console, hBuf |
|
72 } |
|
73 |
|
74 GLDEF_C TInt E32Main() |
|
75 /** |
|
76 * @return - Standard Epoc error code on process exit |
|
77 * Secure variant only |
|
78 * Process entry point. Called by client using RProcess API |
|
79 */ |
|
80 { |
|
81 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
82 if(cleanup == NULL) |
|
83 { |
|
84 RProcess::Rendezvous(KErrNoMemory); |
|
85 return KErrNoMemory; |
|
86 } |
|
87 #if (defined TRAP_IGNORE) |
|
88 TRAP_IGNORE(MainL()); |
|
89 RProcess::Rendezvous(KErrNone); |
|
90 #else |
|
91 TRAPD(err,MainL()); |
|
92 RProcess::Rendezvous(err); |
|
93 #endif |
|
94 delete cleanup; |
|
95 return KErrNone; |
|
96 } |
|