localisation/apparchitecture/inc/apgicnflpartner.h
branchSymbian3
changeset 57 b8d18c84f71c
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
       
     1 // Copyright (c) 1997-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __APGICNFL_PARTNER_H__
       
    17 #define __APGICNFL_PARTNER_H__
       
    18 
       
    19 #include <apadef.h>
       
    20 #include <apaid.h>
       
    21 /*
       
    22 #include <bitdev.h>
       
    23 #include <apmstd.h>
       
    24 #include <badesca.h>
       
    25 */
       
    26 
       
    27    class CApaResourceFileWriterBase : public CBase
       
    28    	{
       
    29    protected:
       
    30    	class RBufferSink;
       
    31    	class MDataSink
       
    32    		{
       
    33    	public:
       
    34    		void WriteBufferL(const TDesC8& aBuffer);
       
    35    		void WriteCompressedUnicodeRunL(TInt aNumberOfBytesWhenUncompressed, const TDesC8& aTextAsCompressedUnicode);
       
    36    		void WriteInCompressedUnicodeFormatL(TInt aNumberOfBytesWhenUncompressed, const TDesC8& aData, TBool aInCompressedUnicodeRun);
       
    37    		TInt NumberOfBytesWhenUncompressed() const;
       
    38    		inline TBool CompressedUnicodeFormat() const {return (iBufferSinkForCompressedUnicodeFormat!=NULL);}
       
    39    	protected:
       
    40    		MDataSink(RBufferSink* aBufferSinkForCompressedUnicodeFormat);
       
    41    		void FlushL(TBool aFinalFlush);
       
    42    		void Reset(TInt& aNumberOfBytesWhenUncompressed);
       
    43    	private:
       
    44    		void WriteRunLengthL(TInt aRunLength);
       
    45    	private:
       
    46    		enum
       
    47    			{
       
    48    			EFlag_InCompressedUnicodeRun	=0x00000001
       
    49    			};
       
    50    	private:
       
    51    		// new virtual functions
       
    52    		virtual void DoWriteBufferL(const TDesC8& aBuffer)=0;
       
    53    	private:
       
    54    		TInt iNumberOfBytesWhenUncompressed;
       
    55    		TUint iFlags;
       
    56    		RBufferSink* iBufferSinkForCompressedUnicodeFormat; // does not own what it points to
       
    57    		};
       
    58    	class RBufferSink : public MDataSink
       
    59    		{
       
    60    	public:
       
    61    		RBufferSink(RBufferSink* aBufferSinkForCompressedUnicodeFormat);
       
    62    		void ConstructLC();
       
    63    		void Close();
       
    64    		void FlushAndGetAndResetL(TInt& aNumberOfBytesWhenUncompressed, RBuf8& aBuffer);
       
    65    	private:
       
    66    		// from MDataSink
       
    67    		virtual void DoWriteBufferL(const TDesC8& aBuffer);
       
    68    	private:
       
    69    		RBuf8 iBuffer;
       
    70    		};
       
    71    protected:
       
    72    	CApaResourceFileWriterBase();
       
    73    	void DoGenerateFileContentsL(RBuf8& aBuffer, TUid aUid2, TUid aUid3) const;
       
    74    	void WriteUidTypeL(MDataSink& aDataSink, TUid aUid2, TUid aUid3) const;
       
    75    	void WriteTextL(MDataSink& aDataSink, const TDesC& aText) const;
       
    76    	void WriteText8L(MDataSink& aDataSink, const TDesC8& aText8) const;
       
    77    	void WriteUint8L(MDataSink& aDataSink, TUint aUint8) const;
       
    78    	void WriteLittleEndianUint16L(MDataSink& aDataSink, TUint aUint16) const;
       
    79    	void WriteLittleEndianUint32L(MDataSink& aDataSink, TUint aUint32) const;
       
    80    	void WriteBufferL(MDataSink& aDataSink, const TDesC8& aBuffer) const;
       
    81    private:
       
    82    	static HBufC8* AsCompressedUnicodeLC(const TDesC& aUncompressedUnicode);
       
    83    	void MainResourceInCompiledFormatLC(TInt& aMainResourceSizeInBytesWhenUncompressed, RBuf8& aBuffer, TBool aCompressedUnicodeFormat) const;
       
    84    private:
       
    85    	// new virtual functions
       
    86    	virtual void MainResourceInCompiledFormatL(MDataSink& aDataSink) const=0;
       
    87    	virtual const TDesC8* SecondResourceL(TBool& aSecondResourceInCompressedUnicodeFormat) const=0;
       
    88    	};
       
    89 
       
    90 /**
       
    91    Used to support the registration of non-native applications.
       
    92    
       
    93    The task of this class is to generate the resource files expected by the Apparc server. Applications 
       
    94    that register other applications can use functions of this class to customise the generated resource files.
       
    95    
       
    96    @publishedPartner
       
    97    @released
       
    98    */
       
    99    class CApaRegistrationResourceFileWriter : public CApaResourceFileWriterBase
       
   100    	{
       
   101    public:
       
   102    	IMPORT_C static CApaRegistrationResourceFileWriter* NewL(TUid aAppUid, const TDesC& aAppFile, TUint aAttributes);
       
   103    	IMPORT_C virtual ~CApaRegistrationResourceFileWriter();
       
   104    	TUid AppUid() const;
       
   105    	void GenerateFileContentsL(RBuf8& aBuffer) const;
       
   106    	void SetLocalisableResourceFileL(const TDesC& aLocalisableResourceFile);
       
   107    	IMPORT_C void SetAppIsHiddenL(TBool aAppIsHidden);
       
   108    	IMPORT_C void SetEmbeddabilityL(TApaAppCapability::TEmbeddability aEmbeddability);
       
   109    	IMPORT_C void SetSupportsNewFileL(TBool aSupportsNewFile);
       
   110    	IMPORT_C void SetLaunchInBackgroundL(TBool aLaunchInBackground);
       
   111    	IMPORT_C void SetGroupNameL(const TDesC& aGroupName);
       
   112    	IMPORT_C void SetDefaultScreenNumberL(TInt aDefaultScreenNumber);
       
   113    	IMPORT_C void SetOpaqueDataL(const TDesC8& aOpaqueData);
       
   114    	IMPORT_C void AddDataTypeL(TInt aPriority, const TDesC8& aType);
       
   115    	IMPORT_C void AddFileOwnershipInfoL(const TDesC& aFileName);
       
   116    // Not needing to be supported for the foreseeable future:
       
   117    //	IMPORT_C void AddServiceInfoL(TUid aServiceUid, const TDesC8* aOpaqueData);
       
   118    //	IMPORT_C void AddServiceInfoDataTypeL(TUid aServiceUid, TInt aPriority, const TDesC8& aType);
       
   119    private:
       
   120    	struct SDataType // DATATYPE
       
   121    		{
       
   122    		TInt iPriority;
       
   123    		HBufC8* iType;
       
   124    		};
       
   125    	struct SFileOwnershipInfo // FILE_OWNERSHIP_INFO
       
   126    		{
       
   127    		HBufC* iFileName;
       
   128    		};
       
   129    private:
       
   130    	CApaRegistrationResourceFileWriter(TUid aAppUid, TUint aAttributes);
       
   131    	void ConstructL(const TDesC& aAppFile);
       
   132    	void WriteDataTypeL(MDataSink& aDataSink, const SDataType& aDataType) const;
       
   133    	void WriteFileOwnershipInfoL(MDataSink& aDataSink, const SFileOwnershipInfo& aFileOwnershipInfo) const;
       
   134    	// from CApaResourceFileWriterBase
       
   135    	virtual void MainResourceInCompiledFormatL(MDataSink& aDataSink) const;
       
   136    	virtual const TDesC8* SecondResourceL(TBool& aSecondResourceInCompressedUnicodeFormat) const;
       
   137    private:
       
   138    	TUid iAppUid;
       
   139    	HBufC* iAppFile;
       
   140    	TUint iAttributes;
       
   141    	HBufC* iLocalisableResourceFile;
       
   142    	TBool iAppIsHidden;
       
   143    	TApaAppCapability::TEmbeddability iEmbeddability;
       
   144    	TBool iSupportsNewFile;
       
   145    	TBool iLaunchInBackground;
       
   146    	HBufC* iGroupName;
       
   147    	TInt iDefaultScreenNumber;
       
   148    	HBufC8* iOpaqueData;
       
   149    	RArray<SDataType> iDataTypeList;
       
   150    	RArray<SFileOwnershipInfo> iFileOwnershipList;
       
   151    	};
       
   152 
       
   153 /**
       
   154    @internalAll
       
   155    */
       
   156    class CApaLocalisableResourceFileWriter : public CApaResourceFileWriterBase
       
   157    	{
       
   158    public:
       
   159    	IMPORT_C static CApaLocalisableResourceFileWriter* NewL(const TDesC& aShortCaption, const TDesC& aCaption, TInt aNumberOfIcons, const TDesC& aGroupName);
       
   160    	IMPORT_C virtual ~CApaLocalisableResourceFileWriter();
       
   161    	void GenerateFileContentsL(RBuf8& aBuffer) const;
       
   162    	void SetIconFileL(const TDesC& aIconFile);
       
   163    // Not needing to be supported for the foreseeable future:
       
   164    //	IMPORT_C void AddViewDataL(TUid aViewUid, TInt aScreenMode, const TDesC& aCaption, TInt aNumberOfIcons, const TDesC& aIconFile);
       
   165    private:
       
   166    	struct SCaptionAndIconInfo // CAPTION_AND_ICON_INFO
       
   167    		{
       
   168    		HBufC* iCaption;
       
   169    		TInt iNumberOfIcons;
       
   170    		HBufC* iIconFile;
       
   171    		};
       
   172    private:
       
   173    	CApaLocalisableResourceFileWriter(TInt aNumberOfIcons);
       
   174    	void ConstructL(const TDesC& aShortCaption, const TDesC& aCaption, const TDesC& aGroupName);
       
   175    	void WriteCaptionAndIconInfoL(MDataSink& aDataSink, const SCaptionAndIconInfo& aCaptionAndIcon) const;
       
   176    	// from CApaResourceFileWriterBase
       
   177    	virtual void MainResourceInCompiledFormatL(MDataSink& aDataSink) const;
       
   178    	virtual const TDesC8* SecondResourceL(TBool& aSecondResourceInCompressedUnicodeFormat) const;
       
   179    private:
       
   180    	HBufC* iShortCaption;
       
   181    	SCaptionAndIconInfo iCaptionAndIcon;
       
   182    	HBufC* iGroupName;
       
   183    	};
       
   184 
       
   185 
       
   186 
       
   187 #endif
       
   188