00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00055 iTelephony->GetCurrentNetworkInfo(iStatus, iCurrentNetworkInfoV1Pckg);
00056 SetActive();
00057 }
00058
00065 CCurrentNetworkInfo::CCurrentNetworkInfo(MExecAsync* aController)
00066 : CISVAPIAsync(aController, KNetworkInfo),
00067 iCurrentNetworkInfoV1Pckg(iCurrentNetworkInfoV1)
00068 {
00069
00070 }
00071
00075 void CCurrentNetworkInfo::ConstructL()
00076 {
00077
00078 }
00079
00084 void CCurrentNetworkInfo::RunL()
00085 {
00086 if(iStatus != KErrNone)
00087 {
00088 iConsole->Printf(KError);
00089
00090
00091 iConsole->Printf(_L("%d\n"), iStatus.Int());
00092 }
00093 else
00094 {
00095 TBuf<30> theStatus;
00096 if (iRequestNotify)
00097 {
00098 iConsole->ClearScreen();
00099 iConsole->Printf(_L("~*THIS IS A NOTIFICATION*~\n"));
00100 }
00101 iConsole->Printf(KNetworkInfoMsg);
00102 iConsole->Printf(iCurrentNetworkInfoV1.iDisplayTag);
00103 iConsole->Printf(KNewLine);
00104 switch (iCurrentNetworkInfoV1.iStatus)
00105 {
00106 case CTelephony::ENetworkStatusUnknown:
00107 theStatus.Append(_L("ENetworkStatusUnknown\n"));
00108 break;
00109 case CTelephony::ENetworkStatusAvailable:
00110 theStatus.Append(_L("ENetworkStatusUnavailable\n"));
00111 break;
00112 case CTelephony::ENetworkStatusCurrent:
00113 theStatus.Append(_L("ENetworkStatusCurrent\n"));
00114 break;
00115 case CTelephony::ENetworkStatusForbidden:
00116 theStatus.Append(_L("ENetworkStatusForbidden\n"));
00117 break;
00118 }
00119 iConsole->Printf(theStatus);
00120 if(iCurrentNetworkInfoV1.iAccess)
00121 {
00122
00123 iConsole->Printf((_L("The Cell Id is : %d\n")), iCurrentNetworkInfoV1.iCellId);
00124 iConsole->Printf((_L("The Area Code is : %d\n")), iCurrentNetworkInfoV1.iLocationAreaCode);
00125 }
00126 if (iRequestNotify)
00127 {
00128 RequestNotificationL();
00129 }
00130 else
00131 {
00132 ExampleComplete();
00133 }
00134 }
00135 }
00136
00140 void CCurrentNetworkInfo::DoRequestNotificationL()
00141 {
00142
00143
00144 _LIT( KNotifyPanic, "CCurrentNetworkInfo Notify Method" );
00145 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00146 iRequestNotify = ETrue;
00147
00148
00149 iTelephony->NotifyChange( iStatus,
00150 CTelephony::ECurrentNetworkInfoChange,
00151 iCurrentNetworkInfoV1Pckg );
00152 SetActive();
00153 }
00154
00158 void CCurrentNetworkInfo::DoCancel()
00159 {
00160 iRequestNotify = EFalse;
00161
00162
00163 iTelephony->CancelAsync(CTelephony::ECurrentNetworkInfoChangeCancel);
00164 }
00165