|
1 /* |
|
2 * Copyright (c) 2004 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: This class provides the base class for metadata parsers. |
|
15 * This class is the highest class in parser hierarchy. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MMETADATAPARSER_H |
|
22 #define MMETADATAPARSER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <MetaDataField.hrh> |
|
27 #include <f32file.h> |
|
28 #include <charconv.h> |
|
29 #include "MetaDataID3v1Genre.h" |
|
30 #include <barsc.h> |
|
31 #include <barsread.h> |
|
32 |
|
33 |
|
34 // FORWARD DECLARATION |
|
35 class CMetaDataFieldContainer; |
|
36 |
|
37 // CONSTANTS |
|
38 const TInt KUnicodeBOMNotFound = 0; |
|
39 const TInt KUnicodeBOMBigEndian = 1; |
|
40 const TInt KUnicodeBOMLittleEndian = 2; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * This class implements the base class in metadata hierarchy. |
|
46 * |
|
47 * @lib MetaDataUtility.lib |
|
48 * @since 3.0 |
|
49 */ |
|
50 class CMetaDataParser : public CBase |
|
51 { |
|
52 public: // Destructor |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CMetaDataParser(); |
|
58 |
|
59 protected: // Constructor |
|
60 |
|
61 /** |
|
62 * C++ default constructor. |
|
63 */ |
|
64 CMetaDataParser(); |
|
65 |
|
66 public: // New functions |
|
67 |
|
68 /** |
|
69 * Parses the source and if metadata is found, the metadata fields are |
|
70 * inserted into the container. |
|
71 * @since 3.0 |
|
72 * @param aWantedFields An array of TMetaDataFieldId's. Empty array is interpreted as all fields. |
|
73 * @param aContainer On return, metadata found in aSource is stored here |
|
74 * @return void |
|
75 */ |
|
76 virtual void ParseL( const RArray<TMetaDataFieldId>& aWantedFields, |
|
77 CMetaDataFieldContainer& aContainer ) = 0; |
|
78 |
|
79 /** |
|
80 * Returns whether metadata was found or not. |
|
81 * @since 3.0 |
|
82 * @return ETrue, if metadata was found |
|
83 */ |
|
84 TBool MetaDataExists(); |
|
85 |
|
86 /** |
|
87 * Returns id3 version for ID3 tag types |
|
88 * @since 3.0 |
|
89 * @return TID3Type enum |
|
90 */ |
|
91 virtual TID3Version ID3Version(); |
|
92 |
|
93 /** |
|
94 * Maps ID3v1 genre integer to string |
|
95 * @param aNum genre integer code |
|
96 * @param aGenrePtr string genre value returned |
|
97 * @since 3.0 |
|
98 * @return void |
|
99 */ |
|
100 void MapID3GenreToStringL(TInt aNum, TDes& aGenrePtr); |
|
101 |
|
102 /** |
|
103 * Maps ID3v2 genre integer to string |
|
104 * @param aNum genre integer code |
|
105 * @param aGenrePtr string genre value returned |
|
106 * @since 3.0 |
|
107 * @return void |
|
108 */ |
|
109 |
|
110 void MapID3GenreToStringL(TInt aNum, TDes8& aGenrePtr); |
|
111 void GenerateTopCharacterSetsL(); |
|
112 void SelectCharacterSetsForLanguageL(TInt aLanguage); |
|
113 void ReadCharacterSetResourceL(TInt aResourceId); |
|
114 TBool IsInTopCharacterSet(TUint aCharacterSetId); |
|
115 |
|
116 protected: |
|
117 |
|
118 /** |
|
119 * Strips trailing zeros at the end of the field. |
|
120 * @since 3.0 |
|
121 * @param aDesc The original descriptor |
|
122 * @return Pointer to descriptor without whitespace |
|
123 */ |
|
124 TPtrC8 StripTrailingZeroes( const TDesC8& aDesc, TInt encoding = 0); |
|
125 TPtrC StripTrailingZeroes( const TDesC& aDesc); |
|
126 |
|
127 /** |
|
128 * Returns BOM indication in the provided unicode. |
|
129 * @since 3.0 |
|
130 * @param aUnicode Descriptor containing unicode. |
|
131 * @return KUnicodeBOMNotFound, KUnicodeBOMBigEndian, or KUnicodeBOMLittleEndian |
|
132 */ |
|
133 TInt UnicodeBOM( const TDesC8& aUnicode ); |
|
134 |
|
135 protected: // Data |
|
136 |
|
137 // Metadata container |
|
138 CMetaDataFieldContainer* iContainer; |
|
139 // Metadata exists |
|
140 TBool iExists; |
|
141 // File session |
|
142 RFs iFs; |
|
143 // Character set for unicode conversion |
|
144 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iCharacterSet; |
|
145 // Most likely character set for unicode conversion |
|
146 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iTopCharacterSet; |
|
147 |
|
148 RResourceFile iRscFile; |
|
149 |
|
150 //CArrayFixFlat<TInt>* installedLanguages; |
|
151 }; |
|
152 |
|
153 #endif // MMETADATAPARSER_H |
|
154 |
|
155 // End of File |