5
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: tsysinfocurrentnetworknotify
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "tsysinfonetworktests.h"
|
|
21 |
#include "sysinfoservice.h"
|
|
22 |
#include "entitykeys.h"
|
|
23 |
#include "tsysinfocurrentnetworknotify.h"
|
|
24 |
|
|
25 |
using namespace SysInfo;
|
|
26 |
|
|
27 |
CCurrentNetNotify* CCurrentNetNotify::NewL(CStifLogger* aLog)
|
|
28 |
{
|
|
29 |
CCurrentNetNotify* self = new(ELeave) CCurrentNetNotify(aLog);
|
|
30 |
self->ConstructL();
|
|
31 |
return self;
|
|
32 |
}
|
|
33 |
|
|
34 |
CCurrentNetNotify::~CCurrentNetNotify()
|
|
35 |
{
|
|
36 |
Cancel();
|
|
37 |
|
|
38 |
if(iWaitSchedular->IsStarted())
|
|
39 |
iWaitSchedular->AsyncStop();
|
|
40 |
|
|
41 |
delete iSysInfoService;
|
|
42 |
delete iWaitSchedular;
|
|
43 |
delete iTimer;
|
|
44 |
}
|
|
45 |
|
|
46 |
void CCurrentNetNotify::ConstructL()
|
|
47 |
{
|
|
48 |
iSysInfoService = CSysInfoService::NewL();
|
|
49 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait();
|
|
50 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this);
|
|
51 |
CActiveScheduler::Add(this);
|
|
52 |
}
|
|
53 |
|
|
54 |
CCurrentNetNotify::CCurrentNetNotify(CStifLogger* aLog)
|
|
55 |
:CActive(EPriorityStandard),
|
|
56 |
iLog(aLog)
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
void CCurrentNetNotify::DoCancel()
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
void CCurrentNetNotify::RunL()
|
|
65 |
{
|
|
66 |
TestFuncL();
|
|
67 |
}
|
|
68 |
|
|
69 |
void CCurrentNetNotify::Start()
|
|
70 |
{
|
|
71 |
SetActive();
|
|
72 |
TRequestStatus* temp = &iStatus;
|
|
73 |
User::RequestComplete(temp, KErrNone);
|
|
74 |
iWaitSchedular->Start();
|
|
75 |
}
|
|
76 |
|
|
77 |
TInt CCurrentNetNotify::Result()
|
|
78 |
{
|
|
79 |
return iResult;
|
|
80 |
}
|
|
81 |
|
|
82 |
void CCurrentNetNotify::TestFuncL()
|
|
83 |
{
|
45
|
84 |
TInt64 x = 6000000000;
|
|
85 |
const TTimeIntervalMicroSeconds32 OneMinute = TTimeIntervalMicroSeconds32(x);
|
5
|
86 |
iTransId = 6666;
|
|
87 |
TRAPD(err,iSysInfoService->GetNotificationL(KNetwork,KCurrentNetwork,iTransId,this));
|
|
88 |
iResult = err;
|
|
89 |
iTimer->After(OneMinute);
|
|
90 |
}
|
|
91 |
|
|
92 |
void CCurrentNetNotify::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
|
|
93 |
CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType /*aType*/,TInt aError)
|
|
94 |
{
|
|
95 |
|
|
96 |
iLog->Log(_L("CurrentNetwork read..."));
|
|
97 |
|
|
98 |
if(!aError)
|
|
99 |
{
|
|
100 |
if(aTransID ==iTransId )
|
|
101 |
{
|
|
102 |
TInt32 tid = aTransID;
|
|
103 |
CNetworkInfo* networkInfo= ((CNetworkInfo*)aOutput);
|
|
104 |
|
|
105 |
TPtrC networkName = networkInfo->NetworkName();
|
|
106 |
iLog->Log(_L("Network name..."));
|
|
107 |
iLog->Log(networkName);
|
|
108 |
|
|
109 |
|
|
110 |
TInt networkMode =networkInfo->NetworkMode();
|
|
111 |
iLog->Log(_L("Network mode..."));
|
|
112 |
TBuf<50> buf;
|
|
113 |
buf.AppendNum(networkMode);
|
|
114 |
iLog->Log(buf);
|
|
115 |
|
|
116 |
TInt networkStatus = networkInfo->NetworkStatus();
|
|
117 |
iLog->Log(_L("Network Status..."));
|
|
118 |
buf.Zero();
|
|
119 |
buf.AppendNum(networkStatus);
|
|
120 |
iLog->Log(buf);
|
|
121 |
|
|
122 |
TPtrC countryCode = networkInfo->CountryCode();
|
|
123 |
iLog->Log(_L("Country Code..."));
|
|
124 |
buf.Zero();
|
|
125 |
buf.Copy(countryCode);
|
|
126 |
iLog->Log(buf);
|
|
127 |
|
|
128 |
TPtrC networkCode = networkInfo->NetworkCode();
|
|
129 |
iLog->Log(_L("Network Code..."));
|
|
130 |
buf.Zero();
|
|
131 |
buf.Copy(networkCode);
|
|
132 |
iLog->Log(buf);
|
|
133 |
|
|
134 |
TUint locationAreaCode =networkInfo->LocationAreaCode();
|
|
135 |
iLog->Log(_L("Location Area Code..."));
|
|
136 |
buf.Zero();
|
|
137 |
buf.AppendNum(locationAreaCode);
|
|
138 |
iLog->Log(buf);
|
|
139 |
|
|
140 |
TUint cellId = networkInfo->CellId();
|
|
141 |
iLog->Log(_L("CellId..."));
|
|
142 |
buf.Zero();
|
|
143 |
buf.AppendNum(cellId);
|
|
144 |
iLog->Log(buf);
|
|
145 |
|
|
146 |
TBool validLocationAreaCode = networkInfo->ValidLocationAreaCode();
|
|
147 |
iLog->Log(_L("ValidLocationAreaCode..."));
|
|
148 |
buf.Zero();
|
|
149 |
buf.AppendNum(validLocationAreaCode);
|
|
150 |
iLog->Log(buf);
|
|
151 |
|
|
152 |
|
|
153 |
iResult = PASS;
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
else
|
|
158 |
{
|
|
159 |
iResult = PASS;
|
|
160 |
|
|
161 |
}
|
|
162 |
}
|
|
163 |
else
|
|
164 |
{
|
|
165 |
iLog->Log(_L("ERROR SET"));
|
|
166 |
iResult = FAIL;
|
|
167 |
}
|
|
168 |
delete aOutput;
|
|
169 |
iWaitSchedular->AsyncStop();
|
|
170 |
}
|
|
171 |
|
|
172 |
void CCurrentNetNotify::HandleTimeOut()
|
|
173 |
{
|
|
174 |
iLog->Log(_L("TimeOut reached..."));
|
|
175 |
iSysInfoService->Cancel(1);
|
|
176 |
iResult = FAIL;
|
|
177 |
iWaitSchedular->AsyncStop();
|
|
178 |
}
|
|
179 |
|
|
180 |
|
|
181 |
|