examples/Telephony/ETel3rdPartyExample/PhoneMonitoring/CMainMenu.cpp

00001 /*
00002 Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:  
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         // Empty method
00057         }
00058 
00062 void CMainMenu::ConstructL()
00063         {
00064         CBaseMenuAsync::ConstructL();
00065         iPhoneId = CPhoneId::NewL(this);
00066 
00067         iBatteryInfo = CBatteryInfo::NewL(this);
00068         iSignalInfo = CSignalInfo::NewL(this);
00069 
00070         iFlightModeInfo = CFlightModeInfo::NewL(this);
00071         iGetIndicator = CGetIndicator::NewL(this);
00072         }
00073 
00078 CMainMenu::~CMainMenu()
00079         {
00080         delete iTelephony;
00081         delete iPhoneId;
00082 
00083         delete  iBatteryInfo;
00084         delete iSignalInfo;
00085 
00086         delete iFlightModeInfo;
00087         delete iGetIndicator;
00088         }
00089 
00096 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType)
00097         {
00098         if(iState==ESetNotifier || aDerivedType == KFlightModeInfo)
00099                 {
00100                 switch(aDerivedType)
00101                         {
00102                 case KBatteryInfo:
00103                         iLastOperation = iBatteryInfo;
00104                         break;
00105                 case KSignalInfo:
00106                         iLastOperation = iSignalInfo;
00107                         break;
00108                 case KFlightModeInfo:
00109                         iLastOperation = iFlightModeInfo;
00110                         break;
00111                 case KGetIndicator:
00112                         iLastOperation = iGetIndicator;
00113                         break;
00114                 case KNotType:
00115                 case KPhoneId:
00116                 case KSubscriberId:
00117                 case KLockInfo:
00118                 case KNetworkInfo:
00119                 case KNetworkName:
00120                 case KOperatorName:
00121                 case KCallInfo:
00122                 case KLineStatus:
00123                 case KCallStatus:
00124                 case KNetworkRegInfo:
00125                 case KAnswerIncomingCall:
00126                 case KDialCall:
00127                 case KDynamicCaps:
00128                 case KHold:
00129                 case KResume:
00130                 case KSwap:
00131                 case KSendDTMF:
00132                 case KHangup:
00133                 case KCallWaitingStatus:
00134                 case KCallForwardingStatus:
00135                 case KCallBarringStatus:
00136                 case KIdentityServiceStatus:
00137                 default:
00138                         break;  
00139                         }
00140                 TRAPD(errNotify, iLastOperation->RequestNotificationL());
00141                 if (errNotify != KErrNone)
00142                         {
00143                         iConsole->Printf(_L("Notification Request for TTelISVExampleType"));
00144                         iConsole->Printf(_L("%d left with error code "), aDerivedType);
00145                         iConsole->Printf(_L("%d\n"), errNotify);
00146                         return;
00147                         };
00148                         
00149                 // Check the type of iLastOperation to see what it has been cast to.
00150                 switch(iLastOperation->GetExampleType())
00151                         {
00152                 case KBatteryInfo:
00153                         iState = EGetFlightModeInfo;
00154                         iLastOperation = iFlightModeInfo;
00155                         SetActive();
00156                         CompleteOwnRequest(KErrNone);
00157                         break;
00158                 case KSignalInfo:
00159                         iConsole->Printf(KMenuMsg);
00160                         GetInput();
00161                         break;
00162                 case KFlightModeInfo:
00163                         Cancel();
00164                         iState = EGetSignalInfo;
00165                         iLastOperation = iSignalInfo;
00166                         SetActive();
00167                         CompleteOwnRequest(KErrNone);
00168                         break;
00169                 case KGetIndicator:
00170                         iState = EGetBatteryInfo;
00171                         iLastOperation = iBatteryInfo;
00172                         SetActive();
00173                         CompleteOwnRequest(KErrNone);
00174                         break;
00175                 default:
00176 
00177                         break;
00178                         }
00179                 }
00180         else if(aDerivedType == KPhoneId)
00181                 {
00182                 iLastOperation = iGetIndicator;
00183                 SetActive();
00184                 CompleteOwnRequest(KErrNone);
00185                 }
00186         }
00187 
00194 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType)
00195         {
00196         switch(aDerivedType)
00197                 {
00198         case KFlightModeInfo:
00199                 if (IsActive())
00200                         {
00201                         Cancel();
00202                         }
00203                 if (iSignalInfo->IsActive())
00204                         {
00205                         iSignalInfo->Cancel();
00206                         }
00207                 iConsole->Printf(KMenuMsg);
00208                 GetInput();
00209                 break;
00210         
00211         case KNotType:
00212         case KPhoneId:
00213         case KSubscriberId:
00214         case KBatteryInfo:
00215         case KSignalInfo:
00216         case KGetIndicator:
00217         case KLockInfo:
00218         case KNetworkInfo:
00219         case KNetworkName:
00220         case KOperatorName:
00221         case KCallInfo:
00222         case KLineStatus:
00223         case KCallStatus:
00224         case KNetworkRegInfo:
00225         case KAnswerIncomingCall:
00226         case KDialCall:
00227         case KDynamicCaps:
00228         case KHold:
00229         case KResume:
00230         case KSwap:
00231         case KSendDTMF:
00232         case KHangup:
00233         case KCallWaitingStatus:
00234         case KCallForwardingStatus:
00235         case KCallBarringStatus:
00236         case KIdentityServiceStatus:
00237         default:
00238                 break;
00239                 }
00240         }
00241 
00245 void CMainMenu::RunL()
00246         {
00247         switch(iState)
00248                 {
00249         case EStart:
00250                 iState = EGetIndicator;
00251                 iLastOperation = iPhoneId;
00252                 TRAPD(errPhone, iLastOperation->StartRequestL());
00253                 if (errPhone != KErrNone)
00254                         {
00255                         iConsole->Printf(_L("Request left with error code "));
00256                         iConsole->Printf(_L("%d\n"), errPhone);
00257                         return;
00258                         };
00259                 break;
00260         case EEnd:
00261                 CActiveScheduler::Stop();
00262                 break;
00263         case EGetIndicator:
00264         case EGetBatteryInfo:
00265         case EGetSignalInfo:
00266         case EGetFlightModeInfo:
00267                 iState = ESetNotifier;
00268                 TRAPD(err, iLastOperation->StartRequestL());
00269                 if (err != KErrNone)
00270                         {
00271                         iConsole->Printf(_L("Request left with error code "));
00272                         iConsole->Printf(_L("%d\n"), err);
00273                         return;
00274                         }
00275                 break;
00276         case EWaitingForKeyPress:
00277                 {
00278                 TInt c = iConsole->KeyCode();
00279                 switch(c)
00280                         {
00281                 case 'E':
00282                 case 'e':
00283                 case EKeyEscape:
00284                         iGetIndicator->Cancel();
00285                         iBatteryInfo->Cancel();
00286                         iSignalInfo->Cancel();
00287                         iFlightModeInfo->Cancel();
00288 
00289                         CActiveScheduler::Stop();
00290                         break;
00291                 default:
00292                         GetInput();
00293                         }
00294                 }
00295                 break;
00296         default:
00297                 break;
00298                 }
00299         }
00300 
00304 void CMainMenu::DoCancel()
00305         {
00306         if(iState == EStart)
00307                 {
00308                 CompleteOwnRequest(KErrCancel);
00309                 }
00310         else
00311                 {
00312                 iConsole->ReadCancel();
00313                 }
00314         }
00315 

Generated by  doxygen 1.6.2