24
|
1 |
// Copyright (c) 2005-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 |
|
|
17 |
#include "CBaseMenuAsync.h"
|
|
18 |
|
|
19 |
/**
|
|
20 |
Completes a request so that the RunL() code of the active object is executed.
|
|
21 |
|
|
22 |
@param aErr The error code to pass to User::RequestComplete().
|
|
23 |
*/
|
|
24 |
void CBaseMenuAsync::CompleteOwnRequest(TInt aErr)
|
|
25 |
{
|
|
26 |
TRequestStatus* status = &iStatus;
|
|
27 |
|
|
28 |
// Complete an asynchronous request
|
|
29 |
User::RequestComplete(status, aErr);
|
|
30 |
}
|
|
31 |
|
|
32 |
/**
|
|
33 |
Starts (this) active object making it active so it can take
|
|
34 |
input and perform required functionality.
|
|
35 |
*/
|
|
36 |
void CBaseMenuAsync::Start()
|
|
37 |
{
|
|
38 |
PostOwnRequest();
|
|
39 |
SetActive();
|
|
40 |
CompleteOwnRequest(KErrNone);
|
|
41 |
}
|
|
42 |
|
|
43 |
/**
|
|
44 |
Sets its own status to KRequestPending.
|
|
45 |
*/
|
|
46 |
void CBaseMenuAsync::PostOwnRequest()
|
|
47 |
{
|
|
48 |
iStatus = KRequestPending;
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
Ends execution of the active object.
|
|
53 |
*/
|
|
54 |
void CBaseMenuAsync::Terminate()
|
|
55 |
{
|
|
56 |
iState = EEnd;
|
|
57 |
SetActive();
|
|
58 |
CompleteOwnRequest(KErrNone);
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
Constructor.
|
|
63 |
|
|
64 |
@param aConsole Reference to console object to which output will be displayed
|
|
65 |
*/
|
|
66 |
CBaseMenuAsync::CBaseMenuAsync(CConsoleBase& aConsole)
|
|
67 |
: CActive(EPriorityUserInput),
|
|
68 |
iState(EStart),
|
|
69 |
iConsole(&aConsole)
|
|
70 |
{
|
|
71 |
CActiveScheduler::Add(this);
|
|
72 |
}
|
|
73 |
|
|
74 |
/**
|
|
75 |
Places a request for input to the console, reads the input character from the
|
|
76 |
keypad (keyboard etc.)
|
|
77 |
*/
|
|
78 |
void CBaseMenuAsync::GetInput()
|
|
79 |
{
|
|
80 |
// Gets a keystroke from the console window, asynchronously.
|
|
81 |
iConsole->Read(iStatus);
|
|
82 |
iState = EWaitingForKeyPress;
|
|
83 |
SetActive();
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
Second phase constructor.
|
|
88 |
*/
|
|
89 |
void CBaseMenuAsync::ConstructL()
|
|
90 |
{
|
|
91 |
iTelephony = CTelephony::NewL();
|
|
92 |
}
|