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 "CCurrentNetworkInfo.h" 00018 00026 CCurrentNetworkInfo* CCurrentNetworkInfo::NewL(MExecAsync* aController) 00027 { 00028 CCurrentNetworkInfo* self = new(ELeave) CCurrentNetworkInfo(aController); 00029 CleanupStack::PushL(self); 00030 self->ConstructL(); 00031 CleanupStack::Pop(self); 00032 return self; 00033 } 00034 00039 CCurrentNetworkInfo::~CCurrentNetworkInfo() 00040 { 00041 Cancel(); 00042 } 00043 00048 void CCurrentNetworkInfo::DoStartRequestL() 00049 { 00050 _LIT( KNotifyPanic, "CCurrentNetworkInfo Notify Method" ); 00051 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); 00052 iRequestNotify = EFalse; 00053 00054 // Retrieves over-the-air network information about the currently registered mobile network. 00055 iTelephony->GetCurrentNetworkInfo(iStatus, 00056 iCurrentNetworkInfoV1Pckg); 00057 SetActive(); 00058 } 00059 00066 CCurrentNetworkInfo::CCurrentNetworkInfo(MExecAsync* aController) 00067 : CISVAPIAsync(aController, KNetworkInfo), 00068 iCurrentNetworkInfoV1Pckg(iCurrentNetworkInfoV1) 00069 { 00070 // Empty method 00071 } 00072 00076 void CCurrentNetworkInfo::ConstructL() 00077 { 00078 // Empty method 00079 } 00080 00085 void CCurrentNetworkInfo::RunL() 00086 { 00087 if(iStatus != KErrNone) 00088 { 00089 iConsole->Printf(KError); 00090 00091 // Print the error status code 00092 iConsole->Printf(_L("%d\n"), iStatus.Int()); 00093 } 00094 else 00095 { 00096 TBuf<30> theStatus; 00097 if (iRequestNotify) 00098 { 00099 iConsole->ClearScreen(); 00100 iConsole->Printf(_L("~*THIS IS A NOTIFICATION*~\n")); 00101 } 00102 00103 // Print the console message if there is no error 00104 iConsole->Printf(KNetworkInfoMsg); 00105 iConsole->Printf(iCurrentNetworkInfoV1.iDisplayTag); 00106 iConsole->Printf(KNewLine); 00107 switch (iCurrentNetworkInfoV1.iStatus) 00108 { 00109 case CTelephony::ENetworkStatusUnknown: 00110 theStatus.Append(_L("ENetworkStatusUnknown\n")); 00111 break; 00112 case CTelephony::ENetworkStatusAvailable: 00113 theStatus.Append(_L("ENetworkStatusUnavailable\n")); 00114 break; 00115 case CTelephony::ENetworkStatusCurrent: 00116 theStatus.Append(_L("ENetworkStatusCurrent\n")); 00117 break; 00118 case CTelephony::ENetworkStatusForbidden: 00119 theStatus.Append(_L("ENetworkStatusForbidden\n")); 00120 break; 00121 } 00122 iConsole->Printf(theStatus); 00123 if(iCurrentNetworkInfoV1.iAccess) 00124 { 00125 iConsole->Printf((_L("The Cell Id is : %d\n")), 00126 iCurrentNetworkInfoV1.iCellId); 00127 iConsole->Printf((_L("The Area Code is : %d\n")), 00128 iCurrentNetworkInfoV1.iLocationAreaCode); 00129 } 00130 if (iRequestNotify) 00131 { 00132 ExampleNotify(); 00133 } 00134 else 00135 { 00136 ExampleComplete(); 00137 } 00138 } 00139 } 00140 00144 void CCurrentNetworkInfo::DoRequestNotificationL() 00145 { 00146 // Panics if this object is already performing an asynchronous operation. 00147 // Application will panic if you call SetActive() on an already active object. 00148 _LIT( KNotifyPanic, "CCurrentNetworkInfo Notify Method" ); 00149 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); 00150 iRequestNotify = ETrue; 00151 00152 // Registers interest in receiving change notifications for events. 00153 iTelephony->NotifyChange( iStatus, 00154 CTelephony::ECurrentNetworkInfoChange, 00155 iCurrentNetworkInfoV1Pckg ); 00156 SetActive(); 00157 } 00158 00162 void CCurrentNetworkInfo::DoCancel() 00163 { 00164 iRequestNotify = EFalse; 00165 00166 // Cancels an outstanding asynchronous request 00167 iTelephony->CancelAsync(CTelephony::ECurrentNetworkInfoChangeCancel); 00168 } 00169
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.