|
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 <escapeutils.h> |
|
20 #include <tinternetdate.h> |
|
21 #include <utf.h> |
|
22 |
|
23 #include "irbrowsecatagoryitems.h" |
|
24 #include "irbrowsechannelitems.h" |
|
25 #include "ircachemgmt.h" |
|
26 #include "irdataprovider.h" |
|
27 #include "irdataproviderconstants.h" |
|
28 #include "irdebug.h" |
|
29 #include "irhttprequestdata.h" |
|
30 #include "irotaupdate.h" |
|
31 #include "irsessionlogger.h" |
|
32 #include "irsettings.h" |
|
33 #include "irxmlcontenthandler.h" |
|
34 #include "isdsclientdll.h" |
|
35 #include "misdsresponseobserver.h" |
|
36 #include "irisdspreset.h" |
|
37 |
|
38 const TInt KChannelidMaxLength = 25; |
|
39 const TInt KTwo = 2; |
|
40 /*const TInt KDays = 7; |
|
41 const TInt KHour = 24; |
|
42 const TInt KMinute = 60; |
|
43 const TInt KSecond = 60;*/ |
|
44 const TInt KUrlPassMaxLength = 124; |
|
45 const TInt KChidMaxLength = 6; |
|
46 const TInt KCopyOfTimeMaxLength = 32; |
|
47 const TInt KMaxLength = 256; |
|
48 const TInt KFour = 4; |
|
49 |
|
50 _LIT(KBrowseUrl,"/do/directory/browse?type="); |
|
51 _LIT(KChannelnSearchUrl,"/do/directory/browse?type=channels&searchText="); |
|
52 _LIT(KGetIRIDUrl,"/do/service/getIrid"); |
|
53 _LIT(KGenres,"genres"); |
|
54 _LIT(KLanguages,"languages"); |
|
55 _LIT(KCountries,"countries"); |
|
56 _LIT(KHotpicks,"hotpicks"); |
|
57 _LIT(KOtaUpdateUrl,"/do/service/otaUpdate?irid="); |
|
58 _LIT(KLogUsageUrl,"/do/service/logUsage"); |
|
59 _LIT(KSearchUrl,"&start=1&size=50"); |
|
60 _LIT(KMultiSearchUrl, "/do/directory/browse?type=channels&genreID=%S&countryID=%S&languageID=%S&searchText="); |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CIRIsdsClient::NewL(MIsdsResponseObserver& aobserver) |
|
64 // Used by UI to create instance of CIRIsdsClient. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C CIRIsdsClient* CIRIsdsClient::NewL( MIsdsResponseObserver& aobserver, |
|
68 const TDesC& aISDSBaseUrl ) |
|
69 { |
|
70 IRLOG_DEBUG( "CIRIsdsClient::NewL - Entering" ); |
|
71 CIRIsdsClient* self = CIRIsdsClient::NewLC( aobserver, aISDSBaseUrl ); |
|
72 |
|
73 CleanupStack::Pop( self ); |
|
74 IRLOG_DEBUG( "CIRIsdsClient::NewL - Exiting." ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CIRIsdsClient::NewLC(MIsdsResponseObserver& aobserver) |
|
80 // Creates instance of CIRIsdsClient. |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CIRIsdsClient* CIRIsdsClient::NewLC( MIsdsResponseObserver& aobserver, |
|
84 const TDesC& aISDSBaseUrl ) |
|
85 { |
|
86 IRLOG_DEBUG( "CIRIsdsClient::NewLC - Entering" ); |
|
87 CIRIsdsClient* self = new ( ELeave ) CIRIsdsClient( aobserver ); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL( aISDSBaseUrl ); |
|
90 IRLOG_DEBUG( "CIRIsdsClient::NewLC - Exiting." ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CIRIsdsClient::ConstructL() |
|
96 // Symbian two phased constructor |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CIRIsdsClient::ConstructL( const TDesC& aISDSBaseUrl ) |
|
100 { |
|
101 //!Construsting the DataproviderDLL instance |
|
102 IRLOG_DEBUG( "IRIsdsClient::ConstructL - Entering" ); |
|
103 iSettings = CIRSettings::OpenL(); |
|
104 iISDSBaseUrl = aISDSBaseUrl.AllocL(); |
|
105 //Base URL required to browse through the category |
|
106 iCatgoryURL.Zero(); |
|
107 iCatgoryURL.Copy( *iISDSBaseUrl ); |
|
108 iCatgoryURL.Append( KBrowseUrl ); |
|
109 //Base URL required to search isds |
|
110 iSearchURL.Zero(); |
|
111 iSearchURL.Copy( *iISDSBaseUrl ); |
|
112 iSearchURL.Append( KChannelnSearchUrl ); |
|
113 //Base URL required to get IRID |
|
114 iGetIridUrl.Zero(); |
|
115 iGetIridUrl.Copy( *iISDSBaseUrl ); |
|
116 iGetIridUrl.Append( KGetIRIDUrl ); |
|
117 //creates DataProvider |
|
118 iDataProvider = CIRDataProvider::NewL( *this ); |
|
119 //creates XML Parser |
|
120 iXmlReader = CIRXMLContentHandler::NewL( *this, *this ); |
|
121 //creates Cache manager |
|
122 iCache = CIRCacheMgmt::OpenL( *this ); |
|
123 iCache->AddObserverL( this ); |
|
124 //Session Log |
|
125 iBrowseReport = CIRReportGenerator::OpenL(); |
|
126 // Retrive the current language and set it as an Accept Language |
|
127 TLanguage currentLanguage = User::Language(); |
|
128 iShortLanguageCode = IRLanguageMapper::MapLanguage( currentLanguage ); |
|
129 |
|
130 IRLOG_DEBUG( "IRIsdsClient::ConstructL - Exiting." ); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CIRIsdsClient::CIRIsdsClient(MIsdsResponseObserver& aobserver) |
|
135 // Default constructor |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 CIRIsdsClient::CIRIsdsClient( MIsdsResponseObserver& aobserver ) |
|
139 : iIsdsResponseObserver( aobserver ) |
|
140 { |
|
141 IRLOG_DEBUG( "CIRIsdsClient::CIRIsdsClient" ); |
|
142 //No implementation |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CIRIsdsClient::~CIRIsdsClient() |
|
147 // Destructor |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 CIRIsdsClient::~CIRIsdsClient() |
|
151 { |
|
152 IRLOG_DEBUG( "CIRIsdsClient::~CIRIsdsClient - Entering" ); |
|
153 delete iDataProvider; |
|
154 delete iXmlReader; |
|
155 if ( iSendPreset ) |
|
156 { |
|
157 iSendPreset->ResetAndDestroy(); |
|
158 } |
|
159 delete iSendPreset; |
|
160 |
|
161 if ( iCache ) |
|
162 { |
|
163 iCache->RemoveObserver( this ); |
|
164 iCache->Close(); |
|
165 } |
|
166 |
|
167 if ( iSettings ) |
|
168 { |
|
169 iSettings->Close(); |
|
170 } |
|
171 delete iISDSBaseUrl; |
|
172 if ( iBrowseReport ) |
|
173 { |
|
174 iBrowseReport->Close(); |
|
175 } |
|
176 if ( iTempRequestObject ) |
|
177 { |
|
178 delete iTempRequestObject; |
|
179 iTempRequestObject = NULL; |
|
180 } |
|
181 |
|
182 IRLOG_DEBUG( "CIRIsdsClient::~CIRIsdsClient - Exiting." ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CIRIsdsClient::IRIsdsIsCategoryCachedL |
|
187 // Destructor |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 EXPORT_C TBool CIRIsdsClient::IRIsdsIsCategoryCachedL( |
|
191 TIRIsdsclientInterfaceIDs aISDSClientRequest) |
|
192 { |
|
193 iForceGet=EFalse; |
|
194 TInt res = 0; |
|
195 iCacheReqMade = EFalse; |
|
196 switch( aISDSClientRequest ) |
|
197 { |
|
198 //When genre data is requested by user |
|
199 case EGenre: |
|
200 { |
|
201 //set the request type for subsiquent Use |
|
202 |
|
203 iCachePath.Zero(); |
|
204 iCachePath.Copy( KGenres ); |
|
205 iCache->CheckCacheL( 0, KGenres, iForceGet, res ); |
|
206 } |
|
207 |
|
208 break; |
|
209 //When Language data is requested by user |
|
210 case ELanguages: |
|
211 { |
|
212 |
|
213 iCachePath.Zero(); |
|
214 iCachePath.Copy( KLanguages ); |
|
215 iCache->CheckCacheL( 0, KLanguages, iForceGet, res ); |
|
216 |
|
217 } |
|
218 break; |
|
219 //When Country data is requested by user |
|
220 case ECountries: |
|
221 { |
|
222 |
|
223 iCachePath.Zero(); |
|
224 iCachePath.Copy( KCountries ); |
|
225 iCache->CheckCacheL( 0, KCountries, iForceGet, res ); |
|
226 } |
|
227 break; |
|
228 |
|
229 //When hotpics data is requested by user |
|
230 case Ehotpicks: |
|
231 { |
|
232 //set the request type for subsiquent Use |
|
233 iCachePath.Zero(); |
|
234 iCachePath.Copy( KHotpicks ); |
|
235 iCache->CheckCacheL( 1, KHotpicks, iForceGet, res ); |
|
236 |
|
237 } |
|
238 break; |
|
239 default: |
|
240 break; |
|
241 } |
|
242 |
|
243 if ( res == CIRCacheMgmt::ECacheUseable ) |
|
244 { |
|
245 return ETrue; |
|
246 } |
|
247 |
|
248 return EFalse; |
|
249 } |
|
250 // --------------------------------------------------------------------------- |
|
251 // void CIRIsdsClientInteface(TIRIsdsclientInterfaceIDs aISDSClientRequest) |
|
252 // Called by UI to make request to ISDS for catogories |
|
253 // @param :ENUM value depending on catogory which user wants to explore |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 |
|
257 EXPORT_C TBool CIRIsdsClient::IRIsdsClientIntefaceL( |
|
258 TIRIsdsclientInterfaceIDs aISDSClientRequest ) |
|
259 { |
|
260 //cancels any pending request |
|
261 IRLOG_DEBUG( "CIRIsdsClient::IRIsdsClientIntefaceL - Entering" ); |
|
262 CIRHttpRequestData * requestData = new ( ELeave ) CIRHttpRequestData; |
|
263 CleanupStack::PushL( requestData ); |
|
264 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
265 //Sets the Htpp method to GET |
|
266 requestData->iMethod = EIRHttpGET; |
|
267 //check for valid cache |
|
268 iForceGet = EFalse; |
|
269 |
|
270 TInt res = 0; |
|
271 |
|
272 switch ( aISDSClientRequest ) |
|
273 { |
|
274 //When genre data is requested by user |
|
275 case EGenre: |
|
276 { |
|
277 //set the request type for subsiquent Use |
|
278 iRequestType = 0; |
|
279 iDataFrom = EFalse; |
|
280 iCachePath.Zero(); |
|
281 iCachePath.Copy( KGenres ); |
|
282 iCacheReqMade = ETrue; |
|
283 iCache->CheckCacheL( 0, KGenres, iForceGet, res ); |
|
284 if ( res == 0 )//if cache is not available |
|
285 { |
|
286 requestData->iUri.Copy( iCatgoryURL ); |
|
287 requestData->iUri.Append( KGenres ); |
|
288 iConditonalGet = EFalse; |
|
289 //issues request for Genre data |
|
290 IRHttpIssueRequestL( *requestData ); |
|
291 iBrowseUrl.Zero(); |
|
292 iBrowseUrl.Copy( requestData->iUri ); |
|
293 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
294 iDataFrom = ETrue; |
|
295 } |
|
296 if ( res == -1 )//i cache is stale |
|
297 { |
|
298 iConditonalGet = ETrue; |
|
299 requestData->iIfModifiedSince = iLastModifiedTime.DateTime(); |
|
300 requestData->isIfModifiedSet = ETrue; |
|
301 requestData->iUri.Copy( iCatgoryURL ); |
|
302 requestData->iUri.Append( KGenres ); |
|
303 IRHttpIssueRequestL( *requestData ); |
|
304 iBrowseUrl.Zero(); |
|
305 iBrowseUrl.Copy( requestData->iUri ); |
|
306 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
307 iDataFrom = ETrue; |
|
308 } |
|
309 if ( res == 1 ) |
|
310 { |
|
311 requestData->iUri.Copy( iCatgoryURL ); |
|
312 requestData->iUri.Append( KGenres ); |
|
313 iBrowseUrl.Zero(); |
|
314 iBrowseUrl.Copy( requestData->iUri ); |
|
315 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
316 } |
|
317 } |
|
318 break; |
|
319 //When Language data is requested by user |
|
320 case ELanguages: |
|
321 { |
|
322 //set the request type for subsiquent Use |
|
323 iRequestType = 0; |
|
324 iDataFrom = EFalse; |
|
325 |
|
326 iCachePath.Zero(); |
|
327 iCachePath.Copy( KLanguages ); |
|
328 iCacheReqMade = ETrue; |
|
329 iCache->CheckCacheL( 0, KLanguages, iForceGet, res ); |
|
330 |
|
331 if ( res == 0 )//if cache is not available |
|
332 { |
|
333 requestData->iUri.Copy( iCatgoryURL ); |
|
334 requestData->iUri.Append( KLanguages ); |
|
335 //Isuues request for language data |
|
336 IRHttpIssueRequestL( *requestData ); |
|
337 iConditonalGet = EFalse; |
|
338 iBrowseUrl.Zero(); |
|
339 iBrowseUrl.Copy( requestData->iUri ); |
|
340 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
341 iDataFrom = ETrue; |
|
342 } |
|
343 if ( res == -1 )//i cache is stale |
|
344 { |
|
345 iConditonalGet = ETrue; |
|
346 requestData->iIfModifiedSince = iLastModifiedTime.DateTime(); |
|
347 requestData->isIfModifiedSet = ETrue; |
|
348 requestData->iUri.Copy( iCatgoryURL ); |
|
349 requestData->iUri.Append( KLanguages ); |
|
350 //Isuues request for language data if cache isnt valid |
|
351 IRHttpIssueRequestL( *requestData ); |
|
352 iBrowseUrl.Zero(); |
|
353 iBrowseUrl.Copy( requestData->iUri ); |
|
354 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
355 iDataFrom = ETrue; |
|
356 } |
|
357 if ( res == 1 ) |
|
358 { |
|
359 requestData->iUri.Copy( iCatgoryURL ); |
|
360 requestData->iUri.Append( KLanguages ); |
|
361 iBrowseUrl.Zero(); |
|
362 iBrowseUrl.Copy( requestData->iUri ); |
|
363 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
364 } |
|
365 } |
|
366 break; |
|
367 //When Country data is requested by user |
|
368 case ECountries: |
|
369 { |
|
370 //set the request type for subsiquent Use |
|
371 iRequestType = 0; |
|
372 iDataFrom = EFalse; |
|
373 |
|
374 iCachePath.Zero(); |
|
375 iCachePath.Copy( KCountries ); |
|
376 iCacheReqMade = ETrue; |
|
377 iCache->CheckCacheL( 0, KCountries, iForceGet, res ); |
|
378 if ( res == 0 )//if cache is not available |
|
379 { |
|
380 requestData->iUri.Copy( iCatgoryURL ); |
|
381 requestData->iUri.Append( KCountries ); |
|
382 //Isuues request for country data |
|
383 IRHttpIssueRequestL( *requestData ); |
|
384 iConditonalGet = EFalse; |
|
385 iBrowseUrl.Zero(); |
|
386 iBrowseUrl.Copy( requestData->iUri ); |
|
387 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
388 iDataFrom = ETrue; |
|
389 } |
|
390 if ( res == -1 )//i cache is stale |
|
391 { |
|
392 iConditonalGet = ETrue; |
|
393 requestData->iIfModifiedSince = iLastModifiedTime.DateTime(); |
|
394 requestData->isIfModifiedSet = ETrue; |
|
395 requestData->iUri.Copy( iCatgoryURL ); |
|
396 requestData->iUri.Append( KCountries ); |
|
397 //Isuues request for country data if cache isnt valid |
|
398 IRHttpIssueRequestL( *requestData ); |
|
399 iBrowseUrl.Zero(); |
|
400 iBrowseUrl.Copy( requestData->iUri ); |
|
401 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
402 iDataFrom = ETrue; |
|
403 } |
|
404 if ( res == 1 ) |
|
405 { |
|
406 requestData->iUri.Copy( iCatgoryURL ); |
|
407 requestData->iUri.Append( KCountries ); |
|
408 iBrowseUrl.Zero(); |
|
409 iBrowseUrl.Copy( requestData->iUri ); |
|
410 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
411 } |
|
412 |
|
413 } |
|
414 break; |
|
415 |
|
416 //When hotpics data is requested by user |
|
417 case Ehotpicks: |
|
418 { |
|
419 //set the request type for subsiquent Use |
|
420 iRequestType = 1; |
|
421 iCacheReqMade = ETrue; |
|
422 iCache->CheckCacheL( 1, KHotpicks, iForceGet, res ); |
|
423 iCachePath.Zero(); |
|
424 iCachePath.Copy( KHotpicks ); |
|
425 iDataFrom = EFalse; |
|
426 |
|
427 if ( res == 0 )//if cache is not available |
|
428 { |
|
429 requestData->iUri.Copy( iCatgoryURL ); |
|
430 requestData->iUri.Append( KHotpicks ); |
|
431 //Isuues request for hotpics data |
|
432 IRHttpIssueRequestL( *requestData ); |
|
433 iConditonalGet = EFalse; |
|
434 iBrowseUrl.Zero(); |
|
435 iBrowseUrl.Copy( requestData->iUri ); |
|
436 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
437 iDataFrom = ETrue; |
|
438 } |
|
439 if ( res == -1 )//i cache is stale |
|
440 { |
|
441 iConditonalGet = ETrue; |
|
442 requestData->iIfModifiedSince = iLastModifiedTime.DateTime(); |
|
443 requestData->isIfModifiedSet = ETrue; |
|
444 requestData->iUri.Copy( iCatgoryURL ); |
|
445 requestData->iUri.Append( KHotpicks ); |
|
446 //Isuues request for hotpics data if cache isnt valid |
|
447 IRHttpIssueRequestL( *requestData ); |
|
448 iBrowseUrl.Zero(); |
|
449 iBrowseUrl.Copy( requestData->iUri ); |
|
450 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
451 iDataFrom = ETrue; |
|
452 } |
|
453 if ( res == 1 ) |
|
454 { |
|
455 requestData->iUri.Copy( iCatgoryURL ); |
|
456 requestData->iUri.Append( KHotpicks ); |
|
457 iBrowseUrl.Zero(); |
|
458 iBrowseUrl.Copy( requestData->iUri ); |
|
459 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
460 } |
|
461 } |
|
462 break; |
|
463 |
|
464 } |
|
465 CleanupStack::PopAndDestroy( requestData ); |
|
466 IRLOG_DEBUG( "CIRIsdsClient::IRIsdsClientIntefaceL - Exiting." ); |
|
467 return iDataFrom; |
|
468 }//end of function |
|
469 |
|
470 // --------------------------------------------------------------------------- |
|
471 // CIRIsdsClient::GetDataProvider |
|
472 // |
|
473 // --------------------------------------------------------------------------- |
|
474 // |
|
475 EXPORT_C CIRDataProvider* CIRIsdsClient::GetDataProvider() |
|
476 { |
|
477 IRLOG_DEBUG( "CIRIsdsClient::GetDataProvider" ); |
|
478 return iDataProvider; |
|
479 } |
|
480 |
|
481 // --------------------------------------------------------------------------- |
|
482 // void IRHttpContentNotChanged() |
|
483 // this is call back funtion called by Dataprovider in case |
|
484 // HTTP content isnt changed by ISDS |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 void CIRIsdsClient::IRHttpResponseCodeReceived( TInt aResponseCode, |
|
488 CIRHttpResponseData& aResponseHeaders ) |
|
489 { |
|
490 IRLOG_INFO2( "CIRIsdsClient::IRHttpResponseCodeReceived (%d)", aResponseCode ); |
|
491 TInt res = KErrNotFound; |
|
492 switch ( aResponseCode ) |
|
493 { |
|
494 case KNotFound://404 |
|
495 { |
|
496 //make channel user defined. |
|
497 if ( iSyncRequest ) |
|
498 { |
|
499 iSyncRequest = EFalse; |
|
500 //make the preset user-defined |
|
501 TRAP_IGNORE(iIsdsResponseObserver.IsdsPresetRemovedL( |
|
502 iPresetToBeSynced)) |
|
503 } |
|
504 |
|
505 /*if(iOtaReqFrom) |
|
506 { |
|
507 TRAP_IGNORE(PurgeOtaInfoL()) |
|
508 }*/ |
|
509 |
|
510 } |
|
511 break; |
|
512 case KNotModified://304 |
|
513 { |
|
514 if ( iConditonalGet ) |
|
515 { |
|
516 //update the trust period |
|
517 //no problem if it leaves |
|
518 TRAP_IGNORE( iCache->UpdateTrustPeriodL( iRequestType,iCachePath, |
|
519 aResponseHeaders ) ) |
|
520 //do a forced get because the data is notmodifed in isds and |
|
521 //trustable |
|
522 iForceGet = ETrue; |
|
523 iCacheReqMade = ETrue; |
|
524 TRAP_IGNORE( iCache->CheckCacheL( iRequestType,iCachePath, |
|
525 iForceGet,res ) ) |
|
526 } |
|
527 /*if(iOtaReqFrom) |
|
528 { |
|
529 TRAP_IGNORE(PurgeOtaInfoL()) |
|
530 }*/ |
|
531 } |
|
532 break; |
|
533 default: |
|
534 { |
|
535 |
|
536 } |
|
537 break; |
|
538 } |
|
539 IRLOG_DEBUG( "CIRIsdsClient::IRHttpResponseCodeReceived - Exiting." ); |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------------------------- |
|
543 // void RHttpGeneralError(TInt aErrorCode) |
|
544 // It is a call back function called by the data provider |
|
545 // to return error code in case of some error. |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 void CIRIsdsClient::IRHttpGeneralError( TInt aErrorCode ) |
|
549 { |
|
550 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Entering" ); |
|
551 IRLOG_ERROR2( "CIRIsdsClient::IRHttpGeneralError (%d)", aErrorCode ); |
|
552 if ( iSyncRequest ) |
|
553 { |
|
554 IRLOG_DEBUG( "CIRISDSCLIENT::IRHTTPGENERALERROR--IF ISYNC" ); |
|
555 iSyncRequest = EFalse; |
|
556 if ( aErrorCode == KNotModified || aErrorCode == KServiceUnavailable ) |
|
557 { |
|
558 TRAP_IGNORE( iIsdsResponseObserver.IsdsPresetNoChangeL() ) |
|
559 return; |
|
560 } |
|
561 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (1)." ); |
|
562 } |
|
563 |
|
564 /*if(iOtaReqFrom) |
|
565 { |
|
566 //if internal service request |
|
567 //reset the flag |
|
568 iOtaReqFrom = EFalse |
|
569 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (2)." ) |
|
570 return |
|
571 }*/ |
|
572 if ( iConditonalGet ) |
|
573 { |
|
574 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (3)." ); |
|
575 iConditonalGet = EFalse; |
|
576 if ( aErrorCode == KNotModified ) |
|
577 { |
|
578 return; |
|
579 } |
|
580 } |
|
581 if ( iPostResponsePending ) |
|
582 { |
|
583 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (4)." ); |
|
584 IRLOG_DEBUG( "CIRISDSCLIENT::ISDSGENERALERROR--POSTPENDING" ); |
|
585 iPostResponsePending = EFalse; |
|
586 //no action required |
|
587 //session log is backed up before sending; |
|
588 return; |
|
589 } |
|
590 if ( iIRIDPending ) |
|
591 { |
|
592 IRRDEBUG2("CIRISDSCLIENT::IRHTTPGENERALERROR--IF IRID",KNullDesC ); |
|
593 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (7)." ); |
|
594 iIRIDPending = EFalse; |
|
595 //dTRAP_IGNORE( IRGetIRIDL() ) |
|
596 } |
|
597 IRLOG_DEBUG("CIRISDSCLIENT::IRHTTPGENERALERROR--BEFORE TRAPD" ); |
|
598 TRAPD( errd, iIsdsResponseObserver.IsdsErrorL( aErrorCode ) ); |
|
599 if ( errd ) |
|
600 { |
|
601 IRLOG_DEBUG("CIRISDSCLIENT::IRHTTPGENERALERROR--IF ERRD" ); |
|
602 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (5)." ); |
|
603 return; |
|
604 } |
|
605 IRLOG_DEBUG( "CIRIsdsClient::IRHttpGeneralError - Exiting (6)." ); |
|
606 } |
|
607 |
|
608 // --------------------------------------------------------------------------- |
|
609 // void IRHttpDataReceived(TDesC& aXmlPath) |
|
610 // It is a call back function called by the data provider |
|
611 // once it recieves the XML data |
|
612 // --------------------------------------------------------------------------- |
|
613 // |
|
614 void CIRIsdsClient::IRHttpDataReceived( const TDesC& aXmlPath, |
|
615 const CIRHttpResponseData& aResponseHeaders ) |
|
616 { |
|
617 IRLOG_DEBUG( "CIRIsdsClient::IRHttpDataReceived - Entering" ); |
|
618 TBuf<KMaxLength> xmlPath; |
|
619 xmlPath.Copy( aXmlPath ); |
|
620 //!Calls XML parser with file path to XML file recieved |
|
621 TRAPD( xmlErr,iXmlReader->ParseXmlL( xmlPath, iCachePath, aResponseHeaders ) ) |
|
622 if ( xmlErr != KErrNone ) |
|
623 { |
|
624 IRLOG_DEBUG( "CIRIsdsClient::IRHttpDataReceived - Exiting (1)." ); |
|
625 return; |
|
626 } |
|
627 |
|
628 if ( iIRIDPending ) |
|
629 { |
|
630 iIRIDPending = EFalse; |
|
631 //if any request is pending by the time IRID response comes |
|
632 if ( iReqPending ) |
|
633 { |
|
634 //issue the pending request |
|
635 TRAP_IGNORE( IRHttpIssueRequestL( *iTempRequestObject ) ) |
|
636 } |
|
637 } |
|
638 |
|
639 IRLOG_DEBUG( "CIRIsdsClient::IRHttpDataReceived - Exiting (2)." ); |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // CIRIsdsClient::IRIsdsIsChannelCachedL |
|
644 // |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 EXPORT_C TBool CIRIsdsClient::IRIsdsIsChannelCachedL( TUint aSelectedOption ) |
|
648 { |
|
649 TInt res = 0; |
|
650 iCacheReqMade = EFalse; |
|
651 iForceGet=EFalse; |
|
652 |
|
653 //previous data from cache |
|
654 if (iCatDataFrom) |
|
655 { |
|
656 if (aSelectedOption >= iCache->iPtrCategory->Count()) |
|
657 { |
|
658 User::Leave(KErrArgument); |
|
659 } |
|
660 |
|
661 if (iCache->iPtrCategory->Count()) |
|
662 { |
|
663 iCachePath.Zero(); |
|
664 iCachePath.Copy( |
|
665 (*(iCache->iPtrCategory))[aSelectedOption]->iCatId->Des()); |
|
666 |
|
667 iCache->CheckCacheL(1, |
|
668 iCachePath, |
|
669 iForceGet, res); |
|
670 } |
|
671 } |
|
672 //previous data from xml |
|
673 else |
|
674 { |
|
675 if (aSelectedOption >= iXmlReader->iPtrCategory->Count()) |
|
676 { |
|
677 User::Leave( KErrArgument ); |
|
678 } |
|
679 |
|
680 if (iXmlReader->iPtrCategory->Count()) |
|
681 { |
|
682 iCachePath.Zero(); |
|
683 iCachePath.Copy( |
|
684 (*(iXmlReader-> iPtrCategory))[aSelectedOption]->iCatId->Des()); |
|
685 iCache->CheckCacheL( |
|
686 1, |
|
687 iCachePath, |
|
688 iForceGet, res ); |
|
689 } |
|
690 } |
|
691 |
|
692 if( CIRCacheMgmt::ECacheUseable == res ) |
|
693 return ETrue; |
|
694 |
|
695 return EFalse; |
|
696 } |
|
697 |
|
698 // --------------------------------------------------------------------------- |
|
699 // void CIRIsdsClientInteface(TUint aSelectedOption,TIRIsdsClientInterfaces aChoice) |
|
700 // This API is used by the UI to make request for isds listed channels |
|
701 // --------------------------------------------------------------------------- |
|
702 // |
|
703 EXPORT_C TBool CIRIsdsClient::IRIsdsClientIntefaceL( TUint aSelectedOption, |
|
704 TIRIsdsClientInterfaces aChoice, TInt aHistoryBool ) |
|
705 { |
|
706 IRLOG_DEBUG( "CIRIsdsClient::IRIsdsClientIntefaceL - Entering" ); |
|
707 iForceGet = EFalse; |
|
708 CIRHttpRequestData * requestData = new ( ELeave ) CIRHttpRequestData; |
|
709 CleanupStack::PushL( requestData ); |
|
710 requestData->iMethod = EIRHttpGET; |
|
711 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
712 requestData->iUri.Copy( *iISDSBaseUrl ); |
|
713 |
|
714 TBool isAdvPresent = EFalse; |
|
715 |
|
716 TInt res( 0 ); |
|
717 if ( aChoice == ECatagory ) |
|
718 { |
|
719 //set the request type for subsiquent Use |
|
720 iRequestType = 1; |
|
721 //previous data from cache |
|
722 if ( iCatDataFrom ) |
|
723 { |
|
724 TInt categoryCacheIndex; |
|
725 |
|
726 if ( ( *( iCache->iPtrCategory ) )[0]->iCatGetOperation ) |
|
727 { |
|
728 isAdvPresent = EFalse; |
|
729 } |
|
730 else |
|
731 { |
|
732 isAdvPresent = ETrue; |
|
733 } |
|
734 if ( !isAdvPresent ) |
|
735 { |
|
736 categoryCacheIndex = 0; |
|
737 } |
|
738 else |
|
739 { |
|
740 categoryCacheIndex = 1; |
|
741 } |
|
742 |
|
743 if ( aSelectedOption >= iCache->iPtrCategory->Count() ) |
|
744 { |
|
745 User::Leave( KErrArgument ); |
|
746 } |
|
747 |
|
748 if ( iCache->iPtrCategory->Count() ) |
|
749 { |
|
750 iCachePath.Zero(); |
|
751 iCachePath.Copy( |
|
752 ( *( iCache->iPtrCategory ) )[aSelectedOption]->iCatId->Des() ); |
|
753 iCacheReqMade = ETrue; |
|
754 iCache->CheckCacheL( |
|
755 1, |
|
756 ( *( iCache->iPtrCategory ) )[aSelectedOption]-> iCatId->Des(), |
|
757 iForceGet, res ); |
|
758 iDataFrom = EFalse; |
|
759 if ( res == 0 ) |
|
760 { |
|
761 requestData->iUri.Append( |
|
762 ( *( iCache-> iPtrCategory ) )[categoryCacheIndex]->iCatGetOperation->Des() ); |
|
763 requestData->iUri.Append( |
|
764 ( *( iCache-> iPtrCategory ) )[aSelectedOption]->iCatId->Des() ); |
|
765 IRHttpIssueRequestL( *requestData ); |
|
766 iConditonalGet = EFalse; |
|
767 iBrowseUrl.Copy( requestData->iUri ); |
|
768 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
769 iDataFrom = ETrue; |
|
770 } |
|
771 if ( res == -1 ) |
|
772 { |
|
773 iConditonalGet = ETrue; |
|
774 requestData->iIfModifiedSince |
|
775 = iLastModifiedTime.DateTime(); |
|
776 requestData->isIfModifiedSet = ETrue; |
|
777 requestData->iUri.Append( |
|
778 ( *( iCache-> iPtrCategory ) )[categoryCacheIndex]->iCatGetOperation->Des() ); //0 |
|
779 requestData->iUri.Append( |
|
780 ( *( iCache-> iPtrCategory ) )[aSelectedOption]->iCatId->Des() ); |
|
781 IRHttpIssueRequestL( *requestData ); |
|
782 iBrowseUrl.Copy( requestData->iUri ); |
|
783 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
784 iDataFrom = ETrue; |
|
785 } |
|
786 } |
|
787 } |
|
788 //previous data from xml |
|
789 else |
|
790 { |
|
791 TInt categoryXmlIndex; |
|
792 if ( ( *( iXmlReader->iPtrCategory ) )[0]->iCatGetOperation ) |
|
793 { |
|
794 isAdvPresent = EFalse; |
|
795 } |
|
796 else |
|
797 { |
|
798 isAdvPresent = ETrue; |
|
799 } |
|
800 if ( !isAdvPresent ) |
|
801 { |
|
802 categoryXmlIndex = 0; |
|
803 } |
|
804 else |
|
805 { |
|
806 categoryXmlIndex = 1; |
|
807 } |
|
808 |
|
809 if ( aSelectedOption >= iXmlReader->iPtrCategory->Count() ) |
|
810 { |
|
811 User::Leave( KErrArgument ); |
|
812 } |
|
813 |
|
814 if ( iXmlReader->iPtrCategory->Count() ) |
|
815 { |
|
816 iCachePath.Zero(); |
|
817 iCachePath.Copy( |
|
818 ( *( iXmlReader-> iPtrCategory ) )[aSelectedOption]->iCatId->Des() ); |
|
819 iCacheReqMade = ETrue; |
|
820 iCache->CheckCacheL( |
|
821 1, |
|
822 ( *( iXmlReader-> iPtrCategory ) )[aSelectedOption]->iCatId->Des(), |
|
823 iForceGet, res ); |
|
824 iDataFrom = EFalse; |
|
825 if ( res == 0 ) |
|
826 { |
|
827 requestData->iUri.Append( |
|
828 ( *( iXmlReader-> iPtrCategory ) )[categoryXmlIndex]->iCatGetOperation->Des() ); |
|
829 requestData->iUri.Append( |
|
830 ( *( iXmlReader-> iPtrCategory ) )[aSelectedOption]->iCatId->Des() ); |
|
831 IRHttpIssueRequestL( *requestData ); |
|
832 iConditonalGet = EFalse; |
|
833 iBrowseUrl.Copy( requestData->iUri ); |
|
834 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
835 iDataFrom = ETrue; |
|
836 } |
|
837 if ( res == -1 ) |
|
838 { |
|
839 iConditonalGet = ETrue; |
|
840 requestData->iIfModifiedSince |
|
841 = iLastModifiedTime.DateTime(); |
|
842 requestData->isIfModifiedSet = ETrue; |
|
843 requestData->iUri.Append( |
|
844 ( *( iXmlReader-> iPtrCategory ) )[categoryXmlIndex]->iCatGetOperation->Des() ); |
|
845 requestData->iUri.Append( |
|
846 ( *( iXmlReader-> iPtrCategory ) )[aSelectedOption]->iCatId->Des() ); |
|
847 IRHttpIssueRequestL( *requestData ); |
|
848 iBrowseUrl.Copy( requestData->iUri ); |
|
849 iBrowseReport->BrowseUrl( iBrowseUrl, 0 ); |
|
850 iDataFrom = ETrue; |
|
851 } |
|
852 } |
|
853 } |
|
854 } |
|
855 else if ( aChoice == EChannels ) |
|
856 { |
|
857 |
|
858 TBuf<KChannelidMaxLength> channelid; |
|
859 //set the request type for subsiquent Use |
|
860 iRequestType = KTwo; |
|
861 _LIT(KFormat,"%d"); |
|
862 if ( aHistoryBool ) |
|
863 { |
|
864 _LIT(KPresetFetchUrl,"/do/directory/getPreset?channelid="); |
|
865 requestData->iUri.Append( KPresetFetchUrl ); |
|
866 TBuf<KChannelidMaxLength> channelid; |
|
867 _LIT(KFormat,"%d"); |
|
868 channelid.Format( KFormat, aSelectedOption ); |
|
869 requestData->iUri.Append( channelid ); |
|
870 IRHttpIssueRequestL( *requestData ); |
|
871 iConditonalGet = EFalse; |
|
872 //Session Log |
|
873 iBrowseUrl.Zero(); |
|
874 iBrowseUrl.Copy( requestData->iUri ); |
|
875 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
876 iDataFrom = ETrue; |
|
877 CleanupStack::PopAndDestroy( requestData ); |
|
878 return iDataFrom; |
|
879 } |
|
880 |
|
881 //previous data from cache |
|
882 if ( iChannelDataFrom ) |
|
883 { |
|
884 TInt channelCacheIndex; |
|
885 if ( ( *( iCache->iPtrChannel ) )[0]->iChannelGetOperation ) |
|
886 { |
|
887 isAdvPresent = EFalse; |
|
888 } |
|
889 else |
|
890 { |
|
891 isAdvPresent = ETrue; |
|
892 } |
|
893 if ( !isAdvPresent ) |
|
894 { |
|
895 channelCacheIndex = 0; |
|
896 } |
|
897 else |
|
898 { |
|
899 channelCacheIndex = 1; |
|
900 } |
|
901 |
|
902 if( aSelectedOption >= iCache->iPtrChannel->Count()) |
|
903 { |
|
904 User::Leave( KErrArgument ); |
|
905 } |
|
906 |
|
907 if ( iCache->iPtrChannel->Count() ) |
|
908 { |
|
909 channelid.Format( |
|
910 KFormat, |
|
911 ( *( iCache-> iPtrChannel ) )[aSelectedOption]->iChannelID ); |
|
912 iCachePath.Zero(); |
|
913 iCachePath.Copy( channelid ); |
|
914 iCacheReqMade = ETrue; |
|
915 iCache->CheckCacheL( KTwo, channelid, iForceGet, res ); |
|
916 iDataFrom = EFalse; |
|
917 if ( res == 0 || res == -1 ) |
|
918 { |
|
919 requestData->iUri.Append( |
|
920 ( *( iCache-> iPtrChannel ) )[channelCacheIndex]->iChannelGetOperation->Des() ); |
|
921 requestData->iUri.Append( channelid ); |
|
922 IRHttpIssueRequestL( *requestData ); |
|
923 iConditonalGet = EFalse; |
|
924 //Session Log |
|
925 iBrowseUrl.Copy( requestData->iUri ); |
|
926 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
927 iDataFrom = ETrue; |
|
928 } |
|
929 } |
|
930 } |
|
931 //previous data from xml |
|
932 else |
|
933 { |
|
934 TInt channelXmlIndex; |
|
935 if ( 0 == ( *( iXmlReader->iPtrChannel ) ).Count() ) |
|
936 { |
|
937 CleanupStack::PopAndDestroy( requestData ); |
|
938 IRLOG_DEBUG( "CIRIsdsClient::IRIsdsClientIntefaceL - Error!" ); |
|
939 return iDataFrom; |
|
940 } |
|
941 |
|
942 if ( ( *( iXmlReader->iPtrChannel ) )[0]->iChannelGetOperation ) |
|
943 { |
|
944 isAdvPresent = EFalse; |
|
945 } |
|
946 else |
|
947 { |
|
948 isAdvPresent = ETrue; |
|
949 } |
|
950 if ( !isAdvPresent ) |
|
951 { |
|
952 channelXmlIndex = 0; |
|
953 } |
|
954 else |
|
955 { |
|
956 channelXmlIndex = 1; |
|
957 } |
|
958 |
|
959 if( aSelectedOption >= iXmlReader->iPtrChannel->Count()) |
|
960 { |
|
961 User::Leave( KErrArgument ); |
|
962 } |
|
963 |
|
964 if ( iXmlReader->iPtrChannel->Count() ) |
|
965 { |
|
966 channelid.Format( |
|
967 KFormat, |
|
968 ( *( iXmlReader-> iPtrChannel ) )[aSelectedOption]->iChannelID ); |
|
969 iCachePath.Zero(); |
|
970 iCachePath.Copy( channelid ); |
|
971 iCacheReqMade = ETrue; |
|
972 iCache->CheckCacheL( KTwo, channelid, iForceGet, res ); |
|
973 iDataFrom = EFalse; |
|
974 if ( res == 0 || res == -1 ) |
|
975 { |
|
976 requestData->iUri.Append( |
|
977 ( *( iXmlReader-> iPtrChannel ) )[channelXmlIndex]->iChannelGetOperation->Des() ); |
|
978 requestData->iUri.Append( channelid ); |
|
979 IRHttpIssueRequestL( *requestData ); |
|
980 iConditonalGet = EFalse; |
|
981 //Session Log |
|
982 iBrowseUrl.Copy( requestData->iUri ); |
|
983 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
984 iDataFrom = ETrue; |
|
985 } |
|
986 } |
|
987 } |
|
988 } |
|
989 else |
|
990 { |
|
991 |
|
992 } |
|
993 CleanupStack::PopAndDestroy( requestData ); |
|
994 IRLOG_DEBUG( "CIRIsdsClient::IRIsdsClientIntefaceL - Exiting" ); |
|
995 return iDataFrom; |
|
996 } |
|
997 |
|
998 // --------------------------------------------------------------------------- |
|
999 // void CIRGetIRID() |
|
1000 // This API is used by the UI to get IR ID from |
|
1001 // isds if it doesnt have one |
|
1002 // --------------------------------------------------------------------------- |
|
1003 // |
|
1004 EXPORT_C void CIRIsdsClient::IRGetIRIDL() |
|
1005 { |
|
1006 IRLOG_DEBUG( "CIRIsdsClient::IRGetIRIDL - Entering" ); |
|
1007 //if irid is not available fetch it |
|
1008 if ( iSettings->GetIRIDL().Length() == 0 ) |
|
1009 { |
|
1010 iReqFromGetIRIDFunc = ETrue; |
|
1011 iIRIDPending = EFalse; |
|
1012 CIRHttpRequestData *requestData = new ( ELeave ) CIRHttpRequestData(); |
|
1013 CleanupStack::PushL( requestData ); |
|
1014 requestData->iMethod = EIRHttpGET; |
|
1015 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1016 requestData->iUri.Copy( iGetIridUrl ); |
|
1017 IRHttpIssueRequestL( *requestData ); |
|
1018 CleanupStack::PopAndDestroy( requestData ); |
|
1019 iIRIDPending = ETrue; |
|
1020 IRLOG_DEBUG( "CIRIsdsClient::IRGetIRIDL - Exiting (1)." ); |
|
1021 return; |
|
1022 } |
|
1023 IRLOG_DEBUG( "CIRIsdsClient::IRGetIRIDL - Exiting (2)." ); |
|
1024 } |
|
1025 |
|
1026 // --------------------------------------------------------------------------- |
|
1027 // void GetOtaStatus() |
|
1028 // This API is used by the UI to query for ota update |
|
1029 // --------------------------------------------------------------------------- |
|
1030 // |
|
1031 EXPORT_C void CIRIsdsClient::GetOtaStatusL(TBool& aDataFrom) |
|
1032 { |
|
1033 IRLOG_DEBUG( "CIRIsdsClient::GetOtaStatusL - Entering" ); |
|
1034 |
|
1035 CIRHttpRequestData *requestData = new ( ELeave ) CIRHttpRequestData(); |
|
1036 |
|
1037 CleanupStack::PushL( requestData ); |
|
1038 |
|
1039 requestData->iMethod = EIRHttpGET; |
|
1040 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1041 iGetOtaStatus.Zero(); |
|
1042 iGetOtaStatus.Copy( *iISDSBaseUrl ); |
|
1043 iGetOtaStatus.Append( KOtaUpdateUrl ); |
|
1044 iGetOtaStatus.Append( iSettings->GetIRIDL() ); |
|
1045 |
|
1046 //set the request type for subsiquent Use |
|
1047 iRequestType = EOtaInfo; |
|
1048 iDataFrom = EFalse; |
|
1049 iCachePath.Zero(); |
|
1050 iCachePath.Copy( KOtaUpdateUrl ); |
|
1051 TInt res = 0; |
|
1052 //check cache if it is a genral service request |
|
1053 //not initiated by the user. |
|
1054 if ( iOtaReqFrom ) |
|
1055 { |
|
1056 iCacheReqMade = ETrue; |
|
1057 iCache->CheckCacheL( EOtaInfo, KOtaUpdateUrl, iForceGet, res ); |
|
1058 } |
|
1059 if ( res == 1 ) |
|
1060 { |
|
1061 aDataFrom = EFalse; |
|
1062 } |
|
1063 //if cache is not available or stale(dont use the trust period val) |
|
1064 if ( res == 0 || res == -1 ) |
|
1065 { |
|
1066 requestData->iUri.Copy( iGetOtaStatus ); |
|
1067 iConditonalGet = EFalse; |
|
1068 //issues request for ota data |
|
1069 iDataProvider->IRHttpIssueRequestL( *requestData ); |
|
1070 iDataFrom = ETrue; |
|
1071 aDataFrom = ETrue; |
|
1072 } |
|
1073 CleanupStack::PopAndDestroy( requestData ); |
|
1074 |
|
1075 IRLOG_DEBUG( "CIRIsdsClient::GetOtaStatusL - Exiting." ); |
|
1076 } |
|
1077 |
|
1078 // --------------------------------------------------------------------------- |
|
1079 // CIRIsdsClient::IRISDSPostL() |
|
1080 // This API is used to Post Irapp usage report to isds |
|
1081 // --------------------------------------------------------------------------- |
|
1082 // |
|
1083 EXPORT_C void CIRIsdsClient::IRISDSPostL(TFileName &/*aFileName*/) |
|
1084 { |
|
1085 IRLOG_DEBUG( "CIRIsdsClient::IRISDSPostL - Entering" ); |
|
1086 IRRDEBUG2("CIRISDSCLIENT::ISDSPOSTL",KNullDesC); |
|
1087 //Cancels any pending requests |
|
1088 IRISDSCancelRequest(); |
|
1089 CIRHttpRequestData * requestData = new ( ELeave ) CIRHttpRequestData; |
|
1090 CleanupStack::PushL( requestData ); |
|
1091 //Sets the Http Method to POST |
|
1092 requestData->iMethod = EIRHttpPOST; |
|
1093 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1094 requestData->iUri.Copy( *iISDSBaseUrl ); |
|
1095 requestData->iUri.Append( KLogUsageUrl ); |
|
1096 //issues request to post the log usage report to isds |
|
1097 iPostResponsePending = ETrue; |
|
1098 IRHttpIssueRequestL( *requestData ); |
|
1099 CleanupStack::PopAndDestroy( requestData ); |
|
1100 IRLOG_DEBUG( "CIRIsdsClient::IRISDSPostL - Exiting" ); |
|
1101 } |
|
1102 |
|
1103 // --------------------------------------------------------------------------- |
|
1104 // void CIRISDSCancelRequest() |
|
1105 // This API is used by the UI to cancel a request made. |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // |
|
1108 EXPORT_C void CIRIsdsClient::IRISDSCancelRequest() |
|
1109 { |
|
1110 IRLOG_DEBUG( "CIRIsdsClient::IRISDSCancelRequest - Entering" ); |
|
1111 iSyncRequest = EFalse; |
|
1112 iReqFromSync = EFalse; |
|
1113 iOtaReqFrom = EFalse; |
|
1114 iConditonalGet = EFalse; |
|
1115 iPostResponsePending = EFalse; |
|
1116 iIRIDPending = EFalse; |
|
1117 iDataProvider->IRHttpCancelRequest(); |
|
1118 IRLOG_DEBUG( "CIRIsdsClient::IRISDSCancelRequest - Exiting" ); |
|
1119 } |
|
1120 |
|
1121 // --------------------------------------------------------------------------- |
|
1122 // void IRISDSMultiSearchL() |
|
1123 // This API is used by the UI to search a channel. |
|
1124 // --------------------------------------------------------------------------- |
|
1125 // |
|
1126 EXPORT_C void CIRIsdsClient::IRISDSMultiSearchL(const TDesC& aGenreID, |
|
1127 const TDesC& aCountryID, |
|
1128 const TDesC& aLanguageID, |
|
1129 const TDesC& aSearchText) |
|
1130 { |
|
1131 IRLOG_DEBUG( "CIRIsdsClient::IRISDSMultiSearch - Entering" ); |
|
1132 CIRHttpRequestData * requestData= new(ELeave) CIRHttpRequestData(); |
|
1133 iCachePath.Zero(); |
|
1134 CleanupStack::PushL(requestData); |
|
1135 |
|
1136 requestData->iMethod = EIRHttpGET; |
|
1137 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1138 |
|
1139 HBufC8* utfEncodedSearchText = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aSearchText ); |
|
1140 CleanupStack::PushL( utfEncodedSearchText ); |
|
1141 |
|
1142 |
|
1143 HBufC8 *encodedQuery = NULL; |
|
1144 encodedQuery = EscapeUtils::EscapeEncodeL(*utfEncodedSearchText, |
|
1145 EscapeUtils::EEscapeQuery); |
|
1146 |
|
1147 HBufC* searchURL = HBufC::NewLC(iISDSBaseUrl->Length() |
|
1148 + KMultiSearchUrl().Length() |
|
1149 + aGenreID.Length() |
|
1150 + aLanguageID.Length() |
|
1151 + aCountryID.Length() |
|
1152 + KSearchUrl().Length() |
|
1153 + utfEncodedSearchText->Size()/2+1 ); |
|
1154 |
|
1155 HBufC* searchPartURL = HBufC::NewLC( KMultiSearchUrl().Length() |
|
1156 + aGenreID.Length() |
|
1157 + aLanguageID.Length() |
|
1158 + aCountryID.Length() ); |
|
1159 |
|
1160 searchPartURL->Des().Format( KMultiSearchUrl, &aGenreID, &aCountryID, |
|
1161 &aLanguageID ); |
|
1162 |
|
1163 HBufC* searchText = HBufC::NewLC( utfEncodedSearchText->Size()/2+1 ); |
|
1164 TPtr searchTextPtr( searchText->Des() ); |
|
1165 searchTextPtr.Copy( *utfEncodedSearchText ); |
|
1166 |
|
1167 TPtr uriPtr( searchURL->Des() ); |
|
1168 uriPtr.Append( *iISDSBaseUrl ); |
|
1169 uriPtr.Append( *searchPartURL ); |
|
1170 uriPtr.Append( searchTextPtr ); |
|
1171 uriPtr.Append( KSearchUrl ); |
|
1172 |
|
1173 if ( encodedQuery ) |
|
1174 { |
|
1175 delete encodedQuery; |
|
1176 } |
|
1177 |
|
1178 requestData->iUri.Copy( searchURL->Left( requestData->iUri.MaxLength() ) ); |
|
1179 IRHttpIssueRequestL( *requestData ); |
|
1180 CleanupStack::PopAndDestroy( searchText ); |
|
1181 CleanupStack::PopAndDestroy( searchPartURL ); |
|
1182 CleanupStack::PopAndDestroy( searchURL ); |
|
1183 CleanupStack::PopAndDestroy( utfEncodedSearchText ); |
|
1184 |
|
1185 |
|
1186 iBrowseUrl.Zero(); |
|
1187 iBrowseUrl.Copy( requestData->iUri ); |
|
1188 EncodeUrlL( iBrowseUrl ); |
|
1189 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
1190 CleanupStack::PopAndDestroy( requestData ); |
|
1191 |
|
1192 IRLOG_DEBUG( "CIRIsdsClient::IRISDSMultiSearch - Exiting." ); |
|
1193 } |
|
1194 |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // void CIRISDSSearch(TDesC& aSearchString) |
|
1197 // This API is used by the UI to search channels from isds |
|
1198 // --------------------------------------------------------------------------- |
|
1199 // |
|
1200 EXPORT_C void CIRIsdsClient::IRISDSSearchL(const TDesC& aSearchString) |
|
1201 { |
|
1202 IRLOG_DEBUG( "CIRIsdsClient::IRISDSSearchL - Entering" ); |
|
1203 CIRHttpRequestData * requestData = new ( ELeave ) CIRHttpRequestData(); |
|
1204 iCachePath.Zero(); |
|
1205 CleanupStack::PushL( requestData ); |
|
1206 //Sets the Http method to GET |
|
1207 requestData->iMethod = EIRHttpGET; |
|
1208 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1209 |
|
1210 // This is a blatant hack to circumvent the fact that the application has hard-coded |
|
1211 // 256 to be the maximum length of the URI everywhere. Due to time-restraints it is |
|
1212 // not feasible to fix the actual issue here, so every search query that would exceed |
|
1213 // the said limit is truncated to fit it. |
|
1214 // |
|
1215 // The practical impacts of this hack is that should the maximum length be exceeded, |
|
1216 // a connection timed out query is most often displayed. |
|
1217 // |
|
1218 // The scope of this quick hack is to enable users to perform search with UTF-8 characters |
|
1219 // with no possibility of application panics due to descriptor overflows, not to fix |
|
1220 // the actual problem with the hard-coded TBufs in the application. |
|
1221 |
|
1222 HBufC8* utfEncoded = CnvUtfConverter::ConvertFromUnicodeToUtf8L( |
|
1223 aSearchString ); |
|
1224 CleanupStack::PushL( utfEncoded ); |
|
1225 HBufC8* uri = HBufC8::NewL( iSearchURL.Size() + utfEncoded->Size() |
|
1226 + KSearchUrl().Size() ); |
|
1227 TPtr8 uriPtr( uri->Des() ); |
|
1228 uriPtr.Copy( iSearchURL ); |
|
1229 |
|
1230 HBufC8 *encodedQuery = NULL; |
|
1231 encodedQuery = EscapeUtils::EscapeEncodeL( *utfEncoded, |
|
1232 EscapeUtils::EEscapeQuery ); |
|
1233 uriPtr.Append( *encodedQuery ); |
|
1234 uriPtr.Append( KSearchUrl ); |
|
1235 if ( encodedQuery ) |
|
1236 { |
|
1237 delete encodedQuery; |
|
1238 } |
|
1239 CleanupStack::PopAndDestroy( utfEncoded ); |
|
1240 requestData->iUri.Copy( uri->Left( requestData->iUri.MaxLength() ) ); |
|
1241 delete uri; |
|
1242 |
|
1243 IRHttpIssueRequestL( *requestData ); |
|
1244 iBrowseUrl.Zero(); |
|
1245 iBrowseUrl.Copy( requestData->iUri ); |
|
1246 EncodeUrlL( iBrowseUrl ); |
|
1247 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
1248 CleanupStack::PopAndDestroy( requestData ); |
|
1249 IRLOG_DEBUG( "CIRIsdsClient::IRISDSSearchL - Exiting." ); |
|
1250 } |
|
1251 |
|
1252 // --------------------------------------------------------------------------- |
|
1253 //void ParsedStructure(TInt aChoice) |
|
1254 //Call back funtion called by XML parser after parsing is over |
|
1255 // --------------------------------------------------------------------------- |
|
1256 // |
|
1257 void CIRIsdsClient::ParsedStructureL(TInt aChoice) |
|
1258 { |
|
1259 IRLOG_DEBUG( "CIRIsdsClient::ParsedStructureL - Entering" ); |
|
1260 //if catogory info is recieved |
|
1261 if ( aChoice == ECategoryInfoRecieved ) |
|
1262 { |
|
1263 iCatDataFrom = EFalse; |
|
1264 iIsdsResponseObserver.IsdsCatogoryDataReceivedL( |
|
1265 *( iXmlReader-> iPtrCategory ) ); |
|
1266 } |
|
1267 // if channels list is recieved |
|
1268 else if ( aChoice == EChannelListRecieved ) |
|
1269 { |
|
1270 iChannelDataFrom = EFalse; |
|
1271 iIsdsResponseObserver.IsdsChannelDataReceivedL( |
|
1272 *( iXmlReader->iPtrChannel ) ); |
|
1273 } |
|
1274 |
|
1275 //if preset data is recieved |
|
1276 else if ( aChoice == EPresetDataRecieved ) |
|
1277 { |
|
1278 if ( iSyncRequest ) |
|
1279 { |
|
1280 iSyncRequest = EFalse; |
|
1281 //update the preset(replace it) |
|
1282 iIsdsResponseObserver.IsdsPresetChangedL( |
|
1283 *iXmlReader->iPtrPreset->At( 0 ) ); |
|
1284 } |
|
1285 else |
|
1286 { |
|
1287 iIsdsResponseObserver.IsdsPresetDataReceivedL( |
|
1288 *( iXmlReader-> iPtrPreset ) ); |
|
1289 } |
|
1290 } |
|
1291 /*else if(aChoice==EOtaInfoRecieved) |
|
1292 { |
|
1293 if(!iOtaReqFrom) |
|
1294 { |
|
1295 iIsdsResponseObserver.IsdsOtaInfoRecieved(*iXmlReader->iOTA) |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 iOtaReqFrom=EFalse; |
|
1300 //update settings |
|
1301 if(iXmlReader->iOTA->iUpdateInterval!=0) |
|
1302 { |
|
1303 iSettings->SetSilencePeriodL(iXmlReader->iOTA->iUpdateInterval) |
|
1304 } |
|
1305 else |
|
1306 { |
|
1307 iSettings->SetSilencePeriodL(KDays*KHour*KMinute*KSecond) |
|
1308 } |
|
1309 } |
|
1310 }*/ |
|
1311 else if ( aChoice == EIridRecieved ) |
|
1312 { |
|
1313 iSettings->SetIRIDL( iXmlReader->iRID ); |
|
1314 } |
|
1315 else if ( aChoice == ESessionLogRecieved ) |
|
1316 { |
|
1317 //session log is recieved in ISDS |
|
1318 iPostResponsePending = EFalse; |
|
1319 iBrowseReport->ReponseFromISDSObtained(); |
|
1320 } |
|
1321 |
|
1322 else |
|
1323 { |
|
1324 TRAPD(errd,iIsdsResponseObserver.IsdsErrorL( KDataProviderTimeout) ); |
|
1325 if ( errd ) |
|
1326 { |
|
1327 IRLOG_DEBUG( "CIRIsdsClient::ParsedStructureL - Exiting ." ); |
|
1328 return; |
|
1329 } |
|
1330 } |
|
1331 IRLOG_DEBUG( "CIRIsdsClient::ParsedStructureL - Exiting." ); |
|
1332 } |
|
1333 |
|
1334 // --------------------------------------------------------------------------- |
|
1335 // void ParseError() |
|
1336 // Call back funtion called by XML parser in case of parsing error |
|
1337 // --------------------------------------------------------------------------- |
|
1338 // |
|
1339 void CIRIsdsClient::ParseError( TInt aErrorCode ) |
|
1340 { |
|
1341 IRLOG_ERROR( "CIRIsdsClient::ParseError - Entering" ); |
|
1342 |
|
1343 IRHttpGeneralError( aErrorCode ); |
|
1344 IRLOG_DEBUG( "CIRIsdsClient::ParseError - Exiting." ); |
|
1345 } |
|
1346 |
|
1347 // --------------------------------------------------------------------------- |
|
1348 // void CacheError() |
|
1349 // |
|
1350 // --------------------------------------------------------------------------- |
|
1351 // |
|
1352 void CIRIsdsClient::CacheError() |
|
1353 { |
|
1354 IRLOG_ERROR( "CIRIsdsClient::CacheError" ); |
|
1355 } |
|
1356 |
|
1357 // --------------------------------------------------------------------------- |
|
1358 // void CacheFailed() |
|
1359 // |
|
1360 // --------------------------------------------------------------------------- |
|
1361 // |
|
1362 void CIRIsdsClient::CacheFailed() |
|
1363 { |
|
1364 IRLOG_WARNING( "CIRIsdsClient::CacheFailed" ); |
|
1365 } |
|
1366 |
|
1367 // --------------------------------------------------------------------------- |
|
1368 // cache is present but Stale. |
|
1369 // called by cache mgmt as a callback. |
|
1370 // after copying the lastmodified time into its variable |
|
1371 // here it is copied into the variable ilastModifiedTime |
|
1372 // --------------------------------------------------------------------------- |
|
1373 // |
|
1374 void CIRIsdsClient::CacheInvalid() |
|
1375 { |
|
1376 IRLOG_DEBUG( "CIRIsdsClient::CacheInvalid - Entering" ); |
|
1377 iLastModifiedTime = iCache->iLastModified; |
|
1378 IRLOG_DEBUG( "CIRIsdsClient::CacheInvalid - Exiting" ); |
|
1379 } |
|
1380 |
|
1381 // --------------------------------------------------------------------------- |
|
1382 // void CachedStructureL() |
|
1383 // |
|
1384 // --------------------------------------------------------------------------- |
|
1385 // |
|
1386 void CIRIsdsClient::CachedStructureL( TInt aChoice ) |
|
1387 { |
|
1388 IRLOG_DEBUG( "CIRIsdsClient::CachedStructureL - Entering" ); |
|
1389 if ( iCacheReqMade ) |
|
1390 { |
|
1391 iCacheReqMade = EFalse; |
|
1392 //if catogory info is recieved |
|
1393 if ( aChoice == ECategoryInfoRecieved ) |
|
1394 { |
|
1395 iCatDataFrom = ETrue; |
|
1396 iIsdsResponseObserver.IsdsCatogoryDataReceivedL( |
|
1397 *( iCache->iPtrCategory ) ); |
|
1398 } |
|
1399 |
|
1400 // if channels list is recieved |
|
1401 else if ( aChoice == EChannelListRecieved ) |
|
1402 { |
|
1403 iChannelDataFrom = ETrue; |
|
1404 iIsdsResponseObserver.IsdsChannelDataReceivedL( |
|
1405 *( iCache->iPtrChannel ) ); |
|
1406 } |
|
1407 |
|
1408 //if preset data is recieved |
|
1409 else if ( aChoice == EPresetDataRecieved ) |
|
1410 { |
|
1411 //multiple presets can be presented to the UI. |
|
1412 iIsdsResponseObserver.IsdsPresetDataReceivedL( |
|
1413 *( iCache->iPtrPreset ) ); |
|
1414 } |
|
1415 |
|
1416 //if ota data is recieved |
|
1417 /*else if(aChoice==EOtaInfoRecieved) |
|
1418 { |
|
1419 if(!iOtaReqFrom) |
|
1420 { |
|
1421 iIsdsResponseObserver.IsdsOtaInfoRecieved(*iCache->iOTA) |
|
1422 } |
|
1423 else |
|
1424 { |
|
1425 iOtaReqFrom=EFalse; |
|
1426 //update settings |
|
1427 if(iCache->iOTA->iUpdateInterval!=0) |
|
1428 { |
|
1429 iSettings->SetSilencePeriodL(iCache->iOTA->iUpdateInterval) |
|
1430 } |
|
1431 else |
|
1432 { |
|
1433 iSettings->SetSilencePeriodL(KDays*KHour*KMinute*KSecond) |
|
1434 } |
|
1435 } |
|
1436 }*/ |
|
1437 //if logo data is recieved |
|
1438 else if ( aChoice == KFour ) |
|
1439 { |
|
1440 //No implementation |
|
1441 } |
|
1442 else |
|
1443 { |
|
1444 TRAPD( errd, iIsdsResponseObserver.IsdsErrorL( KDataProviderTimeout ) ); |
|
1445 if ( errd ) |
|
1446 { |
|
1447 IRLOG_DEBUG( "CIRIsdsClient::CachedStructureL- Exiting ." ); |
|
1448 return; |
|
1449 } |
|
1450 } |
|
1451 } |
|
1452 IRLOG_DEBUG( "CIRIsdsClient::CachedStructureL - Exiting." ); |
|
1453 } |
|
1454 |
|
1455 // --------------------------------------------------------------------------- |
|
1456 // void CIRIsdsClient::SyncPresetL() |
|
1457 // Used to syncronize presets |
|
1458 // --------------------------------------------------------------------------- |
|
1459 // |
|
1460 EXPORT_C TInt CIRIsdsClient::SyncPresetL(TInt aPresetId,const TDesC& |
|
1461 aIfModifiedSince ) |
|
1462 { |
|
1463 IRLOG_DEBUG( "CIRIsdsClient::SyncPresetL - Entering" ); |
|
1464 IRRDEBUG2("CIRISDCLIENT::SYNCPRESETL",KNullDesC); |
|
1465 iReqFromSync = ETrue; |
|
1466 iPresetToBeSynced = aPresetId; |
|
1467 CIRHttpRequestData * requestData = new ( ELeave ) CIRHttpRequestData; |
|
1468 CleanupStack::PushL( requestData ); |
|
1469 requestData->iMethod = EIRHttpGET; |
|
1470 |
|
1471 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1472 TDateTime lastModified; |
|
1473 ConvertToTimeDate( aIfModifiedSince, lastModified ); |
|
1474 requestData->isIfModifiedSet = ETrue; |
|
1475 requestData->iIfModifiedSince.Set( lastModified.Year(), |
|
1476 lastModified.Month(), lastModified.Day(), |
|
1477 lastModified.Hour(), lastModified.Minute(), |
|
1478 lastModified.Second(), lastModified.MicroSecond() ); |
|
1479 _LIT(KPresetFetchUrl,"/do/directory/getPreset?channelid="); |
|
1480 |
|
1481 TBuf<KUrlPassMaxLength> urlPass( iSettings->GetISDSBaseUrlL() ); |
|
1482 urlPass.Append( KPresetFetchUrl ); |
|
1483 |
|
1484 TBuf<KChidMaxLength> chid; |
|
1485 _LIT(KFormat,"%d"); |
|
1486 chid.Format( KFormat, aPresetId ); |
|
1487 urlPass.Append( chid ); |
|
1488 requestData->iUri.Copy( urlPass ); |
|
1489 |
|
1490 IRHttpIssueRequestL( *requestData ); |
|
1491 CleanupStack::PopAndDestroy( requestData ); |
|
1492 IRLOG_DEBUG( "CIRIsdsClient::SyncPresetL - Exiting." ); |
|
1493 return 1; |
|
1494 } |
|
1495 |
|
1496 // --------------------------------------------------------------------------- |
|
1497 // void ReleaseResources() |
|
1498 // |
|
1499 // --------------------------------------------------------------------------- |
|
1500 // |
|
1501 EXPORT_C void CIRIsdsClient::ReleaseResources() |
|
1502 { |
|
1503 IRLOG_DEBUG( "CIRIsdsClient::ReleaseResources - Entering" ); |
|
1504 iDataProvider->ReleaseResources(); |
|
1505 IRLOG_DEBUG( "CIRIsdsClient::ReleaseResources - Exiting" ); |
|
1506 } |
|
1507 |
|
1508 //--------------------------------------------------------------------------- |
|
1509 //CIRIsdsClient::GetMultiplePresetsL |
|
1510 //for multiple selected presets to be saved |
|
1511 // |
|
1512 //--------------------------------------------------------------------------- |
|
1513 // |
|
1514 EXPORT_C void CIRIsdsClient::GetMultiplePresetsL( |
|
1515 const RArray<TInt>& aIndexArray, TBool& aDataFrom ) |
|
1516 { |
|
1517 IRLOG_DEBUG( "CIRIsdsClient::GetMultiplePresetsL - Entering" ); |
|
1518 _LIT(KSeparator,","); |
|
1519 //get the count of the no of requested presets |
|
1520 TInt multiSelectedCount = aIndexArray.Count(); |
|
1521 //allocate space for the request url |
|
1522 HBufC8* channelIds = HBufC8::NewLC( multiSelectedCount |
|
1523 * KDefaultRealWidth + multiSelectedCount ); |
|
1524 //http request data |
|
1525 CIRHttpRequestData* requestData = new ( ELeave ) CIRHttpRequestData; |
|
1526 requestData->iUri.Copy( *iISDSBaseUrl ); |
|
1527 CleanupStack::PushL( requestData ); |
|
1528 requestData->iAcceptLanguage.Copy( iShortLanguageCode ); |
|
1529 //create a tptr to modify it |
|
1530 TPtr8 channelIdPtr = channelIds->Des(); |
|
1531 //set the request type |
|
1532 iRequestType = EPresets; |
|
1533 //result |
|
1534 TInt res; |
|
1535 _LIT8(KFormat,"%d"); |
|
1536 //if from cache |
|
1537 if ( iChannelDataFrom ) |
|
1538 { |
|
1539 for ( TInt i = 0; i < multiSelectedCount; i++ ) |
|
1540 { |
|
1541 ASSERT( aIndexArray[i] >= 0 && aIndexArray[i] < iCache->iPtrChannel->Count() ); |
|
1542 TInt channelID = iCache->iPtrChannel->At( aIndexArray[i] )->iChannelID; |
|
1543 if ( i != 0 ) |
|
1544 { |
|
1545 channelIdPtr.Append( KSeparator ); |
|
1546 } |
|
1547 TBuf8<KChannelidMaxLength> channelIdBuf; |
|
1548 channelIdBuf.Format( KFormat, channelID ); |
|
1549 channelIdPtr.Append( channelIdBuf ); |
|
1550 } |
|
1551 iCachePath.Zero(); |
|
1552 iCachePath.Copy( *channelIds ); |
|
1553 //check if cache is available |
|
1554 iCacheReqMade = ETrue; |
|
1555 iCache->CheckCacheL( EPresets, iCachePath, iForceGet, res ); |
|
1556 aDataFrom = EFalse; |
|
1557 if ( res == KErrNone ) |
|
1558 { |
|
1559 requestData->iUri.Append( |
|
1560 ( *( iCache-> iPtrChannel ) )[0]->iChannelGetOperation->Des() ); |
|
1561 requestData->iUri.Append( *channelIds ); |
|
1562 IRHttpIssueRequestL( *requestData ); |
|
1563 iConditonalGet = EFalse; |
|
1564 //Session Log |
|
1565 iBrowseUrl.Copy( requestData->iUri ); |
|
1566 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
1567 aDataFrom = ETrue; |
|
1568 } |
|
1569 if ( res == KErrNotFound ) |
|
1570 { |
|
1571 iConditonalGet = ETrue; |
|
1572 requestData->iIfModifiedSince = iLastModifiedTime.DateTime(); |
|
1573 requestData->isIfModifiedSet = ETrue; |
|
1574 requestData->iUri.Append( |
|
1575 ( *( iCache-> iPtrChannel ) )[0]->iChannelGetOperation->Des() ); |
|
1576 requestData->iUri.Append( *channelIds ); |
|
1577 IRHttpIssueRequestL( *requestData ); |
|
1578 iBrowseUrl.Copy( requestData->iUri ); |
|
1579 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
1580 aDataFrom = ETrue; |
|
1581 } |
|
1582 } |
|
1583 //if from xml file |
|
1584 else |
|
1585 { |
|
1586 for ( TInt i = 0; i < multiSelectedCount; i++ ) |
|
1587 { |
|
1588 ASSERT( aIndexArray[i] >= 0 && aIndexArray[i] < iXmlReader->iPtrChannel->Count() ); |
|
1589 TInt channelID = iXmlReader->iPtrChannel->At( aIndexArray[i] )->iChannelID; |
|
1590 if ( i != 0 ) |
|
1591 { |
|
1592 channelIdPtr.Append( KSeparator ); |
|
1593 } |
|
1594 TBuf8<KChannelidMaxLength> channelIdBuf; |
|
1595 channelIdBuf.Format( KFormat, channelID ); |
|
1596 channelIdPtr.Append( channelIdBuf ); |
|
1597 } |
|
1598 iCachePath.Zero(); |
|
1599 iCachePath.Copy( *channelIds ); |
|
1600 iCacheReqMade = ETrue; |
|
1601 iCache->CheckCacheL( EPresets, iCachePath, iForceGet, res ); |
|
1602 aDataFrom = EFalse; |
|
1603 if ( res == KErrNone ) |
|
1604 { |
|
1605 requestData->iUri.Append( |
|
1606 ( *( iXmlReader-> iPtrChannel ) )[0]->iChannelGetOperation->Des() ); |
|
1607 requestData->iUri.Append( *channelIds ); |
|
1608 IRHttpIssueRequestL( *requestData ); |
|
1609 iConditonalGet = EFalse; |
|
1610 //Session Log |
|
1611 iBrowseUrl.Copy( requestData->iUri ); |
|
1612 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
1613 aDataFrom = ETrue; |
|
1614 } |
|
1615 if ( res == KErrNotFound ) |
|
1616 { |
|
1617 iConditonalGet = ETrue; |
|
1618 requestData->iIfModifiedSince = iLastModifiedTime.DateTime(); |
|
1619 requestData->isIfModifiedSet = ETrue; |
|
1620 requestData->iUri.Append( |
|
1621 ( *( iXmlReader-> iPtrChannel ) )[0]->iChannelGetOperation->Des() ); |
|
1622 requestData->iUri.Append( *channelIds ); |
|
1623 IRHttpIssueRequestL( *requestData ); |
|
1624 //Session Log |
|
1625 iBrowseUrl.Copy( requestData->iUri ); |
|
1626 iBrowseReport->BrowseUrl( iBrowseUrl, 1 ); |
|
1627 aDataFrom = ETrue; |
|
1628 } |
|
1629 } |
|
1630 CleanupStack::PopAndDestroy( requestData ); |
|
1631 CleanupStack::PopAndDestroy( channelIds ); |
|
1632 IRLOG_DEBUG( "CIRIsdsClient::GetMultiplePresetsL - Exiting" ); |
|
1633 } |
|
1634 |
|
1635 //--------------------------------------------------------------------------- |
|
1636 //CIRIsdsClient::ConvertToTimeDate |
|
1637 //converts the date-time stamp (last modified) to Symbian DateTime format |
|
1638 //--------------------------------------------------------------------------- |
|
1639 void CIRIsdsClient::ConvertToTimeDate( const TDesC& aTime, |
|
1640 TDateTime& aDateTime ) const |
|
1641 { |
|
1642 IRLOG_DEBUG( "CIRIsdsClient::ConvertToTimeDate - Entering" ); |
|
1643 TBuf8<KCopyOfTimeMaxLength> copyOfTime; |
|
1644 copyOfTime.Copy( aTime ); |
|
1645 TInternetDate time; |
|
1646 TRAPD( error,time.SetDateL( copyOfTime ) ); |
|
1647 if ( !error ) |
|
1648 { |
|
1649 aDateTime = time.DateTime(); |
|
1650 } |
|
1651 |
|
1652 IRLOG_DEBUG( "CIRIsdsClient::ConvertToTimeDate - Exiting." ); |
|
1653 } |
|
1654 |
|
1655 //--------------------------------------------------------------------------- |
|
1656 //CIRIsdsClient::IRHttpIssueRequestL |
|
1657 //Issues Http Request to DataProvider to get data from URL in Request object |
|
1658 //The Request URL is also encoded here |
|
1659 //--------------------------------------------------------------------------- |
|
1660 // |
|
1661 void CIRIsdsClient::IRHttpIssueRequestL( CIRHttpRequestData &aRequestObject ) |
|
1662 { |
|
1663 IRLOG_DEBUG( "CIRIsdsClient::IRHttpIssueRequestL - Entering" ); |
|
1664 IRRDEBUG2("CIRISDSCLIENT::IRHTTPISSUEREQUESTL",KNullDesC); |
|
1665 if ( iIRIDPending ) |
|
1666 { |
|
1667 //if IRID reqeust is pending then queue the reuest |
|
1668 //till IRID response comes |
|
1669 iReqPending = ETrue; |
|
1670 //temporary request object |
|
1671 iTempRequestObject = new ( ELeave ) CIRHttpRequestData; |
|
1672 iTempRequestObject->iMethod = aRequestObject.iMethod; |
|
1673 iTempRequestObject->iIfModifiedSince |
|
1674 = aRequestObject.iIfModifiedSince; |
|
1675 iTempRequestObject->isIfModifiedSet = aRequestObject.isIfModifiedSet; |
|
1676 iTempRequestObject->iAcceptLanguage = aRequestObject.iAcceptLanguage; |
|
1677 iTempRequestObject->iContentType = aRequestObject.iContentType; |
|
1678 iTempRequestObject->iUri = aRequestObject.iUri; |
|
1679 } |
|
1680 else |
|
1681 { |
|
1682 if ( iSettings->GetIRIDL().Length() == 0 ) |
|
1683 { |
|
1684 if ( iReqFromGetIRIDFunc ) |
|
1685 { |
|
1686 iReqFromGetIRIDFunc = EFalse; |
|
1687 iDataProvider->IRHttpIssueRequestL( aRequestObject ); |
|
1688 } |
|
1689 else |
|
1690 { |
|
1691 //When the user cancels the http req,irid is not present. |
|
1692 //On next request,automatically first irid req is made. |
|
1693 //save the actual request |
|
1694 //get irid from isds |
|
1695 //once irid is received send the saved request to isds |
|
1696 iReqPending = ETrue; |
|
1697 //temporary request object |
|
1698 iTempRequestObject = new ( ELeave ) CIRHttpRequestData; |
|
1699 iTempRequestObject->iMethod = aRequestObject.iMethod; |
|
1700 iTempRequestObject->iIfModifiedSince |
|
1701 = aRequestObject.iIfModifiedSince; |
|
1702 iTempRequestObject->isIfModifiedSet |
|
1703 = aRequestObject.isIfModifiedSet; |
|
1704 iTempRequestObject->iAcceptLanguage |
|
1705 = aRequestObject.iAcceptLanguage; |
|
1706 iTempRequestObject->iContentType |
|
1707 = aRequestObject.iContentType; |
|
1708 iTempRequestObject->iUri = aRequestObject.iUri; |
|
1709 IRGetIRIDL(); |
|
1710 } |
|
1711 } |
|
1712 else |
|
1713 { |
|
1714 iReqPending = EFalse; |
|
1715 if ( iReqFromSync ) |
|
1716 { |
|
1717 iReqFromSync = EFalse; |
|
1718 iSyncRequest = ETrue; |
|
1719 } |
|
1720 iDataProvider->IRHttpIssueRequestL( aRequestObject ); |
|
1721 } |
|
1722 } |
|
1723 IRLOG_DEBUG( "CIRIsdsClient::IRHttpIssueRequestL - Exiting." ); |
|
1724 } |
|
1725 |
|
1726 //--------------------------------------------------------------------------- |
|
1727 //CIRIsdsClient::EncodeUrlL |
|
1728 //This url encoding is for session log |
|
1729 //--------------------------------------------------------------------------- |
|
1730 // |
|
1731 void CIRIsdsClient::EncodeUrlL( TDes &aQuery ) |
|
1732 { |
|
1733 IRLOG_DEBUG( "CIRIsdsClient::EncodeUrlL - Entering" ); |
|
1734 //Encodes the URL inside the request object |
|
1735 HBufC *encodedurl = NULL; |
|
1736 encodedurl = EscapeUtils::EscapeEncodeL( aQuery, |
|
1737 EscapeUtils::EEscapeUrlEncoded ); |
|
1738 aQuery.Copy( encodedurl->Left( aQuery.MaxLength() ) ); |
|
1739 //encoded url is released |
|
1740 if ( encodedurl ) |
|
1741 { |
|
1742 delete encodedurl; |
|
1743 } |
|
1744 IRLOG_DEBUG( "CIRIsdsClient::EncodeUrlL - Exiting." ); |
|
1745 } |
|
1746 |
|
1747 //--------------------------------------------------------------------------- |
|
1748 //CIRIsdsClient::PurgeOtaInfoL |
|
1749 //delete all the data cached wrt OTA |
|
1750 //--------------------------------------------------------------------------- |
|
1751 // |
|
1752 EXPORT_C void CIRIsdsClient::PurgeOtaInfoL() |
|
1753 { |
|
1754 IRLOG_DEBUG( "CIRIsdsClient::PurgeOtaInfoL - Entering" ); |
|
1755 //reset update available flag to 0 |
|
1756 iSettings->ReSetUpdateAvailableL(); |
|
1757 //reset silence period to 0 |
|
1758 iSettings->SetSilencePeriodL( 0 ); |
|
1759 //reset silence period start time to a zero string |
|
1760 iSettings->SetSilencePeriodStartL( KNullDesC ); |
|
1761 //clear the cache info if any |
|
1762 TRAP_IGNORE( iCache->RemoveOtaInfoL() ) |
|
1763 IRLOG_DEBUG( "CIRIsdsClient::PurgeOtaInfoL - Exiting" ); |
|
1764 } |