1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CHARVESTERM3UPLAYLISTPARSER_H__ |
|
20 #define __CHARVESTERM3UPLAYLISTPARSER_H__ |
|
21 |
|
22 #include <charconv.h> |
|
23 |
|
24 // |
|
25 // CAudioMDParser |
|
26 // |
|
27 class CHarvesterM3UPlaylistParser : public CBase |
|
28 { |
|
29 public: |
|
30 static CHarvesterM3UPlaylistParser* NewL( RFs& aFs, |
|
31 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aAvailableCharacterSet, |
|
32 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aTopCharacterSet ); |
|
33 virtual ~CHarvesterM3UPlaylistParser(); |
|
34 |
|
35 TBool ParseL( const TDesC& aFileName, RPointerArray<HBufC>& aUriArray ); |
|
36 void Reset(); |
|
37 |
|
38 private: |
|
39 CHarvesterM3UPlaylistParser( RFs& aFs, |
|
40 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aAvailableCharacterSet, |
|
41 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aTopCharacterSet ); |
|
42 |
|
43 /** |
|
44 * Reads data from playlist file to the buffer |
|
45 */ |
|
46 void ReadPlaylistFileToBufferL(); |
|
47 |
|
48 /** |
|
49 * Parses the buffer where playlist file was read to. |
|
50 */ |
|
51 void ParsePlaylistBufferL( |
|
52 RPointerArray<HBufC>& aPlaylist, |
|
53 TInt& aInvalidItemCount); |
|
54 |
|
55 /** |
|
56 * Auto detects the character encoding from the supplied character |
|
57 * set |
|
58 * @param aSample a sample of the file |
|
59 * @param aCharSetId auto-detected character set for the supplied |
|
60 * sample |
|
61 * @param aCharacterSet a character set to detect the encoding from |
|
62 * @return KErrNone if a character set is found; otherwise |
|
63 * KErrNotFound. |
|
64 */ |
|
65 TInt DetectCharacterSetL( |
|
66 const TDesC8& aSample, |
|
67 const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>& aCharacterSet, |
|
68 TUint& aCharSetId ); |
|
69 |
|
70 /** |
|
71 * Reads next line from iBuffer and stores it to iLine. Returns EFalse |
|
72 * if there are no more new lines. |
|
73 */ |
|
74 TBool ReadNextLineL(); |
|
75 |
|
76 /** |
|
77 * Decides what to do with an iLine read from iBuffer |
|
78 */ |
|
79 void ProcessLineL( |
|
80 RPointerArray<HBufC>& aPlaylist, |
|
81 TInt& aInvalidItemCount); |
|
82 |
|
83 /** |
|
84 * Parses path or extended info from an iLine and stores them to iItem |
|
85 */ |
|
86 TInt ParseLineL( |
|
87 TFileName& aItem, |
|
88 TInt& aInvalidItemCount); |
|
89 |
|
90 /** |
|
91 * Parses and returns an absolute path if aPath is relative to playlist |
|
92 * file's path. If path is not valid or it doesn't exist, error code is |
|
93 * returned in aError. |
|
94 * |
|
95 * caller assumes ownership of the returned HBufC |
|
96 */ |
|
97 HBufC* ParseAbsolutePathLC( |
|
98 const TDesC& aPath, |
|
99 TInt& aError); |
|
100 |
|
101 private: |
|
102 RFs& iFs; |
|
103 |
|
104 TPtrC iPlaylistFilePath; |
|
105 |
|
106 TInt iInvalidItems; |
|
107 |
|
108 HBufC* iBuffer; |
|
109 TPtrC iBufferPtr; |
|
110 |
|
111 // Not owned. |
|
112 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iAvailableCharacterSet; |
|
113 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iTopCharacterSet; |
|
114 |
|
115 TInt iEndLineNumber; |
|
116 TInt iCurrentLineNumber; |
|
117 |
|
118 HBufC* iLine; |
|
119 |
|
120 TBool iExtendedFormat; |
|
121 |
|
122 TFileName iItem; |
|
123 }; |
|
124 |
|
125 |
|
126 |
|
127 #endif // __CHARVESTERM3UPLAYLISTPARSER_H__ |
|
128 |
|