filehandling/fileconverterfw/INC/CONCNF.H
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 #if !defined(__CONCNF_H__)
       
    17 #define __CONCNF_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <f32file.h>
       
    21 #include <s32stor.h>
       
    22 #include <apmstd.h>
       
    23 #include <barsc.h>
       
    24 #include <barsread.h>
       
    25 
       
    26 /**
       
    27 @publishedAll 
       
    28 @released 
       
    29 */
       
    30 #define KMaxTranslation 50
       
    31 
       
    32 /** Buffer to contain a localised data type name. 
       
    33 
       
    34 @publishedAll 
       
    35 @released */
       
    36 typedef TBuf<KMaxTranslation> TTranslation;
       
    37 
       
    38 
       
    39 class TLanguageInfo
       
    40 /** Holds a localised name for a data type. 
       
    41 
       
    42 @publishedAll 
       
    43 @released */
       
    44 	{
       
    45 public:
       
    46 	TLanguageInfo();
       
    47 	IMPORT_C TLanguageInfo(TLanguage aLanguage,TTranslation aTranslation);
       
    48 public:
       
    49 	void InternalizeL(RReadStream& aStream);
       
    50 	void ExternalizeL(RWriteStream& aStream) const;
       
    51 	TLanguage Language();
       
    52 	TTranslation Translation();
       
    53 	void ReadFromResource(TResourceReader& aReader);
       
    54 public:
       
    55 	TLanguage	iLanguage;
       
    56 	TTranslation iTranslation;
       
    57 	};
       
    58 
       
    59 class CMimeInfo : public CBase
       
    60 /** Holds the localised names for a data type.
       
    61 
       
    62 @publishedAll
       
    63 @released */
       
    64 	{
       
    65 public:
       
    66 	IMPORT_C ~CMimeInfo();
       
    67 	IMPORT_C static CMimeInfo* NewLC(TDataType& aMime);
       
    68 	static CMimeInfo* NewL();
       
    69 	static CMimeInfo* NewLC(const CMimeInfo* aInfo);
       
    70 public:
       
    71 	void InternalizeL(RReadStream& aStream);
       
    72 	void ExternalizeL(RWriteStream& aStream) const;
       
    73 	TDataType Mime();
       
    74 	TTranslation Text();
       
    75 	IMPORT_C void AddLanguageL(TLanguageInfo aLang);
       
    76 	static CMimeInfo* NewLC(TResourceReader& aReader);
       
    77 private:
       
    78 	void ConstructL();
       
    79 	void ConstructL(TResourceReader& aReader);
       
    80 	void AddLanguageInfoL(TResourceReader& aReader);
       
    81 private:
       
    82 	TDataType iMime;
       
    83 	CArrayFixFlat<TLanguageInfo> *iLanguageInfo;
       
    84 	};
       
    85 
       
    86 class CCnaConverter : public CBase
       
    87 /** Holds the inherent properties of a converter. 
       
    88 
       
    89 These are its UID and the data types it supports.
       
    90 
       
    91 Note that the setter functions affect only the current object, not the stored 
       
    92 information for the converter.
       
    93 
       
    94 @publishedAll
       
    95 @released */
       
    96 	{
       
    97 public:
       
    98 	static CCnaConverter* NewLC();
       
    99 	static CCnaConverter* NewL();
       
   100 	IMPORT_C static CCnaConverter* NewL(TUid aUid);
       
   101 	IMPORT_C static CCnaConverter* NewLC(TUid aUid);
       
   102 	IMPORT_C static CCnaConverter* NewL(const CCnaConverter& aConverter);
       
   103 	IMPORT_C static CCnaConverter* NewLC(const CCnaConverter& aConverter);
       
   104 	IMPORT_C ~CCnaConverter();
       
   105 	IMPORT_C void SetUid(TUid aUid);
       
   106 	IMPORT_C TBool MimeFrom(const TDataType& aMimeType) const;
       
   107 	IMPORT_C TBool MimeTo(const TDataType& aMimeType) const;
       
   108 	IMPORT_C TTranslation MimeFromText(const TDataType& aMimeType) const;
       
   109 	IMPORT_C TTranslation MimeToText(const TDataType& aMimeType) const;
       
   110 	IMPORT_C TInt CountFrom() const;
       
   111 	IMPORT_C TInt CountTo() const;
       
   112 	IMPORT_C TDataType MimeFrom(TInt aIndex) const;
       
   113 	IMPORT_C TDataType MimeTo(TInt aIndex) const;
       
   114 	IMPORT_C TTranslation MimeFromText(TInt aIndex) const;
       
   115 	IMPORT_C TTranslation MimeToText(TInt aIndex) const;
       
   116 	inline TUid Uid() const;
       
   117 	static CCnaConverter* NewL(TUid aUid,TResourceReader& aReader);	
       
   118 private:
       
   119 	CCnaConverter();
       
   120 	void ConstructL();
       
   121 	TBool FindMime(const TDataType& aMimeType, const CArrayPtrFlat<CMimeInfo>* aList) const;
       
   122 	TTranslation FindMimeText(const TDataType& aMimeType, const CArrayPtrFlat<CMimeInfo>* aList) const;
       
   123 	void ConstructL(TUid aUid,TResourceReader& aReader);
       
   124 	void AddMimeDataL(TResourceReader& aReader, CArrayPtrFlat<CMimeInfo>& aMimeInfo);
       
   125 private:
       
   126 	TUid iUid;
       
   127 	CArrayPtrFlat<CMimeInfo>* iMimeFrom;
       
   128 	CArrayPtrFlat<CMimeInfo>* iMimeTo;
       
   129 	};
       
   130 
       
   131 inline TUid CCnaConverter::Uid() const
       
   132 /** Gets the converter UID.
       
   133 
       
   134 @return Converter UID */
       
   135 	{return iUid;}
       
   136 
       
   137 class CCnaConvInfoFile2 : public CBase
       
   138 /**
       
   139 implementation class
       
   140 @internalComponent
       
   141 */
       
   142 	{
       
   143 public:
       
   144 	~CCnaConvInfoFile2();
       
   145 	//
       
   146 protected:
       
   147 	void ConstructL();
       
   148 protected:
       
   149 	RFs iFs;
       
   150 	RResourceFile iResourceFile;
       
   151 	CArrayPtr<CCnaConverter>* iConverters;
       
   152 	};
       
   153 
       
   154 /** Encapsulates a collection of converter properties (CCnaConverter) read from a converter 
       
   155 information (.rsc) file.
       
   156 
       
   157 @publishedAll
       
   158 @released
       
   159 */
       
   160 // Each RSC file contains CCnaConverter information for each
       
   161 // available CConverterBase2 derived class in its associated DLL.
       
   162 
       
   163 // In addition there may be INI files for each converter which supply run time extended
       
   164 // CCnaConverter information such as additional mime types.
       
   165 class CCnaConvInfoFileReader2 : public CCnaConvInfoFile2
       
   166 	{
       
   167 public:
       
   168 	IMPORT_C static CCnaConvInfoFileReader2* NewLC(const TDesC& aFileName);
       
   169 	IMPORT_C static CCnaConvInfoFileReader2* NewL(const TDesC& aFileName);
       
   170 	IMPORT_C TInt Count();
       
   171 	IMPORT_C CCnaConverter* AtL(TInt anIndex);
       
   172 	//
       
   173 	IMPORT_C void RestoreL();
       
   174 private:
       
   175 	CCnaConvInfoFileReader2();
       
   176 	void RestoreConverterL(TResourceReader& aReader);
       
   177 	void ConstructL(const TDesC& aFileName);
       
   178 	};
       
   179 
       
   180 #endif