localisation/apparchitecture/apgrfx/APGAIR.H
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(__APGAIR_H__)
       
    17 #define __APGAIR_H__
       
    18 
       
    19 #if !defined(__APAID_H__)
       
    20 #include <apaid.h>
       
    21 #endif
       
    22 #if !defined(__APMSTD_H__)
       
    23 #include <apmstd.h>
       
    24 #endif
       
    25 
       
    26 #include <barsc.h>
       
    27 #include <barsread.h>
       
    28 
       
    29 /**
       
    30 @internalComponent
       
    31 */
       
    32 class ApaUtils
       
    33 	{
       
    34 public:
       
    35 	IMPORT_C static TBool HandleAsRegistrationFile(const TUidType& aUidType);
       
    36 	};
       
    37 
       
    38 /** The 2nd UID that defines a resource file as being an application registration resource file.
       
    39 
       
    40 @internalComponent
       
    41 */
       
    42 const TUid KUidAppRegistrationFile ={0x101F8021};
       
    43 
       
    44 class CApaMaskedBitmap;
       
    45 class CApaAppViewData;
       
    46 class TEntry;
       
    47 class RFs;
       
    48 class CResourceFile;
       
    49 class RResourceReader;
       
    50 class CApaAppList;
       
    51 class CApaAppIconArray;
       
    52 
       
    53 /**
       
    54 @internalComponent
       
    55 */
       
    56 
       
    57 NONSHARABLE_CLASS(CApaIconLoader) : public CBase
       
    58 	{
       
    59 public:
       
    60 	static CApaIconLoader* NewL(RFs& aFs);
       
    61 	static CApaIconLoader* NewLC(RFs& aFs);
       
    62 	~CApaIconLoader();
       
    63 
       
    64 	void AddIconArrayL(const CApaAppIconArray& aIcons);
       
    65 	void LoadAllIconsL();
       
    66 	TBool LoadIconsL(TInt aNumOfIcons, const TDesC& aMbmFileName, CArrayPtr<CApaMaskedBitmap>& aIcons);
       
    67 
       
    68 private:
       
    69 	CApaIconLoader(RFs& aFs);
       
    70 	void ConstructL();
       
    71 	TInt IconIndexL(const TDesC& aFileName, TBool& aUseCache);
       
    72 	static TInt CompareIcons(const CApaMaskedBitmap& aFirst, const CApaMaskedBitmap& aSecond);
       
    73 
       
    74 private:
       
    75 	struct TKeyValuePair
       
    76 		{
       
    77 	public:
       
    78 		HBufC* iFileName; // key
       
    79 		TInt iIndex; // value
       
    80 		};
       
    81 private:
       
    82 	RFs& iFs;
       
    83 	RArray<TKeyValuePair> iIconIndexArray;
       
    84 	TInt iCachedArrayIndex;
       
    85 	RPointerArray<CApaAppIconArray> iIconArrays;
       
    86 	};
       
    87 
       
    88 /**
       
    89 @internalComponent
       
    90 */
       
    91 NONSHARABLE_CLASS(CApaAppIconArray) : public CBase
       
    92 	{
       
    93 public:
       
    94 	static CApaAppIconArray* NewL(); // creates a dummy icon array
       
    95 	static CApaAppIconArray* NewAppIconsL(TInt aNumOfIcons, const TDesC& aMbmFileName, CApaIconLoader& aIconLoader);
       
    96 	static CApaAppIconArray* NewViewIconsL(TInt aNumOfIcons, const TDesC& aMbmFileName, CApaIconLoader& aIconLoader);
       
    97 	static CApaAppIconArray* NewDefaultIconsL(); // creates a CApaAppIconArray that uses the default icons
       
    98 	static CApaAppIconArray* NewRealDefaultIconsLC(TInt aNumOfIcons, const TDesC& aMbmFileName, CApaIconLoader& aIconLoader); // creates the CApaAppIconArray that contains the default icons
       
    99 	~CApaAppIconArray();
       
   100 
       
   101 	TBool LoadIconsL();
       
   102 
       
   103 	CApaMaskedBitmap* IconBySize(const TSize& aSize) const;
       
   104 	CArrayFixFlat<TSize>* IconSizesL() const;
       
   105 	TInt Count() const;
       
   106 	TBool DefaultIconsUsed() const;
       
   107 	CApaMaskedBitmap* operator[](TInt aIndex) const;
       
   108 #ifdef SYMBIAN_APPARC_APPINFO_CACHE	
       
   109 	TBool AreAppIconsLoaded() const;
       
   110 	TBool AreViewIconsLoaded() const;
       
   111 #endif	// SYMBIAN_APPARC_APPINFO_CACHE
       
   112 	
       
   113 private:
       
   114 	static CApaAppIconArray* NewL(TInt aNumOfIcons, const TDesC& aMbmFileName, CApaIconLoader& aIconLoader, TBool aFallbackToDefaultIcons);
       
   115 	static CApaAppIconArray* NewLC(TInt aNumOfIcons, const TDesC& aMbmFileName, CApaIconLoader& aIconLoader, TBool aFallbackToDefaultIcons);
       
   116 	CApaAppIconArray();
       
   117 	CApaAppIconArray(TInt aNumOfIcons, CApaIconLoader& aIconLoader, TBool aFallbackToDefaultIcons);
       
   118 	void ConstructL(const TDesC& aMbmFileName);
       
   119 	void GetDefaultIconsL();
       
   120 	const CApaAppIconArray& DefaultIcons() const;
       
   121 	
       
   122 private:
       
   123 	TInt iNumOfIcons;
       
   124 	CApaIconLoader* iIconLoader;
       
   125 	TBool iFallbackToDefaultIcons;
       
   126 	HBufC* iMbmFileName;
       
   127 	TBool iDefaultIconsUsed;
       
   128 	CArrayPtrFlat<CApaMaskedBitmap>* iIcons;
       
   129 	CApaAppList* iDefaultIconsProvider;
       
   130 	};
       
   131 
       
   132 class CApaAppInfoReader : public CBase
       
   133 /**
       
   134 Abstract base class for application information readers.
       
   135 
       
   136 Concrete implementations should read information from some
       
   137 data source and implement policy specific to each reader.
       
   138 
       
   139 @internalComponent
       
   140 */
       
   141 	{
       
   142 public:
       
   143 	~CApaAppInfoReader();
       
   144 public:
       
   145 	HBufC* AppBinaryFullName();
       
   146 	TUidType AppBinaryUidType() const;
       
   147 	TTime TimeStamp() const;
       
   148 	TTime IconFileTimeStamp() const;
       
   149 	void Capability(TDes8& aCapabilityBuf) const;
       
   150 	TUint DefaultScreenNumber() const;
       
   151 	HBufC* Caption();
       
   152 	HBufC* ShortCaption();
       
   153 	CApaAppIconArray* Icons();
       
   154 #ifdef SYMBIAN_APPARC_APPINFO_CACHE	
       
   155 	TInt NumOfAppIcons() const;
       
   156 	virtual CApaIconLoader* IconLoader() = 0;
       
   157 #else	
       
   158 	TBool DefaultIconsUsed() const;
       
   159 #endif	// SYMBIAN_APPARC_APPINFO_CACHE
       
   160 	CArrayPtrFlat<CApaAppViewData>* Views();
       
   161 	CDesCArray* OwnedFiles();
       
   162 	HBufC* IconFileName();
       
   163 	TBool NonMbmIconFile() const;
       
   164 	HBufC* LocalisableResourceFileName();
       
   165 	TTime LocalisableResourceFileTimeStamp() const;
       
   166 	TLanguage AppLanguage() const;
       
   167 	CArrayFixFlat<TApaAppServiceInfo>* ServiceArray(TInt& aIndexOfFirstOpenService);
       
   168 	HBufC8* OpaqueData();
       
   169 
       
   170 public:
       
   171 	virtual TBool Read()=0;
       
   172 protected:
       
   173 	CApaAppInfoReader(RFs& aFs, const TUid aAppUid);
       
   174 	
       
   175 protected:
       
   176 	RFs& iFs;
       
   177 	TUid iAppUid;
       
   178 	HBufC* iAppBinaryFullName;
       
   179 	TUidType iAppBinaryUidType;
       
   180 	TTime iTimeStamp;
       
   181 	TTime iIconFileTimeStamp;
       
   182 	TApaAppCapability iCapability;
       
   183 	TUint iDefaultScreenNumber;
       
   184 	HBufC* iCaption;
       
   185 	HBufC* iShortCaption;
       
   186 	CApaAppIconArray* iIcons;
       
   187 #ifdef SYMBIAN_APPARC_APPINFO_CACHE
       
   188 	TInt iNumOfAppIcons;
       
   189 #else
       
   190 	TBool iDefaultIconsUsed;
       
   191 #endif
       
   192 	CArrayPtrFlat<CApaAppViewData>* iViewDataArray;
       
   193 	CDesCArray* iOwnedFileArray;
       
   194 	HBufC* iIconFileName;
       
   195 	TBool iNonMbmIconFile; // ETrue if icon filename is not an MBM file, however, EFalse does not necessarily mean it is an MBM file
       
   196 	HBufC* iLocalisableResourceFileName;
       
   197 	TTime iLocalisableResourceFileTimeStamp;
       
   198 	TLanguage iApplicationLanguage;
       
   199 	CArrayFixFlat<TApaAppServiceInfo>* iServiceArray;
       
   200 	TInt iIndexOfFirstOpenService;
       
   201 	TBool iOpenServiceIsLegacy;
       
   202 	HBufC8* iOpaqueData;
       
   203 	};
       
   204 
       
   205 class CApaAppInfoReaderV2 : public CApaAppInfoReader
       
   206 /**
       
   207 Reads application information from a combination of registration file,
       
   208 optional localisable resource file and optional icon file.
       
   209 Application information stored in this way is referred to as version 2.
       
   210 
       
   211 @internalComponent
       
   212 */
       
   213 	{
       
   214 public:
       
   215 #ifdef SYMBIAN_APPARC_APPINFO_CACHE
       
   216 	static CApaAppInfoReaderV2* NewL(RFs& aFs, const TDesC& aRegistrationFileName, const TUid aAppUid);
       
   217 	virtual CApaIconLoader* IconLoader();
       
   218 #else
       
   219 	static CApaAppInfoReaderV2* NewL(RFs& aFs, const TDesC& aRegistrationFileName, const TUid aAppUid,const TDesC& aDefaultAppIconFileName);
       
   220 #endif	// SYMBIAN_APPARC_APPINFO_CACHE
       
   221 	~CApaAppInfoReaderV2();
       
   222 
       
   223 public:
       
   224 	virtual TBool Read();
       
   225 	static TBool FileIsMbm(const TDesC& aFileName);
       
   226 
       
   227 private:
       
   228 #ifdef SYMBIAN_APPARC_APPINFO_CACHE
       
   229 	CApaAppInfoReaderV2(RFs& aFs, const TDesC& aRegistrationFileName, const TUid aAppUid);
       
   230 #else
       
   231 	CApaAppInfoReaderV2(RFs& aFs, const TDesC& aRegistrationFileName, const TUid aAppUid, const TDesC& aDefaultAppIconFileName);
       
   232 #endif
       
   233 	void ConstructL();
       
   234 	void ReadMandatoryInfoL(CResourceFile*& aRegistrationFile, RResourceReader& aResourceReader);
       
   235 	void ReadNonLocalisableInfoL(RResourceReader& aResourceReader, CResourceFile*& aLocalisableResourceFile, TUint& aLocalisableResourceId);
       
   236 	void ReadNonLocalisableOptionalInfoL(RResourceReader& aResourceReader, const CResourceFile* aRegistrationFile, CResourceFile* aLocalisableResourceFile);
       
   237 	void ReadDataTypesL(RResourceReader& aResourceReader, CArrayFixFlat<TDataTypeWithPriority>& aDatatypes);
       
   238 	void ReadLocalisableInfoL(const CResourceFile* aResourceFile, TUint aResourceId, TBool& aUseDefaultIcons);
       
   239 	HBufC* FullIconFileNameL(const TDesC& aIconFileName) const;
       
   240 	TBool HasWriteDeviceDataCap();
       
   241     void ReadAppSecurityInfo();
       
   242 	
       
   243     TBool FileIsMbmWithGenericExtensionL(const TDesC& aFileName) const;
       
   244 	static HBufC8* ReadOpaqueDataL(TUint aResourceId, const CResourceFile* aRegistrationFile, CResourceFile* aLocalisableResourceFile);
       
   245 
       
   246 private:
       
   247 	const TDesC& iRegistrationFileName;
       
   248 	TBool iHasWriteDeviceDataCap;
       
   249     TBool iIsSidTrusted;
       
   250     // This flag is used to determine if app security info was allready read
       
   251     TBool iSecurityInfoHasBeenRead;
       
   252 	CApaIconLoader* iIconLoader;	
       
   253 #ifndef SYMBIAN_APPARC_APPINFO_CACHE
       
   254 	const TDesC& iDefaultAppIconFileName;
       
   255 #endif
       
   256 	};
       
   257 
       
   258 #endif