|
1 /* |
|
2 * Copyright (c) 2008 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: Wrapper class for ROAP trigger download via DL mananger |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ROHANDLERDMGRWRAPPER_H |
|
20 #define ROHANDLERDMGRWRAPPER_H |
|
21 |
|
22 namespace Roap |
|
23 { |
|
24 class MRoapObserver; |
|
25 } |
|
26 |
|
27 class CDRMRights; |
|
28 |
|
29 class MHttpDownloadMgrObserver; |
|
30 |
|
31 class MRoHandlerDMgrWrapper |
|
32 { |
|
33 |
|
34 public: |
|
35 virtual void HandleRoapTriggerL( const TDesC8& aTrigger ) = 0; |
|
36 |
|
37 virtual void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ) = 0; |
|
38 |
|
39 virtual void DownloadAndHandleRoapTriggerFromPrUrlL( const HBufC8* aUrl ) = 0; |
|
40 |
|
41 }; |
|
42 |
|
43 /** |
|
44 * Class for downloading ROAP triggers |
|
45 * |
|
46 */ |
|
47 class CRoHandlerDMgrWrapper: |
|
48 public CActive, // Now active |
|
49 public MHttpDownloadMgrObserver, |
|
50 public Roap::MRoapObserver, |
|
51 public MRoHandlerDMgrWrapper |
|
52 { |
|
53 private: |
|
54 enum TMeterState |
|
55 { |
|
56 EInit, |
|
57 EGetMeteringTrigger, |
|
58 ESaveMeteringTrigger, |
|
59 EMeteringReportSubmit, |
|
60 EGetPrUrlTrigger, |
|
61 ESavePrUrlTrigger, |
|
62 EPrRoapRequest, |
|
63 EComplete |
|
64 }; |
|
65 public: |
|
66 |
|
67 static CRoHandlerDMgrWrapper* NewL(); |
|
68 |
|
69 static CRoHandlerDMgrWrapper* NewLC(); |
|
70 |
|
71 virtual ~CRoHandlerDMgrWrapper(); |
|
72 |
|
73 /** |
|
74 * Download a ROAP trigger from URL and handle it |
|
75 * |
|
76 * @since S60 3.2 |
|
77 * @param aUrl URL of ROAP trigger |
|
78 */ |
|
79 void HandleRoapTriggerL( const TDesC8& aTrigger ); |
|
80 |
|
81 void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ); |
|
82 |
|
83 void DownloadAndHandleRoapTriggerFromPrUrlL( const HBufC8* aUrl ); |
|
84 |
|
85 |
|
86 // from base class MHttpDownloadMgrObserver |
|
87 |
|
88 /** |
|
89 * From MHttpDownloadMgrObserver. |
|
90 * Handle download manager events |
|
91 * |
|
92 * @since S60 3.2 |
|
93 * @param aDownload the download |
|
94 * @param aEvent the event |
|
95 */ |
|
96 void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent ); |
|
97 |
|
98 // From Roap::MRoapObserver |
|
99 /** |
|
100 * ConnectionConfL |
|
101 * @return ETrue: the network can be establish |
|
102 * EFalse: the ROAP transaction is canceled |
|
103 * |
|
104 * @leave System wide error code */ |
|
105 TBool ConnectionConfL(); |
|
106 |
|
107 /** |
|
108 * ContactRiConfL |
|
109 * @return ETrue: the user consent is achieved |
|
110 * EFalse: the user consent is not achieved |
|
111 * |
|
112 * @leave System wide error code */ |
|
113 TBool ContactRiConfL(); |
|
114 |
|
115 /** |
|
116 * TransIdConfL |
|
117 * @return ETrue: the user consent is achieved |
|
118 * EFalse: the user consent is not achieved |
|
119 * |
|
120 * @leave System wide error code */ |
|
121 |
|
122 TBool TransIdConfL(); |
|
123 |
|
124 /** |
|
125 * RightsObjectDetailsL |
|
126 * |
|
127 * The function is called after successful completion of RO acquisition |
|
128 * protocol. The passes information about stored rights objects to the |
|
129 * observer. |
|
130 * |
|
131 * @since 3.0 |
|
132 * @param aRightsList: A list of pointers to rights objects. |
|
133 * Contents of aRightsList are owend by ROAP engine |
|
134 * |
|
135 * @leave System wide error code */ |
|
136 void RightsObjectDetailsL( const RPointerArray<CDRMRights>& aRightsList ); |
|
137 |
|
138 /** |
|
139 * ContentDownloadInfoL |
|
140 * |
|
141 * The function is called when the ROAP engine notices that it is about to |
|
142 * receive a multipart content as a ROAP response. The method must return via |
|
143 * out-parameter the path to a temp folder where the content is saved during |
|
144 * download. The name that is used as filename when saving the content to |
|
145 * the appropriate palce and the maximum size of the content (a safety upper limit) |
|
146 * must also be provided via out-parameters. |
|
147 * |
|
148 * @since 3.0 |
|
149 * @param aTempFolder: (out-param) The path of the temp folder, or KNullDesC |
|
150 * @param aContentName: (out-param) The name of the content, or KNullDesC (defaut name is used) |
|
151 * @param aMaxSize: (out-param) The maximum size of the content, or -1 if not known |
|
152 * |
|
153 * @leave System wide error code */ |
|
154 |
|
155 void ContentDownloadInfoL( TPath& aTempFolder, |
|
156 TFileName& aContentName, |
|
157 TInt& aMaxSize ); |
|
158 |
|
159 /** |
|
160 * ContentDetailsL |
|
161 * |
|
162 * The function is called when the ROAP engine has received a DCF content (together |
|
163 * with a ROAP response) The ROAP engine saves the DCF to the appropriate location |
|
164 * and gives out the information about the saved DCF file by calling this method |
|
165 * |
|
166 * @since 3.0 |
|
167 * @param aPath: The path andf the filename of the saved DCF file |
|
168 * @param aType: The plain MIME type of the saved DCF file |
|
169 * @param aAppUid: The handler app UID of the saved DCF file |
|
170 * |
|
171 * @leave System wide error code */ |
|
172 |
|
173 void ContentDetailsL( const TDesC& aPath, |
|
174 const TDesC8& aType, |
|
175 const TUid& aAppUid ); |
|
176 |
|
177 /** |
|
178 * RoapProgressInfoL |
|
179 * |
|
180 * The function provides progress information about ROAP processing to the |
|
181 * observer |
|
182 * |
|
183 * @since 3.0 |
|
184 * @param aProgressInfo: An integer value representing the state of |
|
185 * ROAP processing, counting in bytes |
|
186 * |
|
187 * @leave System wide error code */ |
|
188 |
|
189 void RoapProgressInfoL( const TInt aProgressInfo ); |
|
190 |
|
191 /** |
|
192 * ErrorUrlL |
|
193 * |
|
194 * The function is called in ROAP error case and it provides an error URL |
|
195 * for the caller. The calling entity should send an HTTP GET request to |
|
196 * the URL which should then return an HTML page. |
|
197 * |
|
198 * @since 3.0 |
|
199 * @param aErrorUrl: The error URL |
|
200 * |
|
201 * |
|
202 * @leave System wide error code */ |
|
203 |
|
204 void ErrorUrlL( const TDesC8& aErrorUrl ); |
|
205 |
|
206 /** |
|
207 * PostResponseUrlL |
|
208 * |
|
209 * The function is called if handled ROAP metering report response |
|
210 * contains PostResponseURL extension. The calling entity should send |
|
211 * an HTTP GET request to the URL, which should return ROAP trigger, |
|
212 * download descriptor or multipart message containing both |
|
213 * download descriptor and ROAP trigger. |
|
214 * |
|
215 * @since 3.2 |
|
216 * @param aPostResponseUrl: The URL to be fetched |
|
217 * after handling ROAP metering response |
|
218 * with PostResponseURL extension. |
|
219 * |
|
220 * |
|
221 * @leave System wide error code */ |
|
222 void PostResponseUrlL( const TDesC8& aPostResponseUrl ); |
|
223 |
|
224 protected: |
|
225 //from Cactive |
|
226 virtual void DoCancel(); |
|
227 |
|
228 virtual void RunL(); |
|
229 |
|
230 virtual TInt RunError( TInt aError ); |
|
231 private: |
|
232 |
|
233 /** |
|
234 * C++ default constructor. |
|
235 */ |
|
236 CRoHandlerDMgrWrapper(); |
|
237 |
|
238 void ConstructL(); |
|
239 |
|
240 /** |
|
241 * Set the browser default access point to be used |
|
242 * |
|
243 * @since S60 3.0 |
|
244 */ |
|
245 void SetDefaultAccessPointL(); |
|
246 |
|
247 void DoDownloadRoapTriggerL( TMeterState aNextState ); |
|
248 |
|
249 void DoSaveRoapTriggerL( TMeterState aNextState ); |
|
250 |
|
251 void DoHandleRoapTriggerL( TMeterState aNextState ); |
|
252 |
|
253 void Continue( TMeterState aNextState, TInt aError ); |
|
254 private: // data |
|
255 |
|
256 /** |
|
257 * Download manager session |
|
258 */ |
|
259 RHttpDownloadMgr iDlMgr; |
|
260 |
|
261 /** |
|
262 * Used to make downloads synchronous |
|
263 */ |
|
264 CActiveSchedulerWait iWait; |
|
265 |
|
266 /** |
|
267 * to store information on download |
|
268 */ |
|
269 TBool iDownloadSuccess; |
|
270 TBool iConnectionError; |
|
271 |
|
272 /** |
|
273 * Post response url for ROAP prUrl, () |
|
274 */ |
|
275 HBufC8* iTriggerUrl; |
|
276 |
|
277 HBufC8* iTriggerBuf; |
|
278 /** |
|
279 * IAP (from ROAP or from UI) |
|
280 */ |
|
281 TUint32 iIapId; |
|
282 |
|
283 TMeterState iState; |
|
284 |
|
285 Roap::CRoapEng* iRoapEng; |
|
286 |
|
287 RFs iFs; |
|
288 |
|
289 HBufC* iFileName; |
|
290 }; |
|
291 |
|
292 #endif // ROHANDLERDMGRWRAPPER_H |