1 /* |
|
2 * Copyright (c) 2006-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: SConPcdUtility implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include <swi/sisregistryentry.h> |
|
21 #include <swi/sisregistrysession.h> |
|
22 #include <swi/sisregistrypackage.h> |
|
23 #include <stringresourcereader.h> |
|
24 // #include <WidgetRegistryClient.h> |
|
25 #include <javaregistryincludes.h> |
|
26 #include <appversion.h> |
|
27 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
28 #include <sconftp.rsg> // Resource to be read header |
|
29 |
|
30 using namespace Java; |
|
31 |
|
32 #include "debug.h" |
|
33 #include "sconpcdutility.h" |
|
34 #include "sconconmltask.h" |
|
35 |
|
36 // localized "unknown vendor". |
|
37 _LIT( KSConResourceName, "z:\\Resource\\sconftp.rsc" ); |
|
38 |
|
39 |
|
40 |
|
41 // METHODS |
|
42 //---------------------------------------------------------------------------- |
|
43 // void SConPcdUtility::ProcessListInstalledAppsL( CSConTask*& aTask ) |
|
44 //---------------------------------------------------------------------------- |
|
45 // |
|
46 void SConPcdUtility::ProcessListInstalledAppsL( CSConTask*& aTask ) |
|
47 { |
|
48 TRACE_FUNC_ENTRY; |
|
49 |
|
50 LOGGER_WRITE_1("iAllApps: %d",(TInt)aTask->iListAppsParams->iAllApps); |
|
51 LOGGER_WRITE8_1("driveList: %S", &aTask->iListAppsParams->iDriveList); |
|
52 |
|
53 AppendInstalledSisL( *aTask->iListAppsParams ); |
|
54 AppendInstalledJavaL( *aTask->iListAppsParams ); |
|
55 AppendInstalledWidgetsL( *aTask->iListAppsParams ); |
|
56 |
|
57 TRACE_FUNC_EXIT; |
|
58 } |
|
59 |
|
60 //---------------------------------------------------------------------------- |
|
61 // void SConPcdUtility::AppendInstalledSisL( RPointerArray<CSConInstApp> &aApps ) |
|
62 // Appends installed sis packages and augmentations to aApps array. |
|
63 //---------------------------------------------------------------------------- |
|
64 // |
|
65 void SConPcdUtility::AppendInstalledSisL( CSConListInstApps& aListInstApps ) |
|
66 { |
|
67 TRACE_FUNC_ENTRY; |
|
68 // Get installed applications from sis registry |
|
69 Swi::RSisRegistrySession sisRegistry; |
|
70 CleanupClosePushL( sisRegistry ); |
|
71 User::LeaveIfError( sisRegistry.Connect() ); |
|
72 |
|
73 RArray<TUid> uids; |
|
74 CleanupClosePushL(uids); |
|
75 sisRegistry.InstalledUidsL( uids ); |
|
76 |
|
77 |
|
78 //Read package information |
|
79 for( TInt i = 0; i < uids.Count(); i++ ) |
|
80 { |
|
81 Swi::RSisRegistryEntry entry; |
|
82 CleanupClosePushL(entry); |
|
83 User::LeaveIfError( entry.Open( sisRegistry, uids[i] ) ); |
|
84 |
|
85 TBool showIt( EFalse ); |
|
86 if ( aListInstApps.iAllApps ) |
|
87 { |
|
88 // show all apps -param defined, exlude stubs on ROM |
|
89 if ( !entry.IsInRomL() ) |
|
90 { |
|
91 showIt = ETrue; |
|
92 } |
|
93 } |
|
94 else |
|
95 { |
|
96 // show if installed one of the specified drives |
|
97 // don't exlude stubs on ROM |
|
98 showIt = IsInstalledToSelectedDrive( aListInstApps.iDriveList, |
|
99 entry.InstalledDrivesL() ); |
|
100 } |
|
101 |
|
102 // Only show if not in rom |
|
103 if ( showIt && entry.IsPresentL() ) |
|
104 { |
|
105 // Add the created object to the list |
|
106 LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : add pkg, index %d", i ); |
|
107 CSConInstApp* app = new (ELeave) CSConInstApp(); |
|
108 CleanupStack::PushL( app ); |
|
109 |
|
110 HBufC* temp = entry.PackageNameL(); |
|
111 TPtrC tempPtr = temp->Des(); |
|
112 LOGGER_WRITE_1("PackageNameL: %S", &tempPtr); |
|
113 CleanupStack::PushL( temp ); |
|
114 if ( temp->Length() > app->iName.MaxLength() ) |
|
115 { |
|
116 User::Leave( KErrTooBig ); |
|
117 } |
|
118 app->iName.Copy( *temp ); |
|
119 CleanupStack::PopAndDestroy( temp ); |
|
120 temp = NULL; |
|
121 |
|
122 temp = entry.UniqueVendorNameL(); |
|
123 CleanupStack::PushL( temp ); |
|
124 if ( temp->Length() > app->iVendor.MaxLength() ) |
|
125 { |
|
126 User::Leave( KErrTooBig ); |
|
127 } |
|
128 app->iVendor.Copy( *temp ); |
|
129 CleanupStack::PopAndDestroy( temp ); |
|
130 temp = NULL; |
|
131 |
|
132 app->iVersion.Copy( entry.VersionL().Name() ); |
|
133 app->iType = ESisApplication; |
|
134 app->iSize = entry.SizeL(); |
|
135 app->iUid = entry.UidL(); |
|
136 |
|
137 User::LeaveIfError( aListInstApps.iApps.Append( app ) ); |
|
138 CleanupStack::Pop( app ); |
|
139 } |
|
140 |
|
141 // Get possible augmentations |
|
142 RPointerArray<Swi::CSisRegistryPackage> augPackages; |
|
143 CleanupResetAndDestroyPushL( augPackages ); |
|
144 entry.AugmentationsL( augPackages ); |
|
145 for ( TInt j( 0 ); j < augPackages.Count(); j++ ) |
|
146 { |
|
147 Swi::RSisRegistryEntry augmentationEntry; |
|
148 CleanupClosePushL( augmentationEntry ); |
|
149 augmentationEntry.OpenL( sisRegistry, *augPackages[j] ); |
|
150 |
|
151 TBool showIt( EFalse ); |
|
152 if ( aListInstApps.iAllApps ) |
|
153 { |
|
154 // show all apps -param defined, exlude stubs on ROM |
|
155 if ( !augmentationEntry.IsInRomL() ) |
|
156 { |
|
157 showIt = ETrue; |
|
158 } |
|
159 } |
|
160 else |
|
161 { |
|
162 // show if installed one of the specified drives |
|
163 // don't exlude stubs on ROM |
|
164 showIt = IsInstalledToSelectedDrive( aListInstApps.iDriveList, |
|
165 augmentationEntry.InstalledDrivesL() ); |
|
166 } |
|
167 |
|
168 // Only show if not in rom |
|
169 if ( showIt && augmentationEntry.IsPresentL() ) |
|
170 { |
|
171 CSConInstApp* augApp = new (ELeave) CSConInstApp(); |
|
172 CleanupStack::PushL( augApp ); |
|
173 augApp->iName.Copy( augPackages[j]->Name() ); |
|
174 |
|
175 HBufC* temp = entry.PackageNameL(); |
|
176 CleanupStack::PushL( temp ); |
|
177 if ( temp->Length() > augApp->iParentName.MaxLength() ) |
|
178 { |
|
179 User::Leave( KErrTooBig ); |
|
180 } |
|
181 augApp->iParentName.Copy( *temp ); |
|
182 CleanupStack::PopAndDestroy( temp ); |
|
183 temp = NULL; |
|
184 |
|
185 augApp->iVendor.Copy( augPackages[j]->Vendor() ); |
|
186 augApp->iVersion.Copy( augmentationEntry.VersionL().Name() ); |
|
187 augApp->iType = ESisAugmentation; |
|
188 augApp->iSize = augmentationEntry.SizeL(); |
|
189 augApp->iUid = augmentationEntry.UidL(); |
|
190 |
|
191 LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : add augmentation, index: %d", j ); |
|
192 LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : add augmentation, basepkg: %d", i ); |
|
193 TInt augindex = augPackages[j]->Index(); |
|
194 LOGGER_WRITE_1( "SConPcdUtility::ProcessListInstalledAppsL : augindex: %d",augindex ); |
|
195 User::LeaveIfError( aListInstApps.iApps.Append( augApp ) ); |
|
196 CleanupStack::Pop( augApp ); |
|
197 } |
|
198 CleanupStack::PopAndDestroy( &augmentationEntry ); |
|
199 } |
|
200 CleanupStack::PopAndDestroy( &augPackages ); |
|
201 CleanupStack::PopAndDestroy( &entry ); |
|
202 } |
|
203 |
|
204 CleanupStack::PopAndDestroy(&uids); |
|
205 CleanupStack::PopAndDestroy(&sisRegistry); |
|
206 TRACE_FUNC_EXIT; |
|
207 } |
|
208 |
|
209 //---------------------------------------------------------------------------- |
|
210 // void SConPcdUtility::AppendInstalledJavaL( RPointerArray<CSConInstApp> &aApps ) |
|
211 // Appends installed java packages to aApps array. |
|
212 //---------------------------------------------------------------------------- |
|
213 // |
|
214 void SConPcdUtility::AppendInstalledJavaL( CSConListInstApps& aListInstApps ) |
|
215 { |
|
216 TRACE_FUNC_ENTRY; |
|
217 CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( ); |
|
218 RArray<TUid> packageUids; |
|
219 CleanupClosePushL( packageUids ); |
|
220 javaRegistry->GetRegistryEntryUidsL( packageUids ); |
|
221 LOGGER_WRITE_1("packageUids.Count(): %d", packageUids.Count()); |
|
222 for (TInt i=0; i<packageUids.Count(); i++ ) |
|
223 { |
|
224 LOGGER_WRITE_1("RegistryEntryL: %d",i); |
|
225 LOGGER_WRITE_1("handle entry uid: 0x%08X",packageUids[i].iUid); |
|
226 CJavaRegistryEntry* entry = javaRegistry->RegistryEntryL( packageUids[i] ); |
|
227 if ( entry ) |
|
228 { |
|
229 CleanupStack::PushL( entry ); |
|
230 if ( entry->Type() >= EGeneralPackage && entry->Type() < EGeneralApplication ) |
|
231 { |
|
232 // entry was correct type |
|
233 CJavaRegistryPackageEntry* packageEntry = ( CJavaRegistryPackageEntry* ) entry; |
|
234 |
|
235 // check do we need to filter it out |
|
236 TBool showIt( EFalse ); |
|
237 if ( aListInstApps.iAllApps ) |
|
238 { |
|
239 showIt = ETrue; |
|
240 } |
|
241 else |
|
242 { |
|
243 TDriveNumber drive = packageEntry->Drive(); |
|
244 if ( aListInstApps.iDriveList.Length() > drive |
|
245 && aListInstApps.iDriveList[ drive ] ) |
|
246 { |
|
247 showIt = ETrue; |
|
248 } |
|
249 } |
|
250 |
|
251 if ( showIt ) |
|
252 { |
|
253 CSConInstApp* app = new (ELeave) CSConInstApp(); |
|
254 CleanupStack::PushL( app ); |
|
255 // Get Uid, name, type, vendor |
|
256 app->iUid = packageEntry->Uid(); |
|
257 app->iName.Copy ( packageEntry->Name() ); |
|
258 LOGGER_WRITE_1( "Name: %S", &app->iName ); |
|
259 app->iType = EJavaApplication; |
|
260 |
|
261 // Get version |
|
262 TAppVersion midletVersion( packageEntry->Version() ); |
|
263 TVersion verType(midletVersion.iMajor, midletVersion.iMinor, midletVersion.iBuild); |
|
264 app->iVersion.Copy( verType.Name() ); |
|
265 |
|
266 // Get vendor |
|
267 if ( entry->NumberOfCertificateChains() > 0 && packageEntry->Vendor().Length() > 0 ) |
|
268 { |
|
269 app->iVendor.Copy( packageEntry->Vendor() ); |
|
270 } |
|
271 else |
|
272 { |
|
273 // untrusted applications do not have certificates. |
|
274 // if the application has a certificate, it is installed either as |
|
275 // trusted or not installed at all. |
|
276 |
|
277 // unknown vendor |
|
278 TFileName myFileName( KSConResourceName ); |
|
279 CStringResourceReader* resReader = CStringResourceReader::NewL( myFileName ); |
|
280 TPtrC bufUnknownSuplier; |
|
281 bufUnknownSuplier.Set( resReader->ReadResourceString( R_SECON_UNKNOWN_SUPPLIER ) ); |
|
282 |
|
283 app->iVendor.Copy( bufUnknownSuplier ); |
|
284 |
|
285 delete resReader; |
|
286 } |
|
287 |
|
288 // Get size |
|
289 app->iSize = packageEntry->UsedUserDiskSpace(); |
|
290 |
|
291 User::LeaveIfError( aListInstApps.iApps.Append( app ) ); |
|
292 CleanupStack::Pop( app ); |
|
293 } |
|
294 } |
|
295 CleanupStack::PopAndDestroy( entry ); |
|
296 } |
|
297 } |
|
298 |
|
299 CleanupStack::PopAndDestroy( &packageUids ); |
|
300 CleanupStack::PopAndDestroy( javaRegistry ); |
|
301 TRACE_FUNC_EXIT; |
|
302 } |
|
303 |
|
304 //---------------------------------------------------------------------------- |
|
305 // void SConPcdUtility::AppendInstalledWidgetsL( RPointerArray<CSConInstApp> &aApps ) |
|
306 // Appends installed widgets to aApps array. |
|
307 //---------------------------------------------------------------------------- |
|
308 // |
|
309 void SConPcdUtility::AppendInstalledWidgetsL( CSConListInstApps& aListInstApps ) |
|
310 { |
|
311 // Commented out as WidgetRegistry will be removed from MCL. |
|
312 // TODO: Check how Widgets should be listed on future. |
|
313 /* |
|
314 TRACE_FUNC_ENTRY; |
|
315 RWidgetRegistryClientSession widgetSession; |
|
316 CleanupClosePushL( widgetSession ); |
|
317 User::LeaveIfError( widgetSession.Connect() ); |
|
318 |
|
319 // Get the list of installed widgets |
|
320 RWidgetInfoArray widgetInfoArr; |
|
321 CleanupClosePushL( widgetInfoArr ); |
|
322 widgetSession.InstalledWidgetsL( widgetInfoArr ); |
|
323 TFileName bundleId; |
|
324 for ( TInt i = 0; i < widgetInfoArr.Count(); i++ ) |
|
325 { |
|
326 CWidgetInfo *item = widgetInfoArr[i]; |
|
327 CleanupStack::PushL( item ); |
|
328 |
|
329 |
|
330 TBool showIt( EFalse ); |
|
331 if ( aListInstApps.iAllApps ) |
|
332 { |
|
333 // show all apps -param defined |
|
334 showIt = ETrue; |
|
335 } |
|
336 else |
|
337 { |
|
338 TDriveUnit locationDrive = item->iDriveName->Des(); |
|
339 // show if installed one of the specified drives |
|
340 if ( aListInstApps.iDriveList.Length() > locationDrive |
|
341 && aListInstApps.iDriveList[locationDrive] ) |
|
342 { |
|
343 showIt = ETrue; |
|
344 } |
|
345 } |
|
346 |
|
347 if ( showIt ) |
|
348 { |
|
349 |
|
350 CSConInstApp* app = new (ELeave) CSConInstApp(); |
|
351 CleanupStack::PushL( app ); |
|
352 app->iName.Copy( *(item->iBundleName) ); |
|
353 app->iType = EWidgetApplication; |
|
354 app->iSize = item->iFileSize; |
|
355 app->iUid = item->iUid; |
|
356 |
|
357 CWidgetPropertyValue* propValue = widgetSession.GetWidgetPropertyValueL( |
|
358 item->iUid, EBundleVersion ); |
|
359 if ( propValue && propValue->iType == EWidgetPropTypeString ) |
|
360 { |
|
361 app->iVersion.Copy( *(propValue->iValue.s) ); |
|
362 } |
|
363 delete propValue; |
|
364 propValue = NULL; |
|
365 bundleId.Zero(); |
|
366 widgetSession.GetWidgetBundleId( item->iUid, bundleId ); |
|
367 app->iWidgetBundleId = bundleId.AllocL(); |
|
368 |
|
369 User::LeaveIfError( aListInstApps.iApps.Append( app ) ); |
|
370 CleanupStack::Pop( app ); // ownership transferred, do not delete |
|
371 } |
|
372 CleanupStack::PopAndDestroy( item ); |
|
373 } |
|
374 User::LeaveIfError( widgetSession.Disconnect() ); |
|
375 |
|
376 CleanupStack::PopAndDestroy( &widgetInfoArr ); |
|
377 CleanupStack::PopAndDestroy( &widgetSession ); |
|
378 TRACE_FUNC_EXIT; |
|
379 */ |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------- |
|
383 // SConPcdUtility::IsInstalledToSelectedDrive |
|
384 // Solve highest drive from aInstalledDrives and check |
|
385 // if that drive is selected |
|
386 // --------------------------------------------------------- |
|
387 // |
|
388 TBool SConPcdUtility::IsInstalledToSelectedDrive( const TDriveList& aSelectedDriveList, TUint aInstalledDrives ) |
|
389 { |
|
390 TInt locationDrive; |
|
391 if( aInstalledDrives ) |
|
392 { |
|
393 // Select the highest drive as location drive |
|
394 TInt drive = EDriveA; |
|
395 while( aInstalledDrives >>= 1 ) |
|
396 { |
|
397 drive++; |
|
398 } |
|
399 locationDrive = drive; |
|
400 } |
|
401 else |
|
402 { |
|
403 // No installed files, select C: as location drive |
|
404 locationDrive = EDriveC; |
|
405 } |
|
406 |
|
407 if ( aSelectedDriveList.Length() > locationDrive && aSelectedDriveList[locationDrive] ) |
|
408 { |
|
409 LOGGER_WRITE("SConPcdUtility::IsInstalledToSelectedDrive : return ETrue"); |
|
410 return ETrue; |
|
411 } |
|
412 else |
|
413 { |
|
414 LOGGER_WRITE("SConPcdUtility::IsInstalledToSelectedDrive : return EFalse"); |
|
415 return EFalse; |
|
416 } |
|
417 } |
|
418 // END OF FILE |
|