examples/Telephony/ETel3rdPartyExample/NetworkInformation/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         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                 // Check the type of iLastOperation to see
00137                 // what it has been cast to.
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                 // Request to be told about particular events occurring 
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                 // Handle key presses
00255                 switch(c)
00256                         {
00257                 case 'E':
00258                 case 'e':
00259                 case EKeyEscape:
00260                         // Cancel notifications
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         }

Generated by  doxygen 1.6.2