examples/Telephony/ETel3rdPartyExample/IncomingCalls/CNetworkRegInfo.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 "CNetworkRegInfo.h"
00018 
00025 CNetworkRegInfo* CNetworkRegInfo::NewL(MExecAsync* aController)
00026         {
00027         CNetworkRegInfo* self = new(ELeave) CNetworkRegInfo(aController);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         CleanupStack::Pop(self);
00031         return self;
00032         }
00033 
00038 CNetworkRegInfo::~CNetworkRegInfo()
00039         {
00040         Cancel();
00041         delete iTelephony;
00042         }
00043 
00048 void CNetworkRegInfo::StartRequestL()
00049         {
00050         iRequestNotify = EFalse;
00051         iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegV1Pckg);
00052         SetActive();
00053         }
00054 
00060 CNetworkRegInfo::CNetworkRegInfo(MExecAsync* aController)
00061         : CISVAPIAsync(aController)
00062         , iNetworkRegV1Pckg(iNetworkRegV1)
00063         {
00064         iExtensionId = KNetworkRegInfo;
00065         }
00066 
00070 void CNetworkRegInfo::ConstructL()
00071         {
00072         CActiveScheduler::Add(this);
00073         iTelephony = CTelephony::NewL();
00074         iRequestNotify = EFalse;
00075         }
00076 
00082 void CNetworkRegInfo::RunL()
00083         {
00084         TBool isNotification = iRequestNotify;
00085         if(iStatus != KErrNone)
00086                 {
00087                 gConsole->Printf(KErrorRom);
00088                 }
00089         else
00090                 {
00091                 TBuf<30> theStatus;
00092                 gConsole->Printf(KNetworkRegMsgRom);
00093                 switch(iNetworkRegV1.iRegStatus)
00094                         {
00095                                 case CTelephony::ERegistrationUnknown:
00096                                         theStatus.Append(_L("ERegistrationUnknown\n"));
00097                                         break;
00098                                 case CTelephony::ENotRegisteredNoService:
00099                                         theStatus.Append(_L("ENotRegisteredNoService\n"));
00100                                         break;
00101                                 case CTelephony::ENotRegisteredEmergencyOnly:
00102                                         theStatus.Append(_L("ENotRegisteredEmergencyOnly\n"));
00103                                         break;
00104                                 case CTelephony::ENotRegisteredSearching:
00105                                         theStatus.Append(_L("ENotRegisteredSearching\n"));
00106                                         break;
00107                                 case CTelephony::ERegisteredBusy:
00108                                         theStatus.Append(_L("ERegisteredBusy\n"));
00109                                         break;
00110                                 case CTelephony::ERegisteredOnHomeNetwork:
00111                                         theStatus.Append(_L("ERegisteredOnHomeNetwork\n"));
00112                                         break;
00113                                 case CTelephony::ERegistrationDenied:
00114                                         theStatus.Append(_L("ERegistrationDenied\n"));
00115                                         break;
00116                                 case CTelephony::ERegisteredRoaming:
00117                                         theStatus.Append(_L("ERegisteredRoaming\n"));
00118                                         break;
00119                                 default:
00120                                         break;
00121                         }
00122                 gConsole->Printf(theStatus);
00123                 }
00124         iRequestNotify = EFalse;
00125         if (isNotification)
00126                 {
00127                 ExampleNotify();
00128                 }
00129         else
00130                 {
00131                 ExampleComplete();
00132                 }
00133         }
00134 
00139 void CNetworkRegInfo::RequestNotificationL()
00140         {
00141         /*
00142         Panics if this object is already performing an asynchronous
00143         operation. Application will panic if you call SetActive() on an already
00144         active object.
00145         */
00146         _LIT( KNotifyPanic, "CNetworkReg Notify Method" );
00147         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00148         iRequestNotify = ETrue;
00149         iTelephony->NotifyChange(       iStatus,
00150                                                                 CTelephony::ENetworkRegistrationStatusChange,
00151                                                                 iNetworkRegV1Pckg );
00152         SetActive();
00153         }
00154 
00158 void CNetworkRegInfo::DoCancel()
00159         {
00160         iRequestNotify = EFalse;
00161         iTelephony->CancelAsync(CTelephony::ENetworkRegistrationStatusChangeCancel);
00162         }

Generated by  doxygen 1.6.2