125 TUidType CApaAppInfoReader::AppBinaryUidType() const |
111 TUidType CApaAppInfoReader::AppBinaryUidType() const |
126 { |
112 { |
127 return iAppBinaryUidType; |
113 return iAppBinaryUidType; |
128 } |
114 } |
129 |
115 |
|
116 void CApaAppInfoReader::Capability(TDes8& aCapabilityBuf) const |
|
117 { |
|
118 TApaAppCapabilityBuf buf(iCapability); |
|
119 TApaAppCapability::CopyCapability(aCapabilityBuf, buf); |
|
120 } |
|
121 |
|
122 TUint CApaAppInfoReader::DefaultScreenNumber() const |
|
123 { |
|
124 return iDefaultScreenNumber; |
|
125 } |
|
126 |
|
127 HBufC* CApaAppInfoReader::Caption() |
|
128 { |
|
129 HBufC* caption = iCaption; |
|
130 iCaption = NULL; // ownership transferred to caller |
|
131 return caption; |
|
132 } |
|
133 |
|
134 HBufC* CApaAppInfoReader::ShortCaption() |
|
135 { |
|
136 HBufC* shortCaption = iShortCaption; |
|
137 iShortCaption = NULL; // ownership transferred to caller |
|
138 return shortCaption; |
|
139 } |
|
140 |
|
141 CApaAppIconArray* CApaAppInfoReader::Icons() |
|
142 { |
|
143 CApaAppIconArray* icons = iIcons; |
|
144 iIcons = NULL; // ownership transferred to caller |
|
145 return icons; |
|
146 } |
|
147 |
|
148 TInt CApaAppInfoReader::NumOfAppIcons() const |
|
149 { |
|
150 return iNumOfAppIcons; |
|
151 } |
|
152 |
|
153 CArrayPtrFlat<CApaAppViewData>* CApaAppInfoReader::Views() |
|
154 { |
|
155 CArrayPtrFlat<CApaAppViewData>* viewDataArray = iViewDataArray; |
|
156 iViewDataArray = NULL; // ownership transferred to caller |
|
157 return viewDataArray; |
|
158 } |
|
159 |
|
160 CDesCArray* CApaAppInfoReader::OwnedFiles() |
|
161 { |
|
162 CDesCArray* ownedFileArray = iOwnedFileArray; |
|
163 iOwnedFileArray = NULL; // ownership transferred to caller |
|
164 return ownedFileArray; |
|
165 } |
|
166 |
|
167 HBufC* CApaAppInfoReader::IconFileName() |
|
168 { |
|
169 HBufC* iconFileName = iIconFileName; |
|
170 iIconFileName = NULL; // ownership transferred to caller |
|
171 return iconFileName; |
|
172 } |
|
173 |
|
174 TBool CApaAppInfoReader::NonMbmIconFile() const |
|
175 { |
|
176 return iNonMbmIconFile; |
|
177 } |
|
178 |
|
179 |
|
180 TLanguage CApaAppInfoReader::AppLanguage() const |
|
181 { |
|
182 return iApplicationLanguage; |
|
183 } |
|
184 |
|
185 CArrayFixFlat<TApaAppServiceInfo>* CApaAppInfoReader::ServiceArray(TInt& aIndexOfFirstOpenService) |
|
186 { |
|
187 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = iServiceArray; |
|
188 iServiceArray = NULL; |
|
189 aIndexOfFirstOpenService = iIndexOfFirstOpenService; |
|
190 return serviceArray; |
|
191 } |
|
192 |
|
193 HBufC8* CApaAppInfoReader::OpaqueData() |
|
194 { |
|
195 HBufC8* opaqueData = iOpaqueData; |
|
196 iOpaqueData = NULL; |
|
197 return opaqueData; |
|
198 } |
|
199 |
|
200 CApaIconLoader* CApaAppInfoReader::IconLoader() |
|
201 { |
|
202 CApaIconLoader* iconLoader = iIconLoader; |
|
203 iIconLoader = NULL; // ownership transferred to caller |
|
204 return iconLoader; |
|
205 } |
|
206 |
|
207 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
208 |
|
209 CApaAppInfoReader::CApaAppInfoReader(RFs& aFs, const Usif::CApplicationRegistrationData& aAppInfo, const Usif::RSoftwareComponentRegistry& aScr) : |
|
210 iFs(aFs), |
|
211 iDefaultScreenNumber(0), |
|
212 iNonMbmIconFile(EFalse), |
|
213 iApplicationLanguage(ELangNone), |
|
214 iIndexOfFirstOpenService(KErrNotFound), |
|
215 iAppInfo(aAppInfo), |
|
216 iScr(aScr) |
|
217 { |
|
218 } |
|
219 |
|
220 CApaAppInfoReader* CApaAppInfoReader::NewL(RFs& aFs, const Usif::CApplicationRegistrationData& aAppInfo, const Usif::RSoftwareComponentRegistry& aScr) |
|
221 { |
|
222 CApaAppInfoReader* self = new(ELeave) CApaAppInfoReader(aFs, aAppInfo, aScr); |
|
223 CleanupStack::PushL(self); |
|
224 self->ConstructL(); |
|
225 CleanupStack::Pop(self); |
|
226 return self; |
|
227 } |
|
228 |
|
229 /* |
|
230 * Reads the application information from SCR. |
|
231 */ |
|
232 TBool CApaAppInfoReader::ReadL() |
|
233 { |
|
234 ReadAppRegistrationInfoL(); |
|
235 ReadLocalisationInfoL(); |
|
236 #ifdef _DEBUG |
|
237 DisplayAppInfo(); |
|
238 #endif |
|
239 return ETrue; |
|
240 } |
|
241 |
|
242 #ifdef _DEBUG |
|
243 void CApaAppInfoReader::DisplayAppInfo() |
|
244 { |
|
245 RDebug::Print(_L("[Apparc] Application UID: %X"), iAppUid.iUid); |
|
246 if(iAppBinaryFullName) |
|
247 RDebug::Print(_L("[Apparc] AppBinary Name: %S"), iAppBinaryFullName); |
|
248 |
|
249 RDebug::Print(_L("[Apparc] Embeddability: %d"), iCapability.iEmbeddability); |
|
250 RDebug::Print(_L("[Apparc] Hidden: %d"), iCapability.iAppIsHidden); |
|
251 RDebug::Print(_L("[Apparc] NewFile: %d"), iCapability.iSupportsNewFile); |
|
252 RDebug::Print(_L("[Apparc] Launch in Foreground: %d"), iCapability.iLaunchInBackground); |
|
253 RDebug::Print(_L("[Apparc] Attributes: %X"), iCapability.iAttributes); |
|
254 RDebug::Print(_L("[Apparc] Group Name: %S"), &iCapability.iGroupName); |
|
255 |
|
256 RDebug::Print(_L("[Apparc] Default Screen Number: %d"), iDefaultScreenNumber); |
|
257 RDebug::Print(_L("[Apparc] Application Language: %d"), iApplicationLanguage); |
|
258 |
|
259 if(iCaption) |
|
260 RDebug::Print(_L("[Apparc] Short Cpation: %S"), iCaption); |
|
261 |
|
262 if(iShortCaption) |
|
263 RDebug::Print(_L("[Apparc] Caption: %S"), iShortCaption); |
|
264 |
|
265 if(iServiceArray) |
|
266 { |
|
267 for(TInt index=0;index<iServiceArray->Count();index++) |
|
268 { |
|
269 TApaAppServiceInfo serviceInfo=(*iServiceArray)[index]; |
|
270 RDebug::Print(_L("[Apparc] Service Uid: %X"), serviceInfo.Uid().iUid); |
|
271 |
|
272 for(TInt j=0;j<serviceInfo.DataTypes().Count();j++) |
|
273 { |
|
274 TDataTypeWithPriority dataType=(serviceInfo.DataTypes())[j]; |
|
275 RDebug::Print(_L("[Apparc] Data Type: %s Priority:%d"), &dataType.iDataType, dataType.iPriority); |
|
276 } |
|
277 |
|
278 } |
|
279 } |
|
280 |
|
281 if(iIconFileName) |
|
282 { |
|
283 RDebug::Print(_L("[Apparc] Icon File: %S"), iIconFileName); |
|
284 |
|
285 if(iNonMbmIconFile) |
|
286 RDebug::Print(_L("[Apparc] Its Non MBM icon file")); |
|
287 RDebug::Print(_L("[Apparc] Num Icons: %d"), iNumOfAppIcons); |
|
288 } |
|
289 |
|
290 if(iViewDataArray) |
|
291 { |
|
292 for(TInt index=0; index<iViewDataArray->Count();index++) |
|
293 { |
|
294 CApaAppViewData* view= (*iViewDataArray)[index]; |
|
295 RDebug::Print(_L("[Apparc] ViewID: %X"), view->Uid().iUid); |
|
296 //RDebug::Print(_L("[Apparc] View Caption: %s"), view->Caption()); |
|
297 //RDebug::Print(_L("[Apparc] View Icon File: %s"), view->IconFileName()); |
|
298 if(view->NonMbmIconFile()) |
|
299 RDebug::Print(_L("[Apparc] Its Non MBM icon file")); |
|
300 RDebug::Print(_L("[Apparc] Screen Mode: %d"), view->ScreenMode()); |
|
301 } |
|
302 } |
|
303 } |
|
304 |
|
305 #endif |
|
306 |
|
307 |
|
308 void CApaAppInfoReader::ReadAppRegistrationInfoL() |
|
309 { |
|
310 //Get 3rd UID of the application |
|
311 iAppUid=iAppInfo.AppUid(); |
|
312 |
|
313 iCapability.iAttributes=iAppInfo.Attributes(); |
|
314 TUid firstUid(KExecutableImageUid); |
|
315 TUid middleUid(KUidApp); |
|
316 |
|
317 //If the application is non-native, first UID should be Null UID and second uid is the non-native application type(i.e type ID of java, widget etc.). |
|
318 if (iCapability.iAttributes & TApaAppCapability::ENonNative) |
|
319 { |
|
320 firstUid=KNullUid; |
|
321 middleUid.iUid=iAppInfo.TypeId(); |
|
322 } |
|
323 else if (iCapability.iAttributes & TApaAppCapability::EBuiltAsDll) |
|
324 { |
|
325 User::Leave(KErrNotSupported); // legacy dll-style app |
|
326 } |
|
327 |
|
328 iAppBinaryUidType=TUidType(firstUid, middleUid, iAppUid); |
|
329 |
|
330 //If executable file name is not given then just leave. |
|
331 if(iAppInfo.AppFile().Length() ==0 ) |
|
332 User::Leave(KErrGeneral); |
|
333 |
|
334 //Absolute path of the executable file is stored in iAppBinaryFullName |
|
335 iAppBinaryFullName=iAppInfo.AppFile().AllocL(); |
|
336 |
|
337 // //Check whether the binary exists. |
|
338 /*RLibrary::TInfoBuf infoBuf; |
|
339 TInt ret = RLibrary::GetInfo(*iAppBinaryFullName, infoBuf); |
|
340 User::LeaveIfError(ret); |
|
341 |
|
342 if(infoBuf().iUids[2]!=iAppUid && iAppBinaryUidType[1]==KUidApp) |
|
343 User::Leave(KErrNotFound);*/ |
|
344 |
|
345 iCapability.iAppIsHidden=iAppInfo.Hidden(); |
|
346 iCapability.iEmbeddability = static_cast<TApaAppCapability::TEmbeddability>(iAppInfo.Embeddability()); |
|
347 iCapability.iLaunchInBackground=iAppInfo.Launch(); |
|
348 iCapability.iSupportsNewFile=iAppInfo.NewFile(); |
|
349 |
|
350 iDefaultScreenNumber=iAppInfo.DefaultScreenNumber(); |
|
351 |
|
352 iCapability.iGroupName=iAppInfo.GroupName(); |
|
353 |
|
354 RPointerArray<Usif::COpaqueData> appOpaqueData=iAppInfo.AppOpaqueData(); |
|
355 ASSERT(!(appOpaqueData.Count()>1)); |
|
356 |
|
357 if(appOpaqueData.Count()>0) |
|
358 { |
|
359 iOpaqueData=appOpaqueData[0]->OpaqueData().AllocL(); |
|
360 } |
|
361 else |
|
362 { |
|
363 //If opaque data is not available, create an empty object and assign to iOpaqueData |
|
364 iOpaqueData=HBufC8::NewL(0); |
|
365 } |
|
366 |
|
367 ReadServiceInfoL(iAppInfo.ServiceArray()); |
|
368 ReadOwnedFilesInfoL(iAppInfo.OwnedFileArray()); |
|
369 } |
|
370 |
|
371 |
|
372 /* |
|
373 * Reads service information of the application. |
|
374 */ |
|
375 void CApaAppInfoReader::ReadServiceInfoL(const RPointerArray<Usif::CServiceInfo>& aServiceInfo) |
|
376 { |
|
377 TInt serviceCount=aServiceInfo.Count(); |
|
378 |
|
379 if (serviceCount > 0) |
|
380 { |
|
381 iServiceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4); |
|
382 } |
|
383 else |
|
384 { |
|
385 //if service information is not avaliable, just return. |
|
386 return; |
|
387 } |
|
388 |
|
389 //Read application service info one at a time and store in iServiceArray. |
|
390 for (TInt index=0;index<serviceCount;index++) |
|
391 { |
|
392 TUid serviceUid=aServiceInfo[index]->Uid(); |
|
393 |
|
394 CArrayFixFlat<TDataTypeWithPriority>* mimeTypesSupported = new(ELeave) CArrayFixFlat<TDataTypeWithPriority>(5); |
|
395 CleanupStack::PushL(mimeTypesSupported); |
|
396 |
|
397 //Read supported mime types of a service |
|
398 ReadMimeTypesSupportedL(aServiceInfo[index]->DataTypes(), *mimeTypesSupported); |
|
399 |
|
400 RPointerArray<Usif::COpaqueData> serviceOpaqueData=aServiceInfo[index]->OpaqueData(); |
|
401 //SCR schould give atmost only one opaque data for a service. |
|
402 ASSERT(!(serviceOpaqueData.Count()>1)); |
|
403 |
|
404 HBufC8* opaqueData=NULL; |
|
405 if(serviceOpaqueData.Count()>0) |
|
406 { |
|
407 opaqueData= serviceOpaqueData[0]->OpaqueData().AllocL(); |
|
408 } |
|
409 else |
|
410 { |
|
411 //If opaque data is not available, create an empty object and assign to opaqueData |
|
412 opaqueData=HBufC8::NewL(0); |
|
413 } |
|
414 |
|
415 TApaAppServiceInfo serviceInfo(serviceUid, mimeTypesSupported,opaqueData); // takes ownership of mimeTypesSupported and opaqueData |
|
416 CleanupStack::PushL(opaqueData); |
|
417 iServiceArray->AppendL(serviceInfo); |
|
418 CleanupStack::Pop(2, mimeTypesSupported); |
|
419 |
|
420 //If service UID is KOpenServiceUid and it is first open service then initialize iIndexOfFirstOpenService |
|
421 if ((serviceUid == KOpenServiceUid) && (iIndexOfFirstOpenService < 0)) |
|
422 iIndexOfFirstOpenService = iServiceArray->Count() - 1; |
|
423 } |
|
424 } |
|
425 |
|
426 |
|
427 /* |
|
428 * Reads supported mime types and its handling priorities of a service |
|
429 */ |
|
430 void CApaAppInfoReader::ReadMimeTypesSupportedL(const RPointerArray<Usif::CDataType>& dataTypes, CArrayFixFlat<TDataTypeWithPriority>& aMimeTypesSupported) |
|
431 { |
|
432 |
|
433 const TInt dataTypeArraySize = dataTypes.Count(); |
|
434 //if there are no data types available, just return. |
|
435 if (dataTypeArraySize <= 0) |
|
436 return; |
|
437 |
|
438 for (TInt i=0; i < dataTypeArraySize; i++) |
|
439 { |
|
440 TDataTypePriority priority = static_cast<TDataTypePriority>(dataTypes[i]->Priority()); |
|
441 |
|
442 //Check for data priority of UnTrusted apps however the trusted apps will not have any restrictions |
|
443 //over the data priority. |
|
444 //If an untrusted app has write device data capability (i.e. still has priority = KDataTypePrioritySystem), |
|
445 //do not restrict to KDataTypeUnTrustedPriorityThreshold |
|
446 if (priority > KDataTypeUnTrustedPriorityThreshold || priority == KDataTypePrioritySystem ) |
|
447 { |
|
448 ReadAppSecurityInfo(); |
|
449 |
|
450 if (priority == KDataTypePrioritySystem) |
|
451 { |
|
452 // Check that the app has capability WriteDeviceData |
|
453 if (!iHasWriteDeviceDataCap) |
|
454 priority = KDataTypePriorityNormal; |
|
455 } |
|
456 else |
|
457 { |
|
458 //data priority for UnTrusted apps would be capped if it is greater than the threshold priority i.e, KMaxTInt16. |
|
459 //Component ID is zero if the application is shipped with phone. |
|
460 TBool isInstalledApp=(iScr.GetComponentIdForAppL(iAppBinaryUidType[2])!=0); |
|
461 if (!iIsSidTrusted && isInstalledApp) |
|
462 { |
|
463 //if application sid is in unprotected range and the applciation is instaleld with |
|
464 //one of the installers after phone marketed, then priority needs to be downgraded. |
|
465 priority = KDataTypeUnTrustedPriorityThreshold; |
|
466 } |
|
467 } |
|
468 } |
|
469 |
|
470 TBuf8<KMaxDataTypeLength> buf; |
|
471 //Convert 16-bit descriptor to 8-bit descriptor. |
|
472 buf.Copy(dataTypes[i]->Type()); |
|
473 |
|
474 TDataType dataType(buf); |
|
475 TDataTypeWithPriority dataTypeWithPriority(dataType, priority); |
|
476 aMimeTypesSupported.AppendL(dataTypeWithPriority); |
|
477 } |
|
478 } |
|
479 |
|
480 |
|
481 /* |
|
482 * Reads owned files information. |
|
483 */ |
|
484 void CApaAppInfoReader::ReadOwnedFilesInfoL(const RPointerArray<HBufC>& aOwnedFiles) |
|
485 { |
|
486 const TInt fileOwnershipArraySize = aOwnedFiles.Count(); |
|
487 |
|
488 //if owned files information is not avaliable, just return. |
|
489 if (fileOwnershipArraySize <= 0) |
|
490 return; |
|
491 |
|
492 iOwnedFileArray = new(ELeave) CDesCArraySeg(fileOwnershipArraySize); |
|
493 |
|
494 for (TInt index=0; index < fileOwnershipArraySize; index++) |
|
495 { |
|
496 HBufC *fileowned=aOwnedFiles[index]->Des().AllocL(); |
|
497 CleanupStack::PushL(fileowned); |
|
498 iOwnedFileArray->AppendL(*fileowned); //takes the ownership of fileowned |
|
499 CleanupStack::Pop(fileowned); |
|
500 } |
|
501 } |
|
502 |
|
503 void CApaAppInfoReader::ReadLocalisationInfoL() |
|
504 { |
|
505 RPointerArray<Usif::CLocalizableAppInfo> localisationInfo; |
|
506 localisationInfo=iAppInfo.LocalizableAppInfoList(); |
|
507 ASSERT(localisationInfo.Count() <= 1); |
|
508 |
|
509 if(localisationInfo.Count()<=0) |
|
510 { |
|
511 //If localisable information is not avaialable then assign default icons. |
|
512 TRAP_IGNORE(iIcons = CApaAppIconArray::NewDefaultIconsL()); |
|
513 return; |
|
514 } |
|
515 |
|
516 //Group name provided in localisation file takes precedence over group name provided in registration file name. |
|
517 const TDesC& groupName=localisationInfo[0]->GroupName(); |
|
518 |
|
519 if(groupName.Length()>0) |
|
520 { |
|
521 iCapability.iGroupName=groupName; |
|
522 } |
|
523 |
|
524 //Get application language for current phone language. |
|
525 iApplicationLanguage=localisationInfo[0]->ApplicationLanguage(); |
|
526 |
|
527 const Usif::CCaptionAndIconInfo* captionIconInfo=localisationInfo[0]->CaptionAndIconInfo(); |
|
528 |
|
529 TBool useDefaultIcons=ETrue; |
|
530 |
|
531 if(captionIconInfo!=NULL) |
|
532 { |
|
533 iShortCaption=localisationInfo[0]->ShortCaption().AllocL(); |
|
534 if(iShortCaption && iShortCaption->Length() == 0) |
|
535 { |
|
536 delete iShortCaption; |
|
537 iShortCaption=NULL; |
|
538 } |
|
539 |
|
540 iCaption=captionIconInfo->Caption().AllocL(); |
|
541 if(iCaption && iCaption->Length() == 0) |
|
542 { |
|
543 delete iCaption; |
|
544 iCaption=NULL; |
|
545 } |
|
546 |
|
547 iNumOfAppIcons=captionIconInfo->NumOfAppIcons(); |
|
548 |
|
549 if(captionIconInfo->IconFileName().Length()>0) |
|
550 iIconFileName=captionIconInfo->IconFileName().AllocL(); |
|
551 |
|
552 |
|
553 if (iIconFileName && iIconFileName->Length()) |
|
554 { |
|
555 if (iFs.IsValidName(*iIconFileName)) |
|
556 { |
|
557 RFile file; |
|
558 TInt fileSize( 0 ); |
|
559 TInt err= file.Open(iFs, *iIconFileName, EFileShareReadersOnly ); |
|
560 |
|
561 //If the icon file does not exist, use default icons. |
|
562 if(err==KErrNone) |
|
563 { |
|
564 User::LeaveIfError(err); |
|
565 CleanupClosePushL( file ); |
|
566 User::LeaveIfError( file.Size( fileSize ) ); |
|
567 CleanupStack::PopAndDestroy(&file);//file |
|
568 |
|
569 if ( fileSize > 0 ) |
|
570 { |
|
571 if(FileIsMbmWithGenericExtensionL(*iIconFileName)) |
|
572 { |
|
573 if (iNumOfAppIcons > 0) |
|
574 { |
|
575 //Icon file is valid and contains mbm icons. |
|
576 iIcons = CApaAppIconArray::NewAppIconsL(iNumOfAppIcons, *iIconFileName, *iIconLoader); |
|
577 useDefaultIcons=EFalse; |
|
578 } |
|
579 } |
|
580 else |
|
581 { |
|
582 //If the icon file is not a mbm icon file then the file is treated as a non-mbm file. |
|
583 iNonMbmIconFile = ETrue; |
|
584 useDefaultIcons=EFalse; |
|
585 } |
|
586 |
|
587 } |
|
588 } |
|
589 } |
|
590 else |
|
591 { |
|
592 //If the filename is not a valid name then the file is treated as a non-mbm file. |
|
593 iNonMbmIconFile = ETrue; |
|
594 useDefaultIcons=EFalse; |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 if(useDefaultIcons) |
|
600 TRAP_IGNORE(iIcons = CApaAppIconArray::NewDefaultIconsL()); |
|
601 |
|
602 ReadViewInfoL(localisationInfo[0]->ViewDataList()); |
|
603 } |
|
604 |
|
605 /* |
|
606 * Read application view information. |
|
607 */ |
|
608 |
|
609 void CApaAppInfoReader::ReadViewInfoL(const RPointerArray<Usif::CAppViewData>& aViewData) |
|
610 { |
|
611 const TInt numOfViews = aViewData.Count(); |
|
612 |
|
613 //if view information not avaliable, just return. |
|
614 if(numOfViews <=0 ) |
|
615 return; |
|
616 |
|
617 iViewDataArray = new(ELeave) CArrayPtrFlat<CApaAppViewData>(numOfViews); |
|
618 |
|
619 //Read one view information at time and add it iViewDataArray |
|
620 for(TInt view = 0; view < numOfViews; ++view) |
|
621 { |
|
622 CApaAppViewData* viewData = CApaAppViewData::NewLC(); |
|
623 |
|
624 const TUid viewUid = aViewData[view]->Uid(); |
|
625 viewData->SetUid(viewUid); |
|
626 |
|
627 const TInt screenMode = {aViewData[view]->ScreenMode()}; |
|
628 viewData->SetScreenMode(screenMode); |
|
629 |
|
630 const Usif::CCaptionAndIconInfo* viewCaptionIconInfo=aViewData[view]->CaptionAndIconInfo(); |
|
631 |
|
632 if(viewCaptionIconInfo!=NULL) |
|
633 { |
|
634 viewData->SetCaptionL(viewCaptionIconInfo->Caption()); |
|
635 |
|
636 const TInt numOfViewIcons = viewCaptionIconInfo->NumOfAppIcons(); |
|
637 viewData->SetNumOfViewIcons(numOfViewIcons); |
|
638 |
|
639 TPtrC viewIconFile = viewCaptionIconInfo->IconFileName(); |
|
640 |
|
641 if (viewIconFile.Length()) |
|
642 { |
|
643 viewData->SetIconFileNameL(viewIconFile); |
|
644 |
|
645 if (iFs.IsValidName(viewIconFile)) |
|
646 { |
|
647 if(!FileIsMbmWithGenericExtensionL(viewIconFile)) |
|
648 viewData->SetNonMbmIconFile(ETrue); |
|
649 } |
|
650 else //If the filename is not a valid name then the file is treated as a non-mbm file. |
|
651 viewData->SetNonMbmIconFile(ETrue); |
|
652 } |
|
653 else |
|
654 { |
|
655 viewIconFile.Set(KNullDesC); |
|
656 if (numOfViewIcons > 0 && iIconFileName) |
|
657 viewIconFile.Set(*iIconFileName); // default to app icon filename |
|
658 } |
|
659 |
|
660 if (numOfViewIcons > 0 && iFs.IsValidName(viewIconFile) && FileIsMbmWithGenericExtensionL(viewIconFile)) |
|
661 { |
|
662 CApaAppIconArray* iconArray = CApaAppIconArray::NewViewIconsL(numOfViewIcons, viewIconFile, *iIconLoader); |
|
663 viewData->SetIconArray(iconArray); |
|
664 iconArray = NULL; |
|
665 } |
|
666 } |
|
667 |
|
668 iViewDataArray->AppendL(viewData); |
|
669 CleanupStack::Pop(viewData); |
|
670 } |
|
671 } |
|
672 |
|
673 #else |
|
674 |
|
675 CApaAppInfoReader* CApaAppInfoReader::NewL(RFs& aFs, const TDesC& aRegistrationFileName, TUid aAppUid) |
|
676 { |
|
677 CApaAppInfoReader* self = new(ELeave) CApaAppInfoReader(aFs, aRegistrationFileName, aAppUid); |
|
678 CleanupStack::PushL(self); |
|
679 self->ConstructL(); |
|
680 CleanupStack::Pop(self); |
|
681 return self; |
|
682 } |
|
683 |
|
684 CApaAppInfoReader::CApaAppInfoReader(RFs& aFs, const TDesC& aRegistrationFileName, TUid aAppUid) : |
|
685 iFs(aFs), |
|
686 iAppUid(aAppUid), |
|
687 iTimeStamp(0), |
|
688 iDefaultScreenNumber(0), |
|
689 iNonMbmIconFile(EFalse), |
|
690 iLocalisableResourceFileTimeStamp(0), |
|
691 iApplicationLanguage(ELangNone), |
|
692 iIndexOfFirstOpenService(KErrNotFound), |
|
693 iRegistrationFileName(aRegistrationFileName) |
|
694 { |
|
695 } |
|
696 |
130 TTime CApaAppInfoReader::TimeStamp() const |
697 TTime CApaAppInfoReader::TimeStamp() const |
131 { |
698 { |
132 return iTimeStamp; |
699 return iTimeStamp; |
133 } |
700 } |
134 |
701 |
135 TTime CApaAppInfoReader::IconFileTimeStamp() const |
702 TTime CApaAppInfoReader::IconFileTimeStamp() const |
136 { |
703 { |
137 return iIconFileTimeStamp; |
704 return iIconFileTimeStamp; |
138 } |
705 } |
139 |
706 |
140 void CApaAppInfoReader::Capability(TDes8& aCapabilityBuf) const |
|
141 { |
|
142 TApaAppCapabilityBuf buf(iCapability); |
|
143 TApaAppCapability::CopyCapability(aCapabilityBuf, buf); |
|
144 } |
|
145 |
|
146 TUint CApaAppInfoReader::DefaultScreenNumber() const |
|
147 { |
|
148 return iDefaultScreenNumber; |
|
149 } |
|
150 |
|
151 HBufC* CApaAppInfoReader::Caption() |
|
152 { |
|
153 HBufC* caption = iCaption; |
|
154 iCaption = NULL; // ownership transferred to caller |
|
155 return caption; |
|
156 } |
|
157 |
|
158 HBufC* CApaAppInfoReader::ShortCaption() |
|
159 { |
|
160 HBufC* shortCaption = iShortCaption; |
|
161 iShortCaption = NULL; // ownership transferred to caller |
|
162 return shortCaption; |
|
163 } |
|
164 |
|
165 CApaAppIconArray* CApaAppInfoReader::Icons() |
|
166 { |
|
167 CApaAppIconArray* icons = iIcons; |
|
168 iIcons = NULL; // ownership transferred to caller |
|
169 return icons; |
|
170 } |
|
171 |
|
172 TInt CApaAppInfoReader::NumOfAppIcons() const |
|
173 { |
|
174 return iNumOfAppIcons; |
|
175 } |
|
176 |
|
177 CArrayPtrFlat<CApaAppViewData>* CApaAppInfoReader::Views() |
|
178 { |
|
179 CArrayPtrFlat<CApaAppViewData>* viewDataArray = iViewDataArray; |
|
180 iViewDataArray = NULL; // ownership transferred to caller |
|
181 return viewDataArray; |
|
182 } |
|
183 |
|
184 CDesCArray* CApaAppInfoReader::OwnedFiles() |
|
185 { |
|
186 CDesCArray* ownedFileArray = iOwnedFileArray; |
|
187 iOwnedFileArray = NULL; // ownership transferred to caller |
|
188 return ownedFileArray; |
|
189 } |
|
190 |
|
191 HBufC* CApaAppInfoReader::IconFileName() |
|
192 { |
|
193 HBufC* iconFileName = iIconFileName; |
|
194 iIconFileName = NULL; // ownership transferred to caller |
|
195 return iconFileName; |
|
196 } |
|
197 |
|
198 TBool CApaAppInfoReader::NonMbmIconFile() const |
|
199 { |
|
200 return iNonMbmIconFile; |
|
201 } |
|
202 |
|
203 HBufC* CApaAppInfoReader::LocalisableResourceFileName() |
707 HBufC* CApaAppInfoReader::LocalisableResourceFileName() |
204 { |
708 { |
205 HBufC* localisableResourceFileName = iLocalisableResourceFileName; |
709 HBufC* localisableResourceFileName = iLocalisableResourceFileName; |
206 iLocalisableResourceFileName = NULL; // ownership transferred to caller |
710 iLocalisableResourceFileName = NULL; // ownership transferred to caller |
207 return localisableResourceFileName; |
711 return localisableResourceFileName; |
208 } |
712 } |
209 |
713 |
210 TTime CApaAppInfoReader::LocalisableResourceFileTimeStamp() const |
714 TTime CApaAppInfoReader::LocalisableResourceFileTimeStamp() const |
211 { |
715 { |
212 return iLocalisableResourceFileTimeStamp; |
716 return iLocalisableResourceFileTimeStamp; |
213 } |
717 } |
214 |
|
215 TLanguage CApaAppInfoReader::AppLanguage() const |
|
216 { |
|
217 return iApplicationLanguage; |
|
218 } |
|
219 |
|
220 CArrayFixFlat<TApaAppServiceInfo>* CApaAppInfoReader::ServiceArray(TInt& aIndexOfFirstOpenService) |
|
221 { |
|
222 CArrayFixFlat<TApaAppServiceInfo>* serviceArray = iServiceArray; |
|
223 iServiceArray = NULL; |
|
224 aIndexOfFirstOpenService = iIndexOfFirstOpenService; |
|
225 return serviceArray; |
|
226 } |
|
227 |
|
228 HBufC8* CApaAppInfoReader::OpaqueData() |
|
229 { |
|
230 HBufC8* opaqueData = iOpaqueData; |
|
231 iOpaqueData = NULL; |
|
232 return opaqueData; |
|
233 } |
|
234 |
|
235 CApaIconLoader* CApaAppInfoReader::IconLoader() |
|
236 { |
|
237 CApaIconLoader* iconLoader = iIconLoader; |
|
238 iIconLoader = NULL; // ownership transferred to caller |
|
239 return iconLoader; |
|
240 } |
|
241 |
718 |
242 // reads as much info as it can |
719 // reads as much info as it can |
243 // at least captions and icons must be setup on return from this method (using defaults if necessary) |
720 // at least captions and icons must be setup on return from this method (using defaults if necessary) |
244 TBool CApaAppInfoReader::ReadL() |
721 TBool CApaAppInfoReader::ReadL() |
245 { |
722 { |
842 TDataTypeWithPriority dataTypeWithPriority(dataType, priority); |
1209 TDataTypeWithPriority dataTypeWithPriority(dataType, priority); |
843 aMimeTypesSupported.AppendL(dataTypeWithPriority); |
1210 aMimeTypesSupported.AppendL(dataTypeWithPriority); |
844 } |
1211 } |
845 } |
1212 } |
846 |
1213 |
|
1214 |
|
1215 HBufC* CApaAppInfoReader::CreateFullIconFileNameL(const TDesC& aIconFileName) const |
|
1216 { |
|
1217 HBufC* filename = NULL; |
|
1218 if (aIconFileName.Length() == 0) |
|
1219 return NULL; |
|
1220 /* |
|
1221 * aIconFileName may contain a valid string in some format (for eg. URI format) other than path to a regular file on disk |
|
1222 * and that can be a mbm or non-mbm file. Such a filename will be reported as invalid filename by iFs.IsValidName() method. |
|
1223 * aIconFileName will be returned since it is a valid string. |
|
1224 */ |
|
1225 if(!iFs.IsValidName(aIconFileName)) |
|
1226 { |
|
1227 filename = aIconFileName.AllocL(); |
|
1228 return filename; |
|
1229 } |
|
1230 |
|
1231 TParsePtrC parsePtr(aIconFileName); |
|
1232 if (parsePtr.IsWild() || !parsePtr.PathPresent() || !parsePtr.NamePresent()) |
|
1233 return NULL; |
|
1234 |
|
1235 // check for fully qualified icon filename |
|
1236 if (parsePtr.DrivePresent() && BaflUtils::FileExists(iFs, aIconFileName)) |
|
1237 filename = aIconFileName.AllocL(); |
|
1238 else |
|
1239 { |
|
1240 // check for icon file on same drive as localisable resource file |
|
1241 TParse parse; |
|
1242 TPtrC localisableResourceFileDrive = TParsePtrC(*iLocalisableResourceFileName).Drive(); |
|
1243 TInt ret = parse.SetNoWild(localisableResourceFileDrive, &aIconFileName, NULL); |
|
1244 if (ret == KErrNone && BaflUtils::FileExists(iFs, parse.FullName())) |
|
1245 filename = parse.FullName().AllocL(); |
|
1246 else |
|
1247 { |
|
1248 TPtrC registrationFileDrive = TParsePtrC(iRegistrationFileName).Drive(); |
|
1249 if (TInt(TDriveUnit(registrationFileDrive)) != TInt(TDriveUnit(localisableResourceFileDrive))) |
|
1250 { |
|
1251 // check for icon file on same drive as registration file |
|
1252 ret = parse.SetNoWild(registrationFileDrive, &aIconFileName, NULL); |
|
1253 if (ret == KErrNone && BaflUtils::FileExists(iFs, parse.FullName())) |
|
1254 filename = parse.FullName().AllocL(); |
|
1255 } |
|
1256 } |
|
1257 } |
|
1258 |
|
1259 return filename; |
|
1260 } |
|
1261 |
|
1262 #endif |
|
1263 |
|
1264 /*An MBM file may have a generic icon extension. In this case, as a way to check whether the file is an MBM one, |
|
1265 it is necessary to read the content of the fist four 32bit words of it and find out whether these words correspond to |
|
1266 KWriteonceFileStoreUid, KMultiBitmapFileImageUid, zero and KMultiBitmapFileImageChecksum respectively (defined in graphics/gditools/bmconv/bmconv.h). |
|
1267 So the file is opened and the first 4 32 bit words are extracted and compared with the header information of standard MBM file. |
|
1268 If they match, the function returns ETrue, else it returns EFalse */ |
|
1269 TBool CApaAppInfoReader::FileIsMbmWithGenericExtensionL(const TDesC& aFileName) |
|
1270 { |
|
1271 if (aFileName.Length() > 0) |
|
1272 { |
|
1273 //open a file in Share mode - this will allow other methods to access it too |
|
1274 RFile file; |
|
1275 RFs fs; |
|
1276 User::LeaveIfError(fs.Connect()); |
|
1277 CleanupClosePushL(fs); |
|
1278 User::LeaveIfError(file.Open(fs,aFileName,EFileShareReadersOnly)); |
|
1279 //this is done beacuse the file can also be accessed by applist at the same time |
|
1280 //buffer stores the 16 bytes of the file |
|
1281 CleanupClosePushL(file); |
|
1282 TBuf8<16> buffer; |
|
1283 User::LeaveIfError(file.Read(buffer,16)); |
|
1284 CleanupStack::PopAndDestroy();//file |
|
1285 CleanupStack::PopAndDestroy(&fs);//file, fs |
|
1286 //we use a constant pointer to the buffer to read header info |
|
1287 TPtrC8 filePointer(buffer); |
|
1288 |
|
1289 /*The first 16 bytes of an MBM file are the same for any generic MBM file. |
|
1290 These are : |
|
1291 KWriteOnceFileStoreUid = 0x10000037(Emulator MBM file) 0x10000041(ROM image) |
|
1292 KMultiBitMapFileImageUid = 0x10000042(Emulator MBM file) 0x00000001(ROM image) |
|
1293 Zero = 0x00000000(Emulator MBM file) 0x0000000C(ROM image) |
|
1294 checksum = 0x47396439(Emulator MBM file) 0x10000040(ROM image) |
|
1295 The first 16 bytes of the given file is compared with these standard values to ascertain it is MBM file*/ |
|
1296 if((filePointer[3]==0x10)&&(filePointer[2]==0x00)&&(filePointer[1]==0x00)&&(filePointer[0]==0x37)) |
|
1297 {//KWriteOnceFileStoreUid = 0x10000037 |
|
1298 if((filePointer[7]==0x10)&&(filePointer[6]==0x00)&&(filePointer[5]==0x00)&&(filePointer[4]==0x42)) |
|
1299 {//KMultiBitMapFileImageUid = 0x10000042 |
|
1300 if((filePointer[11]==0x00)&&(filePointer[10]==0x00)&&(filePointer[9]==0x00)&&(filePointer[8]==0x00)) |
|
1301 {//Zero = 0x00000000) |
|
1302 if((filePointer[15]==0x47)&&(filePointer[14]==0x39)&&(filePointer[13]==0x64)&&(filePointer[12]==0x39)) |
|
1303 {//checksum = 0x47396439 |
|
1304 return ETrue; |
|
1305 } |
|
1306 } |
|
1307 } |
|
1308 } |
|
1309 //Else Check for ROM Image MBM file's header |
|
1310 else if((filePointer[3]==0x10)&&(filePointer[2]==0x00)&&(filePointer[1]==0x00)&&(filePointer[0]==0x41)) |
|
1311 {//KWriteOnceFileStoreUid = 0x10000041 |
|
1312 if((filePointer[7]==0x00)&&(filePointer[6]==0x00)&&(filePointer[5]==0x00)&&(filePointer[4]==0x01)) |
|
1313 {//KMultiBitMapFileImageUid = 0x00000001 |
|
1314 if((filePointer[11]==0x00)&&(filePointer[10]==0x00)&&(filePointer[9]==0x00)&&(filePointer[8]==0x0C)) |
|
1315 {//Zero = 0x0000000C) |
|
1316 if((filePointer[15]==0x10)&&(filePointer[14]==0x00)&&(filePointer[13]==0x00)&&(filePointer[12]==0x40)) |
|
1317 {//checksum = 0x10000040 |
|
1318 return ETrue; |
|
1319 } |
|
1320 } |
|
1321 } |
|
1322 } |
|
1323 } |
|
1324 return EFalse; |
|
1325 } |
|
1326 |
847 // This method can be used to check whether app has a WriteDeviceCap |
1327 // This method can be used to check whether app has a WriteDeviceCap |
848 // and its sid is trusted |
1328 // and its sid is trusted |
849 void CApaAppInfoReader::ReadAppSecurityInfo() |
1329 void CApaAppInfoReader::ReadAppSecurityInfo() |
850 { |
1330 { |
851 if (!iSecurityInfoHasBeenRead) |
1331 if (!iSecurityInfoHasBeenRead) |