|
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 "CMainMenu.h" |
|
18 |
|
19 /** |
|
20 Factory constructor. |
|
21 |
|
22 @param aConsole Console to which output is printed |
|
23 @return Instance of CMainMenu class |
|
24 */ |
|
25 CMainMenu* CMainMenu::NewLC(CConsoleBase& aConsole) |
|
26 { |
|
27 CMainMenu* self = new(ELeave) CMainMenu(aConsole); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 return self; |
|
31 } |
|
32 |
|
33 /** |
|
34 Constructor. Called by factory constructor CMainMenu::NewLC() |
|
35 |
|
36 @param Console to which output is printed |
|
37 */ |
|
38 CMainMenu::CMainMenu(CConsoleBase& aConsole) |
|
39 : CBaseMenuSync(aConsole) |
|
40 { |
|
41 // Empty method |
|
42 } |
|
43 |
|
44 /** |
|
45 Second phase constructor. |
|
46 */ |
|
47 void CMainMenu::ConstructL() |
|
48 { |
|
49 CBaseMenuSync::ConstructL(); |
|
50 iPhoneId = CPhoneId::NewL(this); |
|
51 iSubscriberId = CSubscriberId::NewL(this); |
|
52 } |
|
53 |
|
54 /** |
|
55 Destructor. |
|
56 Deletes owned objects. |
|
57 */ |
|
58 CMainMenu::~CMainMenu() |
|
59 { |
|
60 delete iPhoneId; |
|
61 delete iSubscriberId; |
|
62 } |
|
63 |
|
64 /** |
|
65 Starts the request to get the phone ID and handles errors if they are returned. |
|
66 */ |
|
67 void CMainMenu::RunL() |
|
68 { |
|
69 switch(iState) |
|
70 { |
|
71 case EStart: |
|
72 iState = EGetPhoneId; |
|
73 SetActive(); |
|
74 CompleteOwnRequest(KErrNone); |
|
75 break; |
|
76 case EEnd: |
|
77 CActiveScheduler::Stop(); |
|
78 break; |
|
79 case EGetPhoneId: |
|
80 iState = EGetSubscriberId; |
|
81 TRAPD(errPhone, iPhoneId->StartRequestL()); |
|
82 if (errPhone != KErrNone) |
|
83 { |
|
84 iConsole->Printf(_L("Request left with error code ")); |
|
85 iConsole->Printf(_L("%d\n"), errPhone); |
|
86 return; |
|
87 } |
|
88 break; |
|
89 case EGetSubscriberId: |
|
90 iState = EEnd; |
|
91 TRAPD(errSub, iSubscriberId->StartRequestL()); |
|
92 if (errSub != KErrNone) |
|
93 { |
|
94 iConsole->Printf(_L("%d\n"), errSub); |
|
95 return; |
|
96 } |
|
97 break; |
|
98 } |
|
99 } |
|
100 |
|
101 /** |
|
102 Cancels the outstanding asynchronous request. |
|
103 */ |
|
104 void CMainMenu::DoCancel() |
|
105 { |
|
106 if(iState == EStart) |
|
107 { |
|
108 CompleteOwnRequest(KErrCancel); |
|
109 } |
|
110 else |
|
111 { |
|
112 iConsole->ReadCancel(); |
|
113 } |
|
114 } |