|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * Declaration of class CCodData. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef COD_DATA_H |
|
22 #define COD_DATA_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <bamdesca.h> |
|
28 #include "CodDefs.h" |
|
29 #include <f32file.h> |
|
30 |
|
31 #include "MediaObject.h" |
|
32 // ================= CONSTANTS ======================= |
|
33 |
|
34 // FORWARD DECLARATION |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * COD / DD Data. |
|
40 */ |
|
41 NONSHARABLE_CLASS( CCodData ): public CBase |
|
42 { |
|
43 |
|
44 public: // types |
|
45 |
|
46 enum TSupressConfirm /// Confirm supress |
|
47 { |
|
48 ENever = 0, ///< Never suppress confirmation. |
|
49 EUserConfirmStepOnly, ///< Suppress user confirmation step only. |
|
50 EAlways ///< Always suppress confirmation. |
|
51 }; |
|
52 |
|
53 |
|
54 public: // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. Leaves on failure. |
|
58 * @return The created COD data. |
|
59 */ |
|
60 IMPORT_C static CCodData* NewL(); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 IMPORT_C virtual ~CCodData(); |
|
66 |
|
67 public: // New methods |
|
68 |
|
69 /** |
|
70 * Check whether COD data is valid (all mandatory values are filled). |
|
71 * @return ETrue if data is valid. |
|
72 */ |
|
73 IMPORT_C TBool IsValid() const; |
|
74 |
|
75 /** |
|
76 * Clear everything. Does not free memory, simply sets all descriptors |
|
77 * to zero length. |
|
78 */ |
|
79 IMPORT_C void Reset(); |
|
80 public://Methods for managing info files |
|
81 |
|
82 /** |
|
83 * Append information to stored in info file. |
|
84 * @return void |
|
85 * @Added in OMA pause-resume feature |
|
86 */ |
|
87 void AppendStorageInfoL(TPtr8& aBuf)const; |
|
88 |
|
89 /** |
|
90 * Load the information from info file |
|
91 * @return void |
|
92 * @Added in OMA pause-resume feature |
|
93 */ |
|
94 void LoadStorageInfoL( RFile& aInFile ); |
|
95 |
|
96 public://Methods to manage media objects |
|
97 |
|
98 /** |
|
99 * Append given media object to the array |
|
100 * @return index of the media object |
|
101 */ |
|
102 TInt AppendMediaObjectL( CMediaObjectData *aMO ); |
|
103 |
|
104 public: // Getters |
|
105 |
|
106 /** |
|
107 * Get Name attribute. |
|
108 * @return Name. |
|
109 */ |
|
110 IMPORT_C TPtrC Name() const; |
|
111 |
|
112 /** |
|
113 * Get Vendor attribute. |
|
114 * @return Vendor. |
|
115 */ |
|
116 IMPORT_C TPtrC Vendor() const; |
|
117 |
|
118 /** |
|
119 * Get Description attribute. |
|
120 * @return Description. |
|
121 */ |
|
122 IMPORT_C TPtrC Description() const; |
|
123 |
|
124 /** |
|
125 * Get Size attribute. |
|
126 * @return Size. |
|
127 */ |
|
128 IMPORT_C TInt Size() const; |
|
129 |
|
130 /** |
|
131 * Get Install-Notify attribute. |
|
132 * @return Install-Notify. |
|
133 */ |
|
134 IMPORT_C TPtrC8 InstallNotify() const; |
|
135 |
|
136 /** |
|
137 * Get Next-URL attribute. |
|
138 * @return Next-URL. |
|
139 */ |
|
140 IMPORT_C TPtrC8 NextUrl() const; |
|
141 |
|
142 /** |
|
143 * Get Next-URLatError attribute. |
|
144 * @return URLatError. |
|
145 */ |
|
146 IMPORT_C TPtrC8 NextUrlAtError() const; |
|
147 |
|
148 /** |
|
149 * Get Info-URL attribute. |
|
150 * @return Info-URL. |
|
151 */ |
|
152 IMPORT_C TPtrC8 InfoUrl() const; |
|
153 |
|
154 /** |
|
155 * Get Price attribute. |
|
156 * @return Price. |
|
157 */ |
|
158 IMPORT_C TPtrC Price() const; |
|
159 |
|
160 /** |
|
161 * Get Icon attribute. |
|
162 * @return Icon. |
|
163 */ |
|
164 IMPORT_C TPtrC8 Icon() const; |
|
165 |
|
166 /** |
|
167 * Get Version attribute (DD specific). |
|
168 * @return Version. |
|
169 */ |
|
170 IMPORT_C TPtrC Version() const; |
|
171 |
|
172 /** |
|
173 * Get source URI. |
|
174 * @return Source URI. |
|
175 */ |
|
176 IMPORT_C TPtrC8 SourceUri() const; |
|
177 |
|
178 /** |
|
179 * Get Order. |
|
180 * @return ETrue if order tag is "Post", EFails iin case of "any". |
|
181 */ |
|
182 IMPORT_C TBool IsPostOrder() const; |
|
183 |
|
184 /** |
|
185 * Get Confirm attribute. |
|
186 * @return Size. |
|
187 */ |
|
188 IMPORT_C TInt SuppressConfirm() const; |
|
189 |
|
190 /** |
|
191 * Get updated DD URI attribute. |
|
192 * @return Size. |
|
193 */ |
|
194 IMPORT_C TPtrC8 UpdatedDDUriL() const; |
|
195 |
|
196 |
|
197 /** |
|
198 * Append given media object to the array |
|
199 * @return media object |
|
200 */ |
|
201 IMPORT_C CMediaObjectData *operator[]( TInt aIndex ); |
|
202 |
|
203 /** |
|
204 * Append given media object to the array |
|
205 * @return media object |
|
206 */ |
|
207 IMPORT_C CMediaObjectData *operator[]( TInt aIndex ) const; |
|
208 |
|
209 /** |
|
210 *Returns the currently Active Download |
|
211 */ |
|
212 IMPORT_C TInt ActiveDownload() const; |
|
213 |
|
214 |
|
215 /** |
|
216 * Get the Count of number of Media Objects. |
|
217 */ |
|
218 inline TInt Count( ) const { return iMediaObjects.Count(); } |
|
219 |
|
220 protected: // Constructors and destructor |
|
221 |
|
222 /** |
|
223 * Constructor. |
|
224 */ |
|
225 CCodData(); |
|
226 |
|
227 /** |
|
228 * Second phase constructor. Leaves on failure. |
|
229 */ |
|
230 void ConstructL(); |
|
231 |
|
232 protected: // Setters |
|
233 |
|
234 /** |
|
235 * Set Name attribute. |
|
236 * @param Name. |
|
237 * @return ETrue if set, EFalse for invalid data. |
|
238 */ |
|
239 TBool SetNameL( const TDesC& aName ); |
|
240 |
|
241 /** |
|
242 * Set Vendor attribute. |
|
243 * @param Vendor. |
|
244 * @return ETrue if set, EFalse for invalid data. |
|
245 */ |
|
246 TBool SetVendorL( const TDesC& aVendor ); |
|
247 |
|
248 /** |
|
249 * Set Description attribute. |
|
250 * @param Description. |
|
251 * @return ETrue if set, EFalse for invalid data. |
|
252 */ |
|
253 TBool SetDescriptionL( const TDesC& aDescription ); |
|
254 |
|
255 /** |
|
256 * Set Size attribute. |
|
257 * @param Size. |
|
258 * @return ETrue if set, EFalse for invalid data. |
|
259 */ |
|
260 TBool SetSize( TUint aSize ); |
|
261 |
|
262 /** |
|
263 * Set suppressConfirm attribute. |
|
264 * @param . |
|
265 * @return ETrue if set, EFalse for invalid data. |
|
266 */ |
|
267 TBool SetSuppressConfirm( TInt aSuppressConfirm ); |
|
268 |
|
269 /** |
|
270 * Set Install-Notify attribute. |
|
271 * @param Install-Notify. |
|
272 * @return ETrue if set, EFalse for invalid data. |
|
273 */ |
|
274 TBool SetInstallNotifyL( const TDesC& aInstallNotify ); |
|
275 |
|
276 /** |
|
277 * Set Next-URL attribute. |
|
278 * @param Next-URL. |
|
279 * @return ETrue if set, EFalse for invalid data. |
|
280 */ |
|
281 TBool SetNextUrlL( const TDesC& aNextUrl ); |
|
282 |
|
283 /** |
|
284 * Set Next-URLatError attribute. |
|
285 * @param URLatError. |
|
286 * @return ETrue if set, EFalse for invalid data. |
|
287 */ |
|
288 TBool SetNextUrlAtErrorL( const TDesC& aNextUrlAtError ); |
|
289 |
|
290 /** |
|
291 * Set Info-URL attribute. |
|
292 * @param Info-URL. |
|
293 * @return ETrue if set, EFalse for invalid data. |
|
294 */ |
|
295 TBool SetInfoUrlL( const TDesC& aInfoUrl ); |
|
296 |
|
297 /** |
|
298 * Set Price attribute. |
|
299 * @param Price. |
|
300 * @return ETrue if set, EFalse for invalid data. |
|
301 */ |
|
302 TBool SetPriceL( const TDesC& aPrice ); |
|
303 |
|
304 /** |
|
305 * Set Icon attribute. |
|
306 * @param Icon. |
|
307 */ |
|
308 TBool SetIconL( const TDesC& aIcon ); |
|
309 |
|
310 /** |
|
311 * Set Version attribute. |
|
312 * @param Version. |
|
313 */ |
|
314 TBool SetVersionL( const TDesC& aVersion ); |
|
315 |
|
316 /** |
|
317 * Set source URI. |
|
318 * @param aSourceUri Source URI. |
|
319 */ |
|
320 void SetSourceUriL( const TDesC8& aSourceUri ); |
|
321 |
|
322 /** |
|
323 * Set Order attribute. |
|
324 * @param aIsPostOrder. |
|
325 */ |
|
326 void SetOrderIsPost( TBool aIsPostOrder ); |
|
327 |
|
328 /** |
|
329 * Set updated DD URI attribute. |
|
330 */ |
|
331 TBool SetUpdatedDDURI( const TDesC& aUrl ); |
|
332 |
|
333 /** |
|
334 * Set updated DD URI attribute. |
|
335 */ |
|
336 void SetActiveDownload( const TInt aMediaObjectId ); |
|
337 |
|
338 |
|
339 private: // implementation details |
|
340 |
|
341 /** |
|
342 * Common setter for string attributes, with overflow check. |
|
343 * @param aBuf Buffer to set. |
|
344 * @param aString String to set. |
|
345 * @param aMaxLength Max length to check. |
|
346 * @return ETrue if set, EFalse for invalid data. |
|
347 */ |
|
348 TBool SetStringAttrL |
|
349 ( HBufC*& aBuf, const TDesC& aString, TInt aMaxLength ); |
|
350 |
|
351 /** |
|
352 * Common setter for string attributes, with overflow check. |
|
353 * @param aBuf Buffer to set. |
|
354 * @param aString String to set. |
|
355 * @param aMaxLength Max length to check. |
|
356 * @return ETrue if set, EFalse for invalid data. |
|
357 */ |
|
358 TBool SetStringAttrL |
|
359 ( HBufC8*& aBuf, const TDesC& aString, TInt aMaxLength ); |
|
360 |
|
361 private: // friends |
|
362 |
|
363 /// Parsers can set the data. |
|
364 friend class TCodParser; |
|
365 |
|
366 /// Parser can set the data. |
|
367 friend class TDdParser; |
|
368 |
|
369 /// Engine can set source URI. |
|
370 friend class CCodEngBase; |
|
371 |
|
372 private: // data |
|
373 |
|
374 HBufC* iName; ///< COD-Name. Name ( of the album ). |
|
375 HBufC* iVendor; ///< COD-Vendor. Vendor ( info of album ). |
|
376 HBufC* iDescription; ///< COD-Description. Description ( of album ). |
|
377 TUint iSize; ///< COD-Size. Total size ( of all tracks in album ). |
|
378 HBufC8* iInstallNotify; ///< COD-Install-Notify. Owned. |
|
379 HBufC8* iNextUrl; ///< COD-Next-URL. Owned. |
|
380 HBufC8* iNextUrlAtError; ///< COD-Next-UrlatError. Owned. |
|
381 HBufC8* iInfoUrl; ///< COD-Info-URL. Owned. |
|
382 HBufC* iPrice; ///< COD-Price. Owned. |
|
383 HBufC8* iIcon; ///< COD-Icon. Owned. |
|
384 HBufC* iVersion; ///< DD-Version. Owned. |
|
385 TBool iIsPostOrder; ///< Order (True if Post or False if Any) // for OMA 2 |
|
386 TInt iSuppressConfirm; ///< Suppress the confirmation for OMA 2 |
|
387 HBufC8* iSourceUri; ///< Source Uri owned. |
|
388 HBufC8* iUpdatedDDUri; ///< Updated DD URI |
|
389 TInt iActiveDownload; ///< Currently Active Media Object |
|
390 RMediaObjectArray iMediaObjects; ///< Media objects |
|
391 }; |
|
392 |
|
393 #endif /* def COD_DATA_H */ |