examples/Telephony/ETel3rdPartyExample/NetworkInformation/CMainMenu.cpp

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 
00017 #include "CMainMenu.h"
00018 
00025 CMainMenu* CMainMenu::NewLC(CConsoleBase& aConsole)
00026         {
00027         CMainMenu* self = new(ELeave) CMainMenu(aConsole);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         return self;
00031         }
00032 
00038 CMainMenu::CMainMenu(CConsoleBase& aConsole)
00039         : CBaseMenuAsync(aConsole)
00040         {
00041         // Empty method
00042         }
00043 
00047 void CMainMenu::ConstructL()
00048         {
00049         CBaseMenuAsync::ConstructL();
00050         iPhoneId = CPhoneId::NewL(this);
00051         iNetworkInfo = CCurrentNetworkInfo::NewL(this);
00052         iFlightModeInfo = CFlightModeInfo::NewL(this);
00053         }
00054 
00059 CMainMenu::~CMainMenu()
00060         {
00061         delete iTelephony;
00062         delete iPhoneId;
00063         delete iFlightModeInfo;
00064         delete iNetworkInfo;
00065         }
00066 
00073 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType)
00074         {
00075    if (iState==ESetNotifier || aDerivedType == KFlightModeInfo)
00076                 {
00077                 switch(aDerivedType)
00078                         {
00079                 case KNetworkInfo:
00080                         iLastOperation = iNetworkInfo;
00081                         break;
00082                 case KFlightModeInfo:
00083                         iLastOperation = iFlightModeInfo;
00084                         break;
00085                 case KNotType:
00086                 case KPhoneId:
00087                 case KSubscriberId:
00088                 case KBatteryInfo:
00089                 case KSignalInfo:
00090                 case KGetIndicator:
00091                 case KLockInfo:
00092                 case KNetworkName:
00093                 case KOperatorName:
00094                 case KCallInfo:
00095                 case KLineStatus:
00096                 case KCallStatus:       
00097                 case KNetworkRegInfo:
00098                 case KAnswerIncomingCall:
00099                 case KDialCall:
00100                 case KDynamicCaps:
00101                 case KHold:
00102                 case KResume:
00103                 case KSwap:
00104                 case KSendDTMF:
00105                 case KHangup:
00106                 case KCallWaitingStatus:
00107                 case KCallForwardingStatus:
00108                 case KCallBarringStatus:
00109                 case KIdentityServiceStatus:
00110                 default:
00111                         break;
00112                         }
00113                 TRAPD(errNotify, iLastOperation->RequestNotificationL());
00114                 if (errNotify != KErrNone)
00115                         {
00116                         iConsole->Printf(_L("Notification Request for TTelISVExampleType"));
00117                         iConsole->Printf(_L("%d left with error code "), aDerivedType);
00118                         iConsole->Printf(_L("%d\n"), errNotify);
00119                         return;
00120                         };
00121                 // Check the type of iLastOperation to see
00122                 // what it has been cast to.
00123                 switch(iLastOperation->GetExampleType())
00124                         {
00125                 case KFlightModeInfo:
00126                         if (IsActive())
00127                                 {
00128                                 Cancel();
00129                                 }
00130                         iState = EGetNetworkInfo;
00131                         iLastOperation = iNetworkInfo;
00132                         SetActive();
00133                         CompleteOwnRequest(KErrNone);
00134                         break;
00135                 case KNetworkInfo:
00136                         iConsole->Printf(KMenuMsg);
00137                         GetInput();
00138                         break;
00139                 default:
00140 
00141                         break;
00142                         }
00143                 }
00144         else if(aDerivedType == KPhoneId)
00145                 {
00146                 iLastOperation = iFlightModeInfo;
00147                 SetActive();
00148                 CompleteOwnRequest(KErrNone);
00149                 }
00150         }
00151 
00158 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType)
00159         {
00160         switch(aDerivedType)
00161                 {
00162         case KFlightModeInfo:
00163                 // Request to be told about particular events occurring 
00164                 TRAPD(err, iFlightModeInfo->RequestNotificationL());
00165                 if (err != KErrNone)
00166                         {
00167                         iConsole->Printf(_L("%d\n"),err);
00168                         return;
00169                         }
00170                 iNetworkInfo->Cancel();
00171                 break;
00172         case KNotType:
00173         case KPhoneId:
00174         case KSubscriberId:
00175         case KBatteryInfo:
00176         case KSignalInfo:
00177         case KGetIndicator:
00178         case KLockInfo:
00179         case KNetworkInfo:
00180         case KNetworkName:
00181         case KOperatorName:
00182         case KCallInfo:
00183         case KLineStatus:
00184         case KCallStatus:
00185         case KNetworkRegInfo:
00186         case KAnswerIncomingCall:
00187         case KDialCall:
00188         case KDynamicCaps:
00189         case KHold:
00190         case KResume:
00191         case KSwap:
00192         case KSendDTMF:
00193         case KHangup:
00194         case KCallWaitingStatus:
00195         case KCallForwardingStatus:
00196         case KCallBarringStatus:
00197         case KIdentityServiceStatus:
00198         default:
00199                 break;  
00200                 }
00201         }
00202 
00207 void CMainMenu::RunL()
00208         {
00209         switch(iState)
00210                 {
00211         case EStart:
00212                 iState = EGetFlightModeInfo;
00213                 iLastOperation = iPhoneId;
00214                 TRAPD(errPhone, iLastOperation->StartRequestL());
00215                 if (errPhone)
00216                         {
00217                         iConsole->Printf(_L("Request left with error code "));
00218                         iConsole->Printf(_L("%d\n"), errPhone);
00219                         return;
00220                         };
00221                 break;
00222         case EEnd:
00223                 CActiveScheduler::Stop();
00224                 break;
00225         case EGetFlightModeInfo:
00226         case EGetNetworkInfo:
00227                 iState = ESetNotifier;
00228                 TRAPD(err, iLastOperation->StartRequestL());
00229                 if (err)
00230                         {
00231                         iConsole->Printf(_L("Request left with error code "));
00232                         iConsole->Printf(_L("%d\n"), err);
00233                         return;
00234                         }
00235                 break;
00236         case EWaitingForKeyPress:
00237                 {
00238                 TInt c = iConsole->KeyCode();
00239                 // Handle key presses
00240                 switch(c)
00241                         {
00242                 case 'E':
00243                 case 'e':
00244                 case EKeyEscape:
00245                         // Cancel notifications
00246                         iNetworkInfo->Cancel();
00247                         iFlightModeInfo->Cancel();
00248                         CActiveScheduler::Stop();
00249                         break;
00250                 default:
00251                         GetInput();
00252                         }
00253                 }
00254                 break;
00255         default:
00256                 break;
00257                 }
00258         }
00259 
00263 void CMainMenu::DoCancel()
00264         {
00265         if(iState == EStart)
00266                 {
00267                 CompleteOwnRequest(KErrCancel);
00268                 }
00269         else
00270                 {
00271                 iConsole->ReadCancel();
00272                 }
00273         }

Generated by  doxygen 1.6.2