|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 |
|
21 #include "irbrowsecatagoryitems.h" |
|
22 #include "irbrowsechannelitems.h" |
|
23 #include "ircachecleanup.h" |
|
24 #include "ircachemgmt.h" |
|
25 #include "ircacheobserver.h" |
|
26 #include "irdebug.h" |
|
27 #include "irhttprequestdata.h" |
|
28 #include "irisdspreset.h" |
|
29 #include "irotaupdate.h" |
|
30 #include "irsettings.h" |
|
31 |
|
32 //Default trust period value.24 hrs in secs with which the object is to be initialised |
|
33 const TInt KDefaultInterval = 24*60*60; |
|
34 //granualarity for the arrays |
|
35 //the granualarity value is based on superficial observation of the amount of |
|
36 //data recieved for a particular request |
|
37 const TInt KBrowseGranualarity = 32; |
|
38 const TInt KChannelArrayGranualarity = 32; |
|
39 const TInt KPresetGranualarity = 12; |
|
40 //http length format length |
|
41 // "Sun, 06 Nov 1994 08:49:37 GMT" format |
|
42 const TInt KHttpDateLength = 25; |
|
43 |
|
44 //Max size(critical size) in Bytes(90% of the max size) |
|
45 //critical size is the size that triggers cleanup action |
|
46 const TInt KCacheCriticalSizeLimit = KCacheLimitSize*9/10; |
|
47 |
|
48 //No of rows deleted will be one fourth of the total number of rows |
|
49 const TInt KPercentRowsDeleted = 4; |
|
50 |
|
51 //The indexing size for the column DataId is set to 100 |
|
52 const TInt KDataIdIndexSize = 100; |
|
53 |
|
54 //database file name |
|
55 _LIT(KCacheDbFile,"cacheDb.db"); |
|
56 |
|
57 //Table Name CacheTable |
|
58 _LIT(KCacheTable,"CacheTable"); |
|
59 |
|
60 //CacheTable columns |
|
61 _LIT(KRowIndexCol, "RowIndex"); |
|
62 _LIT(KDataTypeCol, "DataType"); |
|
63 _LIT(KDataIdCol, "DataId"); |
|
64 _LIT(KTrustPeriodCol, "TrustPeriod"); |
|
65 _LIT(KLastModifiedCol, "LastModified"); |
|
66 _LIT(KLastAccessedCol, "LastAccessed"); |
|
67 _LIT(KTimeCreation, "Created"); |
|
68 _LIT(KItemCount, "ItemCount"); |
|
69 _LIT(KCachedDataCol, "CachedData"); |
|
70 _LIT(KETagHeader, "ETagHeader"); |
|
71 |
|
72 //Table Index Names |
|
73 _LIT(KRowIndexColIndex, "IndexRowIndex"); |
|
74 _LIT(KDataTypeColIndex, "IndexDataType"); |
|
75 _LIT(KDataIdColIndex, "IndexDataId"); |
|
76 _LIT(KLastAccessedColIndex, "IndexLastAccessed"); |
|
77 _LIT(KTimeCreationIndex, "IndexCreated"); |
|
78 //Field Lengths |
|
79 |
|
80 const TInt KIRObserverArrayGranularity( 2 ); |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Function : OpenL |
|
85 // Standard two phased construction |
|
86 // calls ConstructL() |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 EXPORT_C CIRCacheMgmt* CIRCacheMgmt::OpenL(MIRCacheObserver &aObserver) |
|
90 { |
|
91 IRLOG_DEBUG( "IRCacheMgmt::OpenL - Entering." ); |
|
92 CIRCacheMgmt* self = reinterpret_cast<CIRCacheMgmt*>(Dll::Tls()); |
|
93 |
|
94 if (self) |
|
95 { |
|
96 User::LeaveIfError(self->Open()); |
|
97 } |
|
98 else |
|
99 { |
|
100 self = new (ELeave) CIRCacheMgmt(aObserver); |
|
101 CleanupClosePushL(*self); |
|
102 self->ConstructL(); |
|
103 User::LeaveIfError(Dll::SetTls(self)); |
|
104 CleanupStack::Pop(self); |
|
105 } |
|
106 IRLOG_DEBUG( "IRCacheMgmt::OpenL - Exiting." ); |
|
107 return self; |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // Function : CIRCacheMgmt::~CIRCacheMgmt() |
|
113 // Standard C++ destructor |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CIRCacheMgmt::~CIRCacheMgmt() |
|
117 { |
|
118 IRLOG_DEBUG( "IRCacheMgmt::~CIRCacheMgmt - Entering." ); |
|
119 //array destruction |
|
120 if (iPtrPreset) |
|
121 { |
|
122 iPtrPreset->ResetAndDestroy(); |
|
123 delete iPtrPreset; |
|
124 iPtrPreset = NULL; |
|
125 } |
|
126 if (iPtrCategory) |
|
127 { |
|
128 iPtrCategory->ResetAndDestroy(); |
|
129 } |
|
130 |
|
131 delete iPtrCategory; |
|
132 iPtrCategory = NULL; |
|
133 if (iPtrChannel) |
|
134 { |
|
135 iPtrChannel->ResetAndDestroy(); |
|
136 } |
|
137 |
|
138 delete iPtrChannel; |
|
139 iPtrChannel = NULL; |
|
140 if (iSettings) |
|
141 { |
|
142 iSettings->Close(); |
|
143 } |
|
144 if(iOTA) |
|
145 { |
|
146 delete iOTA; |
|
147 iOTA = NULL; |
|
148 } |
|
149 iLogoData.Close(); |
|
150 CloseDb(); |
|
151 iCacheDb.Close(); |
|
152 delete iCleanup; |
|
153 iFsSession.Close(); |
|
154 iCacheObservers.Close(); |
|
155 Dll::FreeTls(); |
|
156 IRLOG_DEBUG( "IRCacheMgmt::~CIRCacheMgmt - Exiting." ); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // Function : CIRCacheMgmt::CIRCacheMgmt() |
|
161 // Standard C++ constructor |
|
162 // sets the trust period to 24hrs(default) |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 CIRCacheMgmt::CIRCacheMgmt (MIRCacheObserver &aObserver) |
|
166 :iCacheObserver(aObserver), |
|
167 iCacheObservers( KIRObserverArrayGranularity ) |
|
168 { |
|
169 IRLOG_DEBUG( "IRCacheMgmt::CIRCacheMgmt - Entering." ); |
|
170 //default trust period initially set to 24 hrs |
|
171 //to be fetched from central repository |
|
172 iTrustPeriod = TTimeIntervalSeconds(KDefaultInterval); |
|
173 IRLOG_DEBUG( "IRCacheMgmt::CIRCacheMgmt - Exiting." ); |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // Function : CIRCacheMgmt::ConstructL() |
|
178 // Standard two phased construction |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CIRCacheMgmt::ConstructL() |
|
182 { |
|
183 IRLOG_DEBUG( "IRCacheMgmt::ConstructL - Entering." ); |
|
184 User::LeaveIfError(iFsSession.Connect()); |
|
185 //array construction |
|
186 iPtrPreset = new (ELeave) CArrayPtrFlat<CIRIsdsPreset>( |
|
187 KPresetGranualarity); |
|
188 iPtrCategory = new (ELeave) CArrayPtrFlat<CIRBrowseCatagoryItems>( |
|
189 KBrowseGranualarity); |
|
190 iPtrChannel = new (ELeave) CArrayPtrFlat<CIRBrowseChannelItems>( |
|
191 KChannelArrayGranualarity); |
|
192 iOTA = CIROTAUpdate::NewL(); |
|
193 iSettings = CIRSettings::OpenL(); |
|
194 iDatabaseFileName = iSettings->PrivatePath(); |
|
195 iDatabaseFileName.Append(KCacheDbFile); |
|
196 CreateDbConditionalL(); |
|
197 iCleanup = CIRCacheCleanup::NewL(*this); |
|
198 RemoveOtaInfoL(); |
|
199 IRLOG_DEBUG( "IRCacheMgmt::ConstructL - Exiting." ); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // Function : CIRCacheMgmt::CreateDbConditionalL( |
|
204 // Creates dbms conditionally(only if not yet created) |
|
205 // calls CreateDb() |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CIRCacheMgmt::CreateDbConditionalL() |
|
209 { |
|
210 IRLOG_DEBUG( "IRCacheMgmt::CreateDbConditionalL - Entering." ); |
|
211 TInt err=KErrNone; |
|
212 if(!BaflUtils::FileExists(iFsSession, iDatabaseFileName)) |
|
213 { |
|
214 err=CreateDb(); |
|
215 if(KErrNone != err) |
|
216 { |
|
217 User::Leave(err); |
|
218 } |
|
219 } |
|
220 IRLOG_DEBUG( "IRCacheMgmt::CreateDbConditionalL - Exiting." ); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // Function : CIRCacheMgmt::CreateDb() |
|
225 // Creates the tables |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 TInt CIRCacheMgmt::CreateDb() |
|
229 { |
|
230 IRLOG_DEBUG( "IRCacheMgmt::CreateDb - Entering." ); |
|
231 CloseDb(); |
|
232 TInt err=iCacheDb.Replace(iFsSession,iDatabaseFileName); |
|
233 if((err!=0)) |
|
234 { |
|
235 return err; //unable to create file |
|
236 } |
|
237 TRAP(err,//trap start |
|
238 CreateCacheTableL(); |
|
239 CreateCacheIndexL(); |
|
240 )//trap end |
|
241 IRLOG_DEBUG( "IRCacheMgmt::CreateDb - Exiting." ); |
|
242 return err; |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // Function : CIRCacheMgmt::OpenCacheDb() |
|
247 // Opens both the databases |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 TInt CIRCacheMgmt::OpenCacheDb() |
|
251 { |
|
252 IRLOG_DEBUG( "CIRCacheMgmt::OpenCacheDb - Entering" ); |
|
253 CloseDb(); |
|
254 TInt error = KErrNone; |
|
255 if(!BaflUtils::FileExists(iFsSession, iDatabaseFileName)) |
|
256 { |
|
257 //if file doesn't exist function leaves with error code |
|
258 //KErrNotFound |
|
259 return KErrNotFound; |
|
260 } |
|
261 //try and open the db |
|
262 error = iCacheDb.Open(iFsSession,iDatabaseFileName); |
|
263 //return if error |
|
264 if(KErrNone != error ) |
|
265 { |
|
266 return error; |
|
267 } |
|
268 //check if damaged |
|
269 if( iCacheDb.IsDamaged() ) |
|
270 { |
|
271 //if data base is damaged then |
|
272 //try to recover |
|
273 error = iCacheDb.Recover(); |
|
274 return error; |
|
275 } |
|
276 |
|
277 iOpen = ETrue; |
|
278 |
|
279 IRLOG_DEBUG( "CIRCacheMgmt::OpenCacheDb - Exiting." ); |
|
280 return KErrNone; |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // Function : CIRCacheMgmt::CloseDb() |
|
285 // Closes the database |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 void CIRCacheMgmt::CloseDb() |
|
289 { |
|
290 IRLOG_DEBUG( "IRCacheMgmt::CloseDb - Entering." ); |
|
291 iCacheDb.Close(); |
|
292 iOpen = EFalse; |
|
293 IRLOG_DEBUG( "IRCacheMgmt::CloseDb - Exiting." ); |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // Function : CIRCacheMgmt::CheckCache() |
|
298 // API Exposed to Isds Client to check and get the cached items. |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 EXPORT_C void CIRCacheMgmt::CheckCacheL(TInt aType,const TDesC& aName, |
|
302 TBool aForceGet,TInt& aReturn) |
|
303 { |
|
304 IRLOG_DEBUG( "CIRCacheMgmt::CheckCacheL - Entering" ); |
|
305 //opens the db if not open already |
|
306 if(!iOpen) |
|
307 { |
|
308 TInt error = OpenCacheDb(); |
|
309 if(KErrNone != error) |
|
310 { |
|
311 aReturn = ENotCached; |
|
312 return; |
|
313 } |
|
314 } |
|
315 |
|
316 //calls the function FetchCacheIfAvailable() passing the appropriate type and id |
|
317 |
|
318 switch(aType) |
|
319 { |
|
320 case ECatagory: |
|
321 case EChannels: |
|
322 case EPresets: |
|
323 case EOtaInfo: |
|
324 case ELogo: |
|
325 { |
|
326 TRAP_IGNORE(FetchCacheIfAvailableL(aType,aName,aForceGet,aReturn)) |
|
327 break; |
|
328 } |
|
329 |
|
330 default: |
|
331 { |
|
332 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
333 { |
|
334 iCacheObservers[i]->CacheFailed(); |
|
335 } |
|
336 aReturn = ENotCached; |
|
337 break; |
|
338 } |
|
339 } |
|
340 CloseDb(); |
|
341 IRLOG_DEBUG( "CIRCacheMgmt::CheckCacheL - Exiting." ); |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------------------------- |
|
345 // Function : CIRCacheMgmt::FetchCacheIfAvailable() |
|
346 // Fetches the cache if available |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 //generic function to check the validity of the cache |
|
350 void CIRCacheMgmt::FetchCacheIfAvailableL(TInt aType,const TDesC& aId, |
|
351 TBool aForceGet,TInt& aReturnVal) |
|
352 { |
|
353 //Algo**** |
|
354 //1.check the cache table for a request type |
|
355 //2.if the query returns a row,check for validity |
|
356 //3.if invalid(stale) do a conditional get |
|
357 //4.if valid use cache |
|
358 IRLOG_DEBUG( "CIRCacheMgmt::FetchCacheIfAvailableL - Entering" ); |
|
359 //SELECT * FROM KCacheTable WHERE KDataTypeCol = aType AND KDataIdCol=aId |
|
360 _LIT( query, "SELECT * FROM %S WHERE %S = %d AND %S = '%S'" ); |
|
361 |
|
362 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KCacheTable().Length() + |
|
363 KDataTypeCol().Length() + KDataIdCol().Length() + |
|
364 KDefaultRealWidth + aId.Length()); |
|
365 |
|
366 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,aType,&KDataIdCol,&aId); |
|
367 |
|
368 IRLOG_DEBUG2( "CIRCacheMgmt::FetchCacheIfAvailableL - Going to evaluate SQL query: %S", sqlQuery ); |
|
369 RDbView cacheView; |
|
370 User::LeaveIfError(cacheView.Prepare(iCacheDb,*sqlQuery)); |
|
371 CleanupStack::PopAndDestroy(sqlQuery); |
|
372 CleanupClosePushL(cacheView); |
|
373 User::LeaveIfError( cacheView.EvaluateAll() ); |
|
374 |
|
375 //if no row match the query there is no cahche available for that particular |
|
376 //request |
|
377 if(cacheView.IsEmptyL()) |
|
378 { |
|
379 //Return ENotCached |
|
380 aReturnVal = ENotCached; |
|
381 } |
|
382 else |
|
383 { |
|
384 cacheView.FirstL(); |
|
385 cacheView.GetL(); |
|
386 CDbColSet* columns = cacheView.ColSetL(); |
|
387 TTime creationTime = cacheView.ColTime(columns->ColNo( KTimeCreation)); |
|
388 TInt cacheValidityTime = cacheView.ColInt(columns->ColNo( KTrustPeriodCol)); |
|
389 TInt countItems=cacheView.ColInt(columns->ColNo( KItemCount)); |
|
390 IRLOG_DEBUG( "CIRCacheMgmt::FetchCacheIfAvailableL - can check validity." ); |
|
391 //check if cache is valid |
|
392 //get it any way if it is "forcedget" |
|
393 if( aForceGet || CheckValidity(creationTime,cacheValidityTime)) |
|
394 { |
|
395 //Fetch the cached data |
|
396 //FetchCachedData(type,count,&view ) |
|
397 TRAPD(err,FetchCachedDataL(aType,countItems,cacheView)); |
|
398 if(err!=KErrNone) |
|
399 { |
|
400 //something goes wrong ,return not cached and fetch new data |
|
401 aReturnVal = ENotCached; |
|
402 } |
|
403 else |
|
404 { |
|
405 //cache usable |
|
406 aReturnVal = ECacheUseable; |
|
407 } |
|
408 } |
|
409 else |
|
410 { |
|
411 iLastModified = cacheView.ColTime(columns->ColNo( KLastModifiedCol)); |
|
412 iETag = cacheView.ColDes8(columns->ColNo( KETagHeader )); |
|
413 aReturnVal = ECacheNotValid; |
|
414 cacheView.Close(); |
|
415 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
416 { |
|
417 iCacheObservers[i]->CacheInvalid(); |
|
418 } |
|
419 } |
|
420 delete columns; |
|
421 } |
|
422 CleanupStack::PopAndDestroy(&cacheView); |
|
423 IRLOG_DEBUG( "CIRCacheMgmt::FetchCacheIfAvailableL - Exiting." ); |
|
424 |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // Function : CIRCacheMgmt::FetchCachedDataL() |
|
429 // fetches the cached data from the table into the cached structures |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 void CIRCacheMgmt::FetchCachedDataL(TInt aType,TInt aCountItems,RDbView& aCacheView) |
|
433 { |
|
434 //Algo**** |
|
435 //fetch the data and internalize into appropriate structure |
|
436 |
|
437 IRLOG_DEBUG( "CIRCacheMgmt::FetchCachedDataL - Entering" ); |
|
438 CDbColSet* columns = aCacheView.ColSetL(); |
|
439 TInt columnNo = columns->ColNo( KCachedDataCol ); |
|
440 delete columns; |
|
441 switch(aType) |
|
442 { |
|
443 case ECatagory: |
|
444 { |
|
445 //Internalize the category items into the CIRBrowseCatagoryItems array |
|
446 RDbColReadStream instream; |
|
447 instream.OpenLC( aCacheView, columnNo ); |
|
448 CIRBrowseCatagoryItems* ptr; |
|
449 if (iPtrCategory) |
|
450 { |
|
451 iPtrCategory->ResetAndDestroy(); |
|
452 } |
|
453 for(TInt iter=0;iter<aCountItems;iter++) |
|
454 { |
|
455 ptr=CIRBrowseCatagoryItems::NewL(); |
|
456 CleanupStack::PushL(ptr); |
|
457 instream>>*ptr; |
|
458 if (iPtrCategory) |
|
459 { |
|
460 iPtrCategory->AppendL(ptr); |
|
461 } |
|
462 CleanupStack::Pop(ptr); |
|
463 } |
|
464 CleanupStack::PopAndDestroy( &instream ); |
|
465 //update the last accessed time |
|
466 UpdateLastAccessedTimeL(aCacheView); |
|
467 aCacheView.Close(); |
|
468 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
469 { |
|
470 iCacheObservers[i]->CachedStructureL(ECatagory); |
|
471 } |
|
472 break; |
|
473 } |
|
474 case EChannels: |
|
475 { |
|
476 //Internalize the channel items into the CIRBrowseChannelItems array |
|
477 RDbColReadStream instream; |
|
478 instream.OpenLC( aCacheView, columnNo ); |
|
479 if (iPtrChannel) |
|
480 { |
|
481 iPtrChannel->ResetAndDestroy(); |
|
482 } |
|
483 CIRBrowseChannelItems *ptr; |
|
484 for(TInt iter=0;iter<aCountItems;iter++) |
|
485 { |
|
486 ptr = CIRBrowseChannelItems::NewL(); |
|
487 CleanupStack::PushL(ptr); |
|
488 instream>>*ptr; |
|
489 if (iPtrChannel) |
|
490 { |
|
491 iPtrChannel->AppendL(ptr); |
|
492 } |
|
493 CleanupStack::Pop(ptr); |
|
494 } |
|
495 CleanupStack::PopAndDestroy( &instream ); |
|
496 //update the last accessed time |
|
497 UpdateLastAccessedTimeL(aCacheView); |
|
498 aCacheView.Close(); |
|
499 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
500 { |
|
501 iCacheObservers[i]->CachedStructureL(EChannels); |
|
502 } |
|
503 break; |
|
504 } |
|
505 case EPresets: |
|
506 { |
|
507 //Internalize the preset into the CIRIsdsPreset object |
|
508 RDbColReadStream instream; |
|
509 instream.OpenLC( aCacheView, columnNo ); |
|
510 if(iPtrPreset) |
|
511 { |
|
512 iPtrPreset->ResetAndDestroy(); |
|
513 } |
|
514 CIRIsdsPreset *ptr; |
|
515 for(TInt iter=0;iter<aCountItems;iter++) |
|
516 { |
|
517 ptr = CIRIsdsPreset::NewL(); |
|
518 CleanupStack::PushL(ptr); |
|
519 instream>>*ptr; |
|
520 if(iPtrPreset) |
|
521 { |
|
522 iPtrPreset->AppendL(ptr); |
|
523 } |
|
524 CleanupStack::Pop(ptr); |
|
525 } |
|
526 CleanupStack::PopAndDestroy( &instream ); |
|
527 //update the last accessed time |
|
528 UpdateLastAccessedTimeL(aCacheView); |
|
529 aCacheView.Close(); |
|
530 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
531 { |
|
532 iCacheObservers[i]->CachedStructureL(EPresets); |
|
533 } |
|
534 break; |
|
535 } |
|
536 case EOtaInfo: |
|
537 { |
|
538 //Internalize the ota info into the CIROTAUpdate object |
|
539 RDbColReadStream instream; |
|
540 instream.OpenLC( aCacheView, columnNo ); |
|
541 if(iOTA) |
|
542 { |
|
543 delete iOTA; |
|
544 iOTA = NULL; |
|
545 iOTA = CIROTAUpdate::NewL(); |
|
546 instream>>*iOTA; |
|
547 } |
|
548 |
|
549 CleanupStack::PopAndDestroy( &instream ); |
|
550 //update the last accessed time |
|
551 UpdateLastAccessedTimeL(aCacheView); |
|
552 aCacheView.Close(); |
|
553 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
554 { |
|
555 iCacheObservers[i]->CachedStructureL(EOtaInfo); |
|
556 } |
|
557 break; |
|
558 } |
|
559 case ELogo: |
|
560 { |
|
561 //get the logo data from the cache |
|
562 TInt logoSize = aCacheView.ColSize(columnNo); |
|
563 iLogoData.Close(); |
|
564 iLogoData.Zero(); |
|
565 iLogoData.Create(logoSize); |
|
566 |
|
567 RDbColReadStream instream; |
|
568 instream.OpenLC( aCacheView, columnNo ); |
|
569 instream.ReadL(iLogoData,aCacheView.ColLength(columnNo)); |
|
570 CleanupStack::PopAndDestroy( &instream ); |
|
571 //update the last accessed time |
|
572 UpdateLastAccessedTimeL(aCacheView); |
|
573 aCacheView.Close(); |
|
574 for (TInt i = 0 ; i < iCacheObservers.Count() ; i++ ) |
|
575 { |
|
576 iCacheObservers[i]->CachedStructureL(ELogo); |
|
577 } |
|
578 break; |
|
579 } |
|
580 default: |
|
581 { |
|
582 aCacheView.Close(); |
|
583 } |
|
584 } |
|
585 IRLOG_DEBUG( "CIRCacheMgmt::FetchCachedDataL - Exiting." ); |
|
586 } |
|
587 // --------------------------------------------------------------------------- |
|
588 //updates the last accessed field to aid in deletion of old unused data |
|
589 // |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 void CIRCacheMgmt::UpdateLastAccessedTimeL(RDbView &aCacheView) |
|
593 { |
|
594 IRLOG_DEBUG( "IRCacheMgmt::UpdateTrustPeriod - Entering." ); |
|
595 //update the last accessed col |
|
596 CDbColSet* columns = aCacheView.ColSetL(); |
|
597 TInt updateColNo = columns->ColNo( KLastAccessedCol ); |
|
598 delete columns; |
|
599 TTime currentTime; |
|
600 currentTime.UniversalTime(); |
|
601 //update the current time value |
|
602 aCacheView.GetL(); |
|
603 aCacheView.UpdateL(); |
|
604 aCacheView.SetColL(updateColNo,currentTime); |
|
605 aCacheView.PutL(); |
|
606 IRLOG_DEBUG( "IRCacheMgmt::UpdateTrustPeriod - Exiting." ); |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // Function : CIRCacheMgmt::CheckValidity() |
|
611 // Checks the freshness of the cache |
|
612 // --------------------------------------------------------------------------- |
|
613 // |
|
614 TBool CIRCacheMgmt::CheckValidity(const TTime& aCreateTime,TInt aTrustPeriod) const |
|
615 { |
|
616 //Algo**** |
|
617 //1.get the last creation time from the table for the request |
|
618 //2.calculate creation-time + trust-period < current-time * |
|
619 //3.if true the cache is valid |
|
620 //4.else do conditional-get |
|
621 IRLOG_DEBUG( "CIRCacheMgmt::CheckValidity - Entering" ); |
|
622 TTimeIntervalSeconds trustPeriod(aTrustPeriod); |
|
623 TTimeIntervalSeconds diff; |
|
624 TTime currentDeviceTime; |
|
625 currentDeviceTime.UniversalTime(); |
|
626 currentDeviceTime.SecondsFrom(aCreateTime,diff); |
|
627 //Has the cache expired |
|
628 if(diff<trustPeriod) |
|
629 { |
|
630 IRLOG_DEBUG( "CIRCacheMgmt::CheckValidity - Exiting (1)." ); |
|
631 return ETrue; |
|
632 } |
|
633 //Else return false |
|
634 else |
|
635 { |
|
636 IRLOG_DEBUG( "CIRCacheMgmt::CheckValidity - Exiting (2)." ); |
|
637 return EFalse; |
|
638 } |
|
639 } |
|
640 |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // Function : CIRCacheMgmt::CacheCategoryItemsL() |
|
644 // Caches the category array of data.By externalizing it into a file. |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 |
|
648 EXPORT_C void CIRCacheMgmt::CacheCategoryItemsL( |
|
649 CArrayPtrFlat<CIRBrowseCatagoryItems>& aPtrCategory, |
|
650 const TDesC& aName, const CIRHttpResponseData& aResponseHeaders) |
|
651 { |
|
652 //Algo**** |
|
653 //1.check if similar request is cached |
|
654 //2.delete if similar request is already present |
|
655 //3.prepare a view for insertion |
|
656 //4.push in the requested data as serialized data |
|
657 |
|
658 IRLOG_DEBUG( "IRCacheMgmt::CacheCategoryItemsL - Entering" ); |
|
659 TInt error = OpenCacheDb(); |
|
660 if(KErrNone != error) |
|
661 { |
|
662 //no problems if this function returns here. |
|
663 //normal flow won't get affected. |
|
664 //only a particular request wont get cached |
|
665 return; |
|
666 } |
|
667 |
|
668 //clear similar data from the cache table before updating it with fresh data |
|
669 //DELETE FROM KCacheTable WHERE KDataTypeCol = TYPE AND KDataIdCol = DATAID |
|
670 _LIT(query,"DELETE FROM %S WHERE %S = %d AND %S = '%S'"); |
|
671 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KDataTypeCol().Length() + |
|
672 KCacheTable().Length() + KDataIdCol().Length() + |
|
673 KDefaultRealWidth + aName.Length()); |
|
674 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,ECatagory,&KDataIdCol,&aName); |
|
675 iCacheDb.Begin(); |
|
676 //deletes a similar record if it existed. |
|
677 //no problem if it did not exist |
|
678 iCacheDb.Execute(*sqlQuery,EDbCompareNormal); |
|
679 CleanupStack::PopAndDestroy(sqlQuery); |
|
680 iCacheDb.Commit(); |
|
681 |
|
682 //get the cached data view for preset column to update with fresh data. |
|
683 //SELECT * FROM KCacheTable WHERE KDataTypeCol = TYPE |
|
684 _LIT(query1,"SELECT * FROM %S WHERE %S = %d"); |
|
685 HBufC* sqlQuery1 = HBufC::NewLC(query1().Length() + KDataTypeCol().Length() + |
|
686 KCacheTable().Length() + KDefaultRealWidth); |
|
687 sqlQuery1->Des().Format(query1,&KCacheTable,&KDataTypeCol,ECatagory); |
|
688 |
|
689 RDbView cacheTableView; |
|
690 User::LeaveIfError(cacheTableView.Prepare(iCacheDb,*sqlQuery1)); |
|
691 CleanupStack::PopAndDestroy(sqlQuery1); |
|
692 CleanupClosePushL(cacheTableView); |
|
693 |
|
694 User::LeaveIfError(cacheTableView.EvaluateAll()); |
|
695 |
|
696 //prepare insertion values |
|
697 //will go into last accessed aswell as the creation time fields |
|
698 TTime currentTime; |
|
699 currentTime.UniversalTime(); |
|
700 TInt countItems=aPtrCategory.Count(); |
|
701 TInt maxAge; |
|
702 if(aResponseHeaders.iMaxAge.Length() == 0) |
|
703 { |
|
704 maxAge=iTrustPeriod.Int(); |
|
705 } |
|
706 else |
|
707 { |
|
708 TLex8 conv(aResponseHeaders.iMaxAge); |
|
709 conv.Val(maxAge); |
|
710 maxAge = maxAge * KDefaultInterval; |
|
711 } |
|
712 CDbColSet* columns = cacheTableView.ColSetL(); |
|
713 CleanupStack::PushL(columns); |
|
714 //write stream |
|
715 RDbColWriteStream writeStream; |
|
716 //start insertion into the view |
|
717 //insert a new row |
|
718 cacheTableView.InsertL(); |
|
719 //set values |
|
720 cacheTableView.SetColL(columns->ColNo(KDataTypeCol), ECatagory); |
|
721 cacheTableView.SetColL(columns->ColNo(KDataIdCol), aName); |
|
722 cacheTableView.SetColL(columns->ColNo(KTrustPeriodCol), maxAge); |
|
723 cacheTableView.SetColL(columns->ColNo(KItemCount), countItems); |
|
724 //to be set only if available |
|
725 cacheTableView.SetColL(columns->ColNo(KLastModifiedCol),aResponseHeaders.iLastModified); |
|
726 cacheTableView.SetColL(columns->ColNo(KLastAccessedCol), currentTime); |
|
727 cacheTableView.SetColL(columns->ColNo(KTimeCreation), currentTime); |
|
728 //open stream |
|
729 writeStream.OpenLC(cacheTableView,columns->ColNo(KCachedDataCol)); |
|
730 for(TInt iter=0;iter<countItems;iter++) |
|
731 { |
|
732 aPtrCategory[iter]->ExternalizeL(writeStream); |
|
733 } |
|
734 writeStream.CommitL(); |
|
735 CleanupStack::PopAndDestroy(&writeStream); |
|
736 cacheTableView.PutL(); |
|
737 CleanupStack::PopAndDestroy(columns); |
|
738 CleanupStack::PopAndDestroy(&cacheTableView); |
|
739 CloseDb(); |
|
740 IRLOG_DEBUG( "IRCacheMgmt::CacheCategoryItemsL - Exiting." ); |
|
741 |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // Function : CIRCacheMgmt::CacheChannelItemsL() |
|
746 // Caches the channel objects array of data.By externalizing it into a file.. |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 |
|
750 EXPORT_C void CIRCacheMgmt::CacheChannelItemsL(CArrayPtrFlat<CIRBrowseChannelItems>& aPtrChannel, |
|
751 const TDesC& aName,const CIRHttpResponseData& aResponseHeaders) |
|
752 { |
|
753 //Algo**** |
|
754 //1.check if similar request is cached |
|
755 //2.delete if similar request is already present |
|
756 //3.prepare a view for insertion |
|
757 //4.push in the cached data request as serialized data |
|
758 IRLOG_DEBUG( "CIRCacheMgmt::CacheChannelItemsL - Entering" ); |
|
759 |
|
760 TInt error = OpenCacheDb(); |
|
761 if(KErrNone != error) |
|
762 { |
|
763 //no problems if this function returns here. |
|
764 //normal flow won't get affected. |
|
765 //only a particular request wont get cached |
|
766 return; |
|
767 } |
|
768 |
|
769 //convert the id information of descriptor to int value for comparision |
|
770 //clear data from the cache table before updating it with fresh data |
|
771 //DELETE FROM KCacheTable WHERE KDataTypeCol = TYPE AND KDataIdCol = DATAID |
|
772 _LIT(query,"DELETE FROM %S WHERE %S = %d AND %S = '%S'"); |
|
773 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KDataTypeCol().Length() + |
|
774 KCacheTable().Length() + KDataIdCol().Length() + |
|
775 KDefaultRealWidth + aName.Length()); |
|
776 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,EChannels,&KDataIdCol,&aName); |
|
777 iCacheDb.Begin(); |
|
778 //deletes a similar record if it existed. |
|
779 //no problem if it did not exist |
|
780 iCacheDb.Execute(*sqlQuery,EDbCompareNormal); |
|
781 CleanupStack::PopAndDestroy(sqlQuery); |
|
782 iCacheDb.Commit(); |
|
783 |
|
784 //get the cached data view for preset column to update with fresh data. |
|
785 //SELECT * FROM KCacheTable WHERE KDataTypeCol = TYPE |
|
786 _LIT(query1,"SELECT * FROM %S WHERE %S = %d"); |
|
787 HBufC* sqlQuery1 = HBufC::NewLC(query1().Length() + KDataTypeCol().Length() + |
|
788 KCacheTable().Length() + KDefaultRealWidth); |
|
789 RDbView cacheTableView; |
|
790 sqlQuery1->Des().Format(query1,&KCacheTable,&KDataTypeCol,EChannels); |
|
791 User::LeaveIfError(cacheTableView.Prepare(iCacheDb,*sqlQuery1)); |
|
792 CleanupStack::PopAndDestroy(sqlQuery1); |
|
793 CleanupClosePushL(cacheTableView); |
|
794 |
|
795 User::LeaveIfError(cacheTableView.EvaluateAll()); |
|
796 |
|
797 //prepare insertion values |
|
798 //will go into last accessed aswell as the creation time fields |
|
799 TTime currentTime; |
|
800 currentTime.UniversalTime(); |
|
801 TInt countItems=aPtrChannel.Count(); |
|
802 TInt maxAge; |
|
803 if(aResponseHeaders.iMaxAge.Length() == 0) |
|
804 { |
|
805 maxAge=iTrustPeriod.Int(); |
|
806 } |
|
807 else |
|
808 { |
|
809 TLex8 conv(aResponseHeaders.iMaxAge); |
|
810 conv.Val(maxAge); |
|
811 maxAge = maxAge * KDefaultInterval; |
|
812 } |
|
813 TBuf<KHttpDateLength>lastModified; |
|
814 |
|
815 CDbColSet* columns = cacheTableView.ColSetL(); |
|
816 CleanupStack::PushL(columns); |
|
817 //write stream |
|
818 RDbColWriteStream writeStream; |
|
819 |
|
820 //start insertion into the view |
|
821 //insert a new row |
|
822 cacheTableView.InsertL(); |
|
823 //set values |
|
824 cacheTableView.SetColL(columns->ColNo(KDataTypeCol), EChannels); |
|
825 cacheTableView.SetColL(columns->ColNo(KDataIdCol), aName); |
|
826 cacheTableView.SetColL(columns->ColNo(KTrustPeriodCol), maxAge); |
|
827 cacheTableView.SetColL(columns->ColNo(KItemCount), countItems); |
|
828 //to be set only if available |
|
829 cacheTableView.SetColL(columns->ColNo(KLastModifiedCol),aResponseHeaders.iLastModified); |
|
830 // |
|
831 cacheTableView.SetColL(columns->ColNo(KLastAccessedCol), currentTime); |
|
832 cacheTableView.SetColL(columns->ColNo(KTimeCreation), currentTime); |
|
833 //open stream |
|
834 writeStream.OpenLC(cacheTableView,columns->ColNo(KCachedDataCol)); |
|
835 for(TInt iter=0;iter<countItems;iter++) |
|
836 { |
|
837 aPtrChannel[iter]->ExternalizeL(writeStream); |
|
838 } |
|
839 writeStream.CommitL(); |
|
840 CleanupStack::PopAndDestroy(&writeStream); |
|
841 cacheTableView.PutL(); |
|
842 CleanupStack::PopAndDestroy(columns); |
|
843 CleanupStack::PopAndDestroy(&cacheTableView); |
|
844 CloseDb(); |
|
845 IRLOG_DEBUG( "CIRCacheMgmt::CacheChannelItemsL - Exiting." ); |
|
846 |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------------------------- |
|
850 // Function : CIRCacheMgmt::CachePresetItemL() |
|
851 // Caches the preset object .By externalizing it into a file. |
|
852 //multiple presets can be cached at one time |
|
853 // --------------------------------------------------------------------------- |
|
854 // |
|
855 |
|
856 EXPORT_C void CIRCacheMgmt::CachePresetItemL(CArrayPtrFlat<CIRIsdsPreset>& aPtrPresets, |
|
857 const TDesC& aName,const CIRHttpResponseData& aResponseHeaders) |
|
858 { |
|
859 //Algo**** |
|
860 //1.check if similar request is cached |
|
861 //2.delete if similar request is already present |
|
862 //3.prepare a view for insertion |
|
863 //4.push in the cached data request as serialized data |
|
864 IRLOG_DEBUG( "CIRCacheMgmt::CachePresetItemL - Entering" ); |
|
865 |
|
866 TInt error = OpenCacheDb(); |
|
867 if(KErrNone != error) |
|
868 { |
|
869 //no problems if this function returns here. |
|
870 //normal flow won't get affected. |
|
871 //only a particular request wont get cached |
|
872 return; |
|
873 } |
|
874 //convert the id information of descriptor to int value for comparision |
|
875 //clear data from the cache table before updating it with fresh data |
|
876 //DELETE FROM KCacheTable WHERE KDataTypeCol = TYPE AND KDataIdCol = DATAID |
|
877 _LIT(query,"DELETE FROM %S WHERE %S = %d AND %S = '%S'"); |
|
878 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KDataTypeCol().Length() + |
|
879 KCacheTable().Length() + KDataIdCol().Length() + |
|
880 KDefaultRealWidth + aName.Length()); |
|
881 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,EPresets,&KDataIdCol,&aName); |
|
882 iCacheDb.Begin(); |
|
883 //deletes a similar record if it existed. |
|
884 //no problem if it did not exist |
|
885 iCacheDb.Execute(*sqlQuery,EDbCompareNormal); |
|
886 CleanupStack::PopAndDestroy(sqlQuery); |
|
887 iCacheDb.Commit(); |
|
888 |
|
889 //get the cached data view for preset column to update with fresh data. |
|
890 //SELECT * FROM KCacheTable WHERE KDataTypeCol = TYPE |
|
891 _LIT(query1,"SELECT * FROM %S WHERE %S = %d"); |
|
892 HBufC* sqlQuery1 = HBufC::NewLC(query1().Length() + KDataTypeCol().Length() + |
|
893 KCacheTable().Length() + KDefaultRealWidth); |
|
894 sqlQuery1->Des().Format(query1,&KCacheTable,&KDataTypeCol,EPresets); |
|
895 RDbView cacheTableView; |
|
896 User::LeaveIfError(cacheTableView.Prepare(iCacheDb,*sqlQuery1)); |
|
897 CleanupStack::PopAndDestroy(sqlQuery1); |
|
898 CleanupClosePushL(cacheTableView); |
|
899 |
|
900 User::LeaveIfError(cacheTableView.EvaluateAll()); |
|
901 |
|
902 //prepare insertion values |
|
903 //will go into last accessed aswell as the creation time fields |
|
904 TTime currentTime; |
|
905 currentTime.UniversalTime(); |
|
906 |
|
907 TInt maxAge; |
|
908 if(aResponseHeaders.iMaxAge.Length()== 0) |
|
909 { |
|
910 maxAge=iTrustPeriod.Int(); |
|
911 } |
|
912 else |
|
913 { |
|
914 TLex8 conv(aResponseHeaders.iMaxAge); |
|
915 conv.Val(maxAge); |
|
916 maxAge = maxAge * KDefaultInterval; |
|
917 } |
|
918 TBuf<KHttpDateLength>lastModified; |
|
919 //default time set to 24hrs |
|
920 //use iTrustPeriod |
|
921 //type set to EPresets |
|
922 //id set to dataId |
|
923 //last modified time kept null |
|
924 //item count set to 1 |
|
925 CDbColSet* columns = cacheTableView.ColSetL(); |
|
926 CleanupStack::PushL(columns); |
|
927 //write stream |
|
928 RDbColWriteStream writeStream; |
|
929 TInt countItems; |
|
930 countItems = aPtrPresets.Count(); |
|
931 //start insertion into the view |
|
932 //insert a new row |
|
933 cacheTableView.InsertL(); |
|
934 //set values |
|
935 cacheTableView.SetColL(columns->ColNo(KDataTypeCol), EPresets); |
|
936 cacheTableView.SetColL(columns->ColNo(KDataIdCol), aName); |
|
937 cacheTableView.SetColL(columns->ColNo(KTrustPeriodCol), maxAge); |
|
938 cacheTableView.SetColL(columns->ColNo(KItemCount), countItems); |
|
939 //to be set only if available |
|
940 cacheTableView.SetColL(columns->ColNo(KLastModifiedCol), |
|
941 aResponseHeaders.iLastModified); |
|
942 // |
|
943 cacheTableView.SetColL(columns->ColNo(KLastAccessedCol), currentTime); |
|
944 cacheTableView.SetColL(columns->ColNo(KTimeCreation), currentTime); |
|
945 //open stream |
|
946 writeStream.OpenLC(cacheTableView,columns->ColNo(KCachedDataCol)); |
|
947 for(TInt iter=0;iter<countItems;iter++) |
|
948 { |
|
949 aPtrPresets[iter]->ExternalizeL(writeStream); |
|
950 } |
|
951 writeStream.CommitL(); |
|
952 CleanupStack::PopAndDestroy(&writeStream); |
|
953 cacheTableView.PutL(); |
|
954 |
|
955 CleanupStack::PopAndDestroy(columns); |
|
956 CleanupStack::PopAndDestroy(&cacheTableView); |
|
957 CloseDb(); |
|
958 IRLOG_DEBUG( "CIRCacheMgmt::CachePresetItemL - Exiting." ); |
|
959 } |
|
960 // --------------------------------------------------------------------------- |
|
961 // Function : CIRCacheMgmt::CacheOtaInfoL() |
|
962 // Caches the OTA information .By externalizing it into a db. |
|
963 // --------------------------------------------------------------------------- |
|
964 // |
|
965 |
|
966 EXPORT_C void CIRCacheMgmt::CacheOtaInfoL(const CIROTAUpdate& aOta,const TDesC& aName, |
|
967 const CIRHttpResponseData& aResponseHeaders) |
|
968 { |
|
969 //Algo**** |
|
970 //1.check if similar request is cached |
|
971 //2.delete if similar request is already present |
|
972 //3.prepare a view for insertion |
|
973 //4.push in the cached data request as serialized data |
|
974 IRLOG_DEBUG( "CIRCacheMgmt::CacheOtaInfoL - Entering" ); |
|
975 |
|
976 TInt error = OpenCacheDb(); |
|
977 if(KErrNone != error) |
|
978 { |
|
979 //no problems if this function returns here. |
|
980 //normal flow won't get affected. |
|
981 //only a particular request wont get cached |
|
982 return; |
|
983 } |
|
984 //convert the id information of descriptor to int value for comparision |
|
985 //clear data from the cache table before updating it with fresh data |
|
986 //DELETE FROM KCacheTable WHERE KDataTypeCol = TYPE AND KDataIdCol = DATAID |
|
987 _LIT(query,"DELETE FROM %S WHERE %S = %d AND %S = '%S'"); |
|
988 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KDataTypeCol().Length() + |
|
989 KCacheTable().Length() + KDataIdCol().Length() + |
|
990 KDefaultRealWidth + aName.Length()); |
|
991 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,EOtaInfo,&KDataIdCol,&aName); |
|
992 User::LeaveIfError(iCacheDb.Begin()); |
|
993 //deletes a similar record if it existed. |
|
994 //no problem if it did not exist |
|
995 iCacheDb.Execute(*sqlQuery,EDbCompareNormal); |
|
996 CleanupStack::PopAndDestroy(sqlQuery); |
|
997 iCacheDb.Commit(); |
|
998 |
|
999 //get the cached data view for preset column to update with fresh data. |
|
1000 //SELECT * FROM KCacheTable WHERE KDataTypeCol = TYPE |
|
1001 _LIT(query1,"SELECT * FROM %S WHERE %S = %d"); |
|
1002 HBufC* sqlQuery1 = HBufC::NewLC(query1().Length() + KDataTypeCol().Length() + |
|
1003 KCacheTable().Length() + KDefaultRealWidth); |
|
1004 sqlQuery1->Des().Format(query1,&KCacheTable,&KDataTypeCol,EOtaInfo); |
|
1005 RDbView cacheTableView; |
|
1006 User::LeaveIfError(cacheTableView.Prepare(iCacheDb,*sqlQuery1)); |
|
1007 CleanupStack::PopAndDestroy(sqlQuery1); |
|
1008 CleanupClosePushL(cacheTableView); |
|
1009 |
|
1010 User::LeaveIfError(cacheTableView.EvaluateAll()); |
|
1011 |
|
1012 //prepare insertion values |
|
1013 //will go into last accessed aswell as the creation time fields |
|
1014 TTime currentTime; |
|
1015 currentTime.UniversalTime(); |
|
1016 |
|
1017 TInt maxAge; |
|
1018 if(aResponseHeaders.iMaxAge.Length()== 0) |
|
1019 { |
|
1020 maxAge=iTrustPeriod.Int(); |
|
1021 } |
|
1022 else |
|
1023 { |
|
1024 TLex8 conv(aResponseHeaders.iMaxAge); |
|
1025 conv.Val(maxAge); |
|
1026 maxAge = maxAge * KDefaultInterval; |
|
1027 } |
|
1028 TBuf<KHttpDateLength>lastModified; |
|
1029 //default time set to 24hrs |
|
1030 //use iTrustPeriod |
|
1031 //type set to EPresets |
|
1032 //id set to dataId |
|
1033 //last modified time kept null |
|
1034 //item count set to 1 |
|
1035 CDbColSet* columns = cacheTableView.ColSetL(); |
|
1036 CleanupStack::PushL(columns); |
|
1037 //write stream |
|
1038 RDbColWriteStream writeStream; |
|
1039 //start insertion into the view |
|
1040 //insert a new row |
|
1041 cacheTableView.InsertL(); |
|
1042 //set values |
|
1043 cacheTableView.SetColL(columns->ColNo(KDataTypeCol), EOtaInfo); |
|
1044 cacheTableView.SetColL(columns->ColNo(KDataIdCol), aName); |
|
1045 cacheTableView.SetColL(columns->ColNo(KTrustPeriodCol), maxAge); |
|
1046 cacheTableView.SetColL(columns->ColNo(KItemCount), 1); |
|
1047 //to be set only if available |
|
1048 cacheTableView.SetColL(columns->ColNo(KLastModifiedCol), |
|
1049 aResponseHeaders.iLastModified); |
|
1050 // |
|
1051 cacheTableView.SetColL(columns->ColNo(KLastAccessedCol), currentTime); |
|
1052 cacheTableView.SetColL(columns->ColNo(KTimeCreation), currentTime); |
|
1053 //open stream |
|
1054 writeStream.OpenLC(cacheTableView,columns->ColNo(KCachedDataCol)); |
|
1055 aOta.ExternalizeL(writeStream); |
|
1056 writeStream.CommitL(); |
|
1057 CleanupStack::PopAndDestroy(&writeStream); |
|
1058 cacheTableView.PutL(); |
|
1059 |
|
1060 CleanupStack::PopAndDestroy(columns); |
|
1061 CleanupStack::PopAndDestroy(&cacheTableView); |
|
1062 CloseDb(); |
|
1063 IRLOG_DEBUG( "CIRCacheMgmt::CacheOtaInfoL - Exiting." ); |
|
1064 } |
|
1065 |
|
1066 // --------------------------------------------------------------------------- |
|
1067 // Function : CIRCacheMgmt::CacheLogoL() |
|
1068 // Caches the logo data .By externalizing it into a db. |
|
1069 // --------------------------------------------------------------------------- |
|
1070 // |
|
1071 EXPORT_C void CIRCacheMgmt::CacheLogoL(const TDesC8& aData, const TDesC& aUrl, |
|
1072 const CIRHttpResponseData& aResponseHeaders) |
|
1073 { |
|
1074 //Algo**** |
|
1075 //1.check if similar request is cached |
|
1076 //2.delete if similar request is already present |
|
1077 //3.prepare a view for insertion |
|
1078 //4.push in the cached data request as serialized data |
|
1079 IRLOG_DEBUG( "CIRCacheMgmt::CacheLogoL - Entering" ); |
|
1080 |
|
1081 |
|
1082 TInt error = OpenCacheDb(); |
|
1083 if(KErrNone != error) |
|
1084 { |
|
1085 //no problems if this function returns here. |
|
1086 //normal flow won't get affected. |
|
1087 //only a particular request wont get cached |
|
1088 return; |
|
1089 } |
|
1090 //convert the id information of descriptor to int value for comparision |
|
1091 //clear data from the cache table before updating it with fresh data |
|
1092 //DELETE FROM KCacheTable WHERE KDataTypeCol = TYPE AND KDataIdCol = DATAID |
|
1093 _LIT(query,"DELETE FROM %S WHERE %S = %d AND %S = '%S'"); |
|
1094 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KDataTypeCol().Length() + |
|
1095 KCacheTable().Length() + KDataIdCol().Length() + |
|
1096 KDefaultRealWidth + aUrl.Length()); |
|
1097 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,ELogo,&KDataIdCol,&aUrl); |
|
1098 iCacheDb.Begin(); |
|
1099 //deletes a similar record if it existed. |
|
1100 //no problem if it did not exist |
|
1101 iCacheDb.Execute(*sqlQuery,EDbCompareNormal); |
|
1102 CleanupStack::PopAndDestroy(sqlQuery); |
|
1103 iCacheDb.Commit(); |
|
1104 |
|
1105 //get the cached data view for preset column to update with fresh data. |
|
1106 //SELECT * FROM KCacheTable WHERE KDataTypeCol = TYPE |
|
1107 _LIT(query1,"SELECT * FROM %S WHERE %S = %d"); |
|
1108 HBufC* sqlQuery1 = HBufC::NewLC(query1().Length() + KDataTypeCol().Length() + |
|
1109 KCacheTable().Length() + KDefaultRealWidth); |
|
1110 sqlQuery1->Des().Format(query1,&KCacheTable,&KDataTypeCol,ELogo); |
|
1111 RDbView cacheTableView; |
|
1112 User::LeaveIfError(cacheTableView.Prepare(iCacheDb,*sqlQuery1)); |
|
1113 CleanupStack::PopAndDestroy(sqlQuery1); |
|
1114 CleanupClosePushL(cacheTableView); |
|
1115 |
|
1116 User::LeaveIfError(cacheTableView.EvaluateAll()); |
|
1117 |
|
1118 //prepare insertion values |
|
1119 //will go into last accessed aswell as the creation time fields |
|
1120 TTime currentTime; |
|
1121 currentTime.UniversalTime(); |
|
1122 |
|
1123 TInt maxAge; |
|
1124 if(aResponseHeaders.iMaxAge.Length()== 0) |
|
1125 { |
|
1126 maxAge=iTrustPeriod.Int(); |
|
1127 } |
|
1128 else |
|
1129 { |
|
1130 TLex8 conv(aResponseHeaders.iMaxAge); |
|
1131 conv.Val(maxAge); |
|
1132 maxAge = maxAge * KDefaultInterval; |
|
1133 } |
|
1134 TBuf<KHttpDateLength>lastModified; |
|
1135 //default time set to 24hrs |
|
1136 //use iTrustPeriod |
|
1137 //type set to ELogo |
|
1138 //id set to dataId |
|
1139 //last modified time kept null |
|
1140 //item count set to 1 |
|
1141 CDbColSet* columns = cacheTableView.ColSetL(); |
|
1142 CleanupStack::PushL(columns); |
|
1143 //write stream |
|
1144 //start insertion into the view |
|
1145 //insert a new row |
|
1146 cacheTableView.InsertL(); |
|
1147 //set values |
|
1148 cacheTableView.SetColL(columns->ColNo(KDataTypeCol), ELogo); |
|
1149 cacheTableView.SetColL(columns->ColNo(KDataIdCol), aUrl); |
|
1150 cacheTableView.SetColL(columns->ColNo(KTrustPeriodCol), maxAge); |
|
1151 cacheTableView.SetColL(columns->ColNo(KItemCount), 1); |
|
1152 //to be set only if available |
|
1153 cacheTableView.SetColL(columns->ColNo(KLastModifiedCol), |
|
1154 aResponseHeaders.iLastModified); |
|
1155 // |
|
1156 cacheTableView.SetColL(columns->ColNo(KLastAccessedCol), currentTime); |
|
1157 cacheTableView.SetColL(columns->ColNo(KTimeCreation), currentTime); |
|
1158 cacheTableView.SetColL(columns->ColNo(KCachedDataCol), aData); |
|
1159 |
|
1160 cacheTableView.SetColL(columns->ColNo(KETagHeader), |
|
1161 aResponseHeaders.iETag); |
|
1162 |
|
1163 cacheTableView.PutL(); |
|
1164 |
|
1165 |
|
1166 CleanupStack::PopAndDestroy(columns); |
|
1167 CleanupStack::PopAndDestroy(&cacheTableView); |
|
1168 CloseDb(); |
|
1169 IRLOG_DEBUG( "CIRCacheMgmt::CacheLogoL - Exiting." ); |
|
1170 |
|
1171 } |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 // --------------------------------------------------------------------------- |
|
1177 // Function : CIRCacheMgmt::CreateCacheTableL() |
|
1178 // creates the cache table |
|
1179 // --------------------------------------------------------------------------- |
|
1180 // |
|
1181 //CacheTable |
|
1182 // ----------------------------------------------------------------------------------------------------- |
|
1183 //| RowIndex|DataType|DataId|TrustPeriod|LastModified |LastAccessed|Created|ItemCount|CachedData| |
|
1184 //------------------------------------------------------------------------------------------------ |
|
1185 //| auto |TInt |DesC |TInt |TDesC/DateTime|TTime |Time |TInt | Streamed | |
|
1186 //|increment|0,1,2,NotNull|NotNull| NotNull | | | | | Data | |
|
1187 //------------------------------------------------------------------------------------------------------ |
|
1188 void CIRCacheMgmt::CreateCacheTableL() |
|
1189 { |
|
1190 IRLOG_DEBUG( "IRCacheMgmt::CreateCacheTableL - Entering." ); |
|
1191 //the row index column which autoincrements |
|
1192 TDbCol rowIndexCol(KRowIndexCol, EDbColInt32); |
|
1193 rowIndexCol.iAttributes = TDbCol::EAutoIncrement; |
|
1194 |
|
1195 //the datatype column,to identify between ECatagory = 0,EChannels=1,EPresets=2 |
|
1196 TDbCol dataTypeCol(KDataTypeCol, EDbColInt32); |
|
1197 dataTypeCol.iAttributes = TDbCol::ENotNull; |
|
1198 |
|
1199 //the dataID column,to uniquely identify the cached data |
|
1200 TDbCol dataId(KDataIdCol, EDbColLongText16); |
|
1201 dataId.iAttributes = TDbCol::ENotNull; |
|
1202 |
|
1203 //the trust period column to calculate cache validity |
|
1204 TDbCol trustPeriodCol(KTrustPeriodCol, EDbColInt32); |
|
1205 |
|
1206 //the lastmodified column to fetch data conditionally |
|
1207 TDbCol lastModifiedCol(KLastModifiedCol, EDbColDateTime); |
|
1208 |
|
1209 |
|
1210 //the last accessed column used for table clean-up |
|
1211 TDbCol creationTimeCol(KTimeCreation, EDbColDateTime); |
|
1212 |
|
1213 //the time of creation saved to calculate the cache validity |
|
1214 TDbCol lastAccessedCol(KLastAccessedCol, EDbColDateTime); |
|
1215 |
|
1216 //the number of items in the data field |
|
1217 TDbCol itemCountCol(KItemCount, EDbColInt32); |
|
1218 |
|
1219 //the data column to store cached data |
|
1220 //The column stores a potentially large amount of Unicode text data. |
|
1221 TDbCol cachedDataCol(KCachedDataCol, EDbColLongText8); |
|
1222 |
|
1223 //the ETag header received along with the logo data |
|
1224 TDbCol etagHeader(KETagHeader, EDbColText8); |
|
1225 |
|
1226 //colset |
|
1227 CDbColSet* cacheTablerColSet = CDbColSet::NewLC(); |
|
1228 //populate colset |
|
1229 cacheTablerColSet->AddL(rowIndexCol); |
|
1230 cacheTablerColSet->AddL(dataTypeCol); |
|
1231 cacheTablerColSet->AddL(dataId); |
|
1232 cacheTablerColSet->AddL(trustPeriodCol); |
|
1233 cacheTablerColSet->AddL(lastModifiedCol); |
|
1234 cacheTablerColSet->AddL(creationTimeCol); |
|
1235 cacheTablerColSet->AddL(lastAccessedCol); |
|
1236 cacheTablerColSet->AddL(itemCountCol); |
|
1237 cacheTablerColSet->AddL(cachedDataCol); |
|
1238 cacheTablerColSet->AddL(etagHeader); |
|
1239 |
|
1240 // Create the CacheTable table |
|
1241 User::LeaveIfError(iCacheDb.CreateTable(KCacheTable, *cacheTablerColSet)); |
|
1242 |
|
1243 CleanupStack::PopAndDestroy(cacheTablerColSet); |
|
1244 IRLOG_DEBUG( "IRCacheMgmt::CreateCacheTableL - Exiting." ); |
|
1245 } |
|
1246 |
|
1247 // --------------------------------------------------------------------------- |
|
1248 // Function : CIRCacheMgmt::CreateCacheIndexL() |
|
1249 // creates the indices for cache table |
|
1250 // --------------------------------------------------------------------------- |
|
1251 // |
|
1252 void CIRCacheMgmt::CreateCacheIndexL() |
|
1253 { |
|
1254 IRLOG_DEBUG( "IRCacheMgmt::CreateCacheIndexL - Entering." ); |
|
1255 TDbKeyCol rowIndexCol(KRowIndexCol); |
|
1256 TDbKeyCol dataTypeCol(KDataTypeCol); |
|
1257 TDbKeyCol dataIdCol(KDataIdCol,KDataIdIndexSize); |
|
1258 TDbKeyCol timeCreationCol(KTimeCreation); |
|
1259 TDbKeyCol lastAccessedCol(KLastAccessedCol); |
|
1260 |
|
1261 CDbKey* index; |
|
1262 //index on the auto increment row id |
|
1263 index = CDbKey::NewLC(); |
|
1264 index->AddL(rowIndexCol); |
|
1265 User::LeaveIfError(iCacheDb.CreateIndex(KRowIndexColIndex, KCacheTable, |
|
1266 *index)); |
|
1267 CleanupStack::PopAndDestroy(index); |
|
1268 |
|
1269 //index on the datatype column |
|
1270 index = CDbKey::NewLC(); |
|
1271 index->AddL(dataTypeCol); |
|
1272 User::LeaveIfError(iCacheDb.CreateIndex(KDataTypeColIndex, KCacheTable, |
|
1273 *index)); |
|
1274 CleanupStack::PopAndDestroy(index); |
|
1275 |
|
1276 //index on the data id column |
|
1277 index = CDbKey::NewLC(); |
|
1278 index->AddL(dataIdCol); |
|
1279 User::LeaveIfError(iCacheDb.CreateIndex(KDataIdColIndex, KCacheTable, |
|
1280 *index)); |
|
1281 CleanupStack::PopAndDestroy(index); |
|
1282 |
|
1283 //index on the time of record creation column |
|
1284 index = CDbKey::NewLC(); |
|
1285 index->AddL(timeCreationCol); |
|
1286 User::LeaveIfError(iCacheDb.CreateIndex(KTimeCreationIndex, KCacheTable, |
|
1287 *index)); |
|
1288 CleanupStack::PopAndDestroy(index); |
|
1289 |
|
1290 //index on the last accessed column |
|
1291 index = CDbKey::NewLC(); |
|
1292 index->AddL(lastAccessedCol); |
|
1293 User::LeaveIfError(iCacheDb.CreateIndex(KLastAccessedColIndex, KCacheTable, |
|
1294 *index)); |
|
1295 CleanupStack::PopAndDestroy(index); |
|
1296 IRLOG_DEBUG( "IRCacheMgmt::CreateCacheIndexL - Exiting." ); |
|
1297 } |
|
1298 // --------------------------------------------------------------------------- |
|
1299 //void CIRCacheMgmt::UpdateTrustPeriod() |
|
1300 //updates the trust period for a not-modified responce |
|
1301 // --------------------------------------------------------------------------- |
|
1302 |
|
1303 // |
|
1304 EXPORT_C void CIRCacheMgmt::UpdateTrustPeriodL( TInt aType, const TDesC& aName, |
|
1305 CIRHttpResponseData& aResponseHeaders) |
|
1306 { |
|
1307 IRLOG_DEBUG( "IRCacheMgmt::UpdateTrustPeriodL - Entering" ); |
|
1308 TInt error = OpenCacheDb(); |
|
1309 if(KErrNone != error) |
|
1310 { |
|
1311 IRLOG_ERROR2( "IRCacheMgmt::UpdateTrustPeriodL - Error while opening cache DB (%d).", error ); |
|
1312 //no problems if this function returns here. |
|
1313 //normal flow won't get affected. |
|
1314 //only a particular request wont get cached |
|
1315 return; |
|
1316 } |
|
1317 |
|
1318 //SELECT * FROM KCacheTable WHERE KDataTypeCol = TYPE AND KDataIdCol = DATAID |
|
1319 _LIT(query,"SELECT * FROM %S WHERE %S = %d AND %S = '%S'"); |
|
1320 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KCacheTable().Length() + |
|
1321 KDataIdCol().Length() + KDataTypeCol().Length() + aName.Length()+ |
|
1322 KDefaultRealWidth ); |
|
1323 |
|
1324 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,aType,&KDataIdCol,&aName); |
|
1325 //create view |
|
1326 RDbView cacheTableView; |
|
1327 User::LeaveIfError(cacheTableView.Prepare(iCacheDb,*sqlQuery)); |
|
1328 CleanupStack::PopAndDestroy(sqlQuery); |
|
1329 CleanupClosePushL(cacheTableView); |
|
1330 |
|
1331 User::LeaveIfError(cacheTableView.EvaluateAll()); |
|
1332 |
|
1333 //prepare the update data |
|
1334 //will go into last accessed aswell as the creation time fields |
|
1335 TTime currentTime; |
|
1336 currentTime.UniversalTime(); |
|
1337 //get the new trust period from the headers |
|
1338 TInt maxAge; |
|
1339 if(aResponseHeaders.iMaxAge.Length() == 0) |
|
1340 { |
|
1341 maxAge=iTrustPeriod.Int(); |
|
1342 } |
|
1343 else |
|
1344 { |
|
1345 TLex8 conv(aResponseHeaders.iMaxAge); |
|
1346 conv.Val(maxAge); |
|
1347 maxAge = maxAge * KDefaultInterval; |
|
1348 } |
|
1349 CDbColSet* columns = cacheTableView.ColSetL(); |
|
1350 CleanupStack::PushL(columns); |
|
1351 cacheTableView.FirstL(); |
|
1352 if(cacheTableView.AtRow()) |
|
1353 { |
|
1354 cacheTableView.UpdateL(); |
|
1355 //update values |
|
1356 cacheTableView.SetColL(columns->ColNo(KTrustPeriodCol), maxAge); |
|
1357 cacheTableView.SetColL(columns->ColNo(KLastAccessedCol), currentTime); |
|
1358 cacheTableView.SetColL(columns->ColNo(KTimeCreation), currentTime); |
|
1359 cacheTableView.PutL(); |
|
1360 } |
|
1361 |
|
1362 CleanupStack::PopAndDestroy(columns); |
|
1363 CleanupStack::PopAndDestroy(&cacheTableView); |
|
1364 CloseDb(); |
|
1365 IRLOG_DEBUG( "IRCacheMgmt::UpdateTrustPeriod - Exiting." ); |
|
1366 } |
|
1367 |
|
1368 // --------------------------------------------------------------------------- |
|
1369 // Used to dcontrol the cache table size by compacting and clearing up unused items |
|
1370 // --------------------------------------------------------------------------- |
|
1371 // |
|
1372 void CIRCacheMgmt::CheckSizeL() |
|
1373 { |
|
1374 IRLOG_DEBUG( "IRCacheMgmt::CheckSizeL - Entering." ); |
|
1375 OpenCacheDb(); |
|
1376 RDbDatabase::TSize dbSize = iCacheDb.Size(); |
|
1377 iCacheDbSize = dbSize.iSize; |
|
1378 TInt size = CacheSize(); |
|
1379 if( size >= KCacheCriticalSizeLimit ) |
|
1380 { |
|
1381 RemoveOldUnusedDataL(); |
|
1382 OpenCacheDb(); |
|
1383 iCacheDb.Compact(); |
|
1384 //refresh the size information |
|
1385 dbSize = iCacheDb.Size(); |
|
1386 iCacheDbSize = dbSize.iSize; |
|
1387 } |
|
1388 CloseDb(); |
|
1389 IRLOG_DEBUG( "IRCacheMgmt::CheckSizeL - Exiting." ); |
|
1390 } |
|
1391 |
|
1392 // --------------------------------------------------------------------------- |
|
1393 // Used to control the cache table size by compacting and clearing up unused items |
|
1394 // --------------------------------------------------------------------------- |
|
1395 // |
|
1396 void CIRCacheMgmt::RemoveOldUnusedDataL() |
|
1397 { |
|
1398 IRLOG_DEBUG( "IRCacheMgmt::RemoveOldUnusedDataL - Entering." ); |
|
1399 OpenCacheDb(); |
|
1400 RDbTable cacheTable; |
|
1401 //open the table in updatable mode |
|
1402 User::LeaveIfError(cacheTable.Open(iCacheDb, KCacheTable, cacheTable.EUpdatable)); |
|
1403 CleanupClosePushL(cacheTable); |
|
1404 cacheTable.Reset(); |
|
1405 //set index as the last accessed time |
|
1406 cacheTable.SetIndex(KLastAccessedCol); |
|
1407 //begin transaction |
|
1408 iCacheDb.Begin(); |
|
1409 // no of rows deleted is one fourth of the total number of rows |
|
1410 TInt deleteRows = cacheTable.CountL()/KPercentRowsDeleted; |
|
1411 TInt inc = 0; |
|
1412 //delete incrementally |
|
1413 for(cacheTable.FirstL();((inc < deleteRows) && cacheTable.AtRow());inc++) |
|
1414 { |
|
1415 cacheTable.GetL(); |
|
1416 cacheTable.DeleteL(); |
|
1417 cacheTable.NextL(); |
|
1418 } |
|
1419 //commit transaction |
|
1420 iCacheDb.Commit(); |
|
1421 CleanupStack::PopAndDestroy(&cacheTable); |
|
1422 CloseDb(); |
|
1423 IRLOG_DEBUG( "IRCacheMgmt::RemoveOldUnusedDataL - Exiting." ); |
|
1424 } |
|
1425 |
|
1426 // --------------------------------------------------------------------------- |
|
1427 // Used to get the cache table size |
|
1428 // --------------------------------------------------------------------------- |
|
1429 // |
|
1430 TInt CIRCacheMgmt::CacheSize() |
|
1431 { |
|
1432 IRLOG_DEBUG( "IRCacheMgmt::CacheSize - Entering." ); |
|
1433 OpenCacheDb(); |
|
1434 RDbDatabase::TSize dbSize = iCacheDb.Size(); |
|
1435 iCacheDbSize = dbSize.iSize; |
|
1436 CloseDb(); |
|
1437 IRLOG_DEBUG( "IRCacheMgmt::CacheSize - Exiting." ); |
|
1438 return iCacheDbSize; |
|
1439 } |
|
1440 // --------------------------------------------------------------------------- |
|
1441 //remove OTA info from cache if data is not valid any longer |
|
1442 // --------------------------------------------------------------------------- |
|
1443 EXPORT_C void CIRCacheMgmt::RemoveOtaInfoL() |
|
1444 { |
|
1445 IRLOG_DEBUG( "IRCacheMgmt::RemoveOtaInfoL - Entering." ); |
|
1446 //check if the silence period param is set. |
|
1447 //if not set that means the cached ota info if present is not valid. |
|
1448 if(iSettings->GetSilencePeriodL() == 0) |
|
1449 { |
|
1450 TInt error = OpenCacheDb(); |
|
1451 if(KErrNone != error) |
|
1452 { |
|
1453 //no problems if this function returns here. |
|
1454 //normal flow won't get affected. |
|
1455 //only a particular request wont get cached |
|
1456 return; |
|
1457 } |
|
1458 //clear data from the cache table |
|
1459 //DELETE FROM KCacheTable WHERE KDataTypeCol = TYPE |
|
1460 _LIT(query,"DELETE FROM %S WHERE %S = %d"); |
|
1461 HBufC* sqlQuery = HBufC::NewLC(query().Length() + KDataTypeCol().Length() + |
|
1462 KCacheTable().Length() + KDataIdCol().Length()); |
|
1463 sqlQuery->Des().Format(query,&KCacheTable,&KDataTypeCol,EOtaInfo); |
|
1464 User::LeaveIfError(iCacheDb.Begin()); |
|
1465 //no problem if it did not exist |
|
1466 iCacheDb.Execute(*sqlQuery,EDbCompareNormal); |
|
1467 CleanupStack::PopAndDestroy(sqlQuery); |
|
1468 iCacheDb.Commit(); |
|
1469 CloseDb(); |
|
1470 } |
|
1471 IRLOG_DEBUG( "IRCacheMgmt::RemoveOtaInfoL - Exiting." ); |
|
1472 } |
|
1473 |
|
1474 |
|
1475 |
|
1476 // --------------------------------------------------------------------------- |
|
1477 // Adds a cache observer |
|
1478 // --------------------------------------------------------------------------- |
|
1479 // |
|
1480 EXPORT_C void CIRCacheMgmt::AddObserverL( MIRCacheObserver* aObserver ) |
|
1481 { |
|
1482 IRLOG_DEBUG( "IRCacheMgmt::AddObserverL - Entering." ); |
|
1483 iCacheObservers.AppendL( aObserver ); |
|
1484 IRLOG_DEBUG( "IRCacheMgmt::AddObserverL - Exiting." ); |
|
1485 } |
|
1486 |
|
1487 // --------------------------------------------------------------------------- |
|
1488 // Removes a cache observer |
|
1489 // --------------------------------------------------------------------------- |
|
1490 // |
|
1491 EXPORT_C void CIRCacheMgmt::RemoveObserver( MIRCacheObserver* aObserver ) |
|
1492 { |
|
1493 IRLOG_DEBUG( "IRCacheMgmt::RemoveObserver - Entering." ); |
|
1494 TInt objectIndex = iCacheObservers.Find( aObserver ); |
|
1495 |
|
1496 if ( objectIndex != KErrNotFound ) |
|
1497 { |
|
1498 iCacheObservers.Remove( objectIndex ); |
|
1499 } |
|
1500 IRLOG_DEBUG( "IRCacheMgmt::RemoveObserver - Exiting." ); |
|
1501 } |
|
1502 |
|
1503 |
|
1504 |
|
1505 |