|
1 /* |
|
2 * Copyright (c) 2006-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 "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <coemain.h> |
|
20 #include <ezgzip.h> |
|
21 #include <sysutil.h> |
|
22 #include <utf.h> |
|
23 #include <etel3rdparty.h> |
|
24 #include <imcvcodc.h> |
|
25 #include "irdebug.h" |
|
26 #include "irreportsettings.h" |
|
27 #include "irsessiondb.h" |
|
28 #include "irsessionlogger.h" |
|
29 #include "irsessionloggerutility.h" |
|
30 #include "irsettings.h" |
|
31 #include "irnmslogdb.h" |
|
32 #include "irnmslogger.h" |
|
33 #include "irdbstatusobserver.h" |
|
34 #include "irphoneinfo.h" |
|
35 |
|
36 const TUint KFieldPosition = 5; |
|
37 const TInt KAmpMaxLength = 5; |
|
38 const TInt KFormatBuffMaxLength = 6; |
|
39 const TInt KMaxUrlSize = 256; |
|
40 |
|
41 const TUint KSessionLogGranularity = 4; |
|
42 const TUint KNmsLogGranularity = 5; |
|
43 |
|
44 const TUint KSessionLogThreshold = 5; // Session Log Maximum 15 |
|
45 const TUint KNmsLogThreshold = 5; // Nms Log Maximum 15 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // Function: OpenL |
|
49 // Two phase constructor returns the instance of CIRReportGenerator |
|
50 // this is a single ton implementation |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CIRReportGenerator* CIRReportGenerator::OpenL() |
|
54 { |
|
55 IRLOG_DEBUG( "CIRReportGenerator::OpenL" ); |
|
56 CIRReportGenerator* reportGenerator = reinterpret_cast<CIRReportGenerator*>(Dll::Tls()); |
|
57 |
|
58 if (reportGenerator) |
|
59 { |
|
60 User::LeaveIfError(reportGenerator->Open()); |
|
61 IRLOG_INFO( "CIRReportGenerator::OpenL - Opened singleton for new user." ); |
|
62 } |
|
63 else |
|
64 { |
|
65 reportGenerator = new (ELeave) CIRReportGenerator; |
|
66 CleanupClosePushL(*reportGenerator); |
|
67 reportGenerator->ConstructL(); |
|
68 User::LeaveIfError(Dll::SetTls(reportGenerator)); |
|
69 CleanupStack::Pop(reportGenerator); |
|
70 IRLOG_INFO( "CIRSessionLogger::OpenL - Created the CIRReportGenerator singleton." ); |
|
71 } |
|
72 IRLOG_DEBUG( "CIRReportGenerator::OpenL - Exiting." ); |
|
73 return reportGenerator; |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Function: ~CIRReportGenerator |
|
79 // default destructor |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CIRReportGenerator::~CIRReportGenerator() |
|
83 { |
|
84 IRLOG_DEBUG( "CIRReportGenerator::~CIRReportGenerator" ); |
|
85 |
|
86 delete iImeiBase64; |
|
87 iImeiBase64 = NULL; |
|
88 |
|
89 delete iPhoneInfo; |
|
90 iPhoneInfo = NULL; |
|
91 |
|
92 //operation settings instance is removed |
|
93 if( iSettingsData ) |
|
94 { |
|
95 iSettingsData->Close(); // delete is handled like this. |
|
96 } |
|
97 |
|
98 delete iSessionLog; |
|
99 delete iNmsLog; |
|
100 |
|
101 delete iLogSessionDb; |
|
102 delete iNmsLogDb; |
|
103 |
|
104 //session data is also removed |
|
105 if (iSessionData) |
|
106 { |
|
107 iSessionData->ResetAndDestroy(); |
|
108 } |
|
109 delete iSessionData; |
|
110 |
|
111 //NmsLog data is also removed |
|
112 if (iNmsLogData) |
|
113 { |
|
114 iNmsLogData->ResetAndDestroy(); |
|
115 } |
|
116 delete iNmsLogData; |
|
117 |
|
118 iBrowseLog.Close(); //browse log array is closed |
|
119 iLogFile.Close(); |
|
120 //file session is closed |
|
121 iFsSession.Close(); |
|
122 delete iPreviousSessionLog; |
|
123 delete iPreviousNmsLog; |
|
124 Dll::FreeTls(); |
|
125 IRLOG_DEBUG( "CIRReportGenerator::~CIRReportGenerator - Exiting." ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Function: ConstructL |
|
130 // Two phase constructor |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CIRReportGenerator::ConstructL() |
|
134 { |
|
135 IRLOG_DEBUG( "CIRReportGenerator::ConstructL" ); |
|
136 iSessionEndCalled = 0; |
|
137 //file session is connected |
|
138 //Create the IROperation Settings Instance |
|
139 iSettingsData = CIRSettings::OpenL(); |
|
140 |
|
141 User::LeaveIfError(iFsSession.Connect()); |
|
142 |
|
143 //session logger is created |
|
144 iSessionLog = CIRSessionLogger::NewL(); |
|
145 //session logger is created |
|
146 iNmsLog = CIRNmsLogger::NewL(); |
|
147 |
|
148 //session db is created |
|
149 iLogSessionDb = CIRSessionDb::NewL(); |
|
150 //NmsLog db is created |
|
151 iNmsLogDb = CIRNmsLogDb::NewL(); |
|
152 |
|
153 iSessFile =iSettingsData->PrivatePath(); |
|
154 iSessFile.Append(KSession); |
|
155 TInt error = iLogSessionDb->CreateDbConditional(iSessFile); |
|
156 if ( error ) |
|
157 { |
|
158 iSessionDbCreationFailed = ETrue; |
|
159 } |
|
160 else |
|
161 { |
|
162 iSessionDbCreationFailed = EFalse; |
|
163 } |
|
164 |
|
165 iNmsLogFile =iSettingsData->PrivatePath(); |
|
166 iNmsLogFile.Append(KNmsLog); |
|
167 TInt nmsError = iNmsLogDb->CreateDbConditional(iNmsLogFile); |
|
168 if ( nmsError ) |
|
169 { |
|
170 iNmsDbCreationFailed = ETrue; |
|
171 } |
|
172 else |
|
173 { |
|
174 iNmsDbCreationFailed = EFalse; |
|
175 } |
|
176 |
|
177 //session log for five session are to be stored |
|
178 //and is stored in session data |
|
179 iSessionData = new (ELeave) CArrayPtrFlat<CIRSessionLogger>(KSessionLogGranularity); |
|
180 iNmsLogData = new (ELeave) CArrayPtrFlat<CIRNmsLogger>(KNmsLogGranularity); |
|
181 |
|
182 iPhoneInfo = CPhoneInfo::NewL(this); |
|
183 iPhoneInfo->StartUpdating(); |
|
184 |
|
185 IRLOG_DEBUG( "CIRReportGenerator::ConstructL - Exiting." ); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // Function: CIRReportGenerator |
|
190 // default constructor |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 CIRReportGenerator::CIRReportGenerator():iPhoneInfo(NULL), |
|
194 iDbStatusObserver(NULL), |
|
195 iNmsLogDbUpdated(EFalse), |
|
196 iSessionLogDbUpdated(EFalse), |
|
197 iUnComfirmedReportSent(EFalse), |
|
198 iSessionLogUpdationFailed(EFalse), |
|
199 iNmsLogUpdationFailed(EFalse), |
|
200 iSessionDbCreationFailed(EFalse), |
|
201 iNmsDbCreationFailed(EFalse), |
|
202 iImeiBase64(NULL) |
|
203 { |
|
204 //No Implementation |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // Function: LogServerResult |
|
209 // logs server connection result |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C void CIRReportGenerator::LogServerResult(const TDesC& aUrl,TResponse aResult) |
|
213 { |
|
214 iSessionLog->LogServerResult(aUrl,aResult); |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // Function: LogSongRecog |
|
219 // logs song recog |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 EXPORT_C void CIRReportGenerator::LogSongRecog() |
|
223 { |
|
224 //taking the session start time in GMT |
|
225 iSongRecogTimestamp.UniversalTime(); |
|
226 TTimeIntervalSeconds offset(iSettingsData->TimeCorrection()); |
|
227 iSongRecogTimestamp -= offset; |
|
228 iDate = iSongRecogTimestamp.DateTime(); |
|
229 TBuf<64> songRecogTimestamp; |
|
230 FormatDateTime(songRecogTimestamp,iDate); |
|
231 iSessionLog->LogSongRecog(songRecogTimestamp); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // Function: UpdateCurrentBrowseNetwork |
|
236 // logs network browsing |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 EXPORT_C void CIRReportGenerator::UpdateCurrentBrowseNetwork(TInt aNetwork) |
|
240 { |
|
241 iCurrentBrowseNetwork = aNetwork; |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // Function: LogBrowse |
|
246 // logs browse url and status information |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 EXPORT_C void CIRReportGenerator::LogBrowse(const TDesC8& aUrl,TInt aStatus) |
|
250 { |
|
251 IRLOG_DEBUG( "CIRReportGenerator::LogBrowse" ); |
|
252 //browse url is copied |
|
253 iRBrowseLog.iBrowseUrl.Copy(aUrl); |
|
254 //time stamp in GMT is onbtained |
|
255 iBrowseLogTimeStamp.UniversalTime(); |
|
256 |
|
257 TInt time_val = 0; |
|
258 time_val = iSettingsData->TimeCorrection(); |
|
259 TTimeIntervalSeconds offset(time_val); |
|
260 |
|
261 iBrowseLogTimeStamp -= offset; |
|
262 iDate = iBrowseLogTimeStamp.DateTime(); |
|
263 //formated |
|
264 FormatDateTime(iRBrowseLog.iTimeStamp,iDate); |
|
265 _LIT(KFormat,"%d"); |
|
266 (iRBrowseLog.iCurrentNetwork).Format(KFormat, |
|
267 iCurrentBrowseNetwork); |
|
268 //status is stored |
|
269 iRBrowseLog.iStatus = aStatus; |
|
270 TRAP_IGNORE(iBrowseLog.AppendL(iRBrowseLog)) |
|
271 IRLOG_DEBUG( "CIRReportGenerator::LogBrowse - Exiting." ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // Function: SessionStartedL |
|
276 // starts a new session |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 EXPORT_C void CIRReportGenerator::SessionStartedL() |
|
280 { |
|
281 IRLOG_DEBUG( "CIRReportGenerator::SessionStartedL" ); |
|
282 //gets the session id for new session |
|
283 iSessionLog->ResetResource(); |
|
284 |
|
285 iSessionLog->UpdateSessionId(iSettingsData->GetLogRunningNo()); |
|
286 iSettingsData->SetLogRunningNoL(); |
|
287 iFileWritePos = 0; |
|
288 |
|
289 iLogFilePath = iSettingsData->PrivatePath(); |
|
290 iLogFilePath.Append(KLogFileName); |
|
291 //taking the session start time in GMT |
|
292 iSessionStartTime.UniversalTime(); |
|
293 iSessionLog->UpdateSessionStartGMTTime(); |
|
294 TTimeIntervalSeconds offset(iSettingsData->TimeCorrection()); |
|
295 iSessionStartTime -= offset; |
|
296 iDate = iSessionStartTime.DateTime(); |
|
297 FormatDateTime(iSessionLog->StartTime(),iDate); |
|
298 iSessionLog->UnMarkSession(); |
|
299 //collect the neccessary information |
|
300 CollectSettingsData(); |
|
301 iSessionLogUpdationFailed = EFalse; |
|
302 //start adding the intial information in db |
|
303 IRLOG_DEBUG( "CIRReportGenerator::SessionStartedL - Exiting." ); |
|
304 } |
|
305 // --------------------------------------------------------------------------- |
|
306 // Function: NmsLogStartedL |
|
307 // starts a new nmslog |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 EXPORT_C void CIRReportGenerator::NmsLogStartedL() |
|
311 { |
|
312 IRLOG_DEBUG( "CIRReportGenerator::SessionStartedL" ); |
|
313 iNmsTimestamp.UniversalTime(); |
|
314 TInt time_val = 0; |
|
315 time_val = iSettingsData->TimeCorrection(); |
|
316 TTimeIntervalSeconds offset(time_val); |
|
317 |
|
318 iNmsTimestamp -= offset; |
|
319 iDate = iNmsTimestamp.DateTime(); |
|
320 //formated |
|
321 FormatDateTime(iNmsLog->StartTime(),iDate); |
|
322 iNmsLogUpdationFailed = EFalse; |
|
323 //start adding the intial information in db |
|
324 IRLOG_DEBUG( "CIRReportGenerator::SessionStartedL - Exiting." ); |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // Function: SessionEnd |
|
329 // marks the a session |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 EXPORT_C void CIRReportGenerator::SessionEndL( TBool aForcedTermination ) |
|
333 { |
|
334 IRLOG_DEBUG( "CIRReportGenerator::SessionEndL" ); |
|
335 iSessionEndCalled++; |
|
336 //session end |
|
337 if( aForcedTermination ) |
|
338 { |
|
339 //forced ending of session log |
|
340 ForcedSessionEndedL(); |
|
341 } |
|
342 else |
|
343 { |
|
344 //unforced ending of session log |
|
345 iSessionLog->EndLogging(); |
|
346 UnForceSessionEndedL(iSessionLog); |
|
347 } |
|
348 |
|
349 IRLOG_DEBUG( "CIRReportGenerator::SessionEndL - Exiting." ); |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // Function: UpdateTerminatedBy |
|
354 // updates the termination status |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 EXPORT_C void CIRReportGenerator::UpdateTerminatedBy(TTerminationStatus |
|
358 aTerminatedBy) |
|
359 { |
|
360 IRLOG_DEBUG( "CIRReportGenerator::UpdateTerminatedBy" ); |
|
361 iSessionLog->UpdateTerminationStatus(aTerminatedBy); |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // Function: GetConnectedFrom |
|
366 // connected information is stored |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 EXPORT_C void CIRReportGenerator::UpdateConnectedFrom(TConnectedFrom aConnectedFrom) |
|
370 { |
|
371 IRLOG_DEBUG( "CIRReportGenerator::UpdateConnectedFrom" ); |
|
372 iSessionLog->GetConnectedFrom(aConnectedFrom); |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------------------------- |
|
376 // Function: BrowseUrl |
|
377 // logs browse url and result |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 EXPORT_C void CIRReportGenerator::BrowseUrl(const TDesC& aBrowseUrl, |
|
381 TInt aStatus) |
|
382 { |
|
383 IRLOG_DEBUG( "CIRReportGenerator::BrowseUrl" ); |
|
384 _LIT(KAmp,"&"); |
|
385 TBuf8<KAmpMaxLength> amp; |
|
386 amp.Copy(KAmp); |
|
387 TBuf8<KMaxUrlSize> url; |
|
388 url.Copy(aBrowseUrl); |
|
389 _LIT8(KAmpnd,"&"); |
|
390 TInt pos = url.Find(KAmpnd); |
|
391 if(pos > 0) |
|
392 { |
|
393 url.Replace(pos,1,amp); |
|
394 } |
|
395 LogBrowse(url,aStatus); |
|
396 IRLOG_DEBUG( "CIRReportGenerator::BrowseUrl - Exiting." ); |
|
397 } |
|
398 |
|
399 // --------------------------------------------------------------------------- |
|
400 // Function: UpdateChannelID |
|
401 // updates the channel id |
|
402 // --------------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void CIRReportGenerator::UpdateChannelID(TInt aChanneldID) |
|
405 { |
|
406 IRLOG_DEBUG( "CIRReportGenerator::UpdateChannelID" ); |
|
407 iSessionLog->UpdateChannelID(aChanneldID); |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------------------------- |
|
411 // Function: UpdateCurrentNetwork |
|
412 // updates the current network |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 EXPORT_C void CIRReportGenerator::UpdateCurrentNetwork(TInt aCurrentNetwork) |
|
416 { |
|
417 IRLOG_DEBUG( "CIRReportGenerator::UpdateCurrentNetwork" ); |
|
418 iSessionLog->UpdateCurrentNetwork(aCurrentNetwork); |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // Function: UpdateHomeOperator |
|
423 // updates the home network |
|
424 // --------------------------------------------------------------------------- |
|
425 // |
|
426 EXPORT_C void CIRReportGenerator::UpdateHomeOperator(TInt aHomeOperator) |
|
427 { |
|
428 IRLOG_DEBUG( "CIRReportGenerator::UpdateHomeOperator" ); |
|
429 iSessionLog->UpdateHomeOperator(aHomeOperator); |
|
430 } |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // Function: MarkSessionStart |
|
434 // updates the termination status |
|
435 // --------------------------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C void CIRReportGenerator::MarkSessionStart() |
|
438 { |
|
439 iSessionStartTime.UniversalTime(); |
|
440 |
|
441 TInt time_val = 0; |
|
442 time_val = iSettingsData->TimeCorrection(); |
|
443 TTimeIntervalSeconds offset(time_val); |
|
444 |
|
445 iSessionStartTime -= offset; |
|
446 iDate = iSessionStartTime.DateTime(); |
|
447 FormatDateTime(iSessionLog->StartTime(),iDate); |
|
448 //setting session start time |
|
449 iSessionLog->UpdateSessionStartGMTTime(); |
|
450 iSessionLog->MarkSession(); |
|
451 if( iPreviousSessionLog ) |
|
452 { |
|
453 //if previous session exist it added to the log |
|
454 TRAP_IGNORE( UnForceSessionEndedL(iPreviousSessionLog) ) |
|
455 delete iPreviousSessionLog; |
|
456 iPreviousSessionLog = NULL; |
|
457 } |
|
458 } |
|
459 |
|
460 // --------------------------------------------------------------------------- |
|
461 // Function: HandleStopEvents |
|
462 // function handles session state changes |
|
463 // --------------------------------------------------------------------------- |
|
464 // |
|
465 EXPORT_C void CIRReportGenerator::HandleStopEvents(TBool aIsSessionProgressing ) |
|
466 { |
|
467 IRLOG_DEBUG( "CIRReportGenerator::HandleStopEvents" ); |
|
468 if( !aIsSessionProgressing ) |
|
469 { |
|
470 iSessionLog->HandleStopEvents(); |
|
471 } |
|
472 else |
|
473 { |
|
474 iSessionLog->HandleStartEvents(); |
|
475 } |
|
476 IRLOG_DEBUG( "CIRReportGenerator::HandleStopEvents - Exiting." ); |
|
477 } |
|
478 |
|
479 // --------------------------------------------------------------------------- |
|
480 // Function: ReStorePreviousSession |
|
481 // restore the previous session |
|
482 // --------------------------------------------------------------------------- |
|
483 // |
|
484 EXPORT_C TBool CIRReportGenerator::ReStorePreviousSession() |
|
485 { |
|
486 if( iPreviousSessionLog ) |
|
487 { |
|
488 //if previous session exist that is restored |
|
489 //ETrue is returned. |
|
490 iSessionLog->GetBackedUp(*iPreviousSessionLog); |
|
491 delete iPreviousSessionLog; |
|
492 iPreviousSessionLog = NULL; |
|
493 return ETrue; |
|
494 } |
|
495 else |
|
496 { |
|
497 //if previous session doesn't exist EFalse is returned |
|
498 return EFalse; |
|
499 } |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // Function: UpdateConnectionType |
|
504 // updates the connection type |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 EXPORT_C void CIRReportGenerator::UpdateConnectionType(const TDesC& |
|
508 aConnectionType) |
|
509 { |
|
510 IRLOG_DEBUG( "CIRReportGenerator::UpdateConnectionType" ); |
|
511 iSessionLog->UpdateConnectionType(aConnectionType); |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // Function: UpdateNmsType |
|
516 // updates the connection type |
|
517 // --------------------------------------------------------------------------- |
|
518 // |
|
519 EXPORT_C void CIRReportGenerator::UpdateNmsType(const TDesC& aNmsType) |
|
520 { |
|
521 IRLOG_DEBUG( "CIRReportGenerator::UpdateNmsType" ); |
|
522 iNmsLog->UpdateNmsType(aNmsType); |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // Function: SetDbStatusObserser |
|
527 // --------------------------------------------------------------------------- |
|
528 // |
|
529 EXPORT_C void CIRReportGenerator::SetDbStatusObserser(MIRLogDbStatusObserver *aDbStatusObserver) |
|
530 { |
|
531 iDbStatusObserver = aDbStatusObserver; |
|
532 } |
|
533 |
|
534 // --------------------------------------------------------------------------- |
|
535 // Function: reportSent |
|
536 // --------------------------------------------------------------------------- |
|
537 // |
|
538 EXPORT_C void CIRReportGenerator::ReportSent() |
|
539 { |
|
540 iUnComfirmedReportSent = ETrue; |
|
541 } |
|
542 |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // Function : ReponseFromISDSObtained |
|
546 // This function is called when session log is successfully sent |
|
547 // removes all session log entries from sessiondb |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 EXPORT_C void CIRReportGenerator::ReponseFromISDSObtained() |
|
551 { |
|
552 IRLOG_DEBUG( "CIRReportGenerator::ReponseFromISDSObtained" ); |
|
553 iUnComfirmedReportSent = EFalse; |
|
554 TRAP_IGNORE(iLogSessionDb->DeleteAllSessionL()) |
|
555 TRAP_IGNORE(iNmsLogDb->DeleteAllNmsLogL()) |
|
556 for(TInt i = 0; i < iBrowseLogsCntToXml; i++) |
|
557 { |
|
558 if(iBrowseLog.Count() > 0) |
|
559 iBrowseLog.Remove(0); |
|
560 } |
|
561 } |
|
562 |
|
563 // --------------------------------------------------------------------------- |
|
564 // Function: CollectSettingsData |
|
565 // collect information during starting of session |
|
566 // like irid, version information. |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 void CIRReportGenerator::CollectSettingsData() |
|
570 { |
|
571 IRLOG_DEBUG( "CIRReportGenerator::CollectSettingsData" ); |
|
572 _LIT(KData,"1.0"); |
|
573 _LIT(KIRID,"NO IRID"); |
|
574 |
|
575 |
|
576 |
|
577 //gets irid from opsetting |
|
578 TRAP_IGNORE( iIRId.Copy(iSettingsData->GetIRIDL()) ); |
|
579 //if length of irid is zero "no irid" is assigned |
|
580 if((iIRId).Length() == 0) |
|
581 { |
|
582 iIRId.Copy(KIRID); |
|
583 } |
|
584 //version copied |
|
585 iReportVersion.Copy(KData); |
|
586 IRLOG_DEBUG( "CIRReportGenerator::CollectSettingsData - Exiting." ); |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // Function: WriteToXmlL |
|
591 // gathers the information and generates sesion log file and zip file |
|
592 // file will be stored in private path |
|
593 // --------------------------------------------------------------------------- |
|
594 // |
|
595 void CIRReportGenerator::WriteToXmlL() |
|
596 { |
|
597 IRLOG_DEBUG( "CIRReportGenerator::WriteToXmlL" ); |
|
598 //1. log file is created |
|
599 User::LeaveIfError(iLogFile.Replace(iFsSession,iLogFilePath,EFileWrite)); |
|
600 iLogFile.Seek(ESeekStart,iFileWritePos); |
|
601 |
|
602 |
|
603 //2. Write file header. |
|
604 iUniCodeBuf.Copy(KXmlHeader); |
|
605 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
606 WriteBufferToLogFile(); |
|
607 |
|
608 //3. Write Version + IRID + IMEI |
|
609 iUniCodeBuf.Copy(KRPSTARTTAG); |
|
610 iFileWritePos = iUniCodeBuf.Find(KField); |
|
611 //3.1 Write Version |
|
612 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,iReportVersion); |
|
613 iFileWritePos = iUniCodeBuf.Find(KField); |
|
614 //3.2 Write IRID |
|
615 RBuf tempIRID; |
|
616 TRAP_IGNORE( tempIRID.Create(iSettingsData->GetIRIDL()) ); |
|
617 if((tempIRID).Length() != 0) |
|
618 { |
|
619 iIRId.Copy(tempIRID); |
|
620 } |
|
621 tempIRID.Close(); |
|
622 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,iIRId); |
|
623 //3.3 Write IMEI |
|
624 iFileWritePos = iUniCodeBuf.Find(KField); |
|
625 if(NULL == iImeiBase64) |
|
626 { |
|
627 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,KNullDesC); |
|
628 } |
|
629 else |
|
630 { |
|
631 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,*iImeiBase64); |
|
632 } |
|
633 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
634 WriteBufferToLogFile(); |
|
635 |
|
636 //4. Write session log |
|
637 if(!iSessionLogUpdationFailed) |
|
638 { |
|
639 for(TInt count = 0; count<(iSessionData->Count()); count++) |
|
640 { |
|
641 WriteSessionData(count); |
|
642 } |
|
643 } |
|
644 |
|
645 //5. Write browse log |
|
646 WriteBrowseLog(); |
|
647 |
|
648 //6. Write nms log |
|
649 if(!iNmsLogUpdationFailed) |
|
650 { |
|
651 iUniCodeBuf.Copy(KNMSLOGSTARTTAG); |
|
652 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
653 WriteBufferToLogFile(); |
|
654 |
|
655 for(TInt count = 0; count<(iNmsLogData->Count()); count++) |
|
656 { |
|
657 WriteNmsLogData(count); |
|
658 } |
|
659 iUniCodeBuf.Copy(KNMSLOGENDTAG); |
|
660 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
661 WriteBufferToLogFile(); |
|
662 } |
|
663 |
|
664 //7. Write file ending |
|
665 iUniCodeBuf.Copy(KRPENDTAG); |
|
666 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
667 WriteBufferToLogFile(); |
|
668 |
|
669 iLogFile.Close(); |
|
670 ZipFileL(); |
|
671 |
|
672 iBrowseLogsCntToXml = iBrowseLog.Count(); |
|
673 |
|
674 IRLOG_DEBUG( "CIRReportGenerator::WriteToXmlL - Exiting." ); |
|
675 } |
|
676 // --------------------------------------------------------------------------- |
|
677 // Function: WriteNmsLogtoXmlL |
|
678 // logs nmsEvents to Xml file |
|
679 // --------------------------------------------------------------------------- |
|
680 // |
|
681 EXPORT_C void CIRReportGenerator::WriteNmsLogtoXmlL() |
|
682 { |
|
683 IRLOG_DEBUG( "CIRReportGenerator::WriteNmsLogtoXmlL" ); |
|
684 if(iSessionEndCalled == 0) |
|
685 { |
|
686 ForcedSessionEndedL(); |
|
687 iSessionEndCalled++; |
|
688 } |
|
689 iNmsEventFlag = ETrue; |
|
690 UnForceSessionEndedL(iSessionLog); |
|
691 iNmsEventFlag = EFalse; |
|
692 IRLOG_DEBUG( "CIRReportGenerator::WriteNmsLogtoXmlL - Leaving" ); |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // Function: WriteSessionData |
|
697 // gathers session log data and writes to XML file |
|
698 // --------------------------------------------------------------------------- |
|
699 // |
|
700 void CIRReportGenerator::WriteSessionData(TInt aIndex) |
|
701 { |
|
702 IRLOG_DEBUG( "CIRReportGenerator::WriteSessionData" ); |
|
703 |
|
704 ASSERT( aIndex >= 0 && aIndex < iSessionData->Count() ); |
|
705 TBuf<KFormatBuffMaxLength> FormatBuff; |
|
706 _LIT(KConvert,"%d"); |
|
707 |
|
708 // 1. session start time is copied |
|
709 iUniCodeBuf.Copy(KSESSIONSTARTTAG); |
|
710 iFileWritePos = iUniCodeBuf.Find(KField); |
|
711 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
712 At(aIndex))->StartTime()); |
|
713 |
|
714 // 2. session duration is copied |
|
715 iFileWritePos = iUniCodeBuf.Find(KField); |
|
716 TInt duration = (iSessionData->At(aIndex))->SessionDuration(); |
|
717 FormatBuff.Format(KConvert,duration); |
|
718 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
719 |
|
720 // 3. termination status is copied |
|
721 iFileWritePos = iUniCodeBuf.Find(KField); |
|
722 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
723 At(aIndex))->TerminationStatus()); |
|
724 |
|
725 // 4. connected from information is copied |
|
726 iFileWritePos = iUniCodeBuf.Find(KField); |
|
727 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
728 At(aIndex))->ConnectedFrom()); |
|
729 |
|
730 // 5. session id is copied |
|
731 iFileWritePos = iUniCodeBuf.Find(KField); |
|
732 FormatBuff.Format(KConvert,(iSessionData->At(aIndex))->SessionId()); |
|
733 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
734 |
|
735 // 6. channel id is copied |
|
736 iFileWritePos = iUniCodeBuf.Find(KField); |
|
737 FormatBuff.Format(KConvert,(iSessionData->At(aIndex))->ChannelID()); |
|
738 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
739 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
740 |
|
741 WriteBufferToLogFile(); |
|
742 |
|
743 // 8. Write ServerResult |
|
744 TInt ServerResultCount = (iSessionData->At(aIndex))-> |
|
745 SessionData().Count(); |
|
746 for(TInt count=0; count < ServerResultCount;count++) |
|
747 { |
|
748 //channel server urls are copied for the session |
|
749 iUniCodeBuf.Copy(KSERVERRESULTTAG); |
|
750 iFileWritePos = iUniCodeBuf.Find(KField); |
|
751 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
752 At(aIndex)->SessionData()[count].iServerUrl)); |
|
753 |
|
754 //status is copied |
|
755 iFileWritePos = iUniCodeBuf.Find(KField); |
|
756 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
757 At(aIndex)->SessionData()[count].iServerResult)); |
|
758 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
759 //writting the information to the xml file |
|
760 WriteBufferToLogFile(); |
|
761 } |
|
762 |
|
763 // 9. connection type is copied |
|
764 iUniCodeBuf.Copy(KCONNECTIONTAG); |
|
765 iFileWritePos = iUniCodeBuf.Find(KField); |
|
766 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
767 At(aIndex))->ConnectionType()); |
|
768 |
|
769 // 10. current network is copied |
|
770 iFileWritePos = iUniCodeBuf.Find(KField); |
|
771 FormatBuff.Format(KConvert,(iSessionData->At(aIndex))-> |
|
772 CurrentNetwork()); |
|
773 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
774 |
|
775 // 11. home operator is copied |
|
776 iFileWritePos = iUniCodeBuf.Find(KField); |
|
777 FormatBuff.Format(KConvert,(iSessionData->At(aIndex))->HomeOperator()); |
|
778 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
779 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
780 |
|
781 WriteBufferToLogFile(); |
|
782 |
|
783 // 12. Write Song Recog Log |
|
784 iUniCodeBuf.Copy(KSONGRECOGLOGSTARTTAG); |
|
785 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
786 WriteBufferToLogFile(); |
|
787 |
|
788 TInt songRecogLogCount = (iSessionData->At(aIndex))-> |
|
789 SongRecogLog().Count(); |
|
790 for(TInt count=0; count < songRecogLogCount; count++) |
|
791 { |
|
792 iUniCodeBuf.Copy(KSONGRECOGEVENTTAG); |
|
793 iFileWritePos = iUniCodeBuf.Find(KField); |
|
794 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iSessionData-> |
|
795 At(aIndex)->SongRecogLog()[count].iTimeStamp)); |
|
796 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
797 WriteBufferToLogFile(); |
|
798 } |
|
799 |
|
800 iUniCodeBuf.Copy(KSONGRECOGLOGENDTAG); |
|
801 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
802 WriteBufferToLogFile(); |
|
803 |
|
804 // write ending tag </session> |
|
805 iUniCodeBuf.Copy(KSESSIONENDTAG); |
|
806 //tags are also written into xml file |
|
807 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
808 WriteBufferToLogFile(); |
|
809 IRLOG_DEBUG( "CIRReportGenerator::WriteSessionData - Exiting." ); |
|
810 } |
|
811 |
|
812 // --------------------------------------------------------------------------- |
|
813 // Function: WriteBrowseLog |
|
814 // gathers browse log data and writes to XML file |
|
815 // --------------------------------------------------------------------------- |
|
816 // |
|
817 void CIRReportGenerator::WriteBrowseLog() |
|
818 { |
|
819 IRLOG_DEBUG( "CIRReportGenerator::WriteBrowseLog" ); |
|
820 //browse log |
|
821 //browse log tag is written |
|
822 iUniCodeBuf.Copy(KBROWSESTARTTAG); |
|
823 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
824 WriteBufferToLogFile(); |
|
825 for(TInt count = 0; count < (iBrowseLog.Count());count++) |
|
826 { |
|
827 //browse log url is copied |
|
828 iUniCodeBuf.Copy(KBROWSETAG); |
|
829 iFileWritePos = iUniCodeBuf.Find(KField); |
|
830 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition, |
|
831 (iBrowseLog).operator[](count).iBrowseUrl); |
|
832 iFileWritePos = iUniCodeBuf.Find(KField); |
|
833 //browse log time stamp is copied |
|
834 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition, |
|
835 (iBrowseLog).operator[](count).iTimeStamp); |
|
836 iFileWritePos = iUniCodeBuf.Find(KField); |
|
837 //browse log current network is copied |
|
838 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition, |
|
839 (iBrowseLog).operator[](count).iCurrentNetwork); |
|
840 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
841 //browse log is written to xml |
|
842 WriteBufferToLogFile(); |
|
843 } |
|
844 |
|
845 //browse log end tag is copied |
|
846 iUniCodeBuf.Copy(KBROWSEENDTAG); |
|
847 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
848 WriteBufferToLogFile(); |
|
849 IRLOG_DEBUG( "CIRReportGenerator::WriteBrowseLog - Exiting." ); |
|
850 } |
|
851 |
|
852 // --------------------------------------------------------------------------- |
|
853 // Function: ZipFileL |
|
854 // generates the zip file from the input xml file |
|
855 // output file is in gzip format and is stored in private path |
|
856 // --------------------------------------------------------------------------- |
|
857 // |
|
858 void CIRReportGenerator::ZipFileL() |
|
859 { |
|
860 IRLOG_DEBUG( "CIRReportGenerator::ZipFileL" ); |
|
861 //input file is the xml file in private path and output is a gzip file stored |
|
862 //private path |
|
863 //xml file |
|
864 RFile iplogfile; |
|
865 //getting path of zip file |
|
866 TFileName gzipfilepath = iSessionLog->FileName(); |
|
867 gzipfilepath.Append(KGZipLogFileName); |
|
868 |
|
869 iLogFilePath = iSettingsData->PrivatePath(); |
|
870 iLogFilePath.Append(KLogFileName); |
|
871 |
|
872 //input file is opened |
|
873 TInt error = iplogfile.Open(iFsSession,iLogFilePath,EFileStream | EFileRead); |
|
874 CleanupClosePushL( iplogfile ); |
|
875 |
|
876 if( KErrNone != error ) |
|
877 { |
|
878 User::LeaveIfError(error); |
|
879 } |
|
880 |
|
881 //generating zip file |
|
882 |
|
883 TInt fileSize(0); |
|
884 TInt err = iplogfile.Size( fileSize ); |
|
885 |
|
886 if(!err) |
|
887 { |
|
888 TParse zipParse; |
|
889 zipParse.Set( iLogFilePath, NULL, NULL ); |
|
890 |
|
891 TPtrC zipDrive = zipParse.Drive(); |
|
892 |
|
893 TChar driveChar = zipDrive[0]; |
|
894 TInt driveNum(0); |
|
895 RFs::CharToDrive( driveChar, driveNum ); |
|
896 |
|
897 TDriveInfo driveInfo; |
|
898 TInt driveErr = iplogfile.Drive( driveNum, driveInfo ); |
|
899 if( !driveErr |
|
900 && driveNum != EDriveZ |
|
901 && !SysUtil::DiskSpaceBelowCriticalLevelL( |
|
902 &CCoeEnv::Static()->FsSession(), iUTF8Buffer.Size(), driveNum ) ) |
|
903 { |
|
904 // disk space is not below critical level |
|
905 // Next generate the zip file |
|
906 CEZFileToGZip* zip = CEZFileToGZip::NewLC(iFsSession,gzipfilepath, iplogfile); |
|
907 while(zip->DeflateL()) |
|
908 { |
|
909 } |
|
910 CleanupStack::PopAndDestroy(zip); |
|
911 } |
|
912 else |
|
913 { |
|
914 // disk space is below critical level |
|
915 // Do not generate the zip file |
|
916 } |
|
917 } |
|
918 |
|
919 //file is closed |
|
920 CleanupStack::PopAndDestroy(); // iplogfile |
|
921 IRLOG_DEBUG( "CIRReportGenerator::ZipFileL - Exiting." ); |
|
922 } |
|
923 |
|
924 // --------------------------------------------------------------------------- |
|
925 // Function: FormatDateTime |
|
926 // formats the date time given in "%d-%d-%d %d:%d:%d GMT\n" format |
|
927 // copies the result to a descriptor |
|
928 // --------------------------------------------------------------------------- |
|
929 // |
|
930 void CIRReportGenerator::FormatDateTime(TDes& aBuffer,TDateTime aDateTime) |
|
931 { |
|
932 IRLOG_DEBUG( "CIRReportGenerator::FormatDateTime" ); |
|
933 _LIT(KFormatTxt,"%d-%d-%d %d:%d:%d GMT\n"); |
|
934 aBuffer.Format(KFormatTxt,aDateTime.Year(),TInt(aDateTime.Month()+1), |
|
935 //Format the month as a TInt to preserve locale independence |
|
936 //aDateTime.Day()+1, |
|
937 aDateTime.Day()+1, |
|
938 // Day and month ranges begin at zero (0-30 and 0-11), |
|
939 // so add one when formatting |
|
940 aDateTime.Hour(), aDateTime.Minute(), aDateTime.Second() |
|
941 //aDateTime.MicroSecond() |
|
942 ); |
|
943 IRLOG_DEBUG( "CIRReportGenerator::FormatDateTime - Exiting." ); |
|
944 } |
|
945 |
|
946 // --------------------------------------------------------------------------- |
|
947 // Function: WriteBufferToLogFile |
|
948 // Writes the content of iUTF8Buffer to iLogFile |
|
949 // --------------------------------------------------------------------------- |
|
950 // |
|
951 void CIRReportGenerator::WriteBufferToLogFile() |
|
952 { |
|
953 IRLOG_DEBUG( "CIRReportGenerator::WriteBufferToLogFile" ); |
|
954 // Get the drive where iLogFile is located. |
|
955 |
|
956 TInt driveNumber(0); |
|
957 TDriveInfo driveInfo; |
|
958 |
|
959 TInt err = iLogFile.Drive( driveNumber, driveInfo ); |
|
960 |
|
961 // Write the log file only if: |
|
962 // Drive was fetched successflly, |
|
963 // the drive is not Z |
|
964 // and free disk space is not below critical level (128kB) |
|
965 |
|
966 if( !err && driveNumber!=EDriveZ ) |
|
967 { |
|
968 TBool ret = ETrue; |
|
969 TRAP_IGNORE( ret = SysUtil::DiskSpaceBelowCriticalLevelL( |
|
970 &CCoeEnv::Static()->FsSession(),iUTF8Buffer.Size(), driveNumber )) |
|
971 if( !ret ) |
|
972 { |
|
973 iLogFile.Write( iUTF8Buffer ); |
|
974 } |
|
975 else |
|
976 { |
|
977 // Do not write the session log. |
|
978 } |
|
979 } |
|
980 else |
|
981 { |
|
982 // Do not write the session log. |
|
983 } |
|
984 IRLOG_DEBUG( "CIRReportGenerator::WriteBufferToLogFile - Exiting." ); |
|
985 } |
|
986 |
|
987 // --------------------------------------------------------------------------- |
|
988 // Function: UnForceSessionEndedL |
|
989 // Handles Unforced end of the session |
|
990 // --------------------------------------------------------------------------- |
|
991 // |
|
992 void CIRReportGenerator::UnForceSessionEndedL( CIRSessionLogger* aSession ) |
|
993 { |
|
994 // 1. retrieve session log from db |
|
995 if(iSessionDbCreationFailed) |
|
996 { |
|
997 iSessionLogUpdationFailed = ETrue; |
|
998 } |
|
999 else |
|
1000 { |
|
1001 if(iNmsEventFlag) |
|
1002 { |
|
1003 TRAPD(error, |
|
1004 //count is stored |
|
1005 iLogSessionDb->GetAllSessionL(*iSessionData); |
|
1006 ); |
|
1007 if(error) |
|
1008 { |
|
1009 iSessionLogUpdationFailed = ETrue; |
|
1010 } |
|
1011 } |
|
1012 else |
|
1013 { |
|
1014 TRAPD( error, |
|
1015 //loads the information into the db at the end of the session |
|
1016 iLogSessionDb->AddSessionStartL(*aSession); |
|
1017 //count is stored |
|
1018 iLogSessionDb->GetAllSessionL(*iSessionData); |
|
1019 ); |
|
1020 if(error) |
|
1021 { |
|
1022 iSessionLogUpdationFailed = ETrue; |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 TInt count = iSessionData->Count(); |
|
1027 if((count>0) && (count%KSessionLogThreshold == 0)) |
|
1028 { |
|
1029 iSessionLogDbUpdated = ETrue; |
|
1030 } |
|
1031 } |
|
1032 } |
|
1033 } |
|
1034 |
|
1035 // 2. retrieve nms log from db |
|
1036 if(iNmsDbCreationFailed) |
|
1037 { |
|
1038 iNmsLogUpdationFailed = ETrue; |
|
1039 } |
|
1040 else |
|
1041 { |
|
1042 if(!iNmsEventFlag) |
|
1043 { |
|
1044 TRAPD( error, iNmsLogDb->GetAllNmsLogL(*iNmsLogData) ); |
|
1045 if(error) |
|
1046 { |
|
1047 iNmsLogUpdationFailed = ETrue; |
|
1048 } |
|
1049 } |
|
1050 else |
|
1051 { |
|
1052 TRAPD( error, |
|
1053 //loads the information into the db at the end of the session |
|
1054 iNmsLogDb->AddNmsLogStartL(*iNmsLog); |
|
1055 //count is stored |
|
1056 iNmsLogDb->GetAllNmsLogL(*iNmsLogData); |
|
1057 ); |
|
1058 if(error) |
|
1059 { |
|
1060 iNmsLogUpdationFailed = ETrue; |
|
1061 } |
|
1062 else |
|
1063 { |
|
1064 TInt count = iNmsLogData->Count(); |
|
1065 if((count>0) && (count%KNmsLogThreshold == 0)) |
|
1066 { |
|
1067 iNmsLogDbUpdated = ETrue; |
|
1068 } |
|
1069 } |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 //xml file is created and is zipped |
|
1074 WriteToXmlL(); |
|
1075 |
|
1076 if( iDbStatusObserver && |
|
1077 ( iNmsLogDbUpdated || |
|
1078 iSessionLogDbUpdated || |
|
1079 iUnComfirmedReportSent |
|
1080 ) |
|
1081 ) |
|
1082 { |
|
1083 iDbStatusObserver->LogDbNeedFlush(); |
|
1084 iNmsLogDbUpdated = EFalse; |
|
1085 iSessionLogDbUpdated = EFalse; |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 // --------------------------------------------------------------------------- |
|
1090 // Function: ForcedSessionEndedL |
|
1091 // Handles forced end of the session |
|
1092 // --------------------------------------------------------------------------- |
|
1093 // |
|
1094 void CIRReportGenerator::ForcedSessionEndedL() |
|
1095 { |
|
1096 iSessionLog->EndLogging(); |
|
1097 iPreviousSessionLog = CIRSessionLogger::NewL(); |
|
1098 iPreviousSessionLog->GetBackedUp(*iSessionLog); |
|
1099 iPreviousNmsLog = CIRNmsLogger::NewL(); |
|
1100 iPreviousNmsLog->GetBackedUp(*iNmsLog); |
|
1101 } |
|
1102 |
|
1103 /** |
|
1104 * The following methods are for Nms Event Usage Logging |
|
1105 */ |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // Function: UpdateNmsCurrentNetwork |
|
1108 // logs network during Music Store launching |
|
1109 // --------------------------------------------------------------------------- |
|
1110 // |
|
1111 EXPORT_C void CIRReportGenerator::UpdateNmsCurrentNetwork(TInt aNetwork) |
|
1112 { |
|
1113 iNmsLog->UpdateCurrentNetwork(aNetwork); |
|
1114 } |
|
1115 |
|
1116 // --------------------------------------------------------------------------- |
|
1117 // Function: UpdateNmsHomeOperator |
|
1118 // logs network during Music Store Launching |
|
1119 // --------------------------------------------------------------------------- |
|
1120 // |
|
1121 EXPORT_C void CIRReportGenerator::UpdateNmsHomeOperator(TInt aNetwork) |
|
1122 { |
|
1123 iNmsLog->UpdateHomeOperator(aNetwork); |
|
1124 } |
|
1125 |
|
1126 // --------------------------------------------------------------------------- |
|
1127 // Function: UpdateNmsChannelID |
|
1128 // updates the channel id |
|
1129 // --------------------------------------------------------------------------- |
|
1130 // |
|
1131 EXPORT_C void CIRReportGenerator::UpdateNmsChannelID(TInt aChanneldID) |
|
1132 { |
|
1133 IRLOG_DEBUG( "CIRReportGenerator::UpdateNmsChannelID" ); |
|
1134 iNmsLog->UpdateChannelID(aChanneldID); |
|
1135 } |
|
1136 |
|
1137 // --------------------------------------------------------------------------- |
|
1138 // Function: WriteNmsLogData |
|
1139 // gathers Nmslog data and writes to XML file |
|
1140 // --------------------------------------------------------------------------- |
|
1141 // |
|
1142 void CIRReportGenerator::WriteNmsLogData(TInt aIndex) |
|
1143 { |
|
1144 IRLOG_DEBUG( "CIRReportGenerator::WriteNmsLogData" ); |
|
1145 TBuf<KFormatBuffMaxLength> FormatBuff; |
|
1146 _LIT(KConvert,"%d"); |
|
1147 |
|
1148 //NmsEvent Tag is written |
|
1149 iUniCodeBuf.Copy(KNMSEVENTTAG); |
|
1150 |
|
1151 iFileWritePos = iUniCodeBuf.Find(KField); |
|
1152 //Nms Event timestamp is copied |
|
1153 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iNmsLogData-> |
|
1154 At(aIndex))->StartTime()); |
|
1155 |
|
1156 //channel id is copied |
|
1157 iFileWritePos = iUniCodeBuf.Find(KField); |
|
1158 ASSERT( aIndex >= 0 && aIndex < iNmsLogData->Count() ); |
|
1159 FormatBuff.Format(KConvert,(iNmsLogData->At(aIndex))->ChannelID()); |
|
1160 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
1161 |
|
1162 //type is copied |
|
1163 iFileWritePos = iUniCodeBuf.Find(KField); |
|
1164 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,(iNmsLogData-> |
|
1165 At(aIndex))->NmsType()); |
|
1166 iFileWritePos = iUniCodeBuf.Find(KField); |
|
1167 |
|
1168 //current network is copied |
|
1169 ASSERT( aIndex >= 0 && aIndex < iNmsLogData->Count() ); |
|
1170 FormatBuff.Format(KConvert,(iNmsLogData->At(aIndex))-> |
|
1171 CurrentNetwork()); |
|
1172 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
1173 iFileWritePos = iUniCodeBuf.Find(KField); |
|
1174 |
|
1175 //home operator is copied |
|
1176 ASSERT( aIndex >= 0 && aIndex < iNmsLogData->Count() ); |
|
1177 FormatBuff.Format(KConvert,(iNmsLogData->At(aIndex))->HomeOperator()); |
|
1178 iUniCodeBuf.Replace(iFileWritePos,KFieldPosition,FormatBuff); |
|
1179 |
|
1180 CnvUtfConverter::ConvertFromUnicodeToUtf8(iUTF8Buffer,iUniCodeBuf); |
|
1181 //writting the information to the xml file |
|
1182 WriteBufferToLogFile(); |
|
1183 |
|
1184 IRLOG_DEBUG( "CIRReportGenerator::WriteNmsLogData - Exiting." ); |
|
1185 } |
|
1186 |
|
1187 // --------------------------------------------------------------------------- |
|
1188 // Function: ImeiUpdated |
|
1189 // From MIRPhoneInfoObserver |
|
1190 // --------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CIRReportGenerator::ImeiUpdatedL(const TDesC& aImei) |
|
1193 { |
|
1194 if(0 == aImei.Length()) |
|
1195 { |
|
1196 iPhoneInfo->StartUpdating(); |
|
1197 return; |
|
1198 } |
|
1199 // prepare base64 codec input |
|
1200 HBufC8 *imei = HBufC8::NewLC( aImei.Length() ); |
|
1201 TPtr8 imeiPtr = imei->Des(); |
|
1202 imeiPtr.Copy(aImei); |
|
1203 |
|
1204 // prepare base64 codec output |
|
1205 HBufC8 *buffer = HBufC8::NewLC( aImei.Length() * 2 ); |
|
1206 TPtr8 bufferPtr = buffer->Des(); |
|
1207 |
|
1208 // Encoding |
|
1209 TImCodecB64 base64Codec; |
|
1210 base64Codec.Initialise(); |
|
1211 base64Codec.Encode(*imei, bufferPtr); |
|
1212 |
|
1213 // store to data member |
|
1214 if(NULL == iImeiBase64) |
|
1215 { |
|
1216 iImeiBase64 = HBufC16::NewL( aImei.Length() * 2 ); |
|
1217 } |
|
1218 TPtr imeiBase64Ptr = iImeiBase64->Des(); |
|
1219 imeiBase64Ptr.Copy(bufferPtr); |
|
1220 |
|
1221 CleanupStack::PopAndDestroy(buffer); |
|
1222 CleanupStack::PopAndDestroy(imei); |
|
1223 } |
|
1224 |