examples/Telephony/ETel3rdPartyExample/PhoneMonitoring/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 
00052         iBatteryInfo = CBatteryInfo::NewL(this);
00053         iSignalInfo = CSignalInfo::NewL(this);
00054 
00055         iFlightModeInfo = CFlightModeInfo::NewL(this);
00056         iGetIndicator = CGetIndicator::NewL(this);
00057         }
00058 
00063 CMainMenu::~CMainMenu()
00064         {
00065         delete iTelephony;
00066         delete iPhoneId;
00067 
00068         delete  iBatteryInfo;
00069         delete iSignalInfo;
00070 
00071         delete iFlightModeInfo;
00072         delete iGetIndicator;
00073         }
00074 
00081 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType)
00082         {
00083         if(iState==ESetNotifier || aDerivedType == KFlightModeInfo)
00084                 {
00085                 switch(aDerivedType)
00086                         {
00087                 case KBatteryInfo:
00088                         iLastOperation = iBatteryInfo;
00089                         break;
00090                 case KSignalInfo:
00091                         iLastOperation = iSignalInfo;
00092                         break;
00093                 case KFlightModeInfo:
00094                         iLastOperation = iFlightModeInfo;
00095                         break;
00096                 case KGetIndicator:
00097                         iLastOperation = iGetIndicator;
00098                         break;
00099                 case KNotType:
00100                 case KPhoneId:
00101                 case KSubscriberId:
00102                 case KLockInfo:
00103                 case KNetworkInfo:
00104                 case KNetworkName:
00105                 case KOperatorName:
00106                 case KCallInfo:
00107                 case KLineStatus:
00108                 case KCallStatus:
00109                 case KNetworkRegInfo:
00110                 case KAnswerIncomingCall:
00111                 case KDialCall:
00112                 case KDynamicCaps:
00113                 case KHold:
00114                 case KResume:
00115                 case KSwap:
00116                 case KSendDTMF:
00117                 case KHangup:
00118                 case KCallWaitingStatus:
00119                 case KCallForwardingStatus:
00120                 case KCallBarringStatus:
00121                 case KIdentityServiceStatus:
00122                 default:
00123                         break;  
00124                         }
00125                 TRAPD(errNotify, iLastOperation->RequestNotificationL());
00126                 if (errNotify != KErrNone)
00127                         {
00128                         iConsole->Printf(_L("Notification Request for TTelISVExampleType"));
00129                         iConsole->Printf(_L("%d left with error code "), aDerivedType);
00130                         iConsole->Printf(_L("%d\n"), errNotify);
00131                         return;
00132                         };
00133                         
00134                 // Check the type of iLastOperation to see what it has been cast to.
00135                 switch(iLastOperation->GetExampleType())
00136                         {
00137                 case KBatteryInfo:
00138                         iState = EGetFlightModeInfo;
00139                         iLastOperation = iFlightModeInfo;
00140                         SetActive();
00141                         CompleteOwnRequest(KErrNone);
00142                         break;
00143                 case KSignalInfo:
00144                         iConsole->Printf(KMenuMsg);
00145                         GetInput();
00146                         break;
00147                 case KFlightModeInfo:
00148                         Cancel();
00149                         iState = EGetSignalInfo;
00150                         iLastOperation = iSignalInfo;
00151                         SetActive();
00152                         CompleteOwnRequest(KErrNone);
00153                         break;
00154                 case KGetIndicator:
00155                         iState = EGetBatteryInfo;
00156                         iLastOperation = iBatteryInfo;
00157                         SetActive();
00158                         CompleteOwnRequest(KErrNone);
00159                         break;
00160                 default:
00161 
00162                         break;
00163                         }
00164                 }
00165         else if(aDerivedType == KPhoneId)
00166                 {
00167                 iLastOperation = iGetIndicator;
00168                 SetActive();
00169                 CompleteOwnRequest(KErrNone);
00170                 }
00171         }
00172 
00179 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType)
00180         {
00181         switch(aDerivedType)
00182                 {
00183         case KFlightModeInfo:
00184                 if (IsActive())
00185                         {
00186                         Cancel();
00187                         }
00188                 if (iSignalInfo->IsActive())
00189                         {
00190                         iSignalInfo->Cancel();
00191                         }
00192                 iConsole->Printf(KMenuMsg);
00193                 GetInput();
00194                 break;
00195         
00196         case KNotType:
00197         case KPhoneId:
00198         case KSubscriberId:
00199         case KBatteryInfo:
00200         case KSignalInfo:
00201         case KGetIndicator:
00202         case KLockInfo:
00203         case KNetworkInfo:
00204         case KNetworkName:
00205         case KOperatorName:
00206         case KCallInfo:
00207         case KLineStatus:
00208         case KCallStatus:
00209         case KNetworkRegInfo:
00210         case KAnswerIncomingCall:
00211         case KDialCall:
00212         case KDynamicCaps:
00213         case KHold:
00214         case KResume:
00215         case KSwap:
00216         case KSendDTMF:
00217         case KHangup:
00218         case KCallWaitingStatus:
00219         case KCallForwardingStatus:
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 = EGetIndicator;
00236                 iLastOperation = iPhoneId;
00237                 TRAPD(errPhone, iLastOperation->StartRequestL());
00238                 if (errPhone != KErrNone)
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 EGetIndicator:
00249         case EGetBatteryInfo:
00250         case EGetSignalInfo:
00251         case EGetFlightModeInfo:
00252                 iState = ESetNotifier;
00253                 TRAPD(err, iLastOperation->StartRequestL());
00254                 if (err != KErrNone)
00255                         {
00256                         iConsole->Printf(_L("Request left with error code "));
00257                         iConsole->Printf(_L("%d\n"), err);
00258                         return;
00259                         }
00260                 break;
00261         case EWaitingForKeyPress:
00262                 {
00263                 TInt c = iConsole->KeyCode();
00264                 switch(c)
00265                         {
00266                 case 'E':
00267                 case 'e':
00268                 case EKeyEscape:
00269                         iGetIndicator->Cancel();
00270                         iBatteryInfo->Cancel();
00271                         iSignalInfo->Cancel();
00272                         iFlightModeInfo->Cancel();
00273 
00274                         CActiveScheduler::Stop();
00275                         break;
00276                 default:
00277                         GetInput();
00278                         }
00279                 }
00280                 break;
00281         default:
00282                 break;
00283                 }
00284         }
00285 
00289 void CMainMenu::DoCancel()
00290         {
00291         if(iState == EStart)
00292                 {
00293                 CompleteOwnRequest(KErrCancel);
00294                 }
00295         else
00296                 {
00297                 iConsole->ReadCancel();
00298                 }
00299         }
00300 

Generated by  doxygen 1.6.2