examples/Telephony/ETel3rdPartyExample/SuppleServices/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 #include "CMainMenu.h"
00032 
00039 CMainMenu* CMainMenu::NewLC(CConsoleBase& aConsole)
00040         {
00041         CMainMenu* self = new(ELeave) CMainMenu(aConsole);
00042         CleanupStack::PushL(self);
00043         self->ConstructL();
00044         return self;
00045         }
00046 
00052 CMainMenu::CMainMenu(CConsoleBase& aConsole)
00053         : CBaseMenuAsync(aConsole)
00054         {
00055         // Empty method
00056         }
00057 
00061 void CMainMenu::ConstructL()
00062         {
00063         CBaseMenuAsync::ConstructL();
00064         iPhoneId = CPhoneId::NewL(this);
00065         iCallForwarding = CCallForwardingStatus::NewL(this);
00066         iCallWaiting = CCallWaitingStatus::NewL(this);
00067         iCallBarring = CCallBarringStatus::NewL(this);
00068         iFlightModeInfo = CFlightModeInfo::NewL(this);
00069         iIdentityService = CIdentityServiceStatus::NewL(this);
00070         }
00071 
00076 CMainMenu::~CMainMenu()
00077         {
00078         delete iTelephony;
00079         delete iPhoneId;
00080         delete iFlightModeInfo;
00081         delete iCallForwarding;
00082         delete iCallWaiting;
00083         delete iCallBarring;
00084         delete iIdentityService;
00085         }
00086 
00093 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType)
00094         {
00095    if   (iState==ESetNotifier || aDerivedType == KFlightModeInfo)
00096                 {
00097                 switch(aDerivedType)
00098                         {
00099                 case KCallForwardingStatus:
00100                         iLastOperation = iCallForwarding;
00101                         break;
00102                 case KCallBarringStatus:
00103                         iLastOperation = iCallBarring;
00104                         break;
00105                 case KCallWaitingStatus:
00106                         iLastOperation = iCallWaiting;
00107                         break;
00108                 case KFlightModeInfo:
00109                         iLastOperation = iFlightModeInfo;
00110                         break;
00111                 case KIdentityServiceStatus:
00112                         iLastOperation = iIdentityService;
00113                         break;
00114                 case KNotType:
00115                 case KPhoneId:
00116                 case KSubscriberId:
00117                 case KBatteryInfo:
00118                 case KSignalInfo:
00119                 case KGetIndicator:
00120                 case KLockInfo:
00121                 case KNetworkInfo:
00122                 case KNetworkName:
00123                 case KOperatorName:
00124                 case KCallInfo:
00125                 case KLineStatus:
00126                 case KCallStatus:
00127                 case KNetworkRegInfo:
00128                 case KAnswerIncomingCall:
00129                 case KDialCall:
00130                 case KDynamicCaps:
00131                 case KHold:
00132                 case KResume:
00133                 case KSwap:
00134                 case KSendDTMF:
00135                 case KHangup:
00136                 default :
00137                                 break;
00138                         }
00139                 TRAPD(errNotify, iLastOperation->RequestNotificationL());
00140                 if (errNotify != KErrNone)
00141                         {
00142                         iConsole->Printf(_L("Notification Request for TTelISVExampleType"));
00143                         iConsole->Printf(_L("%d left with error code "), aDerivedType);
00144                         iConsole->Printf(_L("%d\n"), errNotify);
00145                         return;
00146                         };
00147                         
00148                 // Check the type of iLastOperation to see what it has been cast to.
00149                 switch(iLastOperation->GetExampleType())
00150                         {
00151                 case KCallBarringStatus:
00152                         iState = ECallWaiting;
00153                         iLastOperation = iCallWaiting;
00154                         SetActive();
00155                         CompleteOwnRequest(KErrNone);
00156                         break;
00157                 case KCallWaitingStatus:
00158                         iState = ECallForwarding;
00159                         iLastOperation = iCallForwarding;
00160                         SetActive();
00161                         CompleteOwnRequest(KErrNone);
00162                         break;
00163                 case KCallForwardingStatus:
00164                         iState = EIdentityService;
00165                         iLastOperation = iIdentityService;
00166                         SetActive();
00167                         CompleteOwnRequest(KErrNone);
00168                         break;
00169                 case KIdentityServiceStatus:
00170                         iConsole->Printf(KMenuMsg);
00171                         GetInput();
00172                         break;
00173                         
00174                 default:
00175                         break;
00176                         }
00177                 }
00178         else if(aDerivedType == KPhoneId)
00179                 {
00180                 iLastOperation = iFlightModeInfo;
00181                 SetActive();
00182                 CompleteOwnRequest(KErrNone);
00183                 }
00184         }
00185 
00192 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType)
00193         {
00194         switch(aDerivedType)
00195                 {
00196         case KFlightModeInfo:
00197                 if (IsActive())
00198                         {
00199                         Cancel();
00200                         }
00201                 iState = ECallBarring;
00202                 iLastOperation = iCallBarring;
00203                 SetActive();
00204                 CompleteOwnRequest(KErrNone);
00205                 break;
00206         case KCallForwardingStatus:
00207                 iState = ECallForwarding;
00208                 iLastOperation = iCallForwarding;
00209                 SetActive();
00210                 CompleteOwnRequest(KErrNone);
00211                 break;
00212         case KNotType: 
00213         case KPhoneId:
00214         case KSubscriberId:
00215         case KBatteryInfo:
00216         case KSignalInfo:
00217         case KGetIndicator:
00218         case KLockInfo:
00219         case KNetworkInfo:
00220         case KNetworkName:
00221         case KOperatorName:
00222         case KCallInfo:
00223         case KLineStatus:
00224         case KCallStatus:
00225         case KNetworkRegInfo:
00226         case KAnswerIncomingCall:
00227         case KDialCall:
00228         case KDynamicCaps:
00229         case KHold:
00230         case KResume:
00231         case KSwap:
00232         case KSendDTMF:
00233         case KHangup:
00234         case KCallWaitingStatus:
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 = EGetFlightModeInfo;
00251                 iLastOperation = iPhoneId;
00252                 TRAPD(errPhone, iLastOperation->StartRequestL());
00253                 if (errPhone)
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 EGetFlightModeInfo:
00264         case ECallWaiting:
00265         case ECallForwarding:
00266         case ECallBarring:
00267         case EIdentityService:
00268                 iState = ESetNotifier;
00269                 TRAPD(err, iLastOperation->StartRequestL());
00270                 if (err != KErrNone)
00271                         {
00272                         iConsole->Printf(_L("Request left with error code "));
00273                         iConsole->Printf(_L("%d\n"), err);
00274                         return;
00275                         }
00276                 break;
00277         case EWaitingForKeyPress:
00278                 {
00279                 TInt c = iConsole->KeyCode();
00280                 switch(c)
00281                         {
00282                 case 'E':
00283                 case 'e':
00284                 case EKeyEscape:
00285                 // cancel notifications
00286                         iFlightModeInfo->Cancel();
00287                         CActiveScheduler::Stop();
00288                         break;
00289                 default:
00290                         GetInput();
00291                         }
00292                 }
00293                 break;
00294         default:
00295                 break;
00296                 }
00297         }
00298 
00302 void CMainMenu::DoCancel()
00303         {
00304         if(iState == EStart)
00305                 {
00306                 CompleteOwnRequest(KErrCancel);
00307                 }
00308         else
00309                 {
00310                 iConsole->ReadCancel();
00311                 }
00312         }
00313 

Generated by  doxygen 1.6.2