225 void CCentRepSWIWatcher::FindChangedEntriesL(TBool aStartup) |
225 void CCentRepSWIWatcher::FindChangedEntriesL(TBool aStartup) |
226 { |
226 { |
227 // Find added or updated entries |
227 // Find added or updated entries |
228 ReadInstallDirL(iCurrentInstallDirEntries); |
228 ReadInstallDirL(iCurrentInstallDirEntries); |
229 |
229 |
230 TInt newCount=iCurrentInstallDirEntries.Count(); |
|
231 TInt currentCount=iInstallEntryArray.Count(); |
|
232 TInt i; |
|
233 TInt r; |
|
234 TInt operation; |
|
235 |
|
236 // If both counts are 0, we shouldn't have been notified, just return |
|
237 if( (newCount==0) && (currentCount==0)) |
|
238 return; |
|
239 |
|
240 if(aStartup) |
|
241 { |
|
242 operation=ESASwisNone; |
|
243 } |
|
244 else |
|
245 { |
|
246 operation=iSWIOperation; |
|
247 } |
|
248 |
|
249 // We don't want cache activity during SWI operations |
230 // We don't want cache activity during SWI operations |
250 TServerResources::iCacheManager->DisableCache(); |
231 TServerResources::iCacheManager->DisableCache(); |
251 |
232 |
252 if( newCount==0) // currentCount > 0, newCount = 0 |
233 TRAPD(err, HandleFileChangesL(aStartup)); |
253 { // All installed files have been deleted |
|
254 // Handle deletes of all files |
|
255 for(i=0;i<currentCount;i++) |
|
256 { |
|
257 iInstallEntryArray[i]->HandleFileDeleteL(operation); |
|
258 } |
|
259 // Free memory of elements |
|
260 iInstallEntryArray.ResetAndDestroy(); |
|
261 } |
|
262 else |
|
263 { |
|
264 if( currentCount==0) // currentCount = 0, newCount > 0 |
|
265 { // All new files need to be handled |
|
266 for(i=0;i<newCount;i++) |
|
267 { |
|
268 CInstallEntry* newEntry=iCurrentInstallDirEntries[i]; |
|
269 newEntry->HandleFileCreateL(operation); |
|
270 } |
|
271 } |
|
272 else // currentCount > 0, newCount > 0 |
|
273 { |
|
274 // Find added and modified entries by going through new entries and |
|
275 // looking for them in current array |
|
276 for(i=0;i<newCount;i++) |
|
277 { |
|
278 CInstallEntry* newEntry=iCurrentInstallDirEntries[i]; |
|
279 r=iInstallEntryArray.Find( newEntry, MatchEntries); |
|
280 // If we find new entry in current array, check modification date |
|
281 if(r>=KErrNone) |
|
282 { |
|
283 CInstallEntry* currentEntry=iInstallEntryArray[r]; |
|
284 if( newEntry->Modified() > currentEntry->Modified()) |
|
285 { |
|
286 // Deal with newly installed file, note use newEntry |
|
287 // so we use new timestamp |
|
288 newEntry->HandleFileUpdateL(operation); |
|
289 } |
|
290 } |
|
291 else if(r==KErrNotFound) // File has been added |
|
292 { |
|
293 // Handle add |
|
294 newEntry->HandleFileCreateL(operation); |
|
295 // Don't leave on KErrNotFound |
|
296 r=KErrNone; |
|
297 } |
|
298 User::LeaveIfError(r); |
|
299 } |
|
300 |
|
301 // Find deleted entries by going through current entries and looking for them |
|
302 // in new array |
|
303 for(i=0;i<currentCount;i++) |
|
304 { |
|
305 CInstallEntry* currentEntry=iInstallEntryArray[i]; |
|
306 r=iCurrentInstallDirEntries.Find( currentEntry, MatchEntries); |
|
307 // If we don't find current entry in new array, it's been deleted |
|
308 if(r==KErrNotFound) |
|
309 { |
|
310 // Deal with uninstalls |
|
311 currentEntry->HandleFileDeleteL(operation); |
|
312 // Don't leave on KErrNotFound |
|
313 r=KErrNone; |
|
314 } |
|
315 User::LeaveIfError(r); |
|
316 } |
|
317 } |
|
318 |
|
319 // Clear out old list |
|
320 iInstallEntryArray.ResetAndDestroy(); |
|
321 |
|
322 // Re-read directory - if any files were corrupt they have been deleted |
|
323 // during the merge, so we need to re-read in case this has occurred |
|
324 ReadInstallDirL(iInstallEntryArray); |
|
325 } |
|
326 |
|
327 SaveInstallDirL(); |
|
328 iCurrentInstallDirEntries.ResetAndDestroy(); |
|
329 |
234 |
330 // SWI operations finished, enable cache |
235 // SWI operations finished, enable cache |
331 TServerResources::iCacheManager->EnableCache(); |
236 TServerResources::iCacheManager->EnableCache(); |
|
237 User::LeaveIfError(err); |
332 } |
238 } |
|
239 |
|
240 void CCentRepSWIWatcher::HandleFileChangesL(TBool aStartup) |
|
241 { |
|
242 TInt newCount=iCurrentInstallDirEntries.Count(); |
|
243 TInt currentCount=iInstallEntryArray.Count(); |
|
244 TInt i; |
|
245 TInt r; |
|
246 TInt operation; |
|
247 |
|
248 // If both counts are 0, we shouldn't have been notified, just return |
|
249 if( (newCount==0) && (currentCount==0)) |
|
250 return; |
|
251 |
|
252 if(aStartup) |
|
253 { |
|
254 operation=ESASwisNone; |
|
255 } |
|
256 else |
|
257 { |
|
258 operation=iSWIOperation; |
|
259 } |
|
260 |
|
261 if( newCount==0) // currentCount > 0, newCount = 0 |
|
262 { // All installed files have been deleted |
|
263 // Handle deletes of all files |
|
264 for(i=0;i<currentCount;i++) |
|
265 { |
|
266 iInstallEntryArray[i]->HandleFileDeleteL(operation); |
|
267 } |
|
268 // Free memory of elements |
|
269 iInstallEntryArray.ResetAndDestroy(); |
|
270 } |
|
271 else |
|
272 { |
|
273 if( currentCount==0) // currentCount = 0, newCount > 0 |
|
274 { // All new files need to be handled |
|
275 for(i=0;i<newCount;i++) |
|
276 { |
|
277 CInstallEntry* newEntry=iCurrentInstallDirEntries[i]; |
|
278 newEntry->HandleFileCreateL(operation); |
|
279 } |
|
280 } |
|
281 else // currentCount > 0, newCount > 0 |
|
282 { |
|
283 // Find added and modified entries by going through new entries and |
|
284 // looking for them in current array |
|
285 for(i=0;i<newCount;i++) |
|
286 { |
|
287 CInstallEntry* newEntry=iCurrentInstallDirEntries[i]; |
|
288 r=iInstallEntryArray.Find( newEntry, MatchEntries); |
|
289 // If we find new entry in current array, check modification date |
|
290 if(r>=KErrNone) |
|
291 { |
|
292 CInstallEntry* currentEntry=iInstallEntryArray[r]; |
|
293 if( newEntry->Modified() > currentEntry->Modified()) |
|
294 { |
|
295 // Deal with newly installed file, note use newEntry |
|
296 // so we use new timestamp |
|
297 newEntry->HandleFileUpdateL(operation); |
|
298 } |
|
299 } |
|
300 else if(r==KErrNotFound) // File has been added |
|
301 { |
|
302 // Handle add |
|
303 newEntry->HandleFileCreateL(operation); |
|
304 // Don't leave on KErrNotFound |
|
305 r=KErrNone; |
|
306 } |
|
307 User::LeaveIfError(r); |
|
308 } |
|
309 |
|
310 // Find deleted entries by going through current entries and looking for them |
|
311 // in new array |
|
312 for(i=0;i<currentCount;i++) |
|
313 { |
|
314 CInstallEntry* currentEntry=iInstallEntryArray[i]; |
|
315 r=iCurrentInstallDirEntries.Find( currentEntry, MatchEntries); |
|
316 // If we don't find current entry in new array, it's been deleted |
|
317 if(r==KErrNotFound) |
|
318 { |
|
319 // Deal with uninstalls |
|
320 currentEntry->HandleFileDeleteL(operation); |
|
321 // Don't leave on KErrNotFound |
|
322 r=KErrNone; |
|
323 } |
|
324 User::LeaveIfError(r); |
|
325 } |
|
326 } |
|
327 |
|
328 // Clear out old list |
|
329 iInstallEntryArray.ResetAndDestroy(); |
|
330 |
|
331 // Re-read directory - if any files were corrupt they have been deleted |
|
332 // during the merge, so we need to re-read in case this has occurred |
|
333 ReadInstallDirL(iInstallEntryArray); |
|
334 } |
|
335 |
|
336 SaveInstallDirL(); |
|
337 iCurrentInstallDirEntries.ResetAndDestroy(); |
|
338 } |
333 |
339 |
334 CInstallEntry::CInstallEntry() : |
340 CInstallEntry::CInstallEntry() : |
335 iUid(KNullUid), |
341 iUid(KNullUid), |
336 iModified(0), |
342 iModified(0), |
337 iFileExt(EUnknown) |
343 iFileExt(EUnknown) |