00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // 00015 00016 #include "CMainMenu.h" 00017 00024 CMainMenu* CMainMenu::NewLC(CConsoleBase& aConsole) 00025 { 00026 CMainMenu* self = new(ELeave) CMainMenu(aConsole); 00027 CleanupStack::PushL(self); 00028 self->ConstructL(); 00029 return self; 00030 } 00031 00037 CMainMenu::CMainMenu(CConsoleBase& aConsole) 00038 : CBaseMenuAsync(aConsole) 00039 { 00040 // Empty method 00041 } 00042 00046 void CMainMenu::ConstructL() 00047 { 00048 CBaseMenuAsync::ConstructL(); 00049 iPhoneId = CPhoneId::NewL(this); 00050 iCallForwarding = CCallForwardingStatus::NewL(this); 00051 iCallWaiting = CCallWaitingStatus::NewL(this); 00052 iCallBarring = CCallBarringStatus::NewL(this); 00053 iFlightModeInfo = CFlightModeInfo::NewL(this); 00054 iIdentityService = CIdentityServiceStatus::NewL(this); 00055 } 00056 00061 CMainMenu::~CMainMenu() 00062 { 00063 delete iTelephony; 00064 delete iPhoneId; 00065 delete iFlightModeInfo; 00066 delete iCallForwarding; 00067 delete iCallWaiting; 00068 delete iCallBarring; 00069 delete iIdentityService; 00070 } 00071 00078 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType) 00079 { 00080 if (iState==ESetNotifier || aDerivedType == KFlightModeInfo) 00081 { 00082 switch(aDerivedType) 00083 { 00084 case KCallForwardingStatus: 00085 iLastOperation = iCallForwarding; 00086 break; 00087 case KCallBarringStatus: 00088 iLastOperation = iCallBarring; 00089 break; 00090 case KCallWaitingStatus: 00091 iLastOperation = iCallWaiting; 00092 break; 00093 case KFlightModeInfo: 00094 iLastOperation = iFlightModeInfo; 00095 break; 00096 case KIdentityServiceStatus: 00097 iLastOperation = iIdentityService; 00098 break; 00099 case KNotType: 00100 case KPhoneId: 00101 case KSubscriberId: 00102 case KBatteryInfo: 00103 case KSignalInfo: 00104 case KGetIndicator: 00105 case KLockInfo: 00106 case KNetworkInfo: 00107 case KNetworkName: 00108 case KOperatorName: 00109 case KCallInfo: 00110 case KLineStatus: 00111 case KCallStatus: 00112 case KNetworkRegInfo: 00113 case KAnswerIncomingCall: 00114 case KDialCall: 00115 case KDynamicCaps: 00116 case KHold: 00117 case KResume: 00118 case KSwap: 00119 case KSendDTMF: 00120 case KHangup: 00121 default : 00122 break; 00123 } 00124 TRAPD(errNotify, iLastOperation->RequestNotificationL()); 00125 if (errNotify != KErrNone) 00126 { 00127 iConsole->Printf(_L("Notification Request for TTelISVExampleType")); 00128 iConsole->Printf(_L("%d left with error code "), aDerivedType); 00129 iConsole->Printf(_L("%d\n"), errNotify); 00130 return; 00131 }; 00132 00133 // Check the type of iLastOperation to see what it has been cast to. 00134 switch(iLastOperation->GetExampleType()) 00135 { 00136 case KCallBarringStatus: 00137 iState = ECallWaiting; 00138 iLastOperation = iCallWaiting; 00139 SetActive(); 00140 CompleteOwnRequest(KErrNone); 00141 break; 00142 case KCallWaitingStatus: 00143 iState = ECallForwarding; 00144 iLastOperation = iCallForwarding; 00145 SetActive(); 00146 CompleteOwnRequest(KErrNone); 00147 break; 00148 case KCallForwardingStatus: 00149 iState = EIdentityService; 00150 iLastOperation = iIdentityService; 00151 SetActive(); 00152 CompleteOwnRequest(KErrNone); 00153 break; 00154 case KIdentityServiceStatus: 00155 iConsole->Printf(KMenuMsg); 00156 GetInput(); 00157 break; 00158 00159 default: 00160 break; 00161 } 00162 } 00163 else if(aDerivedType == KPhoneId) 00164 { 00165 iLastOperation = iFlightModeInfo; 00166 SetActive(); 00167 CompleteOwnRequest(KErrNone); 00168 } 00169 } 00170 00177 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType) 00178 { 00179 switch(aDerivedType) 00180 { 00181 case KFlightModeInfo: 00182 if (IsActive()) 00183 { 00184 Cancel(); 00185 } 00186 iState = ECallBarring; 00187 iLastOperation = iCallBarring; 00188 SetActive(); 00189 CompleteOwnRequest(KErrNone); 00190 break; 00191 case KCallForwardingStatus: 00192 iState = ECallForwarding; 00193 iLastOperation = iCallForwarding; 00194 SetActive(); 00195 CompleteOwnRequest(KErrNone); 00196 break; 00197 case KNotType: 00198 case KPhoneId: 00199 case KSubscriberId: 00200 case KBatteryInfo: 00201 case KSignalInfo: 00202 case KGetIndicator: 00203 case KLockInfo: 00204 case KNetworkInfo: 00205 case KNetworkName: 00206 case KOperatorName: 00207 case KCallInfo: 00208 case KLineStatus: 00209 case KCallStatus: 00210 case KNetworkRegInfo: 00211 case KAnswerIncomingCall: 00212 case KDialCall: 00213 case KDynamicCaps: 00214 case KHold: 00215 case KResume: 00216 case KSwap: 00217 case KSendDTMF: 00218 case KHangup: 00219 case KCallWaitingStatus: 00220 case KCallBarringStatus: 00221 case KIdentityServiceStatus: 00222 default: 00223 break; 00224 } 00225 } 00226 00230 void CMainMenu::RunL() 00231 { 00232 switch(iState) 00233 { 00234 case EStart: 00235 iState = EGetFlightModeInfo; 00236 iLastOperation = iPhoneId; 00237 TRAPD(errPhone, iLastOperation->StartRequestL()); 00238 if (errPhone) 00239 { 00240 iConsole->Printf(_L("Request left with error code ")); 00241 iConsole->Printf(_L("%d\n"), errPhone); 00242 return; 00243 }; 00244 break; 00245 case EEnd: 00246 CActiveScheduler::Stop(); 00247 break; 00248 case EGetFlightModeInfo: 00249 case ECallWaiting: 00250 case ECallForwarding: 00251 case ECallBarring: 00252 case EIdentityService: 00253 iState = ESetNotifier; 00254 TRAPD(err, iLastOperation->StartRequestL()); 00255 if (err != KErrNone) 00256 { 00257 iConsole->Printf(_L("Request left with error code ")); 00258 iConsole->Printf(_L("%d\n"), err); 00259 return; 00260 } 00261 break; 00262 case EWaitingForKeyPress: 00263 { 00264 TInt c = iConsole->KeyCode(); 00265 switch(c) 00266 { 00267 case 'E': 00268 case 'e': 00269 case EKeyEscape: 00270 // cancel notifications 00271 iFlightModeInfo->Cancel(); 00272 CActiveScheduler::Stop(); 00273 break; 00274 default: 00275 GetInput(); 00276 } 00277 } 00278 break; 00279 default: 00280 break; 00281 } 00282 } 00283 00287 void CMainMenu::DoCancel() 00288 { 00289 if(iState == EStart) 00290 { 00291 CompleteOwnRequest(KErrCancel); 00292 } 00293 else 00294 { 00295 iConsole->ReadCancel(); 00296 } 00297 } 00298
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.