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,
00056 iCurrentNetworkInfoV1Pckg);
00057 SetActive();
00058 }
00059
00066 CCurrentNetworkInfo::CCurrentNetworkInfo(MExecAsync* aController)
00067 : CISVAPIAsync(aController, KNetworkInfo),
00068 iCurrentNetworkInfoV1Pckg(iCurrentNetworkInfoV1)
00069 {
00070
00071 }
00072
00076 void CCurrentNetworkInfo::ConstructL()
00077 {
00078
00079 }
00080
00085 void CCurrentNetworkInfo::RunL()
00086 {
00087 if(iStatus != KErrNone)
00088 {
00089 iConsole->Printf(KError);
00090
00091
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
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
00147
00148 _LIT( KNotifyPanic, "CCurrentNetworkInfo Notify Method" );
00149 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00150 iRequestNotify = ETrue;
00151
00152
00153 iTelephony->NotifyChange( iStatus,
00154 CTelephony::ECurrentNetworkInfoChange,
00155 iCurrentNetworkInfoV1Pckg );
00156 SetActive();
00157 }
00158
00162 void CCurrentNetworkInfo::DoCancel()
00163 {
00164 iRequestNotify = EFalse;
00165
00166
00167 iTelephony->CancelAsync(CTelephony::ECurrentNetworkInfoChangeCancel);
00168 }
00169