37
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 "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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <networkhandlingproxy.h>
|
|
19 |
#include <cnwsession.h>
|
|
20 |
#include <xqsettingsmanager.h>
|
|
21 |
#include <xqsettingskey.h>
|
|
22 |
#include <settingsinternalcrkeys.h>
|
|
23 |
#include "infowidgetnetworkhandler.h"
|
|
24 |
#include "infowidgetlogging.h"
|
|
25 |
|
|
26 |
|
|
27 |
/*!
|
|
28 |
\class InfoWidgetNetworkHandler
|
|
29 |
\brief Handles network specific functionality of
|
|
30 |
Operator info widget
|
|
31 |
*/
|
|
32 |
|
|
33 |
/*!
|
|
34 |
InfoWidgetNetworkHandler::InfoWidgetNetworkHandler()
|
|
35 |
*/
|
|
36 |
InfoWidgetNetworkHandler::InfoWidgetNetworkHandler(QObject *parent)
|
|
37 |
:
|
|
38 |
QObject(parent),
|
|
39 |
m_nwSession(0)
|
|
40 |
{
|
|
41 |
DPRINT << ": IN";
|
|
42 |
|
|
43 |
// Initialize key
|
|
44 |
// ToDo: need to check if preference is ON initially
|
|
45 |
enableMcn();
|
|
46 |
|
|
47 |
CNWSession *session = 0;
|
|
48 |
QT_TRAP_THROWING(session = CreateL(*this, m_nwInfo));
|
|
49 |
m_nwSession.reset(session);
|
|
50 |
|
|
51 |
DPRINT << ": OUT";
|
|
52 |
}
|
|
53 |
|
|
54 |
/*!
|
|
55 |
InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler()
|
|
56 |
*/
|
|
57 |
InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler()
|
|
58 |
{
|
|
59 |
DPRINT;
|
|
60 |
|
|
61 |
// Disable MCN setting,
|
|
62 |
// no display client
|
|
63 |
disableMcn();
|
|
64 |
}
|
|
65 |
|
|
66 |
/*!
|
|
67 |
InfoWidgetNetworkHandler::suspend()
|
|
68 |
*/
|
|
69 |
void InfoWidgetNetworkHandler::suspend()
|
|
70 |
{
|
|
71 |
DPRINT;
|
|
72 |
disableMcn();
|
|
73 |
}
|
|
74 |
|
|
75 |
/*!
|
|
76 |
InfoWidgetNetworkHandler::suspend()
|
|
77 |
*/
|
|
78 |
void InfoWidgetNetworkHandler::resume()
|
|
79 |
{
|
|
80 |
DPRINT;
|
|
81 |
enableMcn();
|
|
82 |
}
|
|
83 |
|
|
84 |
/*!
|
|
85 |
InfoWidgetNetworkHandler::serviceProviderName()
|
|
86 |
*/
|
|
87 |
QString InfoWidgetNetworkHandler::serviceProviderName() const
|
|
88 |
{
|
|
89 |
DPRINT;
|
|
90 |
QString qBuf;
|
|
91 |
qBuf = QString((QChar*)m_nwInfo.iSPName.Ptr(),
|
|
92 |
m_nwInfo.iSPName.Length());
|
|
93 |
DPRINT << ": serviceProviderName: " << qBuf;
|
|
94 |
|
|
95 |
return qBuf;
|
|
96 |
}
|
|
97 |
|
|
98 |
/*!
|
|
99 |
InfoWidgetNetworkHandler::serviceProviderNameDisplayRequired()
|
|
100 |
*/
|
|
101 |
bool InfoWidgetNetworkHandler::serviceProviderNameDisplayRequired() const
|
|
102 |
{
|
|
103 |
DPRINT;
|
|
104 |
bool displayRequired(true);
|
|
105 |
|
|
106 |
if (m_nwInfo.iServiceProviderNameDisplayReq ==
|
|
107 |
RMobilePhone::KDisplaySPNNotRequired) {
|
|
108 |
displayRequired = false;
|
|
109 |
}
|
|
110 |
DPRINT << ": serviceProviderNameDisplayRequired: " <<
|
|
111 |
displayRequired;
|
|
112 |
|
|
113 |
return displayRequired;
|
|
114 |
}
|
|
115 |
|
|
116 |
/*!
|
|
117 |
InfoWidgetNetworkHandler::homeZoneTextTag()
|
|
118 |
*/
|
|
119 |
QString InfoWidgetNetworkHandler::homeZoneTextTag() const
|
|
120 |
{
|
|
121 |
DPRINT;
|
|
122 |
QString qBuf;
|
|
123 |
qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(),
|
|
124 |
m_nwInfo.iViagTextTag.Length());
|
|
125 |
DPRINT << ": homeZoneTextTag: " << qBuf;
|
|
126 |
|
|
127 |
return qBuf;
|
|
128 |
}
|
|
129 |
|
|
130 |
/*!
|
|
131 |
InfoWidgetNetworkHandler::homeZoneIndicatorType()
|
|
132 |
*/
|
|
133 |
int InfoWidgetNetworkHandler::homeZoneIndicatorType() const
|
|
134 |
{
|
|
135 |
DPRINT;
|
|
136 |
int indicatorType = m_nwInfo.iViagIndicatorType;
|
|
137 |
DPRINT << ": homeZoneIndicatorType: " << indicatorType;
|
|
138 |
|
|
139 |
return indicatorType;
|
|
140 |
}
|
|
141 |
|
|
142 |
/*!
|
|
143 |
InfoWidgetNetworkHandler::enableMcn()
|
|
144 |
*/
|
|
145 |
void InfoWidgetNetworkHandler::enableMcn()
|
|
146 |
{
|
|
147 |
DPRINT;
|
|
148 |
if (!readMcnDisplayState()) {
|
|
149 |
DPRINT << ": enabling mcn display cenrep";
|
|
150 |
writeMcnDisplayState(true);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
/*!
|
|
155 |
InfoWidgetNetworkHandler::disableMcn()
|
|
156 |
*/
|
|
157 |
void InfoWidgetNetworkHandler::disableMcn()
|
|
158 |
{
|
|
159 |
DPRINT;
|
|
160 |
if (readMcnDisplayState()) {
|
|
161 |
DPRINT << ": disabling mcn display cenrep";
|
|
162 |
writeMcnDisplayState(false);
|
|
163 |
}
|
|
164 |
}
|
|
165 |
|
|
166 |
/*!
|
|
167 |
InfoWidgetNetworkHandler::mcnName()
|
|
168 |
*/
|
|
169 |
QString InfoWidgetNetworkHandler::mcnName() const
|
|
170 |
{
|
|
171 |
DPRINT;
|
|
172 |
QString qBuf;
|
|
173 |
qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(),
|
|
174 |
m_nwInfo.iMCNName.Length());
|
|
175 |
DPRINT << ": mcnName: " << qBuf;
|
|
176 |
|
|
177 |
return qBuf;
|
|
178 |
}
|
|
179 |
|
|
180 |
/*!
|
|
181 |
InfoWidgetNetworkHandler::mcnIndicatorType()
|
|
182 |
*/
|
|
183 |
int InfoWidgetNetworkHandler::mcnIndicatorType() const
|
|
184 |
{
|
|
185 |
DPRINT;
|
|
186 |
int indicatorType = m_nwInfo.iMCNIndicatorType;
|
|
187 |
DPRINT << ": mcnIndicatorType: " << indicatorType;
|
|
188 |
|
|
189 |
return indicatorType;
|
|
190 |
}
|
|
191 |
|
|
192 |
|
|
193 |
/*!
|
|
194 |
InfoWidgetNetworkHandler::networkRegistrationStatus()
|
|
195 |
*/
|
|
196 |
int InfoWidgetNetworkHandler::networkRegistrationStatus() const
|
|
197 |
{
|
|
198 |
DPRINT << ": registration status: " <<
|
|
199 |
static_cast<int>(m_nwInfo.iRegistrationStatus);
|
|
200 |
|
|
201 |
return static_cast<int>(m_nwInfo.iRegistrationStatus);
|
|
202 |
}
|
|
203 |
|
|
204 |
/*!
|
|
205 |
InfoWidgetNetworkHandler::isOnline()
|
|
206 |
|
|
207 |
Check if network registration status is registered and
|
|
208 |
return status accordingly
|
|
209 |
*/
|
|
210 |
bool InfoWidgetNetworkHandler::isOnline() const
|
|
211 |
{
|
|
212 |
bool online(false);
|
|
213 |
|
|
214 |
switch (networkRegistrationStatus()) {
|
|
215 |
case ENWRegisteredBusy: // Fall through
|
|
216 |
case ENWRegisteredOnHomeNetwork: // Fall through
|
|
217 |
case ENWRegisteredRoaming:
|
|
218 |
online = true;
|
|
219 |
break;
|
|
220 |
default:
|
|
221 |
break;
|
|
222 |
}
|
|
223 |
|
|
224 |
DPRINT << ": online: " << online;
|
|
225 |
return online;
|
|
226 |
}
|
|
227 |
|
|
228 |
/*!
|
|
229 |
InfoWidgetNetworkHandler::logCurrentInfo()
|
|
230 |
*/
|
|
231 |
void InfoWidgetNetworkHandler::logCurrentInfo()
|
|
232 |
{
|
|
233 |
DPRINT << ": IN";
|
|
234 |
|
|
235 |
QString qBuf;
|
|
236 |
DPRINT << "iMCNIndicatorType " << m_nwInfo.iMCNIndicatorType;
|
|
237 |
qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(),
|
|
238 |
m_nwInfo.iMCNName.Length());
|
|
239 |
DPRINT << "iMCNName " << qBuf;
|
|
240 |
|
|
241 |
qBuf = QString((QChar*)m_nwInfo.iSPName.Ptr(),m_nwInfo.iSPName.Length());
|
|
242 |
DPRINT << "iSPName " << qBuf;
|
|
243 |
DPRINT << "iServiceProviderNameDisplayReq "
|
|
244 |
<< m_nwInfo.iServiceProviderNameDisplayReq;
|
|
245 |
|
|
246 |
DPRINT << "iViagIndicatorType " << m_nwInfo.iViagIndicatorType;
|
|
247 |
qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(),
|
|
248 |
m_nwInfo.iViagTextTag.Length());
|
|
249 |
DPRINT << "iViagTextTag " << qBuf;
|
|
250 |
|
|
251 |
DPRINT << ": OUT";
|
|
252 |
}
|
|
253 |
|
|
254 |
/*!
|
|
255 |
InfoWidgetNetworkHandler::HandleNetworkMessage()
|
|
256 |
*/
|
|
257 |
void InfoWidgetNetworkHandler::HandleNetworkMessage(
|
|
258 |
const TNWMessages aMessage )
|
|
259 |
{
|
|
260 |
DPRINT << ": message: " << aMessage;
|
|
261 |
|
|
262 |
bool acceptedMessage = false;
|
|
263 |
switch (aMessage) {
|
|
264 |
case ENWMessageCurrentCellInfoMessage: // Fall through
|
|
265 |
case ENWMessageServiceProviderNameChange: // Fall through
|
|
266 |
case ENWMessageNetworkRegistrationStatusChange: // Fall through
|
|
267 |
acceptedMessage = true;
|
|
268 |
break;
|
|
269 |
default:
|
|
270 |
// not interesting message, filter out
|
|
271 |
DPRINT << ": message filtered out";
|
|
272 |
acceptedMessage = false;
|
|
273 |
}
|
|
274 |
|
|
275 |
if (acceptedMessage) {
|
|
276 |
int result = 0;
|
|
277 |
QT_TRYCATCH_ERROR(result, emit networkDataChanged());
|
|
278 |
if (0 != result) {
|
|
279 |
DPRINT << ": Exception occured while emitting signal:" << result;
|
|
280 |
}
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
/*!
|
|
285 |
InfoWidgetNetworkHandler::HandleNetworkError()
|
|
286 |
*/
|
|
287 |
void InfoWidgetNetworkHandler::HandleNetworkError(
|
|
288 |
const TNWOperation aOperation,
|
|
289 |
TInt aErrorCode )
|
|
290 |
{
|
|
291 |
DPRINT << ": operation: " << aOperation <<
|
|
292 |
" error code: " << aErrorCode;
|
|
293 |
|
|
294 |
// Reset invalid data
|
|
295 |
switch (aOperation) {
|
|
296 |
case MNWMessageObserver::ENWGetServiceProviderName:
|
|
297 |
m_nwInfo.iServiceProviderNameDisplayReq =
|
|
298 |
RMobilePhone::KDisplaySPNNotRequired;
|
|
299 |
m_nwInfo.iSPName.Zero();
|
|
300 |
break;
|
|
301 |
default:
|
|
302 |
break;
|
|
303 |
}
|
|
304 |
|
|
305 |
// Emit error signal
|
|
306 |
int result = 0;
|
|
307 |
QT_TRYCATCH_ERROR(result, emit networkError(
|
|
308 |
static_cast<int>(aOperation), static_cast<int>(aErrorCode)));
|
|
309 |
if (0 != result) {
|
|
310 |
DPRINT << ": Exception occured while emitting signal:" << result;
|
|
311 |
}
|
|
312 |
}
|
|
313 |
|
|
314 |
/*!
|
|
315 |
InfoWidgetNetworkHandler::writeMcnDisplayState()
|
|
316 |
|
|
317 |
Handler for cenrep key writing
|
|
318 |
*/
|
|
319 |
void InfoWidgetNetworkHandler::writeMcnDisplayState(bool enabled)
|
|
320 |
{
|
|
321 |
DPRINT << ": IN";
|
|
322 |
|
|
323 |
XQSettingsManager *settingsManager = new XQSettingsManager(0);
|
|
324 |
XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository,
|
|
325 |
KCRUidNetworkSettings.iUid, KSettingsMcnDisplay);
|
|
326 |
int value;
|
|
327 |
if (enabled) {
|
|
328 |
value = 1;
|
|
329 |
} else {
|
|
330 |
value = 0;
|
|
331 |
}
|
|
332 |
bool result = settingsManager->writeItemValue(settingsKey, value );
|
|
333 |
delete settingsManager;
|
|
334 |
|
|
335 |
DPRINT << ": OUT";
|
|
336 |
}
|
|
337 |
|
|
338 |
/*!
|
|
339 |
InfoWidgetNetworkHandler::readMcnDisplayState()
|
|
340 |
*/
|
|
341 |
bool InfoWidgetNetworkHandler::readMcnDisplayState()
|
|
342 |
{
|
|
343 |
DPRINT << ": IN";
|
|
344 |
bool mcnDisplayKeyOn(false);
|
|
345 |
|
|
346 |
XQSettingsManager *settingsManager = new XQSettingsManager(0);
|
|
347 |
XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository,
|
|
348 |
KCRUidNetworkSettings.iUid, KSettingsMcnDisplay);
|
|
349 |
bool conversionOk(false);
|
|
350 |
int value = settingsManager->readItemValue(
|
|
351 |
settingsKey,
|
|
352 |
XQSettingsManager::TypeInt).toInt(&conversionOk);
|
|
353 |
|
|
354 |
if (conversionOk && value == 1) {
|
|
355 |
mcnDisplayKeyOn = true;
|
|
356 |
}
|
|
357 |
delete settingsManager;
|
|
358 |
|
|
359 |
DPRINT << ": OUT";
|
|
360 |
return mcnDisplayKeyOn;
|
|
361 |
}
|
|
362 |
|
|
363 |
|
|
364 |
// End of File.
|