00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "CMainMenu.h"
00033
00040 CMainMenu* CMainMenu::NewLC(CConsoleBase& aConsole)
00041 {
00042 CMainMenu* self = new(ELeave) CMainMenu(aConsole);
00043 CleanupStack::PushL(self);
00044 self->ConstructL();
00045 return self;
00046 }
00047
00053 CMainMenu::CMainMenu(CConsoleBase& aConsole)
00054 : CBaseMenuAsync(aConsole)
00055 {
00056
00057 }
00058
00062 void CMainMenu::ConstructL()
00063 {
00064 CBaseMenuAsync::ConstructL();
00065 iPhoneId = CPhoneId::NewL(this);
00066 iNetworkInfo = CCurrentNetworkInfo::NewL(this);
00067 iFlightModeInfo = CFlightModeInfo::NewL(this);
00068 }
00069
00074 CMainMenu::~CMainMenu()
00075 {
00076 delete iTelephony;
00077 delete iPhoneId;
00078 delete iFlightModeInfo;
00079 delete iNetworkInfo;
00080 }
00081
00088 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType)
00089 {
00090 if (iState==ESetNotifier || aDerivedType == KFlightModeInfo)
00091 {
00092 switch(aDerivedType)
00093 {
00094 case KNetworkInfo:
00095 iLastOperation = iNetworkInfo;
00096 break;
00097 case KFlightModeInfo:
00098 iLastOperation = iFlightModeInfo;
00099 break;
00100 case KNotType:
00101 case KPhoneId:
00102 case KSubscriberId:
00103 case KBatteryInfo:
00104 case KSignalInfo:
00105 case KGetIndicator:
00106 case KLockInfo:
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 case KCallWaitingStatus:
00122 case KCallForwardingStatus:
00123 case KCallBarringStatus:
00124 case KIdentityServiceStatus:
00125 default:
00126 break;
00127 }
00128 TRAPD(errNotify, iLastOperation->RequestNotificationL());
00129 if (errNotify != KErrNone)
00130 {
00131 iConsole->Printf(_L("Notification Request for TTelISVExampleType"));
00132 iConsole->Printf(_L("%d left with error code "), aDerivedType);
00133 iConsole->Printf(_L("%d\n"), errNotify);
00134 return;
00135 };
00136
00137
00138 switch(iLastOperation->GetExampleType())
00139 {
00140 case KFlightModeInfo:
00141 if (IsActive())
00142 {
00143 Cancel();
00144 }
00145 iState = EGetNetworkInfo;
00146 iLastOperation = iNetworkInfo;
00147 SetActive();
00148 CompleteOwnRequest(KErrNone);
00149 break;
00150 case KNetworkInfo:
00151 iConsole->Printf(KMenuMsg);
00152 GetInput();
00153 break;
00154 default:
00155
00156 break;
00157 }
00158 }
00159 else if(aDerivedType == KPhoneId)
00160 {
00161 iLastOperation = iFlightModeInfo;
00162 SetActive();
00163 CompleteOwnRequest(KErrNone);
00164 }
00165 }
00166
00173 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType)
00174 {
00175 switch(aDerivedType)
00176 {
00177 case KFlightModeInfo:
00178
00179 TRAPD(err, iFlightModeInfo->RequestNotificationL());
00180 if (err != KErrNone)
00181 {
00182 iConsole->Printf(_L("%d\n"),err);
00183 return;
00184 }
00185 iNetworkInfo->Cancel();
00186 break;
00187 case KNotType:
00188 case KPhoneId:
00189 case KSubscriberId:
00190 case KBatteryInfo:
00191 case KSignalInfo:
00192 case KGetIndicator:
00193 case KLockInfo:
00194 case KNetworkInfo:
00195 case KNetworkName:
00196 case KOperatorName:
00197 case KCallInfo:
00198 case KLineStatus:
00199 case KCallStatus:
00200 case KNetworkRegInfo:
00201 case KAnswerIncomingCall:
00202 case KDialCall:
00203 case KDynamicCaps:
00204 case KHold:
00205 case KResume:
00206 case KSwap:
00207 case KSendDTMF:
00208 case KHangup:
00209 case KCallWaitingStatus:
00210 case KCallForwardingStatus:
00211 case KCallBarringStatus:
00212 case KIdentityServiceStatus:
00213 default:
00214 break;
00215 }
00216 }
00217
00222 void CMainMenu::RunL()
00223 {
00224 switch(iState)
00225 {
00226 case EStart:
00227 iState = EGetFlightModeInfo;
00228 iLastOperation = iPhoneId;
00229 TRAPD(errPhone, iLastOperation->StartRequestL());
00230 if (errPhone)
00231 {
00232 iConsole->Printf(_L("Request left with error code "));
00233 iConsole->Printf(_L("%d\n"), errPhone);
00234 return;
00235 };
00236 break;
00237 case EEnd:
00238 CActiveScheduler::Stop();
00239 break;
00240 case EGetFlightModeInfo:
00241 case EGetNetworkInfo:
00242 iState = ESetNotifier;
00243 TRAPD(err, iLastOperation->StartRequestL());
00244 if (err)
00245 {
00246 iConsole->Printf(_L("Request left with error code "));
00247 iConsole->Printf(_L("%d\n"), err);
00248 return;
00249 }
00250 break;
00251 case EWaitingForKeyPress:
00252 {
00253 TInt c = iConsole->KeyCode();
00254
00255 switch(c)
00256 {
00257 case 'E':
00258 case 'e':
00259 case EKeyEscape:
00260
00261 iNetworkInfo->Cancel();
00262 iFlightModeInfo->Cancel();
00263 CActiveScheduler::Stop();
00264 break;
00265 default:
00266 GetInput();
00267 }
00268 }
00269 break;
00270 default:
00271 break;
00272 }
00273 }
00274
00278 void CMainMenu::DoCancel()
00279 {
00280 if(iState == EStart)
00281 {
00282 CompleteOwnRequest(KErrCancel);
00283 }
00284 else
00285 {
00286 iConsole->ReadCancel();
00287 }
00288 }