15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <networkhandlingproxy.h> |
18 #include <networkhandlingproxy.h> |
19 #include <cnwsession.h> |
19 #include <cnwsession.h> |
|
20 #include <xqsettingsmanager.h> |
|
21 #include <xqsettingskey.h> |
|
22 #include <settingsinternalcrkeys.h> |
20 #include "infowidgetnetworkhandler.h" |
23 #include "infowidgetnetworkhandler.h" |
21 #include "infowidgetlogging.h" |
24 #include "infowidgetlogging.h" |
22 |
25 |
23 |
26 |
24 /*! |
27 /*! |
25 * InfoWidgetNetworkHandler::InfoWidgetNetworkHandler |
28 \class InfoWidgetNetworkHandler |
26 */ |
29 \brief Handles network specific functionality of |
|
30 Operator info widget |
|
31 */ |
|
32 |
|
33 /*! |
|
34 InfoWidgetNetworkHandler::InfoWidgetNetworkHandler() |
|
35 */ |
27 InfoWidgetNetworkHandler::InfoWidgetNetworkHandler(QObject *parent) |
36 InfoWidgetNetworkHandler::InfoWidgetNetworkHandler(QObject *parent) |
28 : |
37 : |
29 QObject(parent), |
38 QObject(parent), |
30 m_nwSession(0) |
39 m_nwSession(0) |
31 { |
40 { |
32 DPRINT << ": IN"; |
41 DPRINT << ": IN"; |
33 |
42 |
|
43 // Initialize key |
|
44 // ToDo: need to check if preference is ON initially |
|
45 enableMcn(); |
|
46 |
34 CNWSession *session = 0; |
47 CNWSession *session = 0; |
35 QT_TRAP_THROWING(session = CreateL(*this, m_nwInfo)); |
48 QT_TRAP_THROWING(session = CreateL(*this, m_nwInfo)); |
36 m_nwSession.reset(session); |
49 m_nwSession.reset(session); |
37 |
50 |
38 DPRINT << ": OUT"; |
51 DPRINT << ": OUT"; |
39 } |
52 } |
40 |
53 |
41 /*! |
54 /*! |
42 * InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler |
55 InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler() |
43 */ |
56 */ |
44 InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler() |
57 InfoWidgetNetworkHandler::~InfoWidgetNetworkHandler() |
45 { |
58 { |
46 DPRINT << ": IN"; |
59 DPRINT; |
47 |
60 |
48 DPRINT << ": OUT"; |
61 // Disable MCN setting, |
|
62 // no display client |
|
63 disableMcn(); |
49 } |
64 } |
50 |
65 |
51 /*! |
66 /*! |
52 * InfoWidgetNetworkHandler::homeZoneTextTag |
67 InfoWidgetNetworkHandler::suspend() |
53 */ |
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 */ |
54 QString InfoWidgetNetworkHandler::homeZoneTextTag() const |
119 QString InfoWidgetNetworkHandler::homeZoneTextTag() const |
55 { |
120 { |
56 DPRINT; |
121 DPRINT; |
57 QString qBuf; |
122 QString qBuf; |
58 qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(), |
123 qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(), |
61 |
126 |
62 return qBuf; |
127 return qBuf; |
63 } |
128 } |
64 |
129 |
65 /*! |
130 /*! |
66 * InfoWidgetNetworkHandler::homeZoneIndicatorType |
131 InfoWidgetNetworkHandler::homeZoneIndicatorType() |
67 */ |
132 */ |
68 int InfoWidgetNetworkHandler::homeZoneIndicatorType() const |
133 int InfoWidgetNetworkHandler::homeZoneIndicatorType() const |
69 { |
134 { |
70 DPRINT; |
135 DPRINT; |
71 int indicatorType = m_nwInfo.iViagIndicatorType; |
136 int indicatorType = m_nwInfo.iViagIndicatorType; |
72 DPRINT << ": homeZoneIndicatorType: " << indicatorType; |
137 DPRINT << ": homeZoneIndicatorType: " << indicatorType; |
73 |
138 |
74 return indicatorType; |
139 return indicatorType; |
75 } |
140 } |
76 |
141 |
77 /*! |
142 /*! |
78 * InfoWidgetNetworkHandler::mcnName |
143 InfoWidgetNetworkHandler::enableMcn() |
79 */ |
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 */ |
80 QString InfoWidgetNetworkHandler::mcnName() const |
169 QString InfoWidgetNetworkHandler::mcnName() const |
81 { |
170 { |
82 DPRINT; |
171 DPRINT; |
83 QString qBuf; |
172 QString qBuf; |
84 qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(), |
173 qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(), |
87 |
176 |
88 return qBuf; |
177 return qBuf; |
89 } |
178 } |
90 |
179 |
91 /*! |
180 /*! |
92 * InfoWidgetNetworkHandler::mcnIndicatorType |
181 InfoWidgetNetworkHandler::mcnIndicatorType() |
93 */ |
182 */ |
94 int InfoWidgetNetworkHandler::mcnIndicatorType() const |
183 int InfoWidgetNetworkHandler::mcnIndicatorType() const |
95 { |
184 { |
96 DPRINT; |
185 DPRINT; |
97 int indicatorType = m_nwInfo.iMCNIndicatorType; |
186 int indicatorType = m_nwInfo.iMCNIndicatorType; |
98 DPRINT << ": mcnIndicatorType: " << indicatorType; |
187 DPRINT << ": mcnIndicatorType: " << indicatorType; |
99 |
188 |
100 return indicatorType; |
189 return indicatorType; |
101 } |
190 } |
102 |
191 |
103 /*! |
192 |
104 * InfoWidgetNetworkHandler::logCurrentInfo |
193 /*! |
105 */ |
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 */ |
106 void InfoWidgetNetworkHandler::logCurrentInfo() |
231 void InfoWidgetNetworkHandler::logCurrentInfo() |
107 { |
232 { |
108 DPRINT << ": IN"; |
233 DPRINT << ": IN"; |
109 |
234 |
110 DPRINT << "iRegistrationStatus " << m_nwInfo.iRegistrationStatus; |
|
111 DPRINT << "iNetworkMode " << m_nwInfo.iNetworkMode; |
|
112 DPRINT << "iStatus " << m_nwInfo.iStatus; |
|
113 QString qBuf; |
235 QString qBuf; |
114 |
236 DPRINT << "iMCNIndicatorType " << m_nwInfo.iMCNIndicatorType; |
115 qBuf = QString((QChar*)m_nwInfo.iCountryCode.Ptr(), |
237 qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(), |
116 m_nwInfo.iCountryCode.Length()); |
238 m_nwInfo.iMCNName.Length()); |
117 DPRINT << "iCountryCode " << qBuf; |
239 DPRINT << "iMCNName " << qBuf; |
118 |
240 |
119 qBuf = QString((QChar*)m_nwInfo.iNetworkId.Ptr(), |
241 qBuf = QString((QChar*)m_nwInfo.iSPName.Ptr(),m_nwInfo.iSPName.Length()); |
120 m_nwInfo.iNetworkId.Length()); |
242 DPRINT << "iSPName " << qBuf; |
121 DPRINT << "iNetworkId " << qBuf; |
243 DPRINT << "iServiceProviderNameDisplayReq " |
122 |
244 << m_nwInfo.iServiceProviderNameDisplayReq; |
123 qBuf = QString((QChar*)m_nwInfo.iDisplayTag.Ptr(), |
|
124 m_nwInfo.iDisplayTag.Length()); |
|
125 DPRINT << "iDisplayTag " << qBuf; |
|
126 |
|
127 qBuf = QString((QChar*)m_nwInfo.iShortName.Ptr(), |
|
128 m_nwInfo.iShortName.Length()); |
|
129 DPRINT << "iShortName " << qBuf; |
|
130 |
|
131 qBuf = QString((QChar*)m_nwInfo.iLongName.Ptr(), |
|
132 m_nwInfo.iLongName.Length()); |
|
133 DPRINT << "iLongName " << qBuf; |
|
134 |
245 |
135 DPRINT << "iViagIndicatorType " << m_nwInfo.iViagIndicatorType; |
246 DPRINT << "iViagIndicatorType " << m_nwInfo.iViagIndicatorType; |
136 |
|
137 qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(), |
247 qBuf = QString((QChar*)m_nwInfo.iViagTextTag.Ptr(), |
138 m_nwInfo.iViagTextTag.Length()); |
248 m_nwInfo.iViagTextTag.Length()); |
139 DPRINT << "iViagTextTag " << qBuf; |
249 DPRINT << "iViagTextTag " << qBuf; |
140 |
250 |
141 DPRINT << "iMCNIndicatorType " << m_nwInfo.iMCNIndicatorType; |
|
142 |
|
143 qBuf = QString((QChar*)m_nwInfo.iMCNName.Ptr(), |
|
144 m_nwInfo.iMCNName.Length()); |
|
145 DPRINT << "iMCNName " << qBuf; |
|
146 |
|
147 qBuf = QString((QChar*)m_nwInfo.iSPName.Ptr(),m_nwInfo.iSPName.Length()); |
|
148 DPRINT << "iSPName " << qBuf; |
|
149 |
|
150 DPRINT << "iServiceProviderNameDisplayReq " |
|
151 << m_nwInfo.iServiceProviderNameDisplayReq; |
|
152 |
|
153 qBuf = QString((QChar*)m_nwInfo.iNPName.Ptr(), m_nwInfo.iNPName.Length()); |
|
154 DPRINT << "iNPName " << qBuf; |
|
155 |
|
156 qBuf = QString((QChar*)m_nwInfo.iOperatorNameInfo.iName.Ptr(), |
|
157 m_nwInfo.iOperatorNameInfo.iName.Length()); |
|
158 DPRINT << "iOperatorNameInfo iName" << qBuf; |
|
159 DPRINT << "iOperatorNameInfo iType" << m_nwInfo.iOperatorNameInfo.iType; |
|
160 |
|
161 DPRINT << "iNoServerMode " << m_nwInfo.iNoServerMode; |
|
162 |
|
163 DPRINT << "iVoicePrivacyStatus " << m_nwInfo.iVoicePrivacyStatus; |
|
164 |
|
165 qBuf = QString((QChar*)m_nwInfo.iPLMNField.Ptr(), |
|
166 m_nwInfo.iPLMNField.Length()); |
|
167 DPRINT << "iPLMNField " << qBuf; |
|
168 |
|
169 DPRINT << ": OUT"; |
251 DPRINT << ": OUT"; |
170 } |
252 } |
171 |
253 |
172 /*! |
254 /*! |
173 * InfoWidgetNetworkHandler::HandleNetworkMessage |
255 InfoWidgetNetworkHandler::HandleNetworkMessage() |
174 */ |
256 */ |
175 void InfoWidgetNetworkHandler::HandleNetworkMessage( |
257 void InfoWidgetNetworkHandler::HandleNetworkMessage( |
176 const TNWMessages aMessage ) |
258 const TNWMessages aMessage ) |
177 { |
259 { |
178 DPRINT << ": message: " << aMessage; |
260 DPRINT << ": message: " << aMessage; |
179 |
261 |
180 bool acceptedMessage = false; |
262 bool acceptedMessage = false; |
181 switch (aMessage) { |
263 switch (aMessage) { |
182 case ENWMessageCurrentCellInfoMessage: |
264 case ENWMessageCurrentCellInfoMessage: // Fall through |
|
265 case ENWMessageServiceProviderNameChange: // Fall through |
|
266 case ENWMessageNetworkRegistrationStatusChange: // Fall through |
183 acceptedMessage = true; |
267 acceptedMessage = true; |
184 break; |
268 break; |
185 default: |
269 default: |
186 // not interesting message, filter out |
270 // not interesting message, filter out |
187 DPRINT << ": message filtered out"; |
271 DPRINT << ": message filtered out"; |
196 } |
280 } |
197 } |
281 } |
198 } |
282 } |
199 |
283 |
200 /*! |
284 /*! |
201 * InfoWidgetNetworkHandler::HandleNetworkError |
285 InfoWidgetNetworkHandler::HandleNetworkError() |
202 */ |
286 */ |
203 void InfoWidgetNetworkHandler::HandleNetworkError( |
287 void InfoWidgetNetworkHandler::HandleNetworkError( |
204 const TNWOperation aOperation, |
288 const TNWOperation aOperation, |
205 TInt aErrorCode ) |
289 TInt aErrorCode ) |
206 { |
290 { |
207 DPRINT << ": operation: " << aOperation << |
291 DPRINT << ": operation: " << aOperation << |
208 " error code: " << aErrorCode; |
292 " error code: " << aErrorCode; |
209 |
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 |
210 int result = 0; |
306 int result = 0; |
211 QT_TRYCATCH_ERROR(result, emit networkError( |
307 QT_TRYCATCH_ERROR(result, emit networkError( |
212 static_cast<int>(aOperation), static_cast<int>(aErrorCode))); |
308 static_cast<int>(aOperation), static_cast<int>(aErrorCode))); |
213 if (0 != result) { |
309 if (0 != result) { |
214 DPRINT << ": Exception occured while emitting signal:" << result; |
310 DPRINT << ": Exception occured while emitting signal:" << result; |
215 } |
311 } |
216 } |
312 } |
217 |
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 |
218 // End of File. |
364 // End of File. |