examples/Telephony/ETel3rdPartyExample/OutgoingCalls/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 
00026 CNetworkRegInfo* CNetworkRegInfo::NewL(MExecAsync* aController)
00027         {
00028         CNetworkRegInfo* self = new(ELeave) CNetworkRegInfo(aController);
00029         CleanupStack::PushL(self);
00030         self->ConstructL();
00031         CleanupStack::Pop(self);
00032         return self;
00033         }
00034 
00038 CNetworkRegInfo::~CNetworkRegInfo()
00039         {
00040         Cancel();
00041         }
00042 
00047 void CNetworkRegInfo::DoStartRequestL()
00048         {
00049     iRequestNotify = EFalse;
00050    
00051     // Retrieves the current network registration status
00052         iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegV1Pckg);
00053         SetActive();
00054         }
00055 
00062 CNetworkRegInfo::CNetworkRegInfo(MExecAsync* aController)
00063         : CISVAPIAsync(aController, KNetworkRegInfo),
00064           iNetworkRegV1Pckg(iNetworkRegV1)
00065         {
00066         // Empty method
00067         }
00068 
00072 void CNetworkRegInfo::ConstructL()
00073         {
00074         iRequestNotify = EFalse;
00075         }
00076 
00081 void CNetworkRegInfo::RunL()
00082         {
00083         if(iStatus != KErrNone)
00084                 {
00085                 iConsole->Printf(KError);
00086                 
00087                 // Print the output to console if there is no error
00088                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00089                 }
00090         else
00091                 {
00092                 TBuf<30> theStatus;
00093                 iConsole->Printf(KNetworkRegMsg);
00094                 switch(iNetworkRegV1.iRegStatus)
00095                         {
00096                 case CTelephony::ERegistrationUnknown:
00097                         theStatus.Append(_L("ERegistrationUnknown\n"));
00098                         break;
00099                 case CTelephony::ENotRegisteredNoService:
00100                         theStatus.Append(_L("ENotRegisteredNoService\n"));
00101                         break;
00102                 case CTelephony::ENotRegisteredEmergencyOnly:
00103                         theStatus.Append(_L("ENotRegisteredEmergencyOnly\n"));
00104                         break;
00105                 case CTelephony::ENotRegisteredSearching:
00106                         theStatus.Append(_L("ENotRegisteredSearching\n"));
00107                         break;
00108                 case CTelephony::ERegisteredBusy:
00109                         theStatus.Append(_L("ERegisteredBusy\n"));
00110                         break;
00111                 case CTelephony::ERegisteredOnHomeNetwork:
00112                         theStatus.Append(_L("ERegisteredOnHomeNetwork\n"));
00113                         break;
00114                 case CTelephony::ERegistrationDenied:
00115                         theStatus.Append(_L("ERegistrationDenied\n"));
00116                         break;
00117                 case CTelephony::ERegisteredRoaming:
00118                         theStatus.Append(_L("ERegisteredRoaming\n"));
00119                         break;
00120                 default:
00121                         break;
00122                         }
00123                 iConsole->Printf(theStatus);
00124                 }
00125         if (iNetworkRegV1.iRegStatus == CTelephony::ERegisteredOnHomeNetwork)
00126                 {
00127                 ExampleNotify();
00128                 }
00129         else
00130                 {
00131                 RequestNotificationL();
00132                 }
00133         }
00134 
00139 void CNetworkRegInfo::DoRequestNotificationL()
00140         {
00141         // Panic if this object is already performing an asynchronous operation.
00142         // Application will panic if you call SetActive() on an already active object.
00143         _LIT( KNotifyPanic, "CNetworkReg Notify Method" );
00144         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00145         iRequestNotify = ETrue;
00146         
00147         // Registers interest in receiving change notifications for events.
00148         iTelephony->NotifyChange(       iStatus,
00149                                                                 CTelephony::ENetworkRegistrationStatusChange,
00150                                                                 iNetworkRegV1Pckg );
00151         SetActive();
00152         }
00153         
00157 void CNetworkRegInfo::DoCancel()
00158         {
00159         iRequestNotify = EFalse;
00160         
00161         // Cancels an outstanding asynchronous request
00162         iTelephony->CancelAsync(CTelephony::ENetworkRegistrationStatusChangeCancel);
00163         }

Generated by  doxygen 1.6.2