equal
deleted
inserted
replaced
13 * |
13 * |
14 * Description: ?Description |
14 * Description: ?Description |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include <ezgzip.h> |
|
19 #include <bautils.h> |
|
20 #include <f32file.h> |
18 |
21 |
19 #include "irdataprovider.h" |
22 #include "irdataprovider.h" |
20 #include "irdataproviderobserver.h" |
23 #include "irdataproviderobserver.h" |
21 #include "irdebug.h" |
24 #include "irdebug.h" |
22 #include "irhttpdataprovider.h" |
25 #include "irhttpdataprovider.h" |
23 #include "irhttprequestdata.h" |
26 #include "irhttprequestdata.h" |
24 #include "irsettings.h" |
27 #include "irsettings.h" |
25 |
28 |
|
29 _LIT( KGzXmlFile, "iSdsResponse.xml.gz" ); |
|
30 _LIT( KXmlFile, "iSdsResponse.xml" ); |
|
31 |
26 // --------------------------------------------------------------------------- |
32 // --------------------------------------------------------------------------- |
27 // CIRDataProvider::NewL(MIRDataProviderObserver& aObserver) |
33 // CIRDataProvider::NewL(MIRDataProviderObserver& aObserver) |
28 // Creates instance of CIRDataProvider. |
34 // Creates instance of CIRDataProvider. |
29 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
30 // |
36 // |
108 delete iResponseHeaders; |
114 delete iResponseHeaders; |
109 iResponseHeaders = newResponseHeaders; |
115 iResponseHeaders = newResponseHeaders; |
110 |
116 |
111 |
117 |
112 // Create or replace the file used to store xml response from iSDS |
118 // Create or replace the file used to store xml response from iSDS |
113 User::LeaveIfError(iFile.Replace( iFsSession, iXmlFilePath, EFileWrite )); |
119 User::LeaveIfError(iFile.Replace( iFsSession, iXmlGzFilePath, EFileWrite )); |
114 iHttpDataProvider->CancelTransaction(); |
120 iHttpDataProvider->CancelTransaction(); |
115 |
121 |
116 TInt err = iHttpDataProvider->IssueHttpRequestL( aRequestObject ); |
122 TInt err = iHttpDataProvider->IssueHttpRequestL( aRequestObject ); |
117 // Cancel the timer if active |
123 // Cancel the timer if active |
118 iDataProviderTimer->Cancel(); |
124 iDataProviderTimer->Cancel(); |
177 { |
183 { |
178 IRLOG_DEBUG( "CIRDataProvider::HttpEventComplete - Entering" ); |
184 IRLOG_DEBUG( "CIRDataProvider::HttpEventComplete - Entering" ); |
179 iFile.Close(); |
185 iFile.Close(); |
180 iDataProviderTimer->Cancel(); |
186 iDataProviderTimer->Cancel(); |
181 |
187 |
|
188 // unzip the gz file |
|
189 TRAP_IGNORE( UnzipFileL( iXmlFilePath ) ); |
|
190 // delete the original gz file |
|
191 BaflUtils::DeleteFile( iFsSession, iXmlGzFilePath ); |
182 // Need to take a member to a local variable, as the IRHttpDataReceived may initiate |
192 // Need to take a member to a local variable, as the IRHttpDataReceived may initiate |
183 // an IRHttpIssueRequestL() call, causing the headers to be replaced with empty ones, and |
193 // an IRHttpIssueRequestL() call, causing the headers to be replaced with empty ones, and |
184 // causing crashes. |
194 // causing crashes. |
185 CIRHttpResponseData* currentHeaders = iResponseHeaders; |
195 CIRHttpResponseData* currentHeaders = iResponseHeaders; |
186 iResponseHeaders = NULL; // prevents the destructor to delete in case something streange happens. |
196 iResponseHeaders = NULL; // prevents the destructor to delete in case something streange happens. |
339 // --------------------------------------------------------------------------- |
349 // --------------------------------------------------------------------------- |
340 // |
350 // |
341 void CIRDataProvider::ConstructL() // second-phase constructor |
351 void CIRDataProvider::ConstructL() // second-phase constructor |
342 { |
352 { |
343 IRLOG_DEBUG( "CIRDataProvider::ConstructL - Entering" ); |
353 IRLOG_DEBUG( "CIRDataProvider::ConstructL - Entering" ); |
344 _LIT( KXmlFile, "iSdsResponse.xml" ); |
354 ConstructL( KGzXmlFile ); |
345 ConstructL(KXmlFile); |
|
346 iHttpDataProvider->iSetNonUAProfUserAgent = EFalse; |
355 iHttpDataProvider->iSetNonUAProfUserAgent = EFalse; |
347 IRLOG_DEBUG( "CIRDataProvider::ConstructL - Exiting" ); |
356 IRLOG_DEBUG( "CIRDataProvider::ConstructL - Exiting" ); |
348 } |
357 } |
349 |
358 |
350 // --------------------------------------------------------------------------- |
359 // --------------------------------------------------------------------------- |
357 IRLOG_DEBUG( "CIRDataProvider::ConstructL(const TDesC &aFileName) - Entering" ); |
366 IRLOG_DEBUG( "CIRDataProvider::ConstructL(const TDesC &aFileName) - Entering" ); |
358 iHttpDataProvider = CIRHttpDataProvider::NewL( *this ); |
367 iHttpDataProvider = CIRHttpDataProvider::NewL( *this ); |
359 iDataProviderTimer = CIRDataProviderTimer::NewL( EPriorityHigh, *this ); |
368 iDataProviderTimer = CIRDataProviderTimer::NewL( EPriorityHigh, *this ); |
360 User::LeaveIfError(iFsSession.Connect()); |
369 User::LeaveIfError(iFsSession.Connect()); |
361 iIRSettings = CIRSettings::OpenL(); |
370 iIRSettings = CIRSettings::OpenL(); |
362 iXmlFilePath = iIRSettings->PrivatePath(); |
371 iXmlGzFilePath = iIRSettings->PrivatePath(); |
363 iXmlFilePath.Append( aFileName ); |
372 iXmlFilePath = iXmlGzFilePath; |
|
373 iXmlGzFilePath.Append( aFileName ); |
|
374 iXmlFilePath.Append( KXmlFile ); |
364 iTimeOut = iIRSettings->GetTimeOut(); |
375 iTimeOut = iIRSettings->GetTimeOut(); |
365 iHttpDataProvider->iSetNonUAProfUserAgent = ETrue; |
376 iHttpDataProvider->iSetNonUAProfUserAgent = ETrue; |
366 IRLOG_DEBUG( "CIRDataProvider::ConstructL(const TDesC &aFileName) - Exiting." ); |
377 IRLOG_DEBUG( "CIRDataProvider::ConstructL(const TDesC &aFileName) - Exiting." ); |
367 } |
378 } |
368 |
379 |
428 //storing the offset value in setting |
439 //storing the offset value in setting |
429 TRAP_IGNORE( iIRSettings->SetTimeCorrectionL(offsetseconds.Int()) ) |
440 TRAP_IGNORE( iIRSettings->SetTimeCorrectionL(offsetseconds.Int()) ) |
430 IRLOG_DEBUG( "CIRDataProvider::SetOffsetSeconds - Exiting." ); |
441 IRLOG_DEBUG( "CIRDataProvider::SetOffsetSeconds - Exiting." ); |
431 } |
442 } |
432 |
443 |
433 |
444 // --------------------------------------------------------------------------- |
|
445 // CIRDataProvider::UnzipFileL |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 void CIRDataProvider::UnzipFileL( const TDesC& aOutputFile ) |
|
449 { |
|
450 IRLOG_DEBUG( "CIRDataProvider::UnzipFileL - Enter." ); |
|
451 RFile outputFile; |
|
452 CleanupClosePushL( outputFile ); |
|
453 User::LeaveIfError( outputFile.Replace( iFsSession, aOutputFile, |
|
454 EFileStream | EFileWrite | EFileShareExclusive ) ); |
|
455 CEZGZipToFile* gZip = |
|
456 CEZGZipToFile::NewLC( iFsSession, iXmlGzFilePath, outputFile ); |
|
457 |
|
458 while ( gZip->InflateL() ) |
|
459 { |
|
460 // unzip the gz file, quit when finish |
|
461 } |
|
462 CleanupStack::PopAndDestroy( gZip ); |
|
463 CleanupStack::PopAndDestroy( &outputFile ); |
|
464 IRLOG_DEBUG( "CIRDataProvider::UnzipFileL - Exit." ); |
|
465 } |