|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Base classes for CodData IPC |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef HTTPDOWNLOADDATA_H |
|
21 #define HTTPDOWNLOADDATA_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> |
|
26 #include <s32strm.h> |
|
27 |
|
28 // MACROS |
|
29 |
|
30 // COD Attribute length limits. Use these as maximum size in UI controls |
|
31 // displaying COD attributes. |
|
32 |
|
33 /// COD-Name maximum length. |
|
34 #define COD_NAME_MAX_LEN 40 |
|
35 /// COD-Vendor maximum length. |
|
36 #define COD_VENDOR_MAX_LEN 40 |
|
37 /// COD-Description maximum length. |
|
38 #define COD_DESCRIPTION_MAX_LEN 160 |
|
39 /// COD-URL maximum length. |
|
40 #define COD_URL_MAX_LEN 1024 |
|
41 /// COD-Size maximum length. |
|
42 #define COD_SIZE_MAX_LEN 6 |
|
43 /// COD-Type maximum length. |
|
44 #define COD_TYPE_MAX_LEN 40 |
|
45 /// COD-Install-Notify maximum length. |
|
46 #define COD_INSTALL_NOTIFY_MAX_LEN 1024 |
|
47 /// COD-Next-URL maximum length. |
|
48 #define COD_NEXT_URL_MAX_LEN 1024 |
|
49 /// COD-Next-URLatError maximum length. |
|
50 #define COD_NEXT_URL_AT_ERROR_MAX_LEN 1024 |
|
51 /// COD-Info-URL maximum length. |
|
52 #define COD_INFO_URL_MAX_LEN 1024 |
|
53 /// COD-Price maximum length. |
|
54 #define COD_PRICE_MAX_LEN 32 |
|
55 /// COD-Icon maximum length. |
|
56 #define COD_ICON_MAX_LEN 1024 |
|
57 /// COD-Version maximum length. |
|
58 #define COD_VERSION_MAX_LEN 40 |
|
59 /// COD-License maximum length (OMA 2) |
|
60 #define COD_LICENSE_MAX_LEN 1024 |
|
61 /// COD-Order maximum length (OMA 2) |
|
62 #define COD_ORDER_MAX_LEN 32 |
|
63 |
|
64 |
|
65 // CONSTANTS |
|
66 |
|
67 /// Granularity of the type list. |
|
68 LOCAL_D const TInt KTypeGranularity = 1; |
|
69 |
|
70 |
|
71 // TYPE DEFINITIONS |
|
72 |
|
73 // Media object states |
|
74 enum TMediaObjectState |
|
75 { |
|
76 EQueued = 0, //Media object download is queued |
|
77 EInProgress, //Download is in progress |
|
78 EFailed, //Download failed |
|
79 ESucceeded, //Download succeeded |
|
80 ETobeInstalled //Download completed but not moved |
|
81 }; |
|
82 |
|
83 |
|
84 // FORWARD DECLARATION |
|
85 class CDesC8ArrayFlat; |
|
86 class RWriteStream; |
|
87 class RReadStream; |
|
88 |
|
89 |
|
90 // CLASS DECLARATION |
|
91 |
|
92 /** |
|
93 * Media Data Base. |
|
94 */ |
|
95 NONSHARABLE_CLASS( CMediaDataBase ) : public CBase |
|
96 { |
|
97 |
|
98 public: // Constructors and destructor |
|
99 |
|
100 /** |
|
101 * Destructor. |
|
102 */ |
|
103 virtual ~CMediaDataBase() {} |
|
104 |
|
105 public: // Methods |
|
106 |
|
107 /** |
|
108 * Writes 'this' to the stream. |
|
109 */ |
|
110 virtual void ExternalizeL(RWriteStream& aStream) const = 0; |
|
111 |
|
112 /** |
|
113 * Initializes 'this' from stream. |
|
114 */ |
|
115 virtual void InternalizeL(RReadStream& aStream) = 0; |
|
116 |
|
117 public: // Getters |
|
118 |
|
119 /** |
|
120 * Get Name attribute. |
|
121 * @return Name. |
|
122 */ |
|
123 inline TPtrC Name() const { return *iName; } |
|
124 |
|
125 /** |
|
126 * Get Url attribute. |
|
127 * @return Url. |
|
128 */ |
|
129 inline TPtrC8 Url() const { return *iUrl; } |
|
130 |
|
131 /** |
|
132 * Get Size attribute. |
|
133 * @return Size. |
|
134 */ |
|
135 inline TInt Size() const { return iSize; } |
|
136 |
|
137 /** |
|
138 * Get media state attribute. |
|
139 * @return Size. |
|
140 */ |
|
141 inline TMediaObjectState State() const { return iState; } |
|
142 |
|
143 /** |
|
144 * Get Type attribute. |
|
145 * @return Type. |
|
146 */ |
|
147 inline TPtrC8 Type() const |
|
148 { |
|
149 if ( iTypes->MdcaCount() ) |
|
150 return iTypes->MdcaPoint( 0 ); |
|
151 return TPtrC8( KNullDesC8 ); |
|
152 } |
|
153 |
|
154 /** |
|
155 * Get Type attribute list. |
|
156 * @return Type list. |
|
157 */ |
|
158 inline const MDesC8Array& Types() const { return *iTypes; } |
|
159 |
|
160 /** |
|
161 * Get Icon attribute. |
|
162 * @return Icon. |
|
163 */ |
|
164 inline TPtrC8 Icon() const { return *iIcon; } |
|
165 |
|
166 /** |
|
167 * Get source URI. |
|
168 * @return Source URI. |
|
169 */ |
|
170 inline TPtrC8 SourceUri() const { return *iSourceUri; } |
|
171 |
|
172 /** |
|
173 * ProgressiveDownload (DD specific). |
|
174 * @return iProgressiveDl. |
|
175 */ |
|
176 inline TBool ProgressiveDownload() const { return iProgressiveDl; } |
|
177 |
|
178 /** |
|
179 * Check if aType appears in the type list. |
|
180 * @param aType Type to find. |
|
181 * @return ETrue if aType appears in the type list. |
|
182 */ |
|
183 inline TBool HasType( const TDesC8& aType ) const |
|
184 { |
|
185 TInt i; |
|
186 return 0 == iTypes->Find( aType, i, ECmpNormal ); |
|
187 } |
|
188 |
|
189 /** |
|
190 * Get number of elements in the type list. |
|
191 * @return Number of elements. |
|
192 */ |
|
193 inline TInt TypesCount() const { return iTypes->MdcaCount(); } |
|
194 |
|
195 /** |
|
196 * Get Redirected Url. |
|
197 * @return iRedirUrl. |
|
198 */ |
|
199 inline TPtrC8 RedirUrl() const { return *iRedirUrl; } |
|
200 |
|
201 /** |
|
202 * Get Method. |
|
203 * @return iMethod. |
|
204 */ |
|
205 inline TInt Method() const { return iMethod; } |
|
206 |
|
207 /** |
|
208 * Is Redirected? |
|
209 * @return iRedirected. |
|
210 */ |
|
211 inline TBool Redirected() const { return iRedirected; } |
|
212 |
|
213 /** |
|
214 * Get Destination Filename. |
|
215 * @return iDestFilename. |
|
216 */ |
|
217 inline TPtrC DestFilename() const { return *iDestFilename; } |
|
218 |
|
219 /** |
|
220 * Get Downloaded Size. |
|
221 * @return iDownloadedSize. |
|
222 */ |
|
223 inline TInt DownloadedSize() const { return iDownloadedSize; } |
|
224 |
|
225 /** |
|
226 * Get Destination Removable. |
|
227 * @return iDesRemovable. |
|
228 */ |
|
229 inline TBool DesRemovable() const { return iDesRemovable; } |
|
230 |
|
231 /** |
|
232 * Get Last Error Id. |
|
233 * @return iLastErrorId. |
|
234 */ |
|
235 inline TInt LastErrorId() const { return iLastErrorId; } |
|
236 |
|
237 /** |
|
238 * Get Global Error Id. |
|
239 * @return iGlobalErrorId. |
|
240 */ |
|
241 inline TInt GlobalErrorId() const { return iGlobalErrorId; } |
|
242 |
|
243 /** |
|
244 * Get Pausable attribute. |
|
245 * @return iPausable. |
|
246 */ |
|
247 inline TBool Pausable() const { return iPausable; } |
|
248 |
|
249 /** |
|
250 * Get size of this class including actual memory occupied by descriptors. |
|
251 * @return Bytes. |
|
252 */ |
|
253 virtual TInt Bytes() const = 0; |
|
254 |
|
255 /** |
|
256 * Gets the result of Media Object |
|
257 * @ return iResult |
|
258 */ |
|
259 inline TInt Result () const { return iResult; } |
|
260 |
|
261 /** |
|
262 * Get TempPath Filename. |
|
263 * @return iDestFilename. |
|
264 */ |
|
265 inline TPtrC TempFilename() const { return *iTempFilename; } |
|
266 |
|
267 public: // Setters |
|
268 |
|
269 /** |
|
270 * Set Name attribute. |
|
271 * @param Name. |
|
272 * @return ETrue if set, EFalse for invalid data. |
|
273 */ |
|
274 virtual TBool SetNameL( const TDesC& aName ) = 0; |
|
275 |
|
276 /** |
|
277 * Set Url attribute. |
|
278 * @param Url. |
|
279 * @return ETrue if set, EFalse for invalid data. |
|
280 */ |
|
281 virtual TBool SetUrlL( const TDesC8& aUrl ) = 0; |
|
282 |
|
283 /** |
|
284 * Set Size attribute. |
|
285 * @param Size. |
|
286 * @return ETrue if set, EFalse for invalid data. |
|
287 */ |
|
288 virtual TBool SetSize( TUint aSize ) = 0; |
|
289 |
|
290 /** |
|
291 * Set Type attribute (replace all). |
|
292 * @param Type. |
|
293 * @return ETrue if set, EFalse for invalid data. |
|
294 */ |
|
295 virtual TBool SetTypeL( const TDesC8& aType ) = 0; |
|
296 |
|
297 /** |
|
298 * Set Type attribute. |
|
299 * @param Type. |
|
300 * @return ETrue if set, EFalse for invalid data. |
|
301 */ |
|
302 virtual TBool AddTypeL( const TDesC8& aType ) = 0; |
|
303 |
|
304 /** |
|
305 * Reset the Type array. |
|
306 * @return Number of elements. |
|
307 */ |
|
308 virtual void ResetTypes() = 0; |
|
309 |
|
310 /** |
|
311 * Set Icon attribute. |
|
312 * @param Icon. |
|
313 */ |
|
314 virtual TBool SetIconL( const TDesC8& aIcon ) = 0; |
|
315 |
|
316 /** |
|
317 * Set source URI. |
|
318 * @param aSourceUri Source URI. |
|
319 */ |
|
320 virtual void SetSourceUriL( const TDesC8& aSourceUri ) = 0; |
|
321 |
|
322 /** |
|
323 * Set Progressive download attribute. |
|
324 * @param aProgressiveDl Progressive Download setting. |
|
325 */ |
|
326 virtual void SetProgressiveDownload( TBool aProgressiveDl ) = 0; |
|
327 |
|
328 /** |
|
329 * Set state attribute. |
|
330 * @param TMediaObjectState. |
|
331 * @return void. |
|
332 */ |
|
333 virtual void SetState( TMediaObjectState aState ) = 0; |
|
334 |
|
335 /** |
|
336 * Set result attribute. |
|
337 * @param aResult. |
|
338 * @return void. |
|
339 */ |
|
340 virtual void SetResult( TInt aResult ) = 0; |
|
341 |
|
342 /** |
|
343 * Set redir Url attribute. |
|
344 * @param aRedirUrl Redirected Url. |
|
345 * @return void. |
|
346 */ |
|
347 virtual TBool SetRedirUrlL( const TDesC8& aRedirUrl ) = 0; |
|
348 |
|
349 /** |
|
350 * Set method attribute. |
|
351 * @param aMethod Http request method. |
|
352 */ |
|
353 virtual void SetMethod( TInt aMethod ) = 0; |
|
354 |
|
355 /** |
|
356 * Set Progressive download attribute. |
|
357 * @param aRedirected Whether redirected or not. |
|
358 */ |
|
359 virtual void SetRedirected( TBool aRedirected ) = 0; |
|
360 |
|
361 /** |
|
362 * Set destination filename attribute. |
|
363 * @param aDestFilename Destination filename. |
|
364 * @return ETrue if set, EFalse for invalid data. |
|
365 */ |
|
366 virtual TBool SetDestFilenameL( const TDesC& aDestFilename ) = 0; |
|
367 |
|
368 /** |
|
369 * Set Temp filename attribute. |
|
370 * @param aTempFilename TempPath filename. |
|
371 * @return ETrue if set, EFalse for invalid data. |
|
372 */ |
|
373 virtual TBool SetTempFilenameL( const TDesC& aTempFilename ) = 0; |
|
374 |
|
375 /** |
|
376 * Set downloaded size attribute. |
|
377 * @param aDownloadedSize Downloaded size of the media object. |
|
378 * @return ETrue if set, EFalse for invalid data. |
|
379 */ |
|
380 virtual TBool SetDownloadedSize( TInt aDownloadedSize ) = 0; |
|
381 |
|
382 /** |
|
383 * Set destination removable attribute. |
|
384 * @param aDesRemovable Whether removable media drive. |
|
385 */ |
|
386 virtual void SetDesRemovable( TBool aDesRemovable ) = 0; |
|
387 |
|
388 /** |
|
389 * Set last error id attribute. |
|
390 * @param aLastErrorId Last error ID. |
|
391 */ |
|
392 virtual void SetLastErrorId( TInt aLastErrorId ) = 0; |
|
393 |
|
394 /** |
|
395 * Set global error id attribute. |
|
396 * @param aGlobalErrorId Global error ID. |
|
397 */ |
|
398 virtual void SetGlobalErrorId( TInt aGlobalErrorId ) = 0; |
|
399 |
|
400 /** |
|
401 * Set Pausable attribute. |
|
402 * @param aPausable Whether download pausable or not. |
|
403 */ |
|
404 virtual void SetPausable( TBool aPausable ) = 0; |
|
405 |
|
406 protected: // data |
|
407 |
|
408 HBufC* iName; ///< Media-Name. Owned. |
|
409 HBufC8* iUrl; ///< Media-URL. Owned. |
|
410 TUint iSize; ///< Media-Size. |
|
411 CDesC8ArrayFlat* iTypes; ///< Media-Types. Owned. |
|
412 HBufC8* iIcon; ///< Media-Icon. Owned. |
|
413 HBufC8* iSourceUri; ///< Source URI. Owned. |
|
414 TBool iProgressiveDl; ///< Progressive download. //for OMA 2 |
|
415 TMediaObjectState iState; ///< Media object state |
|
416 TInt iResult; |
|
417 HBufC8* iRedirUrl; ///< Media Redirected-URL. |
|
418 TInt iMethod; ///< Media Request-Method. |
|
419 TBool iRedirected; ///< Is Redirected? |
|
420 HBufC* iDestFilename; ///< Media Destination Filename. |
|
421 TInt iDownloadedSize; ///<The media track downloaded size.Should be equal to iSize when download completed successfully |
|
422 TBool iDesRemovable; ///< Is file stored on removable media? |
|
423 TInt iLastErrorId; ///< THttpDownloadMgrError. |
|
424 TInt iGlobalErrorId; ///< Global Error Id. |
|
425 TBool iPausable; ///< Is Media-Download Pausable? |
|
426 HBufC* iTempFilename; ///< Media Temp Filename. |
|
427 }; |
|
428 |
|
429 |
|
430 /** |
|
431 * Download Data Base. |
|
432 */ |
|
433 NONSHARABLE_CLASS( CDownloadDataBase ) : public CBase |
|
434 { |
|
435 |
|
436 public: // Constructors and destructor |
|
437 |
|
438 /** |
|
439 * Destructor. |
|
440 */ |
|
441 virtual ~CDownloadDataBase() {} |
|
442 |
|
443 /* |
|
444 *The MO count |
|
445 */ |
|
446 inline TInt Count() const { return iMediaArray.Count();} |
|
447 |
|
448 protected: // data |
|
449 |
|
450 HBufC* iName; ///< Download-Name. Name ( of the album ). |
|
451 TUint iSize; ///< Download-Size. Total size ( of all tracks in album ). |
|
452 HBufC8* iIcon; ///< Download-Icon. Owned. |
|
453 HBufC8* iUpdatedDDUri; ///< Updated DD URI |
|
454 RPointerArray<CMediaDataBase> iMediaArray; ///< Media objects |
|
455 |
|
456 }; |
|
457 |
|
458 #endif // HTTPDOWNLOADDATA_H |
|
459 |
|
460 // End of File |