|
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 one download in DownloadManager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef HTTPDOWNLOAD_H |
|
21 #define HTTPDOWNLOAD_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "HttpClientAppInstance.h" |
|
25 #include "HttpConnHandler.h" |
|
26 #include "DownloadDataServ.h" |
|
27 |
|
28 #include <HttpDownloadMgrCommon.h> |
|
29 #include <e32base.h> |
|
30 #include <es_sock.h> |
|
31 #include <http.h> |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KDownloadNameMaxSize = 256; |
|
35 |
|
36 // MACROS |
|
37 //#define ?macro ?macro_def |
|
38 |
|
39 // DATA TYPES |
|
40 //enum ?declaration |
|
41 //typedef ?declaration |
|
42 //extern ?data_type; |
|
43 |
|
44 // FUNCTION PROTOTYPES |
|
45 //?type ?function_name(?arg_list); |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 |
|
49 // CLASS DECLARATION |
|
50 class RFs; |
|
51 class RFile; |
|
52 class CFileMan; |
|
53 class CHeaderField; |
|
54 class CHttpStorage; |
|
55 |
|
56 |
|
57 /** |
|
58 * ?one_line_short_description. |
|
59 * ?other_description_lines |
|
60 * |
|
61 * @lib ?library |
|
62 * @since Series 60 v2.8 |
|
63 */ |
|
64 NONSHARABLE_CLASS( CHttpDownload ): public CActive |
|
65 , public MConnectionCallback |
|
66 , public MHTTPTransactionCallback |
|
67 { |
|
68 public: // Constructors and destructor |
|
69 |
|
70 /** |
|
71 * Two-phased constructor. |
|
72 */ |
|
73 static CHttpDownload* NewL( const TDesC8& aUrl, |
|
74 CHttpClientApp *aClientApp, |
|
75 TInt32 aId, |
|
76 CHttpClientAppInstance* aClientAppInstance = NULL ); |
|
77 |
|
78 /** |
|
79 * Destructor. |
|
80 */ |
|
81 virtual ~CHttpDownload(); |
|
82 |
|
83 public: // New functions |
|
84 |
|
85 /** |
|
86 * Starts download process. |
|
87 * @since Series 60 v3.2 |
|
88 * @return none. |
|
89 */ |
|
90 IMPORT_C void Attach( CHttpClientAppInstance* aClientAppInstance ); |
|
91 |
|
92 /** |
|
93 * Starts download process. |
|
94 * @since Series 60 v2.8 |
|
95 * @return none. Leaves on error. |
|
96 */ |
|
97 IMPORT_C void StartL(); |
|
98 |
|
99 /** |
|
100 * Pauses the download process. |
|
101 * @since Series 60 v2.8 |
|
102 * @param bStore if ETrue download state is stored into file |
|
103 * @return none. Leaves on error. |
|
104 */ |
|
105 IMPORT_C void PauseL( TBool bStore = EFalse ); |
|
106 |
|
107 /** |
|
108 * Resets to the download. |
|
109 * @since Series 60 v2.8 |
|
110 * @return none. |
|
111 */ |
|
112 IMPORT_C void Reset(); |
|
113 |
|
114 /** |
|
115 * Deletes the download. Every reference to this object |
|
116 * becomes invalid after this function returns. |
|
117 * @since Series 60 v2.8 |
|
118 * @return none. |
|
119 */ |
|
120 IMPORT_C void Delete( CHttpClientAppInstance* aClAppInstance ); |
|
121 |
|
122 /** |
|
123 * Deletes the info file associated with the download. |
|
124 * This can be called only after the download is completed, |
|
125 * since deletion of the file is illegal when the download is not yet complete. |
|
126 * @since Series 60 v3.2 |
|
127 * @return none. |
|
128 */ |
|
129 IMPORT_C void DeleteInfoFile( CHttpClientAppInstance* aClAppInstance ); |
|
130 |
|
131 /** |
|
132 * Moves/renames download content file. Destination can be |
|
133 * specified with EDlAttrDestFilename |
|
134 * @since Series 60 v2.8 |
|
135 * @param none |
|
136 * @return none. Leaves on error: |
|
137 * KErrNotReady - if download is not completed yet |
|
138 * KErrInUse - if move is in progress |
|
139 */ |
|
140 IMPORT_C void MoveL(); |
|
141 |
|
142 /** |
|
143 * Gets the value for a TInt attribute. |
|
144 * @param aAttribute Identifies the attribute to be retrived. |
|
145 * @param aValue On completion, contains the requested TInt attribute. |
|
146 * @return void. Leaves on error: |
|
147 * - KErrArgument if requested attribute is unknown or not integer |
|
148 */ |
|
149 IMPORT_C void GetIntAttributeL( THttpDownloadAttrib aAttribute, |
|
150 TInt32& aValue ); |
|
151 |
|
152 /** |
|
153 * Gets the value for a TBool attribute. |
|
154 * @param aAttribute Identifies the attribute to be retrived. |
|
155 * @param aValue On completion, contains the requested TBool attribute. |
|
156 * @return void. Leaves on error: |
|
157 * - KErrArgument if requested attribute is unknown or not boolean |
|
158 */ |
|
159 IMPORT_C void GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
|
160 TBool& aValue ); |
|
161 |
|
162 /** |
|
163 * Gets the value for a string attribute. |
|
164 * @param aAttribute Identifies the attribute to be retrived. |
|
165 * @param aValue On completion, contains the requested string. Use a 16-bit descriptor! |
|
166 * @return void. Leaves on error: |
|
167 * - KErrArgument if requested attribute is unknown or not string |
|
168 * - KErrNotFound if requested attribute is not initialized. This can make |
|
169 * easier to differentiate between that string is zero length or not allocated yet. |
|
170 */ |
|
171 IMPORT_C HBufC* GetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
172 TBool& aDelete ); |
|
173 |
|
174 /** |
|
175 * Gets the value for a string attribute. |
|
176 * @param aAttribute Identifies the attribute to be retrived. |
|
177 * @param aValue On completion, contains the requested string. Use a 16-bit descriptor! |
|
178 * @return void. Leaves on error: |
|
179 * - KErrArgument if requested attribute is unknown or not string |
|
180 * - KErrNotFound if requested attribute is not initialized. This can make it |
|
181 * easier to differentiate between that string is zero length or not allocated yet. |
|
182 */ |
|
183 IMPORT_C HBufC8* GetString8AttributeL( THttpDownloadAttrib aAttribute, |
|
184 TBool& aDelete ); |
|
185 |
|
186 /** |
|
187 * |
|
188 */ |
|
189 IMPORT_C RFile* GetFileHandleAttributeL(); |
|
190 |
|
191 /** |
|
192 * Sets the value for a TInt attribute. |
|
193 * @param aAttribute Identifies the attribute to be set. |
|
194 * @param aValue The value to be set. |
|
195 * @return void. Leaves on error: |
|
196 * - KErrArgument if requested attribute is unknown or not integer |
|
197 */ |
|
198 IMPORT_C void SetIntAttributeL( THttpDownloadAttrib aAttribute, |
|
199 const TInt32 aValue ); |
|
200 |
|
201 /** |
|
202 * Sets the value for a TBool attribute. |
|
203 * This method can be used to stop a connection (KConnectionStop). |
|
204 * @param aAttribute Identifies the attribute to be set. |
|
205 * @param aValue The value to be set. |
|
206 * @return void. Leaves on error: |
|
207 * - KErrArgument if requested attribute is unknown or not boolean |
|
208 */ |
|
209 IMPORT_C void SetBoolAttributeL( THttpDownloadAttrib aAttribute, |
|
210 const TBool aValue ); |
|
211 |
|
212 /** |
|
213 * Sets the value for a string attribute. |
|
214 * @param aAttribute Identifies the attribute to be set. |
|
215 * @param aValue The string value to be set. Must be a 16-bit descriptor!. |
|
216 * @return void. Leaves on error: |
|
217 * - KErrArgument if requested attribute is unknown or not string |
|
218 */ |
|
219 IMPORT_C void SetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
220 const TDesC16& aValue ); |
|
221 |
|
222 /** |
|
223 * Sets the value for a string attribute. |
|
224 * @param aAttribute Identifies the attribute to be set. |
|
225 * @param aValue The string value to be set. Must be a 16-bit descriptor!. |
|
226 * @return void. Leaves on error: |
|
227 * - KErrArgument if requested attribute is unknown or not string |
|
228 */ |
|
229 IMPORT_C void SetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
230 const TDesC8& aValue ); |
|
231 |
|
232 /** |
|
233 * |
|
234 */ |
|
235 IMPORT_C void SetFileHandleAttributeL( RFile* aFile ); |
|
236 |
|
237 /** |
|
238 * Returns the associated client application instance. |
|
239 * @since Series 60 v2.8 |
|
240 * @return associated client application instance |
|
241 */ |
|
242 IMPORT_C CHttpClientAppInstance* ClientAppInstance() const; |
|
243 |
|
244 /** |
|
245 * Called only from the server when a leave trapped. |
|
246 * This is the place where client app can be informed |
|
247 * about this error if not done before. |
|
248 * @since Series 60 v2.8 |
|
249 * @param aError Error code from a previous leave |
|
250 * @return none |
|
251 */ |
|
252 IMPORT_C void OnError( TInt aError, |
|
253 THttpDownloadMgrError aDlError = EGeneral ); |
|
254 |
|
255 /** |
|
256 * Gets the value for a TInt attribute. |
|
257 * @param aAttribute Identifies the attribute to be retrived. |
|
258 * @param aMoIndex Identifies the media object index. |
|
259 * @param aValue On completion, contains the requested TInt attribute. |
|
260 * @return void. Leaves on error: |
|
261 * - KErrArgument if requested attribute is unknown or not integer |
|
262 */ |
|
263 IMPORT_C void GetIntAttributeL( THttpDownloadAttrib aAttribute, |
|
264 TInt32& aMoIndex, |
|
265 TInt32& aValue ); |
|
266 |
|
267 /** |
|
268 * Gets the value for a TBool attribute. |
|
269 * @param aAttribute Identifies the attribute to be retrived. |
|
270 * @param aMoIndex Identifies the media object index. |
|
271 * @param aValue On completion, contains the requested TBool attribute. |
|
272 * @return void. Leaves on error: |
|
273 * - KErrArgument if requested attribute is unknown or not boolean |
|
274 */ |
|
275 IMPORT_C void GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
|
276 TInt32& aMoIndex, |
|
277 TBool& aValue ); |
|
278 |
|
279 /** |
|
280 * Gets the value for a string attribute. |
|
281 * @param aAttribute Identifies the attribute to be retrived. |
|
282 * @param aMoIndex Identifies the media object index. |
|
283 * @param aValue On completion, contains the requested string. Use a 16-bit descriptor! |
|
284 * @return void. Leaves on error: |
|
285 * - KErrArgument if requested attribute is unknown or not string |
|
286 * - KErrNotFound if requested attribute is not initialized. This can make |
|
287 * easier to differentiate between that string is zero length or not allocated yet. |
|
288 */ |
|
289 IMPORT_C HBufC* GetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
290 TInt32& aMoIndex, |
|
291 TBool& aDelete ); |
|
292 |
|
293 /** |
|
294 * Gets the value for a string attribute. |
|
295 * @param aAttribute Identifies the attribute to be retrived. |
|
296 * @param aMoIndex Identifies the media object index. |
|
297 * @param aValue On completion, contains the requested string. Use a 16-bit descriptor! |
|
298 * @return void. Leaves on error: |
|
299 * - KErrArgument if requested attribute is unknown or not string |
|
300 * - KErrNotFound if requested attribute is not initialized. This can make it |
|
301 * easier to differentiate between that string is zero length or not allocated yet. |
|
302 */ |
|
303 IMPORT_C HBufC8* GetString8AttributeL( THttpDownloadAttrib aAttribute, |
|
304 TInt32& aMoIndex, |
|
305 TBool& aDelete ); |
|
306 |
|
307 /** |
|
308 * Sets the value for a string attribute. |
|
309 * @param aAttribute Identifies the attribute to be set. |
|
310 * @param aMOIndex - media object index. |
|
311 * @param aValue The string value to be set. Must be a 16-bit descriptor!. |
|
312 * @return void. Leaves on error: |
|
313 * - KErrArgument if requested attribute is unknown or not string |
|
314 */ |
|
315 IMPORT_C void SetStringAttributeL( THttpDownloadAttrib aAttribute, const TInt32 aMOIndex, |
|
316 const TDesC16& aValue ); |
|
317 |
|
318 /** |
|
319 * Sets the Download data (media info). |
|
320 */ |
|
321 IMPORT_C void SetDownloadDataAttributeL(HBufC8* dlData); |
|
322 |
|
323 /** |
|
324 * Sets the media object data (track info). |
|
325 */ |
|
326 IMPORT_C void SetTrackDataAttributeL(TInt aIndex, HBufC8* dlData); |
|
327 |
|
328 /** |
|
329 * Detach the given client instance from the download. |
|
330 * @param aInstance client app instance to be detached |
|
331 * @return ETrue if download is still attached to another instance |
|
332 */ |
|
333 IMPORT_C TBool DetachClientInstance( CHttpClientAppInstance* aInstance ); |
|
334 |
|
335 /** |
|
336 * Return the client application where this download is created. |
|
337 * @since Series 60 v2.8 |
|
338 * @return client application where this download is created |
|
339 */ |
|
340 CHttpClientApp* ClientApp() const; |
|
341 |
|
342 /** |
|
343 * Returns the associated PD client application instance. |
|
344 * @since Series 60 v3.2 |
|
345 * @return associated PD client application instance |
|
346 */ |
|
347 CHttpClientAppInstance* PDClientAppInstance() const; |
|
348 |
|
349 /** |
|
350 * Returns the unique download id. |
|
351 * @since Series 60 v2.8 |
|
352 * @return unique id of this download |
|
353 */ |
|
354 TInt Id() const; |
|
355 |
|
356 /** |
|
357 * Returns the state of this download. |
|
358 * @since Series 60 v2.8 |
|
359 * @return state of this download |
|
360 */ |
|
361 THttpDownloadState State() const; |
|
362 |
|
363 /** |
|
364 * Returns the progress state of the download. |
|
365 * @since Series 60 v2.8 |
|
366 * @return progress state of this download |
|
367 */ |
|
368 THttpProgressState ProgState() const; |
|
369 |
|
370 /** |
|
371 * Returns associated connection handler. |
|
372 * @since Series 60 v2.8 |
|
373 * @return associated connection handler |
|
374 */ |
|
375 CHttpConnHandler* ConnHandler() const; |
|
376 |
|
377 /** |
|
378 * Return EDlAttrNoMedia |
|
379 * @since Series 60 v2.8 |
|
380 * @return ETrue if media is removed |
|
381 */ |
|
382 TBool NoMedia() const; |
|
383 |
|
384 /** |
|
385 * Called when media card removed. |
|
386 * @since Series 60 v2.8 |
|
387 * @return none. |
|
388 */ |
|
389 void MediaRemoved( TUint aUid, TBool aDontCheckMediaUid = EFalse ); |
|
390 |
|
391 /** |
|
392 * Called when media card inserted. |
|
393 * @since Series 60 v2.8 |
|
394 * @return none. |
|
395 */ |
|
396 void MediaInserted( TUint aUid ); |
|
397 |
|
398 /** |
|
399 * Returns the current download destination drive id. |
|
400 * @since Series 60 v2.8 |
|
401 * @return none. |
|
402 */ |
|
403 TInt GetDestinationDriveID() const; |
|
404 |
|
405 /** |
|
406 * Associates download with the given client instance. |
|
407 * @since Series 60 v2.8 |
|
408 * @param aInstance client instance this download to be associated with |
|
409 * @param aNoMoveEvent if ETrue move event disabled |
|
410 * @return none. |
|
411 */ |
|
412 void SetClientInstance( CHttpClientAppInstance* aInstance, |
|
413 TBool aNoMoveEvent = EFalse ); |
|
414 |
|
415 |
|
416 /** |
|
417 * Associates download with the given connection handler |
|
418 * @since Series 60 v2.8 |
|
419 * @param aConnHandler connection handler this download to be associated with |
|
420 * @return ?description |
|
421 */ |
|
422 void SetConnHandler( CHttpConnHandler* aConnHandler ); |
|
423 |
|
424 /** |
|
425 * Returns pausable state of the download |
|
426 */ |
|
427 TBool Pausable() const; |
|
428 |
|
429 /** |
|
430 * Sets a new download name. Triggers EHttpProgDlNameChanged event. |
|
431 * @param aNewName new download name |
|
432 * @return none. Leaves on error. |
|
433 */ |
|
434 void SetDownloadNameL( const TDesC& aNewName ); |
|
435 |
|
436 void Ref() { ++iRefCount; } |
|
437 |
|
438 void Deref() { if( --iRefCount == 0 ) delete this; } |
|
439 |
|
440 public: // Functions from base classes |
|
441 |
|
442 /** |
|
443 * methods from MHTTPTransactionCallback |
|
444 */ |
|
445 virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
446 virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
447 |
|
448 /** |
|
449 * methods from CActive |
|
450 */ |
|
451 virtual void DoCancel(); |
|
452 virtual void RunL(); |
|
453 virtual TInt RunError(TInt aError); |
|
454 |
|
455 /** |
|
456 * methods from MConnectionCallback |
|
457 */ |
|
458 void Connected(); |
|
459 void Suspended(); |
|
460 void Disconnected(); |
|
461 void ConnectionFailed( TInt aError ); |
|
462 |
|
463 protected: // New functions |
|
464 |
|
465 /** |
|
466 * Does real reset on download |
|
467 * @since Series 60 v2.8 |
|
468 * @param aOnDelete if ETrue function called on delete |
|
469 * @return none. |
|
470 */ |
|
471 void DoReset( TBool aOnDelete = EFalse ); |
|
472 |
|
473 /** |
|
474 * Stores download info into file. |
|
475 * @since Series 60 v2.8 |
|
476 * @return none. Leave on error. |
|
477 */ |
|
478 void StoreDownloadInfoL(); |
|
479 |
|
480 /** |
|
481 * Loads download info from file. |
|
482 * @since Series 60 v2.8 |
|
483 * @return none. Leaves on failure. |
|
484 */ |
|
485 void LoadDownloadInfoL(); |
|
486 |
|
487 /** |
|
488 * Checks that (if known) that content |
|
489 * is still valid or expired. |
|
490 * @since Series Series60 |
|
491 * @return ETrue if content is expired |
|
492 */ |
|
493 TBool IsExpired(); |
|
494 |
|
495 /** |
|
496 * Called if download completed. |
|
497 * @since Series 60 v2.8 |
|
498 * @param ?arg1 ?description |
|
499 * @return ?description |
|
500 */ |
|
501 void OnCompletedL(); |
|
502 |
|
503 |
|
504 /** |
|
505 * Checks that if content type is of file storage type |
|
506 * @return ETrue if content is of file storage type |
|
507 */ |
|
508 TBool IsContentFileStorageType(); |
|
509 |
|
510 /** |
|
511 * Reinitialize download. |
|
512 * @since Series 60 v2.8 |
|
513 */ |
|
514 void ReInitializeDownload(); |
|
515 |
|
516 /** |
|
517 * Cancels transaction. |
|
518 * @since Series 60 v2.8 |
|
519 * @return none. |
|
520 */ |
|
521 void CancelTransaction(); |
|
522 |
|
523 /** |
|
524 * Pauses the download process. |
|
525 * @since Series 60 v2.8 |
|
526 * @param aDisconnect if ETrue download disconnects |
|
527 * @return none. Leaves on error. |
|
528 */ |
|
529 void InternalPauseL( TBool aDisconnect = EFalse ); |
|
530 |
|
531 /** |
|
532 * Set download status and calls event callback function. |
|
533 * @since Series 60 v2.8 |
|
534 * @param aProgState see THttpProgressState |
|
535 * @param aStatus see THttpDownloadState |
|
536 * @param aErrorId see THttpDownloadMgrError |
|
537 * @param aGlobalErrorId global error id |
|
538 * @return none. |
|
539 */ |
|
540 void SetDownloadStatus( THttpProgressState aProgState, |
|
541 THttpDownloadState aStatus = EHttpDlInprogress, |
|
542 THttpDownloadMgrError aErrorId = ENoError, |
|
543 TInt aGlobalErrorId = KErrUnknown ); |
|
544 |
|
545 /** |
|
546 * Called when response header received. |
|
547 * @since Series 60 v2.8 |
|
548 * @return none. Leaves on error. |
|
549 */ |
|
550 void ResponseHeaderReceivedL(); |
|
551 |
|
552 /** |
|
553 * Called when a new body chunk received. |
|
554 * @since Series 60 v2.8 |
|
555 * @return none. Leaves on error. |
|
556 */ |
|
557 void ResponseBodyReceivedL( const TDesC8& aBuf ); |
|
558 |
|
559 /** |
|
560 * Start connection creation process. |
|
561 * @since Series 60 v2.8 |
|
562 * @return none. Leaves on error. |
|
563 */ |
|
564 void Connect(); |
|
565 |
|
566 /** |
|
567 * Disconnects download from the network. |
|
568 * @since Series 60 v2.8 |
|
569 * @return none. |
|
570 */ |
|
571 void Disconnect(); |
|
572 |
|
573 /** |
|
574 * Requesting header. |
|
575 * @param aStringPool stringpool of HTTP session |
|
576 * @param aHeaders request header of the transaction |
|
577 * @param ETrue if HEAD method used. |
|
578 * @return none. Leaves on error. |
|
579 */ |
|
580 void SetRequestHeaderL( RStringPool& aStringPool, |
|
581 RHTTPHeaders& aHeaders, |
|
582 TBool aHeadMethod ); |
|
583 |
|
584 /** |
|
585 * Disables pipelining of the transaction. |
|
586 * @since Series 60 v2.8 |
|
587 * @param aStringPool stringpool of HTTP session |
|
588 * @return none. Leaves on error. |
|
589 */ |
|
590 void DisablePipeliningL( RStringPool& aStringPool ); |
|
591 |
|
592 /** |
|
593 * Sets transaction property. |
|
594 * @param aStringPool stringpool of HTTP session |
|
595 * @param aPropertyName name of the property |
|
596 * @param aToken property value |
|
597 * @return none. Leaves on error. |
|
598 */ |
|
599 void SetPropertyL( RStringPool& aStringPool, |
|
600 RStringF aPropertyName, |
|
601 const TDesC8& aToken ); |
|
602 |
|
603 /** |
|
604 * Sets transaction property. |
|
605 * @param aPropertyName name of the property |
|
606 * @param aValue property value |
|
607 * @return none. Leaves on error. |
|
608 */ |
|
609 void SetPropertyL( RStringF aPropertyName, |
|
610 const TInt aValue ); |
|
611 |
|
612 /** |
|
613 * Add client app's own fields to request header |
|
614 * @since Series 60 v2.8 |
|
615 * @param aStringPool stringpool of HTTP session |
|
616 * @param aHeaders request header of the transaction |
|
617 * @return none. Leaves of error |
|
618 */ |
|
619 void SetRequestHeaderAddOnL( RStringPool& aStringPool, |
|
620 RHTTPHeaders& aHeaders ); |
|
621 /** |
|
622 * Set credential properties of transaction |
|
623 * @since Series 60 v2.8 |
|
624 * @param aStringPool stringpool of HTTP session |
|
625 * @return none. Leaves of error |
|
626 */ |
|
627 void SetCredentialsInfoL( RStringPool& aStringPool ); |
|
628 |
|
629 /** |
|
630 * Set 'Range' field in request header. |
|
631 * @since Series 60 v2.8 |
|
632 * @param aStringPool stringpool of HTTP session |
|
633 * @param aHeaders request header of the transaction |
|
634 * @return none. Leaves of error |
|
635 */ |
|
636 void SetRangeFieldL( RStringPool& aStringPool, |
|
637 RHTTPHeaders& aHeaders ); |
|
638 |
|
639 /** |
|
640 * Sets the given header field with the expire value |
|
641 * @since Series 60 v2.8 |
|
642 * @param aField header field to be set |
|
643 * @param aHeaders request header of the transaction |
|
644 * @return ?description |
|
645 */ |
|
646 void SetExpireToFieldL( RStringF& aField, |
|
647 RStringPool& aStringPool, |
|
648 RHTTPHeaders& aHeaders ); |
|
649 |
|
650 /** |
|
651 * Rebuilds the url with scheme and port |
|
652 * @since Series 60 v2.8 |
|
653 * @return none. Leaves of error |
|
654 */ |
|
655 void ParseRequestedUrlL(); |
|
656 |
|
657 /** |
|
658 * Creates the download name from the url |
|
659 * @since Series 60 v2.8 |
|
660 * @return none. Leaves of error |
|
661 */ |
|
662 void ParseDownloadNameL(); |
|
663 |
|
664 /** |
|
665 * Store entire response header with raw data in iHeaders array |
|
666 * @since Series 60 v2.8 |
|
667 * @return none. Leaves of error |
|
668 */ |
|
669 void StoreResponseHeaderL(); |
|
670 |
|
671 /** |
|
672 * Saves credentials info to memory for next submit. |
|
673 * Credential info are deleted in destructor and never |
|
674 * persisted. |
|
675 * @since Series 60 v2.8 |
|
676 * @param aStringPool stringpool of HTTP session |
|
677 * @return none. Leaves of error |
|
678 */ |
|
679 void SaveCredentialsL( RStringPool aStringPool ); |
|
680 |
|
681 /** |
|
682 * Builds up the request and submits the transaction. |
|
683 * @since Series 60 v2.8 |
|
684 * @return none. Leaves of error |
|
685 */ |
|
686 void RequestContentL(); |
|
687 |
|
688 protected: // Functions from base classes |
|
689 |
|
690 private: |
|
691 |
|
692 /** |
|
693 * C++ default constructor. |
|
694 */ |
|
695 CHttpDownload( CHttpClientApp *aClientApp, |
|
696 TInt32 aId, |
|
697 CHttpClientAppInstance* aClientAppInstance ); |
|
698 |
|
699 /** |
|
700 * By default Symbian 2nd phase constructor is private. |
|
701 */ |
|
702 void ConstructL( const TDesC8& aUrl ); |
|
703 |
|
704 // Prohibit copy constructor if not deriving from CBase. |
|
705 // CHttpDownload( const CHttpDownload& ); |
|
706 // Prohibit assigment operator if not deriving from CBase. |
|
707 // CHttpDownload& operator=( const CHttpDownload& ); |
|
708 |
|
709 /** |
|
710 * Called when content type received in response header. |
|
711 * @since Series 60 v2.8 |
|
712 * @return none. Leaves on error. |
|
713 */ |
|
714 void ContentTypeReceivedL(); |
|
715 |
|
716 /** |
|
717 * Handles HTTP error 401 |
|
718 * @since Series 60 v2.8 |
|
719 * @return none. Leaves on error. |
|
720 */ |
|
721 void HttpResponse401L(); |
|
722 |
|
723 /** |
|
724 * Handles HTTP error 407 |
|
725 * @since Series 60 v2.8 |
|
726 * @return none. Leaves on error. |
|
727 */ |
|
728 void HttpResponse407L(); |
|
729 |
|
730 /** |
|
731 * Search for and return a field in response header |
|
732 * @since Series 60 v2.8 |
|
733 * @param aFieldName name of the field |
|
734 * @return index to the field in iHeaders or KErrNotFound |
|
735 */ |
|
736 TInt FindHeaderField( CArrayPtrFlat<CHeaderField>* aHeaders, |
|
737 const TDesC8& aFieldName ) const; |
|
738 |
|
739 /** |
|
740 * Converts download name to unique one. |
|
741 * @since Series 60 v2.8 |
|
742 * @return none. Leaves on error. |
|
743 */ |
|
744 void ConvertDownloadNameUniqueL(); |
|
745 |
|
746 /** |
|
747 * Creates a unique, indexed name |
|
748 * @since Series 60 v2.8 |
|
749 * @return none. Leaves on error. |
|
750 */ |
|
751 void CreateIndexedNameL( HBufC* &aUniqueName, |
|
752 TDesC& aOrgName, |
|
753 TInt& aIndex ); |
|
754 |
|
755 /** |
|
756 * Stores response header received by client application. |
|
757 * It is used only in case of continue download. |
|
758 * @param aResponseHeader see EDlAttrResponseHeader |
|
759 * @return none. Leaves on error. |
|
760 */ |
|
761 void ContinueDownloadStoreResponseHeaderL( |
|
762 const TDesC8& aResponseHeader ); |
|
763 |
|
764 /** |
|
765 * Parses content type and media type from the response header. |
|
766 * @return none. Leaves on error. |
|
767 */ |
|
768 void ParseContentTypeL( RStringPool& aStrPool ); |
|
769 |
|
770 /** |
|
771 * Parses content disposition from the response header. |
|
772 * @return none. Leaves on error. |
|
773 */ |
|
774 void ParseContentDispositionL( RStringPool& aStrPool ); |
|
775 |
|
776 /** |
|
777 * Called mainly from SetDownloadStatus. This function passes |
|
778 * the download statuses to the event handler |
|
779 * @since Series 60 v2.8 |
|
780 * @return none. |
|
781 */ |
|
782 void TriggerEvent( THttpDownloadState aDlState, |
|
783 THttpProgressState aProgState = EHttpProgNone ); |
|
784 |
|
785 /** |
|
786 * Checks that in current situation the download is pausable, or not. |
|
787 * Triggers event to client if pausable attribute changes. |
|
788 * @since Series 60 v2.8 |
|
789 * @return none. |
|
790 */ |
|
791 void UpdatePausable(); |
|
792 |
|
793 /** |
|
794 * Do some (re)initialization before a forced restart. |
|
795 * @since Series 60 v2.8 |
|
796 * @return none. |
|
797 */ |
|
798 void ForcedRestartL(); |
|
799 |
|
800 /** |
|
801 * Returns the raw data of the requested header field. |
|
802 * @since Series 60 v2.8 |
|
803 * @return HBufC8* buffer with raw data of header field. |
|
804 */ |
|
805 HBufC8* HeaderFieldL( CArrayPtrFlat<CHeaderField>* aHeaders, |
|
806 TInt aFieldIndex ); |
|
807 |
|
808 #ifdef DEAD_CODE |
|
809 /** |
|
810 * Checks the response header on 206 response, if the |
|
811 * content is really what we requested and hasn't changed |
|
812 * since last request. |
|
813 * Checked field: date |
|
814 * @return ETrue if content is probably not modified |
|
815 */ |
|
816 TBool CheckIfContentUnModified(); |
|
817 #endif |
|
818 |
|
819 /** |
|
820 * Checks the max length of the string attribute |
|
821 * since last request. |
|
822 * Checked field: date |
|
823 * @return none. |
|
824 */ |
|
825 void CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
|
826 const TDesC16& aValue ); |
|
827 |
|
828 /** |
|
829 * Checks the max length of the string attribute |
|
830 * since last request. |
|
831 * Checked field: date |
|
832 * @return none. |
|
833 */ |
|
834 void CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
|
835 const TDesC8& aValue ); |
|
836 |
|
837 /** |
|
838 * Set cookie transaction property |
|
839 * @param aStringPool stringpool of HTTP session |
|
840 * @return none. Leaves of error. |
|
841 */ |
|
842 void SetCookiesL( RStringPool& aStringPool ); |
|
843 |
|
844 /** |
|
845 * Client side transaction completed. |
|
846 */ |
|
847 void DownloadSucceededL(); |
|
848 |
|
849 /** |
|
850 * Parses input request header add-on and stores it in request headers array. |
|
851 * @param aValue Request header add-on from client application |
|
852 * @return None. Leaves on error. |
|
853 */ |
|
854 void ParseRequestHeaderAddOnL( const TDesC8& aValue ); |
|
855 |
|
856 /** |
|
857 * Load headers from file |
|
858 */ |
|
859 void LoadHeadersL( RFile& aFile, CArrayPtrFlat<CHeaderField>* aHeaders ); |
|
860 |
|
861 /** |
|
862 * Append headers to buffer |
|
863 */ |
|
864 void AppendHeadersL( TPtr8& aBuf, CArrayPtrFlat<CHeaderField>* aHeaders ); |
|
865 |
|
866 /** |
|
867 * Add the given header in the header array |
|
868 * @return None. Leaves on error. |
|
869 */ |
|
870 void AddHeaderL( THttpDownloadAttrib aAttribute, |
|
871 const TDesC8& aValue, |
|
872 const TInt aConversionTable[][2], |
|
873 CArrayPtrFlat<CHeaderField>* aHeaders ); |
|
874 |
|
875 /** |
|
876 * Handles permanent redirection event |
|
877 * @param aNewUrl new URL after redirection |
|
878 * @return None. Leaves on error. |
|
879 */ |
|
880 void RedirectedPermanentlyL( const TDesC8& aNewUrl ); |
|
881 |
|
882 /** |
|
883 * Handles temporary redirection event |
|
884 * @param aNewUrl new URL after redirection |
|
885 * @return None. Leaves on error. |
|
886 */ |
|
887 void RedirectedTemporaryL( const TDesC8& aNewUrl ); |
|
888 |
|
889 /** |
|
890 * Check that the content is supported multipart |
|
891 * @param aBuf new chunk of message body |
|
892 * @return TBool. Leaves on error. |
|
893 */ |
|
894 TBool IsMultipartSupportedL( const TDesC8& aBuf ); |
|
895 |
|
896 /** |
|
897 * Gets the specified attribute from media type |
|
898 * @param aAttribute Required attribute |
|
899 * @return TPtrC8. Leaves on error - KErrNotFound. |
|
900 */ |
|
901 TPtrC8 GetParamFromMediaTypeL( const TDesC8& aAttribute ); |
|
902 |
|
903 /** |
|
904 * Escape decoded URL may contain characters that cannot |
|
905 * be used to create filename. These characters are replaced |
|
906 * with KUrlFixChar |
|
907 * @return none. Leaves on error. |
|
908 */ |
|
909 void FixDownloadNameL(); |
|
910 |
|
911 /** |
|
912 * Set iCodDownload = aValue |
|
913 */ |
|
914 void SetCodFlag( TBool aValue ); |
|
915 |
|
916 |
|
917 /** |
|
918 * Check the contenttype and returns TRUE if drm |
|
919 */ |
|
920 void CheckRealDRMContentType(); |
|
921 |
|
922 /** |
|
923 * Self completes the active object |
|
924 */ |
|
925 void SelfComplete( TInt aReason = KErrNone ); |
|
926 |
|
927 /** |
|
928 *check for correct drive to move from cenrep |
|
929 */ |
|
930 void UpdateDestFileNameL(); |
|
931 |
|
932 /** |
|
933 * notify DcfRepository for new/deleted files |
|
934 */ |
|
935 void UpdateDCFRepositoryL( const TDesC& aFileName ); |
|
936 |
|
937 /** |
|
938 * Move completed media object files to gallery when delete is called |
|
939 * @param aMediaObjectIndex media object index to be moved |
|
940 * @return error code |
|
941 */ |
|
942 TInt MoveInDelete(TInt aMediaObjectIndex); |
|
943 |
|
944 /** |
|
945 * Initiates a move for downloaded media object files to gallery/download folder |
|
946 * @param aMediaObjectIndex media object index to be moved |
|
947 */ |
|
948 void MoveDownloadedMediaObjectL(TInt aMediaObjectIndex); |
|
949 |
|
950 /** |
|
951 * Moves downloaded media object file to gallery/download folder |
|
952 * @param aMediaObjectIndex media object index to be moved |
|
953 */ |
|
954 void MoveDownloadedMediaObjectSyncL(TInt aMediaObjectIndex); |
|
955 |
|
956 /** |
|
957 * Calls ConvertDownloadNameUniqueL to create unique name based on source file name |
|
958 * and destination path. |
|
959 */ |
|
960 void FindUniqueDestinationFileNameL( TDesC& srcFile, HBufC*& destPath ); |
|
961 |
|
962 /** |
|
963 * Notifies gallery about new file |
|
964 * @param aFileName file name |
|
965 */ |
|
966 void CHttpDownload::NotifyMediaGalleryL( const TDesC& aFileName ); |
|
967 |
|
968 /** |
|
969 * ConvertDownloadNameUniqueL |
|
970 */ |
|
971 void CHttpDownload::ConvertDownloadNameUniqueL( HBufC*& filePath, |
|
972 HBufC*& fileName, |
|
973 HBufC*& fileExtn); |
|
974 |
|
975 public: // Data |
|
976 // ?one_line_short_description_of_data |
|
977 //?data_declaration; |
|
978 |
|
979 protected: // Data |
|
980 |
|
981 TInt32 iId; // unique id of the download |
|
982 CHttpClientApp* iClientApp; |
|
983 CHttpClientAppInstance* iClAppInstance; // pointer to the client app's |
|
984 // preferencies class |
|
985 CHttpClientAppInstance* iPDClAppInstance; |
|
986 TInt32 iUserData; // EDlAttrUserData |
|
987 |
|
988 HBufC8* iUrl; // EDlAttrReqUrl |
|
989 HBufC8* iRedirUrl; // EDlAttrRedirUlr |
|
990 HBufC8* iCurrentUrl; // EDlAttrCurrentUrl |
|
991 HBufC* iDlName; // EDlAttrName |
|
992 TInt32 iPort; // EDlAttrPort |
|
993 TInt iTargetApp; // EDlAttrTargetApp |
|
994 THttpMethod iMethod; // EDlAttrMethod |
|
995 |
|
996 TInt iAuthScheme; // EDlAttrAuthScheme |
|
997 HBufC8* iHttpRealm; // EDlAttrRealm |
|
998 HBufC8* iHttpUsername; // EDlAttrUsername |
|
999 HBufC8* iHttpPassword; // EDlAttrPassword |
|
1000 HBufC8* iHttpProxyRealm;// EDlAttrProxyRealm |
|
1001 HBufC8* iHttpProxyUsername; // EDlAttrProxyUsername |
|
1002 HBufC8* iHttpProxyPassword; // EDlAttrProxyPassword |
|
1003 HBufC8* iHttpNonce; // Nonce-value used in digest authentication |
|
1004 // Received from HTTP server, non-accessible from |
|
1005 // outside |
|
1006 |
|
1007 TInt32 iPreferencies; |
|
1008 |
|
1009 TBool iDisconnectOnPause; // EDlAttrDisconnectOnPause |
|
1010 TBool iDisconnectOnReset; // EDlAttrDisconnectOnReset |
|
1011 TInt iCodDownload; // See EDlCodDownload this is a bool attrib but needs to increment! |
|
1012 TInt32 iFotaPckgId; // EDlAttrFotaPckgId |
|
1013 |
|
1014 CArrayPtrFlat<CHeaderField>* iResponseHeaders; // Response header |
|
1015 CArrayPtrFlat<CHeaderField>* iRequestHeaders; // Additional request header |
|
1016 // See ERequestHeaderAddon |
|
1017 CArrayPtrFlat<CHeaderField>* iEntityHeaders; |
|
1018 CArrayPtrFlat<CHeaderField>* iGeneralHeaders; |
|
1019 |
|
1020 // the following members are initialized from |
|
1021 // HTTP response header. |
|
1022 TInt32 iStatusCode; // EDlAttrStatusCode |
|
1023 HBufC8* iContentType; // EDlAttrContentType |
|
1024 HBufC8* iDispositionType; // EDlAttrDispositionType (e.g.:"inline", "attachment") |
|
1025 HBufC* iAttachmentFileName; // EDlAttrFileNameParm |
|
1026 HBufC8* iMediaType; // EDlAttrMediaType |
|
1027 TDateTime iDate; |
|
1028 TDateTime iExpires; |
|
1029 TTimeIntervalSeconds iMaxAge; |
|
1030 |
|
1031 CHttpConnHandler* iConnHandler; // pointer to the CHttpConnHandler. |
|
1032 // Not owned. |
|
1033 RHTTPTransaction iTrans; |
|
1034 TBool iTransValid;// iTrans is a valid transaction |
|
1035 |
|
1036 THttpDownloadState iDlState; // EDlAttrState |
|
1037 THttpProgressState iProgState; // EDlAttrProgressState |
|
1038 |
|
1039 THttpDownloadMgrAction iAction; // EDlAttrAction |
|
1040 THttpRestartActions iRestartAction; // EDlAttrRestartAction |
|
1041 |
|
1042 TInt iLastError; // EDlAttrErrorId |
|
1043 TInt iGlobalErrorId; // EDlAttrGlobalErrorId |
|
1044 |
|
1045 TBool iNoContentTypeCheck; // EDlAttrNoContentTypeCheck |
|
1046 |
|
1047 TInt iDontFireEvent; |
|
1048 |
|
1049 CFileMan* iFileMan; // used in MoveL |
|
1050 |
|
1051 TBool iNoMedia; // See EDlAttrNoMedia |
|
1052 TBool iContinueDownload; // See EDlContinue |
|
1053 |
|
1054 CHttpStorage* iStorage; // Stores received body data |
|
1055 |
|
1056 HBufC8* iHashedMsgBody; // EDlAttrHashedMsgBody |
|
1057 |
|
1058 TBool iUseAttachmentFileName; // Content disposition type = "attachment" |
|
1059 TBool iUseInlineFileName; // Content disposition type = "inline" |
|
1060 |
|
1061 TBool iCodPdAvailable; // COD Progerssive download is available |
|
1062 |
|
1063 TBool iUpdatedDDUriSet; //True if updated DD URI is set from COD Eng |
|
1064 HBufC8* iDDType; // EDlAttrDDType |
|
1065 |
|
1066 CDownloadDataServ* iCodDlData;// COD download info |
|
1067 |
|
1068 TFileName iFname; ///< File name. |
|
1069 |
|
1070 private: // Data |
|
1071 |
|
1072 TBool iNoRealError; // It's set in Get/SetAttrib functions. Indicates |
|
1073 // that if a leave occures it doesn't have any |
|
1074 // real effect on download process and nothing |
|
1075 // to do in the OnError() |
|
1076 TBool iRedirect; // Transaction redirected. |
|
1077 // Restore iCurrentUrl to iUrl after transaction abnormally |
|
1078 // completed (paused, failed) |
|
1079 TBool iPausable; // EDlAttrPausable |
|
1080 |
|
1081 TBool iDlStartedByClient; // Download started by client app via ::StartL. |
|
1082 // In some cases the download is restarted by the engine. |
|
1083 TBool iSilentMode; // EDlAttrSilent |
|
1084 TBool iHidden; // EDlAttrHidden |
|
1085 |
|
1086 TBool iUseCookies; |
|
1087 |
|
1088 TBool iPausableDRM; // Set to ETrue if KDRMOldContentType is found in response header. |
|
1089 TBool iDrmContentLengthValid; // |
|
1090 |
|
1091 |
|
1092 HBufC8* iHeaderOfMultipart; // Header of multipart |
|
1093 TBool iMultiPart; |
|
1094 |
|
1095 TBool iDlNameChanged; //Set if download name has changed |
|
1096 TBool iContTypeRecognitionAvailSent; |
|
1097 |
|
1098 HBufC8* iDownloadInfo; // contains download info |
|
1099 |
|
1100 TInt iRefCount; |
|
1101 |
|
1102 TBool iMoveInProgress; |
|
1103 |
|
1104 TInt iMoLength; //Multiple Media Object Length |
|
1105 TInt iActiveDownload; // Currenlty active Cod Download |
|
1106 TInt iActivePlayedDownload; // Currenlty actively played Cod Download |
|
1107 TInt iMOMoved; // index for bulk move |
|
1108 TBool iMoDownloadCompleted; //MO download Completed.But Move will be issued by PD Client |
|
1109 |
|
1110 public: // Friend classes |
|
1111 //?friend_class_declaration; |
|
1112 protected: // Friend classes |
|
1113 |
|
1114 friend class CHttpStorage; |
|
1115 |
|
1116 private: // Friend classes |
|
1117 //?friend_class_declaration; |
|
1118 }; |
|
1119 |
|
1120 #endif // HTTPDOWNLOAD_H |
|
1121 |
|
1122 // End of File |