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