|
1 /* |
|
2 * Copyright (c) 2002-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 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: Implements CDownloadDataServ |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef DOWNLOAD_DATA_SERV_H |
|
21 #define DOWNLOAD_DATA_SERV_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "HttpDownloadData.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * Media Data Server. |
|
35 */ |
|
36 NONSHARABLE_CLASS( CMediaDataServ ) : public CMediaDataBase |
|
37 { |
|
38 |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two-phased constructor - create object from stream. |
|
43 */ |
|
44 static CMediaDataServ* NewL(RReadStream& aStreamData); |
|
45 |
|
46 /** |
|
47 * Two-phased constructor - create object from stream. |
|
48 */ |
|
49 static CMediaDataServ* NewL(const TDesC8& aStreamData); |
|
50 |
|
51 /** |
|
52 * Destructor. |
|
53 */ |
|
54 ~CMediaDataServ(); |
|
55 |
|
56 public: // Methods |
|
57 |
|
58 /** |
|
59 * Writes 'this' to the stream. |
|
60 */ |
|
61 void ExternalizeL(RWriteStream& aStream) const; |
|
62 |
|
63 /** |
|
64 * Initializes 'this' from stream. |
|
65 */ |
|
66 virtual void InternalizeL(RReadStream& aStream); |
|
67 |
|
68 public: // Getters |
|
69 |
|
70 /** |
|
71 * Get size of this class including actual memory occupied by descriptors. |
|
72 * @return Bytes. |
|
73 */ |
|
74 TInt Bytes() const; |
|
75 |
|
76 public: // Setters |
|
77 |
|
78 /** |
|
79 * Set Name attribute. |
|
80 * @param Name. |
|
81 * @return ETrue if set, EFalse for invalid data. |
|
82 */ |
|
83 TBool SetNameL( const TDesC& aName ); |
|
84 |
|
85 /** |
|
86 * Set Url attribute. |
|
87 * @param Url. |
|
88 * @return ETrue if set, EFalse for invalid data. |
|
89 */ |
|
90 TBool SetUrlL( const TDesC8& aUrl ); |
|
91 |
|
92 /** |
|
93 * Set Size attribute. |
|
94 * @param Size. |
|
95 * @return ETrue if set, EFalse for invalid data. |
|
96 */ |
|
97 TBool SetSize( TUint aSize ); |
|
98 |
|
99 /** |
|
100 * Set Type attribute (replace all). |
|
101 * @param Type. |
|
102 * @return ETrue if set, EFalse for invalid data. |
|
103 */ |
|
104 TBool SetTypeL( const TDesC8& aType ); |
|
105 |
|
106 /** |
|
107 * Set Type attribute. |
|
108 * @param Type. |
|
109 * @return ETrue if set, EFalse for invalid data. |
|
110 */ |
|
111 TBool AddTypeL( const TDesC8& aType ); |
|
112 |
|
113 /** |
|
114 * Reset the Type array. |
|
115 * @return Number of elements. |
|
116 */ |
|
117 void ResetTypes(); |
|
118 |
|
119 /** |
|
120 * Set Icon attribute. |
|
121 * @param Icon. |
|
122 */ |
|
123 TBool SetIconL( const TDesC8& aIcon ); |
|
124 |
|
125 /** |
|
126 * Set source URI. |
|
127 * @param aSourceUri Source URI. |
|
128 */ |
|
129 void SetSourceUriL( const TDesC8& aSourceUri ); |
|
130 |
|
131 /** |
|
132 * Set Progressive download attribute. |
|
133 * @param aProgressiveDl Progressive Download setting. |
|
134 */ |
|
135 void SetProgressiveDownload( TBool aProgressiveDl ); |
|
136 |
|
137 /** |
|
138 * Set state attribute. |
|
139 * @param TMediaObjectState. |
|
140 * @return void. |
|
141 */ |
|
142 void SetState( TMediaObjectState aState ); |
|
143 |
|
144 /** |
|
145 * Set result attribute. |
|
146 * @param aResult. |
|
147 * @return void. |
|
148 */ |
|
149 void SetResult( TInt aResult ); |
|
150 |
|
151 /** |
|
152 * Set redir Url attribute. |
|
153 * @param aRedirUrl Redirected Url. |
|
154 * @return ETrue if set, EFalse for invalid data. |
|
155 */ |
|
156 TBool SetRedirUrlL( const TDesC8& aRedirUrl ); |
|
157 |
|
158 /** |
|
159 * Set method attribute. |
|
160 * @param aMethod Http request method. |
|
161 */ |
|
162 void SetMethod( TInt aMethod ); |
|
163 |
|
164 /** |
|
165 * Set Progressive download attribute. |
|
166 * @param aRedirected Whether redirected or not. |
|
167 */ |
|
168 void SetRedirected( TBool aRedirected ); |
|
169 |
|
170 /** |
|
171 * Set destination filename attribute. |
|
172 * @param aDestFilename Destination filename. |
|
173 * @return ETrue if set, EFalse for invalid data. |
|
174 */ |
|
175 TBool SetDestFilenameL( const TDesC& aDestFilename ); |
|
176 |
|
177 /** |
|
178 * Set downloaded size attribute. |
|
179 * @param aDownloadedSize Downloaded size of the media object. |
|
180 * @return ETrue if set, EFalse for invalid data. |
|
181 */ |
|
182 TBool SetDownloadedSize( TInt aDownloadedSize ); |
|
183 |
|
184 /** |
|
185 * Set destination removable attribute. |
|
186 * @param aDesRemovable Whether removable media drive. |
|
187 */ |
|
188 void SetDesRemovable( TBool aDesRemovable ); |
|
189 |
|
190 /** |
|
191 * Set last error id attribute. |
|
192 * @param aLastErrorId Last error ID. |
|
193 */ |
|
194 void SetLastErrorId( TInt aLastErrorId ); |
|
195 |
|
196 /** |
|
197 * Set global error id attribute. |
|
198 * @param aGlobalErrorId Global error ID. |
|
199 */ |
|
200 void SetGlobalErrorId( TInt aGlobalErrorId ); |
|
201 |
|
202 /** |
|
203 * Set Pausable attribute. |
|
204 * @param aPausable Whether download pausable or not. |
|
205 */ |
|
206 void SetPausable( TBool aPausable ); |
|
207 |
|
208 /** |
|
209 * Set Temp filename attribute. |
|
210 * @param aTempFilename TempPath filename. |
|
211 * @return ETrue if set, EFalse for invalid data. |
|
212 */ |
|
213 TBool SetTempFilenameL( const TDesC& aTempFilename ); |
|
214 |
|
215 private: // implementation details |
|
216 |
|
217 /** |
|
218 * Common setter for string attributes, with overflow check. |
|
219 * @param aBuf Buffer to set. |
|
220 * @param aString String to set. |
|
221 * @param aMaxLength Max length to check. |
|
222 * @return ETrue if set, EFalse for invalid data. |
|
223 */ |
|
224 TBool SetStringAttrL |
|
225 ( HBufC*& aBuf, const TDesC& aString, TInt aMaxLength ); |
|
226 |
|
227 /** |
|
228 * Common setter for string attributes, with overflow check. |
|
229 * @param aBuf Buffer to set. |
|
230 * @param aString String to set. |
|
231 * @param aMaxLength Max length to check. |
|
232 * @return ETrue if set, EFalse for invalid data. |
|
233 */ |
|
234 TBool SetStringAttrL |
|
235 ( HBufC8*& aBuf, const TDesC& aString, TInt aMaxLength ); |
|
236 |
|
237 /** |
|
238 * Common setter for string attributes, with overflow check. |
|
239 * @param aBuf Buffer to set. |
|
240 * @param aString String to set. |
|
241 * @param aMaxLength Max length to check. |
|
242 * @return ETrue if set, EFalse for invalid data. |
|
243 */ |
|
244 TBool SetStringAttrL |
|
245 ( HBufC8*& aBuf, const TDesC8& aString, TInt aMaxLength ); |
|
246 |
|
247 protected: // Constructors and destructor |
|
248 |
|
249 /** |
|
250 * Constructor. |
|
251 */ |
|
252 CMediaDataServ(){} |
|
253 |
|
254 }; |
|
255 |
|
256 |
|
257 /** |
|
258 * Download Data Server - Abstract Class. |
|
259 */ |
|
260 NONSHARABLE_CLASS( CDownloadDataServ ) : public CDownloadDataBase |
|
261 { |
|
262 |
|
263 public: // Constructors and destructor |
|
264 |
|
265 /** |
|
266 * Two-phased constructor - create object from stream. |
|
267 */ |
|
268 static CDownloadDataServ* NewL(const TDesC8& aStreamData); |
|
269 |
|
270 /** |
|
271 * Destructor. |
|
272 */ |
|
273 ~CDownloadDataServ(); |
|
274 |
|
275 public: // Methods |
|
276 |
|
277 /** |
|
278 * Initializes 'this' from stream. |
|
279 */ |
|
280 void InternalizeL(RReadStream& aStream); |
|
281 |
|
282 public: // Methods to manage media data |
|
283 |
|
284 /** |
|
285 * Append given media object to the array |
|
286 * @return media object |
|
287 */ |
|
288 CMediaDataBase* operator[]( TInt aIndex ); |
|
289 |
|
290 /** |
|
291 * Append given media object to the array |
|
292 * @return media object |
|
293 */ |
|
294 CMediaDataBase* operator[]( TInt aIndex ) const; |
|
295 |
|
296 public: // Getters |
|
297 |
|
298 /** |
|
299 * Get the Count of number of elements in Media Array. |
|
300 */ |
|
301 inline TInt Count( ){ return iMediaArray.Count(); } |
|
302 |
|
303 /** |
|
304 * Get Album name attribute. |
|
305 * @return Name. |
|
306 */ |
|
307 inline TPtrC Name() const { return *iName; } |
|
308 |
|
309 public: // Setters |
|
310 |
|
311 /** |
|
312 * Set Album Name attribute. |
|
313 * @param Name. |
|
314 * @return ETrue if set, EFalse for invalid data. |
|
315 */ |
|
316 TBool SetNameL( const TDesC& aName ); |
|
317 |
|
318 private: // implementation details |
|
319 |
|
320 /** |
|
321 * Common setter for string attributes, with overflow check. |
|
322 * @param aBuf Buffer to set. |
|
323 * @param aString String to set. |
|
324 * @param aMaxLength Max length to check. |
|
325 * @return ETrue if set, EFalse for invalid data. |
|
326 */ |
|
327 TBool SetStringAttrL |
|
328 ( HBufC*& aBuf, const TDesC& aString, TInt aMaxLength ); |
|
329 |
|
330 /** |
|
331 * Common setter for string attributes, with overflow check. |
|
332 * @param aBuf Buffer to set. |
|
333 * @param aString String to set. |
|
334 * @param aMaxLength Max length to check. |
|
335 * @return ETrue if set, EFalse for invalid data. |
|
336 */ |
|
337 TBool SetStringAttrL |
|
338 ( HBufC8*& aBuf, const TDesC& aString, TInt aMaxLength ); |
|
339 |
|
340 /** |
|
341 * Common setter for string attributes, with overflow check. |
|
342 * @param aBuf Buffer to set. |
|
343 * @param aString String to set. |
|
344 * @param aMaxLength Max length to check. |
|
345 * @return ETrue if set, EFalse for invalid data. |
|
346 */ |
|
347 TBool SetStringAttrL |
|
348 ( HBufC8*& aBuf, const TDesC8& aString, TInt aMaxLength ); |
|
349 |
|
350 protected: // Constructors and destructor |
|
351 |
|
352 /** |
|
353 * Constructor. |
|
354 */ |
|
355 CDownloadDataServ(){} |
|
356 |
|
357 }; |
|
358 |
|
359 |
|
360 #endif // DOWNLOAD_DATA_SERV_H |
|
361 |
|
362 // End of File |