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 #include "CNetworkRegInfo.h" 00017 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 00037 CNetworkRegInfo::~CNetworkRegInfo() 00038 { 00039 Cancel(); 00040 } 00041 00045 void CNetworkRegInfo::DoStartRequestL() 00046 { 00047 iRequestNotify = EFalse; 00048 00049 // Retrieves the current network registration status. 00050 iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegV1Pckg); 00051 SetActive(); 00052 } 00053 00060 CNetworkRegInfo::CNetworkRegInfo(MExecAsync* aController) 00061 : CISVAPIAsync(aController, KNetworkRegInfo), 00062 iNetworkRegV1Pckg(iNetworkRegV1) 00063 { 00064 // Empty method 00065 } 00066 00070 void CNetworkRegInfo::ConstructL() 00071 { 00072 iRequestNotify = EFalse; 00073 } 00074 00078 void CNetworkRegInfo::RunL() 00079 { 00080 if(iStatus != KErrNone) 00081 { 00082 iConsole->Printf(KError); 00083 00084 // Print the error status code 00085 iConsole->Printf(_L("%d\n"), iStatus.Int()); 00086 } 00087 else 00088 { 00089 // There is no error, so display the current registration status to the 00090 // user. 00091 TBuf<30> theStatus; 00092 if(iRequestNotify) 00093 { 00094 iConsole->ClearScreen(); 00095 iConsole->Printf(_L("*~This is a notifcation\n~*")); 00096 } 00097 iConsole->Printf(KNetworkRegMsg); 00098 switch(iNetworkRegV1.iRegStatus) 00099 { 00100 case CTelephony::ERegistrationUnknown: 00101 theStatus.Append(_L("ERegistrationUnknown\n")); 00102 break; 00103 case CTelephony::ENotRegisteredNoService: 00104 theStatus.Append(_L("ENotRegisteredNoService\n")); 00105 break; 00106 case CTelephony::ENotRegisteredEmergencyOnly: 00107 theStatus.Append(_L("ENotRegisteredEmergencyOnly\n")); 00108 break; 00109 case CTelephony::ENotRegisteredSearching: 00110 theStatus.Append(_L("ENotRegisteredSearching\n")); 00111 break; 00112 case CTelephony::ERegisteredBusy: 00113 theStatus.Append(_L("ERegisteredBusy\n")); 00114 break; 00115 case CTelephony::ERegisteredOnHomeNetwork: 00116 theStatus.Append(_L("ERegisteredOnHomeNetwork\n")); 00117 break; 00118 case CTelephony::ERegistrationDenied: 00119 theStatus.Append(_L("ERegistrationDenied\n")); 00120 break; 00121 case CTelephony::ERegisteredRoaming: 00122 theStatus.Append(_L("ERegisteredRoaming\n")); 00123 break; 00124 default: 00125 break; 00126 } 00127 iConsole->Printf(theStatus); 00128 } 00129 if (iNetworkRegV1.iRegStatus == CTelephony::ERegisteredOnHomeNetwork) 00130 { 00131 ExampleNotify(); 00132 } 00133 else 00134 { 00135 RequestNotificationL(); 00136 } 00137 } 00138 00143 void CNetworkRegInfo::DoRequestNotificationL() 00144 { 00145 // Panic if this object is already performing an asynchronous operation. 00146 // Application will panic if you call SetActive() on an already active object. 00147 _LIT( KNotifyPanic, "CNetworkReg Notify Method" ); 00148 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); 00149 iRequestNotify = ETrue; 00150 00151 // Notify if there is any change 00152 iTelephony->NotifyChange(iStatus, 00153 CTelephony::ENetworkRegistrationStatusChange, 00154 iNetworkRegV1Pckg ); 00155 SetActive(); 00156 } 00157 00161 void CNetworkRegInfo::DoCancel() 00162 { 00163 iRequestNotify = EFalse; 00164 00165 // Cancels an outstanding asynchronous request. 00166 iTelephony->CancelAsync(CTelephony::ENetworkRegistrationStatusChangeCancel); 00167 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.