|
1 /* |
|
2 * Copyright (c) 2009-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: Qt wrapper class implementation for CIRReportGenerator |
|
15 * |
|
16 */ |
|
17 #include <e32cmn.h> |
|
18 #include "irsessionlogger.h" // CIRReportGenerator |
|
19 #include "irqisdsclient.h" |
|
20 #include "irqsettings.h" |
|
21 #include "irqnetworkcontroller.h" |
|
22 #include "irreportsettings.h" |
|
23 #include "irqnwkinfoobserver.h" |
|
24 #include "irqstatisticsreporter_symbian_p.h" |
|
25 #include "irqnetworkcontroller.h" |
|
26 #include "irqlogger.h" |
|
27 |
|
28 //Network Indicator |
|
29 _LIT(KGPRS,"gprs"); |
|
30 _LIT(KWCDMA,"wcdma"); |
|
31 _LIT(KWLAN,"wlan"); |
|
32 _LIT(KCDMA2000,"cdma2000"); |
|
33 _LIT(KEDGE,"edge"); |
|
34 |
|
35 //Music Shop Type |
|
36 _LIT(KFind,"find"); |
|
37 _LIT(KLaunch,"launch"); |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Constructor. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 IRQStatisticsReporterPrivate::IRQStatisticsReporterPrivate():mBody(NULL), |
|
44 mIsdsClient(NULL), |
|
45 mNwkController(NULL), |
|
46 mNwkInfoObserver(NULL), |
|
47 mSessionOngoing(false) |
|
48 { |
|
49 |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Destructor. |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 IRQStatisticsReporterPrivate::~IRQStatisticsReporterPrivate() |
|
57 { |
|
58 if(mBody) |
|
59 { |
|
60 mBody->SetDbStatusObserser(NULL); |
|
61 mBody->Close(); |
|
62 } |
|
63 |
|
64 if(mIsdsClient) |
|
65 { |
|
66 mIsdsClient->closeInstance(); |
|
67 } |
|
68 |
|
69 if(mNwkController) |
|
70 { |
|
71 mNwkController->closeInstance(); |
|
72 } |
|
73 |
|
74 if(mNwkInfoObserver) |
|
75 { |
|
76 mNwkInfoObserver->closeInstance(); |
|
77 } |
|
78 } |
|
79 |
|
80 bool IRQStatisticsReporterPrivate::init() |
|
81 { |
|
82 if(NULL == mBody) |
|
83 { |
|
84 TRAP_IGNORE( mBody = CIRReportGenerator::OpenL()); |
|
85 if(mBody) |
|
86 { |
|
87 mBody->SetDbStatusObserser(this); |
|
88 } |
|
89 } |
|
90 |
|
91 if(NULL == mIsdsClient) |
|
92 { |
|
93 mIsdsClient = IRQIsdsClient::openInstance(); |
|
94 } |
|
95 |
|
96 if(NULL == mNwkController) |
|
97 { |
|
98 mNwkController = IRQNetworkController::openInstance(); |
|
99 } |
|
100 |
|
101 |
|
102 IRQSettings *settingManager = IRQSettings::openInstance(); |
|
103 if(settingManager) |
|
104 { |
|
105 QString logFilePath = settingManager->privatePath(); |
|
106 QString logFileName = QString::fromUtf16(KGZipLogFileName().Ptr(), KGZipLogFileName().Length()); |
|
107 iLogFile = logFilePath + logFileName; |
|
108 settingManager->closeInstance(); |
|
109 } |
|
110 |
|
111 |
|
112 if(NULL == mNwkInfoObserver) |
|
113 { |
|
114 mNwkInfoObserver = IRQNwkInfoObserver::openInstance(); |
|
115 startMonitoringNwkInfo(); |
|
116 } |
|
117 |
|
118 if( mBody |
|
119 && mIsdsClient |
|
120 && mNwkController |
|
121 && mNwkInfoObserver |
|
122 && !iLogFile.isEmpty()) |
|
123 { |
|
124 return true; |
|
125 } |
|
126 else |
|
127 { |
|
128 return true; |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // marks the start of a session |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void IRQStatisticsReporterPrivate::markSessionStart() |
|
137 { |
|
138 if(mBody && mSessionOngoing) |
|
139 { |
|
140 mBody->MarkSessionStart(); |
|
141 } |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // starts a new session |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void IRQStatisticsReporterPrivate::sessionStarted(const int aChanneldId, |
|
149 const IRQStatisticsReporter::IRConnectedFrom aConnectedFrom) |
|
150 { |
|
151 if(!mSessionOngoing) |
|
152 { |
|
153 if(mBody) |
|
154 { |
|
155 updateConnectedFrom(aConnectedFrom); |
|
156 mBody->UpdateChannelID(aChanneldId); |
|
157 updateConnectionType(); |
|
158 |
|
159 TRAPD(error,mBody->SessionStartedL()); |
|
160 if(KErrNone == error) |
|
161 { |
|
162 mSessionOngoing = true; |
|
163 } |
|
164 } |
|
165 } |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // function handle session suspend |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void IRQStatisticsReporterPrivate::suspendSession() |
|
173 { |
|
174 if(mBody && mSessionOngoing) |
|
175 { |
|
176 mBody->HandleStopEvents(EFalse); |
|
177 } |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // function handle session restart |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void IRQStatisticsReporterPrivate::restartSession() |
|
185 { |
|
186 if(mBody && mSessionOngoing) |
|
187 { |
|
188 mBody->HandleStopEvents(ETrue); |
|
189 } |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // ends the session |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void IRQStatisticsReporterPrivate::sessionEnded(const IRQStatisticsReporter::IRTerminatedType aTerminatedBy) |
|
197 { |
|
198 if(mBody && mSessionOngoing) |
|
199 { |
|
200 updateTerminatedBy(aTerminatedBy); |
|
201 TRAP_IGNORE(mBody->SessionEndL(EFalse)); |
|
202 } |
|
203 mSessionOngoing = false; |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // logs server connection result |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void IRQStatisticsReporterPrivate::logServerResult(const QString& aUrl, |
|
211 const IRQStatisticsReporter::IRServerResult aServerResult) |
|
212 { |
|
213 if(mBody && mSessionOngoing) |
|
214 { |
|
215 TPtrC url(reinterpret_cast<const TUint16*>(aUrl.utf16())); |
|
216 switch(aServerResult) |
|
217 { |
|
218 case IRQStatisticsReporter::EIRConnected: |
|
219 mBody->LogServerResult(url,EIRConnected); |
|
220 break; |
|
221 case IRQStatisticsReporter::EIRServerFull: |
|
222 mBody->LogServerResult(url,EIRFull); |
|
223 break; |
|
224 case IRQStatisticsReporter::EIRTimeOut: |
|
225 mBody->LogServerResult(url,EIRConnTimeOut); |
|
226 break; |
|
227 case IRQStatisticsReporter::EIRConnectFailed: |
|
228 mBody->LogServerResult(url,EIRConnFailed); |
|
229 break; |
|
230 default: |
|
231 mBody->LogServerResult(url,EIRConnFailed); |
|
232 break; |
|
233 } |
|
234 } |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // logs nmsEvents to Xml file |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void IRQStatisticsReporterPrivate::logNmsEvent(const IRQStatisticsReporter::IRNmsType aNmsType, |
|
242 const int aChanneldId) |
|
243 { |
|
244 TRAP_IGNORE(doLogNmsEventL(aNmsType,aChanneldId)); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // logs nmsEvents to Xml file |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 void IRQStatisticsReporterPrivate::doLogNmsEventL(const IRQStatisticsReporter::IRNmsType aNmsType, |
|
252 const int aChanneldId) |
|
253 { |
|
254 if(mBody) |
|
255 { |
|
256 updateNmsType(aNmsType); |
|
257 mBody->UpdateNmsChannelID(aChanneldId); |
|
258 mBody->NmsLogStartedL(); |
|
259 mBody->WriteNmsLogtoXmlL(); |
|
260 } |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // logs songRecog event to Xml file |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 void IRQStatisticsReporterPrivate::logSongRecogEvent() |
|
268 { |
|
269 if(mBody && mSessionOngoing) |
|
270 { |
|
271 mBody->LogSongRecog(); |
|
272 } |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // updates the current network |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void IRQStatisticsReporterPrivate::updateCurrentNetwork(const QString &aCurrentNwkMCC, |
|
280 const QString &aCurrentNwkMNC) |
|
281 { |
|
282 QString nwkCode = aCurrentNwkMCC + aCurrentNwkMNC; |
|
283 if(mBody) |
|
284 { |
|
285 mBody->UpdateCurrentNetwork(nwkCode.toInt()); |
|
286 mBody->UpdateCurrentBrowseNetwork(nwkCode.toInt()); |
|
287 mBody->UpdateNmsCurrentNetwork(nwkCode.toInt()); |
|
288 } |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // updates the home network |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void IRQStatisticsReporterPrivate::updateHomeOperator(const QString &aHomeNetworkMCC, |
|
296 const QString &aHomeNetworkMNC) |
|
297 { |
|
298 QString nwkCode = aHomeNetworkMCC + aHomeNetworkMNC; |
|
299 if(mBody) |
|
300 { |
|
301 mBody->UpdateHomeOperator(nwkCode.toInt()); |
|
302 mBody->UpdateNmsHomeOperator(nwkCode.toInt()); |
|
303 } |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // updates the termination status |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void IRQStatisticsReporterPrivate::updateTerminatedBy(const IRQStatisticsReporter::IRTerminatedType aTerminatedBy) |
|
311 { |
|
312 if(mBody) |
|
313 { |
|
314 switch(aTerminatedBy) |
|
315 { |
|
316 case IRQStatisticsReporter::EIRUserTerminated: |
|
317 mBody->UpdateTerminatedBy(EUserTerminated); |
|
318 break; |
|
319 case IRQStatisticsReporter::EIRNoConnToServer: |
|
320 mBody->UpdateTerminatedBy(ENoConnectionToServer); |
|
321 break; |
|
322 case IRQStatisticsReporter::EIRNoConnToNetwork: |
|
323 mBody->UpdateTerminatedBy(ENoConnectionToNetwork); |
|
324 break; |
|
325 default: |
|
326 mBody->UpdateTerminatedBy(EUserTerminated); |
|
327 break; |
|
328 } |
|
329 } |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // updateds connected information |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 void IRQStatisticsReporterPrivate::updateConnectedFrom(const IRQStatisticsReporter::IRConnectedFrom aConnectedFrom) |
|
337 { |
|
338 if(mBody) |
|
339 { |
|
340 switch(aConnectedFrom) |
|
341 { |
|
342 case IRQStatisticsReporter::EIRIsds: |
|
343 mBody->UpdateConnectedFrom(EIRIsds); |
|
344 break; |
|
345 case IRQStatisticsReporter::EIRPresetAdhoc: |
|
346 mBody->UpdateConnectedFrom(EIRPresetAdhoc); |
|
347 break; |
|
348 case IRQStatisticsReporter::EIRPresetIsds: |
|
349 mBody->UpdateConnectedFrom(EIRPresetIsds); |
|
350 break; |
|
351 case IRQStatisticsReporter::EIRHistoryAdhoc: |
|
352 mBody->UpdateConnectedFrom(EIRHistoryAdhoc); |
|
353 break; |
|
354 case IRQStatisticsReporter::EIRHistoryIsds: |
|
355 mBody->UpdateConnectedFrom(EIRHistoryIsds); |
|
356 break; |
|
357 case IRQStatisticsReporter::EIRAdhocManual: |
|
358 mBody->UpdateConnectedFrom(EIRAdhocManual); |
|
359 break; |
|
360 case IRQStatisticsReporter::EIRAdhocExternal: |
|
361 mBody->UpdateConnectedFrom(EIRAdhocExternal); |
|
362 break; |
|
363 default: |
|
364 mBody->UpdateConnectedFrom(EIRIsds); |
|
365 break; |
|
366 } |
|
367 } |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // updates the connection type |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 void IRQStatisticsReporterPrivate::updateConnectionType() |
|
375 { |
|
376 if(mBody && mNwkController) |
|
377 { |
|
378 IRQConnectionType connectionType = mNwkController->identifyConnectionType(); |
|
379 switch(connectionType) |
|
380 { |
|
381 case EIRQGprs: |
|
382 mBody->UpdateConnectionType(KGPRS); |
|
383 break; |
|
384 case EIRQWcdma: |
|
385 mBody->UpdateConnectionType(KWCDMA); |
|
386 break; |
|
387 case EIRQCdma2000: |
|
388 mBody->UpdateConnectionType(KCDMA2000); |
|
389 break; |
|
390 case EIRQWiFi: |
|
391 mBody->UpdateConnectionType(KWLAN); |
|
392 break; |
|
393 case EIRQEdge: |
|
394 mBody->UpdateConnectionType(KEDGE); |
|
395 break; |
|
396 default: |
|
397 mBody->UpdateConnectionType(KNullDesC); |
|
398 break; |
|
399 } |
|
400 } |
|
401 } |
|
402 |
|
403 // --------------------------------------------------------------------------- |
|
404 // updates the nokia music shop access type |
|
405 // --------------------------------------------------------------------------- |
|
406 // |
|
407 void IRQStatisticsReporterPrivate::updateNmsType(const IRQStatisticsReporter::IRNmsType aNmsType) |
|
408 { |
|
409 if(mBody) |
|
410 { |
|
411 switch(aNmsType) |
|
412 { |
|
413 case IRQStatisticsReporter::EIRNmsFind: |
|
414 mBody->UpdateNmsType(KFind); |
|
415 break; |
|
416 case IRQStatisticsReporter::EIRNmsLaunch: |
|
417 mBody->UpdateNmsType(KLaunch); |
|
418 break; |
|
419 default: |
|
420 mBody->UpdateNmsType(KNullDesC); |
|
421 break; |
|
422 } |
|
423 } |
|
424 } |
|
425 |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // From MIRLogDbStatusObserver |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 void IRQStatisticsReporterPrivate::LogDbNeedFlush() |
|
432 { |
|
433 sendReport(); |
|
434 } |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // Send the statistics report to isds server |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 void IRQStatisticsReporterPrivate::sendReport() |
|
441 { |
|
442 if(mNwkController) |
|
443 { |
|
444 if(mNwkController->getNetworkStatus() |
|
445 && mIsdsClient |
|
446 && !iLogFile.isEmpty()) |
|
447 { |
|
448 mIsdsClient->isdsPostLog(iLogFile); |
|
449 if(mBody) |
|
450 { |
|
451 mBody->ReportSent(); |
|
452 } |
|
453 } |
|
454 } |
|
455 } |
|
456 |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // Start to monitor network info changes |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void IRQStatisticsReporterPrivate::startMonitoringNwkInfo() |
|
463 { |
|
464 if(mNwkInfoObserver) |
|
465 { |
|
466 mNwkInfoObserver->startMonitorNwkInfo(); |
|
467 connectAndAssert(mNwkInfoObserver, SIGNAL(currentNwkChanged(const QString, const QString)), |
|
468 this, SLOT(updateCurrentNetwork(const QString, const QString))); |
|
469 connectAndAssert(mNwkInfoObserver, SIGNAL(homeNwkChanged(const QString, const QString)), |
|
470 this, SLOT(updateHomeOperator(const QString, const QString))); |
|
471 } |
|
472 } |