|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of CStreamingLinkModel |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 5 % |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __STREAMINGLINKMODEL_H |
|
23 #define __STREAMINGLINKMODEL_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <f32file.h> |
|
28 #include <badesca.h> |
|
29 #include <e32def.h> |
|
30 |
|
31 #ifdef __WINDOWS_MEDIA |
|
32 #include <asxparser.h> |
|
33 #endif |
|
34 |
|
35 // CLASS DECLARATION |
|
36 class MCLFContentListingEngine; |
|
37 |
|
38 struct LinkStruct { |
|
39 HBufC* link; |
|
40 TBool seek; |
|
41 }; |
|
42 |
|
43 NONSHARABLE_CLASS(CStreamingLinkModel) : public CBase |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 */ |
|
50 IMPORT_C static CStreamingLinkModel* NewL(); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 IMPORT_C virtual ~CStreamingLinkModel(); |
|
56 |
|
57 public: // New functions |
|
58 |
|
59 /** |
|
60 * Opens and reads RAM file to buffer. |
|
61 * @since 2.0 |
|
62 * @param aRamFileName RAM file |
|
63 * @param aEnableFiltering, Is ram file content filtered or not |
|
64 * @return KErrNone or KErrNotFound if no valid links in file |
|
65 */ |
|
66 IMPORT_C TInt OpenLinkFileL( const TDesC& aLinkFileName, TBool aEnableFiltering = ETrue ); |
|
67 |
|
68 /** |
|
69 * Opens and reads RAM file to buffer. |
|
70 * @since 9.2 |
|
71 * @param aFile file handle |
|
72 * @param aEnableFiltering, Is ram file content filtered or not |
|
73 * @return KErrNone or KErrNotFound if no valid links in file |
|
74 */ |
|
75 IMPORT_C TInt OpenLinkFileL( RFile& aFile, TBool aEnableFiltering = ETrue ); |
|
76 |
|
77 /** |
|
78 * Gets next link from opened RAM file. |
|
79 * @since 2.0 |
|
80 * @param aLink, New link. |
|
81 * @param aLocalFile, Is link to local file or not. |
|
82 * @param aParse, Parse the link if not forbidden. |
|
83 * @return KErrNone if there are links left in RAM file, |
|
84 * KErrNotFound if not. |
|
85 */ |
|
86 IMPORT_C TInt GetNextLinkL( TDes& aLink, TBool& aLocalFile, TBool aParse = ETrue ); |
|
87 IMPORT_C TBool IsSeekable(); |
|
88 /** |
|
89 * Returns max link length in opened RAM file |
|
90 * @since 2.0 |
|
91 * @return link length |
|
92 */ |
|
93 IMPORT_C TInt MaxLinkLength(); |
|
94 |
|
95 /** |
|
96 * Creates new RAM file |
|
97 * @since 2.0 |
|
98 * @param aNewRamFileName, New RAM file. |
|
99 * @param aLinkArray, Array which contains links which are |
|
100 * saved to RAM file. |
|
101 * @param aOverWrite, Overwrite existing file or not. |
|
102 * @return KErrNone or one of the system wide error codes. |
|
103 */ |
|
104 IMPORT_C TInt CreateNewLinkFileL( const TDesC& aNewLinkFileName, |
|
105 MDesCArray* aLinkArray, |
|
106 TBool aOverWrite = EFalse ); |
|
107 |
|
108 /** |
|
109 * Frees model's filehandle. |
|
110 * @since 3.0 |
|
111 */ |
|
112 IMPORT_C void FreeFilehandle(); |
|
113 |
|
114 /** |
|
115 * Returns number of links in opened RAM file |
|
116 * @since 3.2 |
|
117 * @return number of links |
|
118 */ |
|
119 IMPORT_C TInt MultiLinksCount(); |
|
120 |
|
121 /** |
|
122 * Reset number of links in opened RAM file for Repeat playlist |
|
123 * @since 3.2 |
|
124 */ |
|
125 IMPORT_C void ResetLinkCount(); |
|
126 |
|
127 /** |
|
128 * Opens and reads ASX file to buffer. |
|
129 * @since 9.2 |
|
130 * @param aLinkFileName Asx file |
|
131 * @param aEnableFiltering, Is ASX file content filtered or not |
|
132 * @return KErrNone or KErrNotFound if no valid links in file |
|
133 */ |
|
134 IMPORT_C TInt OpenAsxFileL( const TDesC& aLinkFileName, |
|
135 TBool aEnableFiltering = ETrue ); |
|
136 |
|
137 /** |
|
138 * Opens and reads ASX file to buffer. |
|
139 * @since 9.2 |
|
140 * @param aFile file handle |
|
141 * @param aEnableFiltering, Is ASX file content filtered or not |
|
142 * @return KErrNone or KErrNotFound if no valid links in file |
|
143 */ |
|
144 IMPORT_C TInt OpenAsxFileL( RFile& aFile, |
|
145 TBool aEnableFiltering = ETrue ); |
|
146 |
|
147 /** |
|
148 * Returns if all the links in the file are local |
|
149 * @ |
|
150 * @return ETrue if all the links are local |
|
151 */ |
|
152 IMPORT_C TBool AreAllLinksLocal(); |
|
153 |
|
154 private: |
|
155 |
|
156 /** |
|
157 * C++ default constructor. |
|
158 */ |
|
159 CStreamingLinkModel(); |
|
160 |
|
161 /** |
|
162 * By default Symbian 2nd phase constructor is private. |
|
163 */ |
|
164 void ConstructL(); |
|
165 |
|
166 private: |
|
167 |
|
168 /** |
|
169 * Reads next line from buffer |
|
170 * @since 2.0 |
|
171 * @param aLine Whole line which was read. |
|
172 * @return KErrNone or one of the system wide error codes. |
|
173 */ |
|
174 TInt ReadNextLine( TDes& aLine ); |
|
175 |
|
176 /** |
|
177 * Determines presence of file handle. |
|
178 * @since 9.2 |
|
179 * @param aFile file handle |
|
180 * @return ETrue if file handle exists. |
|
181 */ |
|
182 TBool FileHandleExists( RFile& aFile ); |
|
183 |
|
184 /** |
|
185 * Parse the ram file and add the link(s) to buffer. |
|
186 * @since 9.2 |
|
187 * @param aRamFile a Ram file |
|
188 * @param aEnableFiltering, is Ram file content filtered or not |
|
189 * @return KErrNone or KErrNotFound if no valid links in file |
|
190 */ |
|
191 TInt PopulateRamLinksL( RFile aRamFile, TBool aEnableFiltering ); |
|
192 |
|
193 /** |
|
194 * Parse the Asx file and add the link(s) to buffer. |
|
195 * @since 9.2 |
|
196 * @param aAsxParser |
|
197 * @param aEnableFiltering, is Asx file content filtered or not |
|
198 * @return KErrNone or KErrNotFound if no valid links in file |
|
199 */ |
|
200 TInt PopulateAsxLinksL( CAsxParser* aAsxParser, TBool aEnableFiltering ); |
|
201 |
|
202 private: // Data |
|
203 RFs iFs; |
|
204 RFile iFileHandle; |
|
205 |
|
206 RPointerArray<LinkStruct> iLinkArray; |
|
207 TPtrC8 iBufferPtr; |
|
208 |
|
209 TInt iLinkCount; |
|
210 |
|
211 MCLFContentListingEngine* iCLFEngine; |
|
212 }; |
|
213 |
|
214 #endif // __STREAMINGLINKMODEL_H |
|
215 |
|
216 // End of File |