|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDDESCRIPTORDOWNLOADSUBOPERATION_H |
|
20 #define C_NCDDESCRIPTORDOWNLOADSUBOPERATION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "ncdbaseoperation.h" |
|
25 #include "ncdoperationdatatypes.h" |
|
26 #include "ncddownloadoperationstates.h" |
|
27 #include "catalogshttptypes.h" |
|
28 #include "catalogshttpobserver.h" |
|
29 #include "ncdoperationobserver.h" |
|
30 |
|
31 class MCatalogsHttpSession; |
|
32 class MCatalogsHttpConfig; |
|
33 class MCatalogsHttpOperation; |
|
34 class MCatalogsHttpHeaders; |
|
35 class CNcdGeneralManager; |
|
36 |
|
37 /** |
|
38 * Download operation |
|
39 * |
|
40 */ |
|
41 class CNcdDescriptorDownloadSubOperation : public CNcdBaseOperation, |
|
42 public MCatalogsHttpObserver |
|
43 { |
|
44 public: |
|
45 |
|
46 /** |
|
47 * NewL |
|
48 * |
|
49 * @param aHttpSession HTTP session used for creating download operations |
|
50 * @param aDestination Destination directory if the descriptor ends in '\' |
|
51 * otherwise full destination path (path + filename) |
|
52 * |
|
53 * @note Preferably the HTTP session has suitable defaults but if not then |
|
54 * Config() can be used to retrieve and change the settings for the download. |
|
55 * @note At least the target directory and access point must be set to the |
|
56 * configuration. |
|
57 * |
|
58 */ |
|
59 static CNcdDescriptorDownloadSubOperation* NewL( |
|
60 CNcdGeneralManager& aGeneralManager, |
|
61 MCatalogsHttpSession& aHttpSession, |
|
62 const TDesC& aUri, |
|
63 MNcdOperationObserver& aObserver, |
|
64 MCatalogsSession& aSession ); |
|
65 |
|
66 |
|
67 /** |
|
68 * Destructor |
|
69 */ |
|
70 virtual ~CNcdDescriptorDownloadSubOperation(); |
|
71 |
|
72 public: // New methods |
|
73 |
|
74 /** |
|
75 * HTTP configuration getter. |
|
76 */ |
|
77 MCatalogsHttpConfig& Config(); |
|
78 |
|
79 /** |
|
80 * HTTP request headers getter |
|
81 */ |
|
82 MCatalogsHttpHeaders& RequestHeaders(); |
|
83 |
|
84 const MCatalogsHttpHeaders& ResponseHeadersL(); |
|
85 |
|
86 /** |
|
87 * Download operation getter |
|
88 */ |
|
89 MCatalogsHttpOperation& HttpOperation(); |
|
90 |
|
91 |
|
92 /** |
|
93 * Returns the response body |
|
94 */ |
|
95 const TDesC8& Body() const; |
|
96 |
|
97 |
|
98 public: // From CNcdBaseOperation |
|
99 |
|
100 /** |
|
101 * Starts the operation. |
|
102 */ |
|
103 TInt Start(); |
|
104 |
|
105 |
|
106 /** |
|
107 * @see CNcdBaseOperation::Cancel() |
|
108 */ |
|
109 void Cancel(); |
|
110 |
|
111 |
|
112 |
|
113 public: // From MCatalogsHttpObserver |
|
114 |
|
115 /** |
|
116 * @see MCatalogsHttpObserver::HandleHttpEvent() |
|
117 */ |
|
118 void HandleHttpEventL( |
|
119 MCatalogsHttpOperation& aOperation, |
|
120 TCatalogsHttpEvent aEvent ); |
|
121 |
|
122 /** |
|
123 * @see MCatalogsHttpObserver::HandleHttpError() |
|
124 */ |
|
125 TBool HandleHttpError( |
|
126 MCatalogsHttpOperation& aOperation, |
|
127 TCatalogsHttpError aError ); |
|
128 |
|
129 protected: // From CNcdBaseOperation |
|
130 |
|
131 /** |
|
132 * @see CNcdBaseOperation::RunOperation() |
|
133 */ |
|
134 TInt RunOperation(); |
|
135 |
|
136 |
|
137 protected: |
|
138 |
|
139 // Constructor |
|
140 CNcdDescriptorDownloadSubOperation( |
|
141 CNcdGeneralManager& aGeneralManager, |
|
142 MCatalogsHttpSession& aHttpSession, |
|
143 MCatalogsSession& aSession ); |
|
144 |
|
145 void ConstructL( |
|
146 const TDesC& aUri, |
|
147 MNcdOperationObserver& aObserver ); |
|
148 |
|
149 private: |
|
150 |
|
151 void NotifyObserversComplete( TInt aError ); |
|
152 |
|
153 void NotifyObserversProgress(); |
|
154 |
|
155 private: |
|
156 |
|
157 MCatalogsHttpSession& iHttpSession; |
|
158 MCatalogsHttpOperation* iDownload; |
|
159 TNcdDownloadState iDownloadState; |
|
160 |
|
161 CBufFlat* iBody; |
|
162 mutable TPtr8 iBodyPtr; |
|
163 }; |
|
164 |
|
165 #endif // C_NCDDESCRIPTORDOWNLOADSUBOPERATION_H |