|
1 /* |
|
2 * Copyright (c) 2010 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: ScrUpdater is Java Captain Symbian plugin that updates |
|
15 * presence information of Java Applications in USIF SCR |
|
16 * when removable drive is added or removed to the device. |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <apgcli.h> |
|
21 #include <e32base.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 #include "javaprocessconstants.h" |
|
25 #include "javasymbianoslayer.h" |
|
26 #include "javauids.h" |
|
27 #include "logger.h" |
|
28 #include "coreinterface.h" |
|
29 #include "booteventprovidermessages.h" |
|
30 #include "mmceventprovidermessages.h" |
|
31 |
|
32 #include "scrupdater.h" |
|
33 |
|
34 using namespace Usif; |
|
35 |
|
36 _LIT(KMediaId, "Media-Id"); |
|
37 |
|
38 /** |
|
39 * Return pointer to ExtensionPluginInterface implementation for this |
|
40 * extension dll |
|
41 */ |
|
42 java::captain::ExtensionPluginInterface* getExtensionPlugin() |
|
43 { |
|
44 return new java::captain::ScrUpdater(); |
|
45 } |
|
46 |
|
47 namespace java // codescanner::namespace |
|
48 { |
|
49 namespace captain // codescanner::namespace |
|
50 { |
|
51 |
|
52 using java::fileutils::driveInfo; |
|
53 using java::fileutils::DriveListenerInterface; |
|
54 |
|
55 /** |
|
56 * Empty contructor |
|
57 */ |
|
58 ScrUpdater::ScrUpdater() |
|
59 { |
|
60 } |
|
61 |
|
62 /** |
|
63 * Empty destructor |
|
64 */ |
|
65 ScrUpdater::~ScrUpdater() |
|
66 { |
|
67 } |
|
68 |
|
69 /** |
|
70 * Implement PluginInterface method |
|
71 */ |
|
72 void ScrUpdater::startPlugin(CoreInterface* /* aCore */) |
|
73 { |
|
74 LOG(EJavaCaptain, EInfo, "ScrUpdater plugin started"); |
|
75 } |
|
76 |
|
77 /** |
|
78 * Implement PluginInterface method |
|
79 */ |
|
80 void ScrUpdater::stopPlugin() |
|
81 { |
|
82 } |
|
83 |
|
84 /** |
|
85 * Implement ExtensionPluginInterface method |
|
86 */ |
|
87 EventConsumerInterface* ScrUpdater::getEventConsumer() |
|
88 { |
|
89 return this; |
|
90 } |
|
91 |
|
92 /** |
|
93 * Handle Java Captain events sent by Boot event provider or |
|
94 * MMC event provider. |
|
95 * |
|
96 * Implement EventConsumerInterface method |
|
97 */ |
|
98 void ScrUpdater::event(const std::string& aEventProvider, |
|
99 java::comms::CommsMessage& aMsg) |
|
100 { |
|
101 if (aEventProvider == BOOT_EVENT_PROVIDER) |
|
102 { |
|
103 int bootType = NORMAL_BOOT_C; |
|
104 getBootMessageParams(aMsg, bootType); |
|
105 LOG1( |
|
106 EJavaCaptain, |
|
107 EInfo, |
|
108 "ScrUpdater::event() boot event received (type=%d)", |
|
109 bootType); |
|
110 switch (bootType) |
|
111 { |
|
112 case IAD_BOOT_C: |
|
113 case FIRST_DEVICE_BOOT_C: |
|
114 case NORMAL_BOOT_C: |
|
115 { |
|
116 // Update presence information |
|
117 TRAPD(err, initializeScrPresenceInfoL()) |
|
118 if (KErrNone != err) |
|
119 { |
|
120 ELOG1(EJavaCaptain, "initializeScrPresenceInfoL: leaved (%d)", err); |
|
121 } |
|
122 } |
|
123 break; |
|
124 |
|
125 default: |
|
126 { |
|
127 WLOG1(EJavaCaptain, |
|
128 "DriveListenerInterface: event() unknown boot event (type=%d)", bootType); |
|
129 } |
|
130 break; |
|
131 } |
|
132 } |
|
133 else if (aEventProvider == MMC_EVENT_PROVIDER) |
|
134 { |
|
135 int operation = 0; |
|
136 driveInfo di; |
|
137 getMmcChangedMessageParams(aMsg, operation, di); |
|
138 LOG1( |
|
139 EJavaCaptain, |
|
140 EInfo, |
|
141 "ScrUpdater::event() mmc event received (operation=%d)", |
|
142 operation); |
|
143 |
|
144 switch (operation) |
|
145 { |
|
146 case DriveListenerInterface::REMOVABLE_MEDIA_REMOVED_C: |
|
147 { |
|
148 // All Java applications in the removed drive are set |
|
149 // to 'not present' state |
|
150 TRAPD(err, removeScrPresencesL(&di)); |
|
151 if (KErrNone != err) |
|
152 { |
|
153 ELOG1(EJavaCaptain, "removeScrPresencesL leaved (%d)", err); |
|
154 } |
|
155 } |
|
156 break; |
|
157 |
|
158 case DriveListenerInterface::REMOVABLE_MEDIA_INSERTED_C: |
|
159 { |
|
160 // Those Java applications in the drive to where the media |
|
161 // (e.g. memory card) was added are set to 'present' state |
|
162 // IF the media id is correct (in other words if the same |
|
163 // memory card that they have been installed to is added |
|
164 // to the drive). |
|
165 TRAPD(err, addScrPresencesL(&di)); |
|
166 if (KErrNone != err) |
|
167 { |
|
168 ELOG1(EJavaCaptain, "addScrPresencesL leaved (%d)", err); |
|
169 } |
|
170 } |
|
171 break; |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 /** |
|
177 * Set the presence state of all Java applications installed |
|
178 * to the removable drive specified in aInfo to not present |
|
179 */ |
|
180 void ScrUpdater::removeScrPresencesL(driveInfo *aInfo) |
|
181 { |
|
182 __UHEAP_MARK; |
|
183 LOG1WSTR(EJavaCaptain, EInfo, |
|
184 "removeScrPresencesL: driveInfo root path is %s", aInfo->iRootPath); |
|
185 |
|
186 RSoftwareComponentRegistry *pScr = createScrL(); |
|
187 CleanupStack::PushL(pScr); |
|
188 |
|
189 // Get ids of all Java components in scr |
|
190 RArray<TComponentId> componentIdList; |
|
191 CleanupClosePushL(componentIdList); |
|
192 |
|
193 CComponentFilter *pJavaSwTypeFilter = CComponentFilter::NewLC(); |
|
194 pJavaSwTypeFilter->SetSoftwareTypeL(Usif::KSoftwareTypeJava); |
|
195 |
|
196 pScr->GetComponentIdsL(componentIdList, pJavaSwTypeFilter); |
|
197 CleanupStack::PopAndDestroy(pJavaSwTypeFilter); |
|
198 |
|
199 // For each component check whether it has been installed |
|
200 // to the removed drive |
|
201 TInt nComponents = componentIdList.Count(); |
|
202 TUint removedDrive = (TUint)(aInfo->iRootPath[0]); |
|
203 // Now removedDrive contains the drive letter, convert it to drive number 0-25 |
|
204 if ((removedDrive > 64) && (removedDrive < 91)) // codescanner::magicnumbers |
|
205 { |
|
206 // 'A' - 'Z' |
|
207 removedDrive -= 65; // codescanner::magicnumbers |
|
208 } |
|
209 else if ((removedDrive > 96) && (removedDrive < 123)) // codescanner::magicnumbers |
|
210 { |
|
211 // 'a' - 'z' |
|
212 removedDrive -= 97; // codescanner::magicnumbers |
|
213 } |
|
214 else |
|
215 { |
|
216 ELOG1WSTR(EJavaCaptain, |
|
217 "removeScrPresencesL: Unexpected root path in remove drive info %s", |
|
218 aInfo->iRootPath); |
|
219 CleanupStack::PopAndDestroy(pScr); |
|
220 return; |
|
221 } |
|
222 |
|
223 LOG2(EJavaCaptain, EInfo, "Number of Java components is %d, removed drive is %d", |
|
224 nComponents, removedDrive); |
|
225 |
|
226 RArray<TApaAppUpdateInfo> removedApps; |
|
227 CleanupClosePushL(removedApps); |
|
228 |
|
229 for (TInt nInd = 0; nInd < nComponents; nInd++) |
|
230 { |
|
231 CComponentEntry *pEntry = CComponentEntry::NewLC(); |
|
232 if (!(pScr->GetComponentL(componentIdList[nInd], *pEntry))) |
|
233 { |
|
234 ELOG1(EJavaCaptain, |
|
235 "removeScrPresencesL: SCR GetComponentIdsL returned id %d " |
|
236 "but GetComponentL does not find it", componentIdList[nInd]); |
|
237 CleanupStack::PopAndDestroy(pEntry); |
|
238 continue; |
|
239 } |
|
240 |
|
241 TInt nInstalledDrives = pEntry->InstalledDrives().Length(); |
|
242 if (nInstalledDrives <= removedDrive) |
|
243 { |
|
244 // SCR InstalledDrives should be array of 26 elements (value 0 or 1) |
|
245 ELOG2(EJavaCaptain, |
|
246 "removeScrPresencesL: The length of InstalledDrives array (%d) " |
|
247 "is smaller than removedDrive (%d)", nInstalledDrives, removedDrive); |
|
248 CleanupStack::PopAndDestroy(pEntry); |
|
249 continue; |
|
250 } |
|
251 |
|
252 LOG1(EJavaCaptain, EInfo, "Java component id %d", componentIdList[nInd]); |
|
253 |
|
254 if (pEntry->InstalledDrives()[removedDrive]) |
|
255 { |
|
256 // This component has been installed to the drive |
|
257 // that has just been removed |
|
258 pScr->SetIsComponentPresentL(componentIdList[nInd], EFalse); |
|
259 |
|
260 LOG1(EJavaCaptain, EInfo, |
|
261 "removeScrPresencesL: set component %d to not present", |
|
262 componentIdList[nInd]); |
|
263 |
|
264 // Gather the Uids of all applications that are no longer present |
|
265 RArray<TUid> appsInComponent; |
|
266 CleanupClosePushL(appsInComponent); |
|
267 pScr->GetAppUidsForComponentL( |
|
268 componentIdList[nInd], appsInComponent); |
|
269 for (TInt nInd2 = 0; nInd2 < appsInComponent.Count(); nInd2++) |
|
270 { |
|
271 TApaAppUpdateInfo appInfo; |
|
272 appInfo.iAppUid = appsInComponent[nInd2]; |
|
273 appInfo.iAction = TApaAppUpdateInfo::EAppNotPresent; |
|
274 removedApps.AppendL(appInfo); |
|
275 } |
|
276 CleanupStack::PopAndDestroy(&appsInComponent); |
|
277 } |
|
278 |
|
279 CleanupStack::PopAndDestroy(pEntry); |
|
280 } |
|
281 |
|
282 // Tell AppArc which applications are no longer present |
|
283 if (removedApps.Count() > 0) |
|
284 { |
|
285 RApaLsSession apaSession; |
|
286 TInt err = apaSession.Connect(); |
|
287 if (KErrNone != err) |
|
288 { |
|
289 ELOG1(EJavaCaptain, "removeScrPresencesL: Error %d when connecting AppArc", err); |
|
290 } |
|
291 else |
|
292 { |
|
293 CleanupClosePushL(apaSession); |
|
294 apaSession.UpdateAppListL(removedApps); |
|
295 CleanupStack::PopAndDestroy(); // closes apaSession |
|
296 } |
|
297 } |
|
298 |
|
299 CleanupStack::PopAndDestroy(); // Close removedApps |
|
300 CleanupStack::PopAndDestroy(); // Close componentIdList |
|
301 CleanupStack::PopAndDestroy(pScr); |
|
302 __UHEAP_MARKEND; |
|
303 } |
|
304 |
|
305 |
|
306 /** |
|
307 * Set the presence state of all Java applications installed |
|
308 * to the removable drive specified in aInfo to present |
|
309 */ |
|
310 void ScrUpdater::addScrPresencesL(driveInfo *aInfo) |
|
311 { |
|
312 __UHEAP_MARK; |
|
313 LOG1WSTR(EJavaCaptain, EInfo, |
|
314 "addScrPresencesL: driveInfo root path is %s", aInfo->iRootPath); |
|
315 |
|
316 RSoftwareComponentRegistry *pScr = createScrL(); |
|
317 CleanupStack::PushL(pScr); |
|
318 |
|
319 // Get ids of all Java components in scr |
|
320 RArray<TComponentId> componentIdList; |
|
321 CleanupClosePushL(componentIdList); |
|
322 |
|
323 CComponentFilter *pJavaSwTypeFilter = CComponentFilter::NewLC(); |
|
324 pJavaSwTypeFilter->SetSoftwareTypeL(Usif::KSoftwareTypeJava); |
|
325 |
|
326 pScr->GetComponentIdsL(componentIdList, pJavaSwTypeFilter); |
|
327 CleanupStack::PopAndDestroy(pJavaSwTypeFilter); |
|
328 |
|
329 // For each component check whether it has been installed |
|
330 // to the added drive AND whether the media id is correct |
|
331 // (in other words if the actual memory card where the component |
|
332 // has been installed to is added to the drive). |
|
333 TInt nComponents = componentIdList.Count(); |
|
334 TUint addedMediaId = (TUint)(aInfo->iId); |
|
335 TUint addedDrive = (TUint)(aInfo->iRootPath[0]); |
|
336 // Now addedDrive contains the drive letter, convert it to drive number 0-25 |
|
337 if ((addedDrive > 64) && (addedDrive < 91)) // codescanner::magicnumbers |
|
338 { |
|
339 // 'A' - 'Z' |
|
340 addedDrive -= 65; // codescanner::magicnumbers |
|
341 } |
|
342 else if ((addedDrive > 96) && (addedDrive < 123)) // codescanner::magicnumbers |
|
343 { |
|
344 // 'a' - 'z' |
|
345 addedDrive -= 97; // codescanner::magicnumbers |
|
346 } |
|
347 else |
|
348 { |
|
349 ELOG1WSTR(EJavaCaptain, |
|
350 "addScrPresencesL: Unexpected root path in add drive info %s", |
|
351 aInfo->iRootPath); |
|
352 CleanupStack::PopAndDestroy(pScr); |
|
353 return; |
|
354 } |
|
355 |
|
356 LOG2(EJavaCaptain, EInfo, "Number of Java components is %d, added drive is %d", |
|
357 nComponents, addedDrive); |
|
358 |
|
359 RArray<TApaAppUpdateInfo> addedApps; |
|
360 CleanupClosePushL(addedApps); |
|
361 |
|
362 for (TInt nInd = 0; nInd < nComponents; nInd++) |
|
363 { |
|
364 CComponentEntry *pEntry = CComponentEntry::NewLC(); |
|
365 if (!(pScr->GetComponentL(componentIdList[nInd], *pEntry))) |
|
366 { |
|
367 ELOG1(EJavaCaptain, |
|
368 "addScrPresencesL: SCR GetComponentIdsL returned id %d " |
|
369 "but GetComponentL does not find it", componentIdList[nInd]); |
|
370 CleanupStack::PopAndDestroy(pEntry); |
|
371 continue; |
|
372 } |
|
373 |
|
374 // When Java Installer registers Java app to SCR it stores also |
|
375 // the media id using SetComponentPropertyL(TComponentId aComponentId, |
|
376 // _L("Media-Id"), TInt64 aValue); (aValue is actually 32 bit int) |
|
377 CIntPropertyEntry* pMediaIdProperty = (CIntPropertyEntry *) |
|
378 pScr->GetComponentPropertyL(componentIdList[nInd], KMediaId); |
|
379 if (NULL == pMediaIdProperty) |
|
380 { |
|
381 ELOG1(EJavaCaptain, |
|
382 "addScrPresencesL: media_id property not found for component %d", |
|
383 componentIdList[nInd]); |
|
384 CleanupStack::PopAndDestroy(pEntry); |
|
385 continue; |
|
386 } |
|
387 CleanupStack::PushL(pMediaIdProperty); |
|
388 |
|
389 TInt nInstalledDrives = pEntry->InstalledDrives().Length(); |
|
390 if (nInstalledDrives <= addedDrive) |
|
391 { |
|
392 // SCR InstalledDrives should be array of 26 elements (value 0 or 1) |
|
393 ELOG2(EJavaCaptain, |
|
394 "addScrPresencesL: The length of InstalledDrives array (%d) " |
|
395 "is smaller than addedDrive (%d)", nInstalledDrives, addedDrive); |
|
396 CleanupStack::PopAndDestroy(pEntry); |
|
397 continue; |
|
398 } |
|
399 |
|
400 LOG1(EJavaCaptain, EInfo, "Java component id %d", componentIdList[nInd]); |
|
401 |
|
402 if (pEntry->InstalledDrives()[addedDrive]) |
|
403 { |
|
404 // This component has been installed to the drive |
|
405 // that has just been added. |
|
406 // Now check whether the media id of the added media |
|
407 // is OK for this component. |
|
408 if (addedMediaId == pMediaIdProperty->IntValue()) |
|
409 { |
|
410 pScr->SetIsComponentPresentL(componentIdList[nInd], ETrue); |
|
411 |
|
412 LOG1(EJavaCaptain, EInfo, |
|
413 "addScrPresencesL: set component %d to present", |
|
414 componentIdList[nInd]); |
|
415 |
|
416 // Gather the Uids of all 'new' applications that are now present |
|
417 RArray<TUid> appsInComponent; |
|
418 CleanupClosePushL(appsInComponent); |
|
419 pScr->GetAppUidsForComponentL( |
|
420 componentIdList[nInd], appsInComponent); |
|
421 for (TInt nInd2 = 0; nInd2 < appsInComponent.Count(); nInd2++) |
|
422 { |
|
423 TApaAppUpdateInfo appInfo; |
|
424 appInfo.iAppUid = appsInComponent[nInd2]; |
|
425 appInfo.iAction = TApaAppUpdateInfo::EAppPresent; |
|
426 addedApps.AppendL(appInfo); |
|
427 } |
|
428 CleanupStack::PopAndDestroy(&appsInComponent); |
|
429 } |
|
430 } |
|
431 |
|
432 CleanupStack::PopAndDestroy(pMediaIdProperty); |
|
433 CleanupStack::PopAndDestroy(pEntry); |
|
434 } |
|
435 |
|
436 // Tell AppArc which 'new' applications are now present |
|
437 if (addedApps.Count() > 0) |
|
438 { |
|
439 RApaLsSession apaSession; |
|
440 TInt err = apaSession.Connect(); |
|
441 if (KErrNone != err) |
|
442 { |
|
443 ELOG1(EJavaCaptain, "addScrPresencesL: Error %d when connecting AppArc", err); |
|
444 } |
|
445 else |
|
446 { |
|
447 CleanupClosePushL(apaSession); |
|
448 apaSession.UpdateAppListL(addedApps); |
|
449 CleanupStack::PopAndDestroy(); // closes apaSession |
|
450 } |
|
451 } |
|
452 |
|
453 CleanupStack::PopAndDestroy(); // Close addedApps |
|
454 CleanupStack::PopAndDestroy(); // Close componentIdList |
|
455 CleanupStack::PopAndDestroy(pScr); |
|
456 __UHEAP_MARKEND; |
|
457 } |
|
458 |
|
459 |
|
460 /** |
|
461 * Loop through all removable drives and get the media id of |
|
462 * the memory card or other removable media in the drive and update |
|
463 * presence information of all Java applications installed |
|
464 * to removable drives accordingly. |
|
465 */ |
|
466 void ScrUpdater::initializeScrPresenceInfoL() |
|
467 { |
|
468 __UHEAP_MARK; |
|
469 RFs fs; // codescanner::rfs |
|
470 User::LeaveIfError(fs.Connect()); |
|
471 CleanupClosePushL(fs); |
|
472 |
|
473 // Which drives are present and what is the media id of |
|
474 // each removable volume |
|
475 TInt err = KErrNone; |
|
476 TInt err2 = KErrNone; |
|
477 TBool drivePresent[EDriveZ + 1]; |
|
478 TUint driveMediaId[EDriveZ + 1]; |
|
479 TVolumeInfo volumeInfo; |
|
480 TDriveInfo driveInfo; |
|
481 |
|
482 for (TInt nInd = EDriveA; nInd < EDriveZ; nInd++) |
|
483 { |
|
484 err = fs.Volume(volumeInfo, nInd); |
|
485 if (KErrNone == err) |
|
486 { |
|
487 drivePresent[nInd] = ETrue; // codescanner::accessArrayElementWithoutCheck2 |
|
488 driveMediaId[nInd] = volumeInfo.iUniqueID; // codescanner::accessArrayElementWithoutCheck2 |
|
489 // If the media is not removable, media id is not checked |
|
490 err2 = fs.Drive(driveInfo, nInd); |
|
491 if (KErrNone != err2) |
|
492 { |
|
493 ELOG1(EJavaCaptain, |
|
494 "initializeScrPresenceInfoL: error (%d) when trying to get drive info", |
|
495 err2); |
|
496 User::Leave(err2); |
|
497 } |
|
498 else |
|
499 { |
|
500 if (!(driveInfo.iDriveAtt & KDriveAttRemovable)) |
|
501 { |
|
502 driveMediaId[nInd] = 0; // codescanner::accessArrayElementWithoutCheck2 |
|
503 } |
|
504 } |
|
505 } |
|
506 else if (KErrNotReady == err) |
|
507 { |
|
508 // no volume in this drive |
|
509 drivePresent[nInd] = EFalse; // codescanner::accessArrayElementWithoutCheck2 |
|
510 driveMediaId[nInd] = 0; // codescanner::accessArrayElementWithoutCheck2 |
|
511 } |
|
512 else |
|
513 { |
|
514 ELOG1(EJavaCaptain, |
|
515 "initializeScrPresenceInfoL: error (%d) when trying to get volume info", |
|
516 err); |
|
517 User::Leave(err); |
|
518 } |
|
519 } |
|
520 CleanupStack::PopAndDestroy(); // close RFs |
|
521 |
|
522 |
|
523 RSoftwareComponentRegistry *pScr = createScrL(); |
|
524 CleanupStack::PushL(pScr); |
|
525 |
|
526 // Get ids of all Java components in scr |
|
527 RArray<TComponentId> componentIdList; |
|
528 CComponentFilter *pJavaSwTypeFilter = CComponentFilter::NewLC(); |
|
529 pJavaSwTypeFilter->SetSoftwareTypeL(Usif::KSoftwareTypeJava); |
|
530 |
|
531 pScr->GetComponentIdsL(componentIdList, pJavaSwTypeFilter); |
|
532 CleanupStack::PopAndDestroy(pJavaSwTypeFilter); |
|
533 CleanupClosePushL(componentIdList); |
|
534 |
|
535 // For each component check whether the drive it has been installed |
|
536 // to is present AND whether the media id is correct |
|
537 TInt nComponents = componentIdList.Count(); |
|
538 |
|
539 LOG1(EJavaCaptain, EInfo, "initializeScrPresenceInfoL: Number of Java components is %d", |
|
540 nComponents); |
|
541 |
|
542 for (TInt nInd = 0; nInd < nComponents; nInd++) |
|
543 { |
|
544 CComponentEntry *pEntry = CComponentEntry::NewLC(); |
|
545 if (!(pScr->GetComponentL(componentIdList[nInd], *pEntry))) |
|
546 { |
|
547 ELOG1(EJavaCaptain, |
|
548 "initializeScrPresenceInfoL: SCR GetComponentIdsL returned id %d " |
|
549 "but GetComponentL does not find it", componentIdList[nInd]); |
|
550 CleanupStack::PopAndDestroy(pEntry); |
|
551 continue; |
|
552 } |
|
553 |
|
554 CIntPropertyEntry* pMediaIdProperty = (CIntPropertyEntry *) |
|
555 pScr->GetComponentPropertyL(componentIdList[nInd], KMediaId); |
|
556 if (NULL == pMediaIdProperty) |
|
557 { |
|
558 ELOG1(EJavaCaptain, |
|
559 "initializeScrPresenceInfoL: media_id property not found for component %d", |
|
560 componentIdList[nInd]); |
|
561 CleanupStack::PopAndDestroy(pEntry); |
|
562 continue; |
|
563 } |
|
564 CleanupStack::PushL(pMediaIdProperty); |
|
565 |
|
566 TInt nInstalledDrives = pEntry->InstalledDrives().Length(); |
|
567 if (nInstalledDrives > (EDriveZ + 1)) |
|
568 { |
|
569 WLOG2(EJavaCaptain, |
|
570 "initializeScrPresenceInfoL: too big (%d) installed drives array for " |
|
571 "component %d", nInstalledDrives, componentIdList[nInd]); |
|
572 nInstalledDrives = EDriveZ; |
|
573 } |
|
574 // When Java components are installed, only one installed drive |
|
575 // and corresponding media id are registered. |
|
576 TInt installationDrive = -1; |
|
577 |
|
578 for (TInt driveNumber = EDriveA; driveNumber < nInstalledDrives; driveNumber++) |
|
579 { |
|
580 if (pEntry->InstalledDrives()[driveNumber]) |
|
581 { |
|
582 installationDrive = driveNumber; |
|
583 break; |
|
584 } |
|
585 } |
|
586 |
|
587 if (installationDrive == -1) |
|
588 { |
|
589 ELOG1(EJavaCaptain, |
|
590 "initializeScrPresenceInfoL: component (id %d) did not have installed drive info", |
|
591 componentIdList[nInd]); |
|
592 CleanupStack::PopAndDestroy(pMediaIdProperty); |
|
593 CleanupStack::PopAndDestroy(pEntry); |
|
594 continue; |
|
595 } |
|
596 |
|
597 if (drivePresent[installationDrive]) // codescanner::accessArrayElementWithoutCheck2 |
|
598 { |
|
599 // Check also the media id |
|
600 if (driveMediaId[installationDrive] == pMediaIdProperty->IntValue()) // codescanner::accessArrayElementWithoutCheck2 |
|
601 { |
|
602 LOG1(EJavaCaptain, EInfo, |
|
603 "initializeScrPresenceInfoL: set component %d to present", |
|
604 componentIdList[nInd]); |
|
605 |
|
606 pScr->SetIsComponentPresentL(componentIdList[nInd], ETrue); |
|
607 } |
|
608 else |
|
609 { |
|
610 LOG1(EJavaCaptain, EInfo, |
|
611 "initializeScrPresenceInfoL: set component %d to NOT present", |
|
612 componentIdList[nInd]); |
|
613 |
|
614 pScr->SetIsComponentPresentL(componentIdList[nInd], EFalse); |
|
615 } |
|
616 } |
|
617 else |
|
618 { |
|
619 LOG1(EJavaCaptain, EInfo, |
|
620 "initializeScrPresenceInfoL: set component %d to NOT present", |
|
621 componentIdList[nInd]); |
|
622 |
|
623 // drive is not present -> Java component installed to that |
|
624 // drive is not present |
|
625 pScr->SetIsComponentPresentL(componentIdList[nInd], EFalse); |
|
626 } |
|
627 |
|
628 CleanupStack::PopAndDestroy(pMediaIdProperty); |
|
629 CleanupStack::PopAndDestroy(pEntry); |
|
630 } |
|
631 |
|
632 CleanupStack::PopAndDestroy(); // Close componentIdList |
|
633 CleanupStack::PopAndDestroy(pScr); // Also closes RSoftwareComponentRegistry |
|
634 |
|
635 __UHEAP_MARKEND; |
|
636 } |
|
637 |
|
638 |
|
639 /** |
|
640 * Creates an instance of RSoftwareComponentRegistry and connects to it. |
|
641 */ |
|
642 RSoftwareComponentRegistry *ScrUpdater::createScrL() |
|
643 { |
|
644 RSoftwareComponentRegistry *pScr = new RSoftwareComponentRegistry; // codescanner::nonleavenew |
|
645 if (NULL == pScr) |
|
646 { |
|
647 ELOG(EJavaInstaller, |
|
648 "CreateScrL: Creating RSoftwareComponentRegistry failed"); |
|
649 User::Leave(KErrGeneral); |
|
650 } |
|
651 TInt err = pScr->Connect(); |
|
652 if (KErrNone != err) |
|
653 { |
|
654 ELOG1(EJavaInstaller, |
|
655 "CreateScrL: Connecting to RSoftwareComponentRegistry failed, error %d", |
|
656 err); |
|
657 delete pScr; |
|
658 User::Leave(err); |
|
659 } |
|
660 |
|
661 return pScr; |
|
662 } |
|
663 |
|
664 |
|
665 } // namespace captain |
|
666 } // namespace java |