|
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 implements an ID3v1 and v1.1 parser as specified in |
|
15 * www.id3.org. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CMETADATAPARSERID3V1_H |
|
22 #define CMETADATAPARSERID3V1_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include "MetaDataParser.h" |
|
27 #include "MetaDataSource.h" |
|
28 #include "MetaDataFieldContainer.h" |
|
29 #include "MetaDataField.h" |
|
30 |
|
31 // CONSTANTS |
|
32 const TInt KID3v1TagLength = 128; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * This class implements an ID3v1 and v1.1 parser. |
|
38 * |
|
39 * @lib MetaDataUtility.lib |
|
40 * @since 3.0 |
|
41 */ |
|
42 class CMetaDataParserID3v1 : public CMetaDataParser |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 * @param aSource Reference to a metadata source |
|
49 * @return A pointer to a new instance of this class |
|
50 */ |
|
51 static CMetaDataParserID3v1* NewL( CMetaDataSource& aSource ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 virtual ~CMetaDataParserID3v1(); |
|
57 |
|
58 public: // Functions from base classes |
|
59 |
|
60 /** |
|
61 * From CMetaDataParser |
|
62 * Parses the source and if metadata is found, the metadata fields are |
|
63 * inserted into the container. |
|
64 * @since 3.0 |
|
65 * @param aWantedFields An array of TMetaDataFieldId's. Empty array is interpreted as all fields. |
|
66 * @param aContainer On return, metadata found in aSource is stored here |
|
67 * @return void |
|
68 */ |
|
69 void ParseL( const RArray<TMetaDataFieldId>& aWantedFields, CMetaDataFieldContainer& aContainer ); |
|
70 |
|
71 enum TAutoDetectCommand // Possible autodetect commands |
|
72 { |
|
73 EDetectFromTopList = 0, |
|
74 EDetectFromNextList, |
|
75 EDetectFromRestList |
|
76 }; |
|
77 |
|
78 /** |
|
79 * From CMetaDataParser |
|
80 * returns ID3 version |
|
81 * @since 3.0 |
|
82 * @return TID3Version |
|
83 */ |
|
84 TID3Version ID3Version(); |
|
85 |
|
86 private: |
|
87 |
|
88 /** |
|
89 * C++ default constructor. |
|
90 */ |
|
91 CMetaDataParserID3v1( CMetaDataSource& aSource ); |
|
92 |
|
93 /** |
|
94 * By default Symbian 2nd phase constructor is private. |
|
95 */ |
|
96 void ConstructL(); |
|
97 |
|
98 /** |
|
99 * Validates whether there is ID3v1 tag in the source or not. |
|
100 */ |
|
101 TBool ValidateL(); |
|
102 |
|
103 /** |
|
104 * Append title to the container, if found. |
|
105 * @return void |
|
106 */ |
|
107 void GetTitleL(); |
|
108 |
|
109 /** |
|
110 * Append artist to the container, if found. |
|
111 * @return void |
|
112 */ |
|
113 void GetArtistL(); |
|
114 |
|
115 /** |
|
116 * Append album to the container, if found. |
|
117 * @return void |
|
118 */ |
|
119 void GetAlbumL(); |
|
120 |
|
121 /** |
|
122 * Append year to the container, if found. |
|
123 * @return void |
|
124 */ |
|
125 void GetYearL(); |
|
126 |
|
127 /** |
|
128 * Append comment to the container, if found. |
|
129 * @return void |
|
130 */ |
|
131 void GetCommentL(); |
|
132 |
|
133 /** |
|
134 * Append album track to the container, if found. |
|
135 * @return void |
|
136 */ |
|
137 void GetAlbumTrackL(); |
|
138 |
|
139 /** |
|
140 * Append genre to the container, if found. |
|
141 * @return void |
|
142 */ |
|
143 void GetGenreL(); |
|
144 |
|
145 /** |
|
146 * Converts to unicode. |
|
147 * @param aDesc Source to be converted to unicode. |
|
148 * @param aUnicode Contains the converted unicode on return. |
|
149 * @return KErrNone if successful, otherwise one of the system errors. |
|
150 */ |
|
151 TInt ConvertToUnicodeL( const TDesC8& aDesc, TDes16& aUnicode ); |
|
152 |
|
153 /** |
|
154 * Detects the character set for the descriptor. |
|
155 * @param aDesc Source to be converted to unicode. |
|
156 * @return KErrNone if successful, otherwise one of the system errors. |
|
157 */ |
|
158 TInt DetectCharacterSetL( const TDesC8& aDesc); |
|
159 |
|
160 private: // Data |
|
161 |
|
162 // Metadata source |
|
163 CMetaDataSource& iSource; |
|
164 // Tag data |
|
165 TBuf8<KID3v1TagLength> iTagData; |
|
166 // Character Set Id used during Unicode conversion |
|
167 TUint iCharacterSetId; |
|
168 }; |
|
169 |
|
170 #endif // CMETADATAPARSERID3V1_H |
|
171 |
|
172 // End of File |