|
1 /* |
|
2 * Copyright (c) 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: Implementation of class CCodDownloadImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <bldvariant.hrh> |
|
22 #include <AiwGenericParam.h> |
|
23 #include <DocumentHandler.h> |
|
24 #include <apgcli.h> |
|
25 #include <eikenv.h> |
|
26 #include <StringLoader.h> |
|
27 #include <ErrorUi.h> |
|
28 #include <DcfRep.h> |
|
29 #include <RoapDef.h> |
|
30 #include <DRMCommon.h> |
|
31 #include <aknmessagequerydialog.h> |
|
32 #include <hlplch.h> |
|
33 #include <MultipartParser.h> |
|
34 #include <AknQueryDialog.h> |
|
35 #include "CodDownloadImpl.h" |
|
36 #include "CodUiPanic.h" |
|
37 #include <CodStatus.h> |
|
38 #include <CodDefs.h> |
|
39 #include <CodError.h> |
|
40 #include <CodEng.h> |
|
41 #include <CodData.h> |
|
42 #include <RoapData.h> |
|
43 #include <DdEng.h> |
|
44 #include <CodUtil.h> |
|
45 #include "CodUiResource.h" |
|
46 #include <CodUi.rsg> |
|
47 #include "CodViewDialog.h" |
|
48 #include "CodLogger.h" |
|
49 #include "CodDialog.h" |
|
50 #include "CodUi.hrh" |
|
51 #include <pathinfo.h> |
|
52 #include <Oma2Agent.h> |
|
53 #include <bldvariant.hrh> |
|
54 #include "CodConfirm.h" |
|
55 #include <bautils.h> |
|
56 |
|
57 #ifdef RD_MULTIPLE_DRIVE |
|
58 #include <driveinfo.h> |
|
59 #endif |
|
60 |
|
61 // ================= CONSTANTS ======================= |
|
62 |
|
63 /// COD MIME type. |
|
64 _LIT8( KCodDataType, COD_MIME_TYPE ); |
|
65 /// multipart/related type. |
|
66 _LIT8( KMultipartRelatedDataType, "multipart/related" ); |
|
67 #ifdef __SYNCML_DM_FOTA |
|
68 /// FOTA Update Package type. |
|
69 _LIT8( KFotaPackageDataType, "application/vnd.nokia.swupd.dp2" ); |
|
70 #endif /*def __SYNCML_DM_FOTA */ |
|
71 /// UID of Wml Browser. |
|
72 LOCAL_D const TInt KCodWmlBrowserUid = 0x10008D39; |
|
73 /// Message prefix, to launch browser with URL. |
|
74 _LIT( KCodMsgLaunchBrowserWithUrl, "4 " ); |
|
75 /// Reserved word "local". |
|
76 _LIT8( KCodReservedWordLocal, "local" ); |
|
77 /// Reserved word "back". |
|
78 _LIT8( KCodReservedWordBack, "back" ); |
|
79 /// For launching more info DRM_HLP_REGISTRATION |
|
80 _LIT(KDRM_HLP_REGISTRATION,"DRM_HLP_REGISTRATION"); |
|
81 /// Next Line |
|
82 _LIT( KNextLine, "\n" ); |
|
83 |
|
84 // ================= MEMBER FUNCTIONS ======================= |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CCodDownloadImpl::NewL() |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C CCodDownloadImpl* CCodDownloadImpl::NewL |
|
91 ( |
|
92 CCodDownload& aProxy, |
|
93 const TDesC8& aBuf, |
|
94 const TDesC8& aType, |
|
95 MCodDownloadObserver& aObserver, |
|
96 CEikonEnv* aEikEnv, |
|
97 const TDesC8* aMultipartBoundary, |
|
98 const TDesC16* aMultipartUrl |
|
99 ) |
|
100 { |
|
101 CLOG(( 2, _L8("-> CCodDownloadImpl::NewL aType<%S> aEikEnv(0x%x)"), \ |
|
102 &aType, aEikEnv )); |
|
103 CCodDownloadImpl* download = |
|
104 new (ELeave) CCodDownloadImpl( aProxy, aObserver, aEikEnv ); |
|
105 CleanupStack::PushL( download ); |
|
106 download->ConstructL( aBuf, aType, aMultipartBoundary, aMultipartUrl ); |
|
107 CleanupStack::Pop( download ); |
|
108 CLOG(( 2, _L8("<- CCodDownloadImpl::NewL") )); |
|
109 return download; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CCodDownloadImpl::NewL() |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CCodDownloadImpl* CCodDownloadImpl::NewL |
|
117 ( |
|
118 CCodDownload& aProxy, |
|
119 const TInt aDownloadId, |
|
120 const TUid aDlUid, |
|
121 const TDesC8& aType, |
|
122 MCodDownloadObserver& aObserver, |
|
123 CEikonEnv* aEikEnv, |
|
124 const TDesC8* aMultipartBoundary, |
|
125 const TDesC16* aMultipartUrl |
|
126 ) |
|
127 { |
|
128 CLOG(( 2, _L8("-> CCodDownloadImpl::NewL aType<%S> aEikEnv(0x%x)"), \ |
|
129 &aType, aEikEnv )); |
|
130 CCodDownloadImpl* download = |
|
131 new (ELeave) CCodDownloadImpl( aProxy, aObserver, aEikEnv ); |
|
132 CleanupStack::PushL( download ); |
|
133 download->ConstructL( aDownloadId, aDlUid, aType, aMultipartBoundary, aMultipartUrl ); |
|
134 CleanupStack::Pop( download ); |
|
135 CLOG(( 2, _L8("<- CCodDownloadImpl::NewL") )); |
|
136 return download; |
|
137 } |
|
138 // --------------------------------------------------------- |
|
139 // CCodDownloadImpl::~CCodDownloadImpl() |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C CCodDownloadImpl::~CCodDownloadImpl() |
|
143 { |
|
144 CLOG(( 2, _L("*** -> CCodDownloadImpl::~CCodDownloadImpl") )); |
|
145 Cancel(); |
|
146 delete iParams; |
|
147 iParts.ResetAndDestroy(); |
|
148 delete iBuf; |
|
149 delete iEng; |
|
150 delete iUiResource; |
|
151 delete iErrorUi; |
|
152 delete iDocHandler; |
|
153 delete iDocParams; |
|
154 delete iPostResponseURL; |
|
155 iFs.Close(); |
|
156 CLOG(( 2, _L("*** <- CCodDownloadImpl::~CCodDownloadImpl") )); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------- |
|
160 // CCodDownloadImpl::StartL() |
|
161 // --------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C void CCodDownloadImpl::StartL( const CAiwGenericParamList* aParams ) |
|
164 { |
|
165 CLOG(( 2, _L("-> CCodDownloadImpl::StartL") )); |
|
166 // __ASSERT_DEBUG( iState == EInit , CodUiPanic( ECodUiRequestPending ) ); |
|
167 __ASSERT_DEBUG( !IsActive(), CodUiPanic( ECodUiRequestPending ) ); |
|
168 |
|
169 iAutoAccept = EFalse; |
|
170 iSilentMode = EFalse; |
|
171 iSuppressNextUrl = EFalse; |
|
172 iSuppressLaunch = EFalse; |
|
173 iFota = EFalse; |
|
174 iParams->Reset(); |
|
175 |
|
176 if ( aParams ) |
|
177 { |
|
178 // We must copy parameters, there is no guarantee that the caller |
|
179 // keeps the original during the whole download process. |
|
180 iParams->AppendL( *aParams ); |
|
181 CodUtil::GetBoolParam |
|
182 ( iSilentMode, EGenericParamSilentDownload, *iParams ); |
|
183 CodUtil::GetBoolParam( iAutoAccept, |
|
184 EGenericParamSuppressDownloadConfirmation, *iParams ); |
|
185 CodUtil::GetBoolParam |
|
186 ( iSuppressNextUrl, EGenericParamSuppressNextUrl, *iParams ); |
|
187 CodUtil::GetBoolParam |
|
188 ( iSuppressLaunch, EGenericParamSuppressLaunch, *iParams ); |
|
189 |
|
190 CodUtil::GetUint32Param( iDownloadId, EGenericParamDownloadId, *iParams ); |
|
191 |
|
192 TUint32 intAppUId(0); |
|
193 CodUtil::GetUint32Param( intAppUId, EGenericParamApplication, *iParams ); |
|
194 iAppUId.iUid = intAppUId; |
|
195 |
|
196 #ifdef __SYNCML_DM_FOTA |
|
197 TInt i( 0 ); |
|
198 if ( iParams->FindFirst( i, EGenericParamFotaPkgId ) ) |
|
199 { |
|
200 CLOG(( 2, _L(" EGenericParamFotaPkgId set"), &iProxy )); |
|
201 iFota = ETrue; |
|
202 } |
|
203 #endif /*def __SYNCML_DM_FOTA */ |
|
204 } |
|
205 |
|
206 |
|
207 |
|
208 if(iDownloadPaused) |
|
209 { |
|
210 iEng->Start(aParams,&iStatus); |
|
211 SetActive(); |
|
212 iState = ELoad; |
|
213 iProgress.iState = TCodDownloadProgress::EInProgress; |
|
214 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EStart ) ); |
|
215 return; |
|
216 } |
|
217 |
|
218 iEng->SetL( iDescriptor, &iStatus, iParams, &iParts ); |
|
219 SetActive(); |
|
220 // Warning: no leave after this point! |
|
221 iState = ESet; |
|
222 ResetProgress(); |
|
223 iProgress.iState = TCodDownloadProgress::EInProgress; |
|
224 CLOG(( 2, _L("CodEventL(0x%x,EStart)"), &iProxy )); |
|
225 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EStart ) ); |
|
226 CLOG(( 2, _L("<- CCodDownloadImpl::StartL") )); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------- |
|
230 // CCodDownloadImpl::Stop() |
|
231 // --------------------------------------------------------- |
|
232 // |
|
233 EXPORT_C void CCodDownloadImpl::Stop() |
|
234 { |
|
235 CLOG(( 2, _L("-> CCodDownloadImpl::Stop") )); |
|
236 iEng->Stop(); |
|
237 delete iDocHandler; |
|
238 iDocHandler = NULL; |
|
239 delete iDocParams; |
|
240 iDocParams = NULL; |
|
241 CLOG(( 2, _L("<- CCodDownloadImpl::Stop") )); |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------- |
|
245 // CCodDownloadImpl::Progress() |
|
246 // --------------------------------------------------------- |
|
247 // |
|
248 EXPORT_C const TCodDownloadProgress& CCodDownloadImpl::Progress() const |
|
249 { |
|
250 CLOG(( 2, _L("CCodDownloadImpl::Progress state(%d) error(%d) cur(%d) max(%d)"), \ |
|
251 iProgress.iState, \ |
|
252 iProgress.iError, \ |
|
253 iProgress.iBytesCur, \ |
|
254 iProgress.iBytesMax )); |
|
255 return iProgress; |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------- |
|
259 // CCodDownloadImpl::Name() |
|
260 // --------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C TPtrC CCodDownloadImpl::Name() |
|
263 { |
|
264 #ifdef __TEST_COD_LOG |
|
265 TPtrC ptr( iEng->Data().Name() ); |
|
266 CLOG(( 2, _L("CCodDownloadImpl::Name returns<%S>"), &ptr )); |
|
267 #endif /* def __TEST_COD_LOG */ |
|
268 |
|
269 if(iEng->Data().Count() > 0) |
|
270 return (*iEng->Data()[iEng->Data().ActiveDownload()]).Name(); |
|
271 else |
|
272 return KNullDesC(); |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------- |
|
276 // CCodDownloadImpl::Type() |
|
277 // --------------------------------------------------------- |
|
278 // |
|
279 EXPORT_C TPtrC8 CCodDownloadImpl::Type() const |
|
280 { |
|
281 #ifdef __TEST_COD_LOG |
|
282 if(iEng->Data().Count() > 0) |
|
283 { |
|
284 TPtrC8 ptr( (*iEng->Data()[iEng->Data().ActiveDownload()]).Type() ); |
|
285 CLOG(( 2, _L8("CCodDownloadImpl::Type returns<%S>"), &ptr )); |
|
286 } |
|
287 #endif /* def __TEST_COD_LOG */ |
|
288 if(iEng->Data().Count() > 0) |
|
289 return (*iEng->Data()[iEng->Data().ActiveDownload()]).Type(); |
|
290 else |
|
291 return KNullDesC8(); |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------- |
|
295 // CCodDownloadImpl::GetPath() |
|
296 // --------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C TPtrC CCodDownloadImpl::GetPath() const |
|
299 { |
|
300 #ifdef __TEST_COD_LOG |
|
301 TPtrC ptr( iEng->GetPath() ); |
|
302 CLOG(( 2, _L("CCodDownloadImpl::GetPath returns<%S>"), &ptr )); |
|
303 #endif /* def __TEST_COD_LOG */ |
|
304 return iEng->GetPath(); |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------- |
|
308 // CCodDownloadImpl::GetDestFilePath() |
|
309 // --------------------------------------------------------- |
|
310 // |
|
311 EXPORT_C TPtrC CCodDownloadImpl::GetDestFilePath (TInt aMOIndex ) const |
|
312 { |
|
313 return iEng->GetDestFilePath(aMOIndex); |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------- |
|
317 // CCodDownloadImpl::ServiceFlowL() |
|
318 // --------------------------------------------------------- |
|
319 // |
|
320 EXPORT_C void CCodDownloadImpl::ServiceFlowL() |
|
321 { |
|
322 CLOG(( 2, _L("-> CCodDownloadImpl::ServiceFlowL") )); |
|
323 if ( iState != ELoadDone ) |
|
324 { |
|
325 // No completed download! |
|
326 User::Leave( KErrNotReady ); |
|
327 } |
|
328 TBool done( ETrue ); |
|
329 TRAPD( err, done = DoServiceFlowL() ); |
|
330 if ( done || err ) |
|
331 { |
|
332 Done(); |
|
333 } |
|
334 CLOG(( 2, _L("<- CCodDownloadImpl::ServiceFlowL") )); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------- |
|
338 // CCodDownloadImpl::NextUrlL() |
|
339 // --------------------------------------------------------- |
|
340 // |
|
341 EXPORT_C HBufC8* CCodDownloadImpl::NextUrlL() const |
|
342 { |
|
343 HBufC8* absUrl = NULL; |
|
344 TBool back( EFalse ); |
|
345 // Empty string is returned while in progress. |
|
346 if ( iState == ELoadDone || iState == EServiceFlow || iState == EInit ) |
|
347 { |
|
348 TPtrC8 url( NextUrlAttr( back ) ); |
|
349 if ( url.Length() ) |
|
350 { |
|
351 absUrl = CodUtil::AbsoluteUrlLC( iEng->Data().SourceUri(), url ); |
|
352 CleanupStack::Pop( absUrl ); |
|
353 } |
|
354 } |
|
355 if ( !absUrl ) |
|
356 { |
|
357 absUrl = HBufC8::NewL( 0 ); |
|
358 } |
|
359 return absUrl; |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // CCodDownloadImpl::PostResponseUrlL() |
|
364 // --------------------------------------------------------- |
|
365 // |
|
366 EXPORT_C HBufC8* CCodDownloadImpl::GetPostResponseUrlL() const |
|
367 { |
|
368 |
|
369 return iPostResponseURL; |
|
370 } |
|
371 |
|
372 |
|
373 // --------------------------------------------------------- |
|
374 // CCodDownloadImpl::UpdatedDDUriL() |
|
375 // --------------------------------------------------------- |
|
376 // |
|
377 EXPORT_C HBufC8* CCodDownloadImpl::UpdatedDDUriL() const |
|
378 { |
|
379 HBufC8* absUrl = NULL; |
|
380 absUrl = CodUtil::AbsoluteUrlLC( iEng->Data().UpdatedDDUriL(), iEng->Data().UpdatedDDUriL() ); |
|
381 CleanupStack::Pop( absUrl ); |
|
382 |
|
383 if ( !absUrl ) |
|
384 { |
|
385 absUrl = HBufC8::NewL( 0 ); |
|
386 } |
|
387 return absUrl; |
|
388 |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------- |
|
392 // CCodDownloadImpl::UpdatedDownlaodDataL() |
|
393 // --------------------------------------------------------- |
|
394 // |
|
395 EXPORT_C HBufC8* CCodDownloadImpl::UpdatedDownloadDataL() const |
|
396 { |
|
397 return (iEng->UpdatedDownloadDataL()); |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // CCodDownloadImpl::UpdatedTrackDataL() |
|
402 // --------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C HBufC8* CCodDownloadImpl::UpdatedTrackDataL(TInt& aValue) const |
|
405 { |
|
406 return (iEng->UpdatedTrackDataL(aValue)); |
|
407 } |
|
408 |
|
409 // --------------------------------------------------------- |
|
410 // CCodDownloadImpl::RemovableMedia() |
|
411 // --------------------------------------------------------- |
|
412 // |
|
413 EXPORT_C TBool CCodDownloadImpl::RemovableMedia() const |
|
414 { |
|
415 TBool removable = iEng->RemovableMedia(); |
|
416 CLOG(( 2, _L("CCodDownloadImpl::RemovableMedia (%d)"), removable )); |
|
417 return removable; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------- |
|
421 // CCodDownloadImpl::UserData() |
|
422 // --------------------------------------------------------- |
|
423 // |
|
424 EXPORT_C TAny* CCodDownloadImpl::UserData() const |
|
425 { |
|
426 CLOG(( 2, _L("CCodDownloadImpl::UserData returns 0x%x"), iUserData )); |
|
427 return iUserData; |
|
428 } |
|
429 |
|
430 // --------------------------------------------------------- |
|
431 // CCodDownloadImpl::SetUserData() |
|
432 // --------------------------------------------------------- |
|
433 // |
|
434 EXPORT_C void CCodDownloadImpl::SetUserData( TAny* aUserData ) |
|
435 { |
|
436 CLOG(( 2, _L("CCodDownloadImpl::SetUserData (0x%x)"), aUserData )); |
|
437 iUserData = aUserData; |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------- |
|
441 // CCodDownloadImpl::SetCodDlAttached() |
|
442 // --------------------------------------------------------- |
|
443 // |
|
444 EXPORT_C void CCodDownloadImpl::SetCodDlAttached(const TBool aValue) |
|
445 { |
|
446 CLOG(( 2, _L("CCodDownloadImpl::SetCodDlAttached") )); |
|
447 iEng->SetCodDlAttached(aValue); |
|
448 iAttached = aValue; |
|
449 } |
|
450 |
|
451 // --------------------------------------------------------- |
|
452 // CCodDownloadImpl::ConstructL() |
|
453 // --------------------------------------------------------- |
|
454 // |
|
455 void CCodDownloadImpl::ConstructL |
|
456 ( |
|
457 const TDesC8& aBuf, |
|
458 const TDesC8& aType, |
|
459 const TDesC8* aMultipartBoundary, |
|
460 const TDesC16* aMultipartUrl |
|
461 ) |
|
462 { |
|
463 iBuf = aBuf.AllocL(); |
|
464 |
|
465 // By default, use the whole buffer and passed type. |
|
466 iDescriptor.Set( *iBuf ); |
|
467 TDataType type( aType ); |
|
468 |
|
469 // For multipart content, use the first part. |
|
470 // If there is no such (or cannot get it), fail on MIME check below. |
|
471 if ( type == TDataType( KMultipartRelatedDataType ) && |
|
472 aMultipartBoundary && aMultipartUrl ) |
|
473 { |
|
474 MultipartParser::ParseL |
|
475 ( *iBuf, aType, *aMultipartBoundary, *aMultipartUrl, iParts ); |
|
476 if ( iParts.Count() ) |
|
477 { |
|
478 // Use first part of multipart/related. |
|
479 iDescriptor.Set( iParts[0]->Body() ); |
|
480 type = iParts[0]->ContentType(); |
|
481 } |
|
482 } |
|
483 |
|
484 // Now iDescriptor and type are either the whole buffer and its type, |
|
485 // or those of the first part of multipart. |
|
486 |
|
487 if ( type == TDataType( KCodDataType ) ) |
|
488 { |
|
489 iCod = ETrue; |
|
490 iEng = CCodEng::NewL( NULL, this ); |
|
491 } |
|
492 else if ( type == TDataType( KDdDataType ) ) |
|
493 { |
|
494 iCod = EFalse; |
|
495 iEng = CDdEng::NewL( NULL, this ); |
|
496 iEng->SetDd2Type(EFalse); |
|
497 } |
|
498 else if ( type == TDataType( KDd2DataType ) ) |
|
499 { |
|
500 iCod = EFalse; |
|
501 iEng = CDdEng::NewL( NULL, this ); |
|
502 iEng->SetDd2Type(ETrue); |
|
503 } |
|
504 else |
|
505 { |
|
506 if( type == TDataType(KNullDesC8)) |
|
507 { |
|
508 iEng = CDdEng::NewL( NULL, this ); |
|
509 } |
|
510 else |
|
511 { |
|
512 User::Leave( KErrNotSupported ); |
|
513 } |
|
514 } |
|
515 // HACK: Priority set lower than DownloadManagerUiLib's download list. |
|
516 // In-download queries (currently, ROAP device registration query) |
|
517 // need to come on top of Download Manager's download list. |
|
518 iEng->SetPriority( CActive::EPriorityStandard - 1 ); |
|
519 if ( iEikEnv ) |
|
520 { |
|
521 iUiResource = CCodUiResource::NewL( *iEikEnv ); |
|
522 iErrorUi = CErrorUI::NewL( *iEikEnv ); |
|
523 } |
|
524 |
|
525 iParams = CAiwGenericParamList::NewL(); |
|
526 } |
|
527 |
|
528 // --------------------------------------------------------- |
|
529 // CCodDownloadImpl::ConstructL() |
|
530 // --------------------------------------------------------- |
|
531 // |
|
532 void CCodDownloadImpl::ConstructL |
|
533 ( |
|
534 const TInt aDownloadId, |
|
535 const TUid aDlUid, |
|
536 const TDesC8& aType, |
|
537 const TDesC8* aMultipartBoundary, |
|
538 const TDesC16* aMultipartUrl |
|
539 ) |
|
540 { |
|
541 //iBuf = aBuf.AllocL(); NO need for Descriptor buffer in case of paused download |
|
542 iParams = CAiwGenericParamList::NewL(); |
|
543 iAutoAccept = EFalse; |
|
544 iSilentMode = EFalse; |
|
545 iSuppressNextUrl = EFalse; |
|
546 iSuppressLaunch = EFalse; |
|
547 iFota = EFalse; |
|
548 iParams->Reset(); |
|
549 iDownloadPaused = ETrue; |
|
550 iState = EInit; |
|
551 |
|
552 // By default, use the whole buffer and passed type. |
|
553 |
|
554 TDataType type( aType ); |
|
555 |
|
556 // For multipart content, use the first part. |
|
557 // If there is no such (or cannot get it), fail on MIME check below. |
|
558 if ( type == TDataType( KMultipartRelatedDataType ) && |
|
559 aMultipartBoundary && aMultipartUrl ) |
|
560 { |
|
561 MultipartParser::ParseL |
|
562 ( *iBuf, aType, *aMultipartBoundary, *aMultipartUrl, iParts ); |
|
563 if ( iParts.Count() ) |
|
564 { |
|
565 // Use first part of multipart/related. |
|
566 iDescriptor.Set( iParts[0]->Body() ); |
|
567 type = iParts[0]->ContentType(); |
|
568 } |
|
569 } |
|
570 |
|
571 // Now iDescriptor and type are either the whole buffer and its type, |
|
572 // or those of the first part of multipart. |
|
573 |
|
574 if ( type == TDataType( KCodDataType ) ) |
|
575 { |
|
576 iCod = ETrue; |
|
577 iEng = CCodEng::NewL( NULL, this ); |
|
578 } |
|
579 else if ( type == TDataType( KDdDataType ) ) |
|
580 { |
|
581 iCod = EFalse; |
|
582 iEng = CDdEng::NewL( NULL, this ); |
|
583 iEng->SetDd2Type(EFalse); |
|
584 } |
|
585 else if ( type == TDataType( KDd2DataType ) ) |
|
586 { |
|
587 iCod = EFalse; |
|
588 iEng = CDdEng::NewL( NULL, this ); |
|
589 iEng->SetDd2Type(ETrue); |
|
590 } |
|
591 else |
|
592 { |
|
593 if( type == TDataType(KNullDesC8)) |
|
594 { |
|
595 iEng = CDdEng::NewL( NULL, this ); |
|
596 } |
|
597 else |
|
598 { |
|
599 User::Leave( KErrNotSupported ); |
|
600 } |
|
601 } |
|
602 // HACK: Priority set lower than DownloadManagerUiLib's download list. |
|
603 // In-download queries (currently, ROAP device registration query) |
|
604 // need to come on top of Download Manager's download list. |
|
605 iEng->SetPriority( CActive::EPriorityStandard - 1 ); |
|
606 if ( iEikEnv ) |
|
607 { |
|
608 iUiResource = CCodUiResource::NewL( *iEikEnv ); |
|
609 iErrorUi = CErrorUI::NewL( *iEikEnv ); |
|
610 } |
|
611 iEng->SetL( aDownloadId, aDlUid, &iParts ); |
|
612 |
|
613 // Warning: no leave after this point! |
|
614 iState = EInit; |
|
615 ResetProgress(); |
|
616 iProgress.iState = TCodDownloadProgress::EPaused; |
|
617 //TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EStart ) ); |
|
618 |
|
619 } |
|
620 // --------------------------------------------------------- |
|
621 // CCodDownloadImpl::DoCancel() |
|
622 // --------------------------------------------------------- |
|
623 // |
|
624 void CCodDownloadImpl::DoCancel() |
|
625 { |
|
626 CLOG(( 2, _L("-> CCodDownloadImpl::DoCancel") )); |
|
627 iEng->Cancel(); |
|
628 iProgress.iError = KErrCancel; |
|
629 iProgress.iState = TCodDownloadProgress::EFailedPermanent; |
|
630 Done(); |
|
631 CLOG(( 2, _L("<- CCodDownloadImpl::DoCancel") )); |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------- |
|
635 // CCodDownloadImpl::Pause() |
|
636 // --------------------------------------------------------- |
|
637 // |
|
638 EXPORT_C void CCodDownloadImpl::Pause() |
|
639 { |
|
640 |
|
641 CLOG(( 2, _L("-> CCodDownloadImpl::Pause") )); |
|
642 iEng->Pause(); |
|
643 iProgress.iState = TCodDownloadProgress::EPaused; |
|
644 //Done(); |
|
645 CLOG(( 2, _L("<- CCodDownloadImpl::Pause") )); |
|
646 } |
|
647 |
|
648 // --------------------------------------------------------- |
|
649 // CCodDownloadImpl::RunL() |
|
650 // --------------------------------------------------------- |
|
651 // |
|
652 void CCodDownloadImpl::RunL() |
|
653 { |
|
654 CLOG(( 2, _L("-> CCodDownloadImpl::RunL iStatus(%d)"), iStatus.Int() )); |
|
655 iProgress.iError = iStatus.Int(); |
|
656 switch ( iState ) |
|
657 { |
|
658 case ESet: |
|
659 { |
|
660 if ( iProgress.iError ) |
|
661 { |
|
662 LoadDoneL(); |
|
663 } |
|
664 else |
|
665 { |
|
666 SetOkL(); |
|
667 } |
|
668 break; |
|
669 } |
|
670 |
|
671 case ELoad: |
|
672 { |
|
673 LoadDoneL(); |
|
674 break; |
|
675 } |
|
676 case EInit: |
|
677 case ELoadDone: |
|
678 default: |
|
679 { |
|
680 CodUiPanic( ECodUiInternal ); |
|
681 break; |
|
682 } |
|
683 } |
|
684 CLOG(( 2, _L("<- CCodDownloadImpl::RunL") )); |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------- |
|
688 // CCodDownloadImpl::RunError() |
|
689 // --------------------------------------------------------- |
|
690 // |
|
691 TInt CCodDownloadImpl::RunError( TInt aError ) |
|
692 { |
|
693 CLOG(( 2, _L("-> CCodDownloadImpl::RunError aError(%d)"), aError )); |
|
694 iProgress.iError = aError; |
|
695 iProgress.iState = TCodDownloadProgress::EFailedPermanent; |
|
696 Done(); |
|
697 CLOG(( 2, _L("<- CCodDownloadImpl::RunError") )); |
|
698 return KErrNone; |
|
699 } |
|
700 |
|
701 // --------------------------------------------------------- |
|
702 // CCodDownloadImpl::SetOkL() |
|
703 // --------------------------------------------------------- |
|
704 // |
|
705 void CCodDownloadImpl::SetOkL() |
|
706 { |
|
707 CLOG(( 2, _L("-> CCodDownloadImpl::SetOkL") )); |
|
708 // Data parsed. |
|
709 CLOG(( 2, _L("CodEventL(0x%x,ENameChanged)"), &iProxy )); |
|
710 iObserver.CodEventL( iProxy, MCodDownloadObserver::ENameChanged ); |
|
711 CLOG(( 2, _L("CodEventL(0x%x,ETypeChanged)"), &iProxy )); |
|
712 iObserver.CodEventL( iProxy, MCodDownloadObserver::ETypeChanged ); |
|
713 TInt cmd( 0 ); |
|
714 TDataType type( Type() ); |
|
715 // if centra respository vale set iAutoAccept true, or the descritor do so |
|
716 // we won't ask for user confirmation |
|
717 if ( iAutoAccept || iEng->Data().SuppressConfirm() ) |
|
718 { |
|
719 cmd = ECodUiCmdAccept; |
|
720 } |
|
721 |
|
722 #ifdef __DRM_OMA2 |
|
723 if ( type == TDataType( KOma2TriggerContentType ) ) |
|
724 { |
|
725 // ROAP Trigger is accepted automatically (no user interaction). |
|
726 cmd = ECodUiCmdAccept; |
|
727 } |
|
728 #endif /*def __DRM_OMA2*/ |
|
729 #ifdef __SYNCML_DM_FOTA |
|
730 if ( type == TDataType( KFotaPackageDataType ) ) |
|
731 { |
|
732 // Safety check, this should be set already (via GenericParam). |
|
733 iFota = ETrue; |
|
734 } |
|
735 if ( iFota && !iEikEnv ) |
|
736 { |
|
737 // FOTA package is auto-accepted, if no UI present. |
|
738 cmd = ECodUiCmdAccept; |
|
739 } |
|
740 #endif /*def __SYNCML_DM_FOTA */ |
|
741 |
|
742 if ( !cmd && iEikEnv ) |
|
743 { |
|
744 CCodConfirm* confirm = new (ELeave) CCodConfirm; |
|
745 if (confirm->ShowDownloadConfirmationL(R_COD_UI_CBA_ACCEPT_CANCEL, |
|
746 iEng->Data(), |
|
747 iCod |
|
748 ) |
|
749 ) |
|
750 { |
|
751 cmd = ECodUiCmdAccept; |
|
752 } |
|
753 else |
|
754 { |
|
755 cmd = ECodUiCmdReject; |
|
756 } |
|
757 delete confirm; |
|
758 } |
|
759 CLOG(( 2, _L(" CCodDownloadImpl::SetOkL cmd(%d)"), cmd )); |
|
760 if ( cmd == ECodUiCmdAccept ) |
|
761 { |
|
762 iEng->Accept( &iStatus ); |
|
763 SetActive(); |
|
764 iState = ELoad; |
|
765 // Do not leave after this point! |
|
766 } |
|
767 else if ( cmd == ECodUiCmdReject ) |
|
768 { |
|
769 iEng->Reject( &iStatus ); |
|
770 SetActive(); |
|
771 iState = ELoad; |
|
772 // Do not leave after this point! |
|
773 } |
|
774 else |
|
775 { |
|
776 // No command. There is no UI to ask user, or dialog was dismissed |
|
777 // in some other way. |
|
778 iProgress.iError = KErrCancel; |
|
779 iProgress.iState = TCodDownloadProgress::EFailedPermanent; |
|
780 Done(); |
|
781 } |
|
782 CLOG(( 2, _L("<- CCodDownloadImpl::SetOkL") )); |
|
783 } |
|
784 |
|
785 // --------------------------------------------------------- |
|
786 // CCodDownloadImpl::LoadDoneL() |
|
787 // --------------------------------------------------------- |
|
788 // |
|
789 void CCodDownloadImpl::LoadDoneL() |
|
790 { |
|
791 CLOG(( 2, _L("-> CCodDownloadImpl::LoadDoneL status(%d)"), \ |
|
792 iEng->GetStatusCode() )); |
|
793 |
|
794 iProgress.iState = iEng->GetProductStatusCode(); |
|
795 if( iEng->Data().Count() > 1 ) |
|
796 { |
|
797 |
|
798 if( iProgress.iState == TCodDownloadProgress::EFailedPermanent ) |
|
799 { |
|
800 iProgress.iError = KErrMultipeObjectDownloadFailed ; |
|
801 } |
|
802 else if( iProgress.iState == TCodDownloadProgress::EFailedTemporary ) |
|
803 { |
|
804 iProgress.iState = TCodDownloadProgress::EPaused; |
|
805 } |
|
806 } |
|
807 |
|
808 if( iProgress.iState == TCodDownloadProgress::EInit ) |
|
809 { |
|
810 iState = EInit; |
|
811 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EUpdatedDDURI ) ); |
|
812 return; |
|
813 } |
|
814 |
|
815 if ( iEng->Data().ActiveDownload() && iEng->Data().Count() && iEng->GetPath().Length() ) |
|
816 { |
|
817 // ROAP involved loading a file, treat as download and not as ROAP. |
|
818 iRoap = EFalse; |
|
819 } |
|
820 |
|
821 // State change must come before the EEndLoad / EDone callback. |
|
822 iState = ELoadDone; |
|
823 if ( iEikEnv && !iFota ) |
|
824 { |
|
825 CLOG(( 2, _L("CodEventL(0x%x,EEndLoad)"), &iProxy )); |
|
826 if( iProgress.iState == TCodDownloadProgress::EFailedPermanent || |
|
827 iProgress.iState == TCodDownloadProgress::EPaused |
|
828 ) |
|
829 |
|
830 { |
|
831 // Done with permanent failure or paused |
|
832 iDownloadPaused = ETrue; |
|
833 iObserver.CodEventL( iProxy, MCodDownloadObserver::EDone ); |
|
834 } |
|
835 else |
|
836 { |
|
837 iObserver.CodEventL( iProxy, MCodDownloadObserver::EEndLoad ); |
|
838 } |
|
839 } |
|
840 else |
|
841 { |
|
842 // No service flow without UI -> we are done. |
|
843 // FOTA does not need any UI activity (except Details View) -> done. |
|
844 Done(); |
|
845 } |
|
846 CLOG(( 2, _L("<- CCodDownloadImpl::LoadDoneL") )); |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------- |
|
850 // CCodDownloadImpl::DoServiceFlowL() |
|
851 // --------------------------------------------------------- |
|
852 // |
|
853 TBool CCodDownloadImpl::DoServiceFlowL() |
|
854 { |
|
855 CLOG(( 2, _L("-> CCodDownloadImpl::DoServiceFlowL") )); |
|
856 __ASSERT_DEBUG( iState == ELoadDone, CodUiPanic( ECodUiInternal ) ); |
|
857 TBool done( ETrue ); |
|
858 if ( iEikEnv && !iFota ) // Safety code. |
|
859 { |
|
860 // No service flow for Cancel or Reject. |
|
861 if ( iProgress.iError != KErrCancel && iProgress.iError != KErrAbort ) |
|
862 { |
|
863 if ( iRoap ) |
|
864 { |
|
865 if ( iProgress.iError ) |
|
866 { |
|
867 done = RoapFailedL(); |
|
868 } |
|
869 else |
|
870 { |
|
871 done = RoapOkL(); |
|
872 } |
|
873 } |
|
874 else |
|
875 { |
|
876 if ( iProgress.iError ) |
|
877 { |
|
878 done = LoadFailedL(); |
|
879 } |
|
880 else |
|
881 { |
|
882 done = LoadOkL(); |
|
883 } |
|
884 } |
|
885 if ( done ) |
|
886 { |
|
887 ActivateNextUrlL(); |
|
888 } |
|
889 } |
|
890 } |
|
891 CLOG(( 2, _L("<- CCodDownloadImpl::DoServiceFlowL (%d)"), done )); |
|
892 return done; |
|
893 } |
|
894 |
|
895 // ---------------------------------------------------------- |
|
896 // CCodDownloadImpl::LoadOkL() |
|
897 // ---------------------------------------------------------- |
|
898 // |
|
899 TBool CCodDownloadImpl::LoadOkL() |
|
900 { |
|
901 CLOG(( 2, _L("-> CCodDownloadImpl::LoadOkL") )); |
|
902 __ASSERT_DEBUG( iEikEnv, CodUiPanic( ECodUiInternal ) ); |
|
903 __ASSERT_DEBUG( !iFota, CodUiPanic( ECodUiInternal ) ); |
|
904 __ASSERT_DEBUG( !iRoap, CodUiPanic( ECodUiInternal ) ); |
|
905 __ASSERT_DEBUG( !iProgress.iError, CodUiPanic( ECodUiInternal ) ); |
|
906 TBool done( ETrue ); // Done by default. |
|
907 // Content is not launched if: |
|
908 // - in silent mode |
|
909 // - suppress launch |
|
910 // - there is no content to launch |
|
911 // - COD is not 'local' |
|
912 // - DRM protected object and no rights present. |
|
913 CLOG(( 2, _L("<- CCodDownloadImpl::LoadOkL (%d)"), done )); |
|
914 return done; |
|
915 } |
|
916 |
|
917 // --------------------------------------------------------- |
|
918 // CCodDownloadImpl::LaunchHelpL() |
|
919 // --------------------------------------------------------- |
|
920 // |
|
921 void CCodDownloadImpl::LaunchHelpL( const TDesC& aContext ) |
|
922 { |
|
923 CArrayFix<TCoeHelpContext>* contexts = |
|
924 new(ELeave) CArrayFixFlat<TCoeHelpContext>( 1 ); |
|
925 CleanupStack::PushL( contexts ); |
|
926 TCoeHelpContext context; |
|
927 context.iMajor = KDRMHelperUid; |
|
928 context.iContext = aContext; |
|
929 contexts->AppendL( context ); |
|
930 CleanupStack::Pop(); // contexts |
|
931 |
|
932 #ifdef __SERIES60_HELP |
|
933 HlpLauncher::LaunchHelpApplicationL( iEikEnv->WsSession(), contexts ); |
|
934 #endif // __SERIES60_HELP |
|
935 } |
|
936 |
|
937 |
|
938 // ---------------------------------------------------------- |
|
939 // CCodDownloadImpl::ShowRoapCallback(TAny* aPtr) |
|
940 // ---------------------------------------------------------- |
|
941 // |
|
942 |
|
943 TInt CCodDownloadImpl::ShowRoapCallback( TAny* aPtr ) |
|
944 { |
|
945 TInt err( KErrNone ); |
|
946 CCodDownloadImpl* self = static_cast<CCodDownloadImpl*>(aPtr); |
|
947 TRAP( err, self->LaunchHelpL( KDRM_HLP_REGISTRATION ) ); |
|
948 return err; |
|
949 } |
|
950 |
|
951 // ---------------------------------------------------------- |
|
952 // CCodDownloadImpl::LoadFailedL() |
|
953 // ---------------------------------------------------------- |
|
954 // |
|
955 TBool CCodDownloadImpl::LoadFailedL() |
|
956 { |
|
957 CLOG(( 2, _L("-> CCodDownloadImpl::LoadFailedL") )); |
|
958 __ASSERT_DEBUG( iEikEnv, CodUiPanic( ECodUiInternal ) ); |
|
959 __ASSERT_DEBUG( !iFota, CodUiPanic( ECodUiInternal ) ); |
|
960 __ASSERT_DEBUG( !iRoap, CodUiPanic( ECodUiInternal ) ); |
|
961 __ASSERT_DEBUG( iProgress.iError, CodUiPanic( ECodUiInternal ) ); |
|
962 TInt resId = 0; |
|
963 TInt err = iProgress.iError; |
|
964 if ( err == KErrCodNoAccessPoint ) |
|
965 { |
|
966 // "No access point" error has the same status code as all connection |
|
967 // related errors, but needs different note. |
|
968 resId = R_QTN_CD_INFO_NO_VALID_AP; |
|
969 } |
|
970 else |
|
971 { |
|
972 // Investigating status code (which carries less information than the |
|
973 // error code) is generally enough to get the correct note. |
|
974 switch( iEng->GetStatusCode() ) |
|
975 { |
|
976 case KHttp900Success: |
|
977 case KHttp902UserCancelled: |
|
978 case KHttp921UserAborted: |
|
979 { |
|
980 // No error note shown for user cancel. |
|
981 err = KErrNone; |
|
982 break; |
|
983 } |
|
984 |
|
985 case KHttp901InsufficientMemory: |
|
986 case KHttp910NoMemory: |
|
987 { |
|
988 resId = R_QTN_CD_INFO_NOT_ENOUGH_MEM; |
|
989 break; |
|
990 } |
|
991 |
|
992 case KHttp903LossOfService: |
|
993 { |
|
994 // User Text Resolver to get "Connection timeout". |
|
995 err = KErrCodHttpNoResponse; |
|
996 break; |
|
997 } |
|
998 |
|
999 case KHttp906InvalidDescriptor: |
|
1000 { |
|
1001 resId = R_QTN_CD_INFO_SYNTAX_ERR; |
|
1002 break; |
|
1003 } |
|
1004 |
|
1005 case KHttp907InvalidType: |
|
1006 { |
|
1007 resId = R_QTN_CD_INFO_UNSUPP_MIME_TYPE; |
|
1008 break; |
|
1009 } |
|
1010 |
|
1011 case KHttp922DeviceAborted: |
|
1012 case KHttp952DeviceAborted: |
|
1013 { |
|
1014 resId = R_QTN_CD_INFO_UNKNOWN_TYPE; |
|
1015 break; |
|
1016 } |
|
1017 |
|
1018 case KHttp905AttributeMismatch: |
|
1019 case KHttp923NonAcceptableContent: |
|
1020 case KHttp953NonAcceptableContent: |
|
1021 { |
|
1022 resId = R_QTN_CD_INFO_UNSUPP_MIME_TYPE; |
|
1023 break; |
|
1024 } |
|
1025 |
|
1026 case KHttp924LoaderError: |
|
1027 case KHttp954LoaderError: |
|
1028 case KHttp951InvalidDdVersion: |
|
1029 { |
|
1030 resId = R_QTN_CD_INFO_GENERIC_ERROR; |
|
1031 break; |
|
1032 } |
|
1033 |
|
1034 default: |
|
1035 { |
|
1036 __ASSERT_DEBUG( EFalse, CodUiPanic( ECodUiUnknownStatus ) ); |
|
1037 break; |
|
1038 } |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 if ( resId ) |
|
1043 { |
|
1044 CodDialog::InfoNoteL( resId, *iEikEnv ); |
|
1045 } |
|
1046 else if ( err ) |
|
1047 { |
|
1048 TPtrC msg( iErrorUi->TextResolver().ResolveErrorString( err ) ); |
|
1049 CodDialog::InfoNoteL( msg ); |
|
1050 } |
|
1051 CLOG(( 2, _L("<- CCodDownloadImpl::LoadFailedL") )); |
|
1052 return ETrue; |
|
1053 } |
|
1054 |
|
1055 // ---------------------------------------------------------- |
|
1056 // CCodDownloadImpl::RoapOkL() |
|
1057 // ---------------------------------------------------------- |
|
1058 // |
|
1059 TBool CCodDownloadImpl::RoapOkL() |
|
1060 { |
|
1061 CLOG(( 2, _L("-> CCodDownloadImpl::RoapOkL") )); |
|
1062 __ASSERT_DEBUG( iEikEnv, CodUiPanic( ECodUiInternal ) ); |
|
1063 __ASSERT_DEBUG( !iFota, CodUiPanic( ECodUiInternal ) ); |
|
1064 __ASSERT_DEBUG( iRoap, CodUiPanic( ECodUiInternal ) ); |
|
1065 __ASSERT_DEBUG( !iProgress.iError, CodUiPanic( ECodUiInternal ) ); |
|
1066 TBool done( ETrue ); |
|
1067 const CRoapData* roapData = iEng->GetRoapData(); |
|
1068 if ( roapData ) // Safety code. |
|
1069 { |
|
1070 switch( roapData->iType ) |
|
1071 { |
|
1072 case Roap::ERegistrationTrigger: |
|
1073 { |
|
1074 CodDialog::ConfNoteL |
|
1075 ( R_QTN_DRM_CONF_DEVICE_REGISTERED, *iEikEnv ); |
|
1076 break; |
|
1077 } |
|
1078 |
|
1079 case Roap::ERoAcquisitionTrigger: |
|
1080 { |
|
1081 done = RoAcqOkL(); |
|
1082 break; |
|
1083 } |
|
1084 |
|
1085 case Roap::EJoinDomainTrigger: |
|
1086 { |
|
1087 if ( roapData->iDomainOperation == Roap::EJoinDomainOperation ) |
|
1088 { |
|
1089 CodDialog::ConfNoteL |
|
1090 ( R_QTN_DRM_CONF_JOINED_TO_DOMAIN, *iEikEnv ); |
|
1091 } |
|
1092 else |
|
1093 { |
|
1094 CodDialog::ConfNoteL |
|
1095 ( R_QTN_DRM_CONF_ACCOUNT_UPDATED, *iEikEnv ); |
|
1096 } |
|
1097 break; |
|
1098 } |
|
1099 |
|
1100 case Roap::ELeaveDomainTrigger: |
|
1101 { |
|
1102 CodDialog::ConfNoteL |
|
1103 ( R_QTN_DRM_INFO_REMOVE_FR_ACCOUNT, *iEikEnv ); |
|
1104 break; |
|
1105 } |
|
1106 |
|
1107 case Roap::EMeteringReportTrigger: |
|
1108 { |
|
1109 break; |
|
1110 } |
|
1111 |
|
1112 default: |
|
1113 { |
|
1114 // We should never get here. |
|
1115 __ASSERT_DEBUG( EFalse, CodUiPanic( ECodUiInternal ) ); |
|
1116 } |
|
1117 } |
|
1118 } |
|
1119 CLOG(( 2, _L("<- CCodDownloadImpl::RoapOkL (%d)"), done )); |
|
1120 return done; |
|
1121 } |
|
1122 |
|
1123 // ---------------------------------------------------------- |
|
1124 // CCodDownloadImpl::RoAcqOkL() |
|
1125 // ---------------------------------------------------------- |
|
1126 // |
|
1127 TBool CCodDownloadImpl::RoAcqOkL() |
|
1128 { |
|
1129 CLOG(( 2, _L("-> CCodDownloadImpl::RoAcqOkL") )); |
|
1130 __ASSERT_DEBUG( iEikEnv, CodUiPanic( ECodUiInternal ) ); |
|
1131 __ASSERT_DEBUG( !iFota, CodUiPanic( ECodUiInternal ) ); |
|
1132 const CRoapData* roapData = iEng->GetRoapData(); |
|
1133 __ASSERT_DEBUG ( roapData, CodUiPanic( ECodUiInternal ) ); |
|
1134 __ASSERT_DEBUG ( roapData->iType == \ |
|
1135 Roap::ERoAcquisitionTrigger, CodUiPanic( ECodUiInternal ) ); |
|
1136 |
|
1137 TFileName name; // Note, filename and extension only! Not full path. |
|
1138 TDataType type; |
|
1139 TUid appUid( TUid::Null() ); |
|
1140 RFile f; |
|
1141 CleanupClosePushL<RFile>( f ); |
|
1142 if ( !iSilentMode && !iSuppressLaunch && roapData->iContentIdList.Count() ) |
|
1143 { |
|
1144 __ASSERT_DEBUG( !iFs.Handle(), CodUiPanic( ECodUiInternal ) ); |
|
1145 User::LeaveIfError( iFs.Connect() ); |
|
1146 User::LeaveIfError( iFs.ShareProtected() ); |
|
1147 CDcfRep* dcfRep = CDcfRep::NewL(); |
|
1148 CleanupStack::PushL( dcfRep ); |
|
1149 // It is not specified what to do if we have more content ids. |
|
1150 // Best guess: open the first. |
|
1151 TPtrC8 cid( *(roapData->iContentIdList[0]) ); |
|
1152 TRAPD( err, dcfRep->GetFileHandleL ( cid, f, iFs ) ); |
|
1153 if ( !err && CodUtil::CanOpenL( f ) ) |
|
1154 { |
|
1155 User::LeaveIfError( f.Name( name ) ); |
|
1156 RApaLsSession apaLs; |
|
1157 User::LeaveIfError( apaLs.Connect() ); |
|
1158 CleanupClosePushL<RApaLsSession>( apaLs ); |
|
1159 User::LeaveIfError( apaLs.AppForDocument( f, appUid, type ) ); |
|
1160 CleanupStack::PopAndDestroy(); // apaLs |
|
1161 } |
|
1162 #ifdef __TEST_COD_LOG |
|
1163 else |
|
1164 { |
|
1165 CLOG(( 4, _L8(" err(%d) getting file by cid<%S>"), err, &cid )); |
|
1166 } |
|
1167 #endif /* def __TEST_COD_LOG */ |
|
1168 CleanupStack::PopAndDestroy( dcfRep ); |
|
1169 } |
|
1170 |
|
1171 TBool done( ETrue ); |
|
1172 if ( appUid.iUid ) |
|
1173 { |
|
1174 // MO (related to the received RO) is already here and is supported |
|
1175 // by the system. Ask user if he wants to open it now. |
|
1176 // "Activation key for 'Foo.jpg' received. Open the file now?" |
|
1177 __ASSERT_DEBUG( iFs.Handle(), CodUiPanic( ECodUiInternal ) ); |
|
1178 __ASSERT_DEBUG( f.SubSessionHandle(), CodUiPanic( ECodUiInternal ) ); |
|
1179 __ASSERT_DEBUG( name.Length(), CodUiPanic( ECodUiInternal ) ); |
|
1180 CAknQueryDialog* dialog = CAknQueryDialog::NewL(); |
|
1181 dialog->PrepareLC( R_COD_UI_CONFIRM_NOTE ); |
|
1182 HBufC* prompt = StringLoader::LoadLC |
|
1183 ( R_QTN_DRM_QUERY_KEY_RECEIVED_OPEN, name, iEikEnv ); |
|
1184 dialog->SetPromptL( *prompt ); |
|
1185 CleanupStack::PopAndDestroy( prompt ); |
|
1186 if ( dialog->RunLD() ) |
|
1187 { |
|
1188 CLOG(( 4, _L(" launching <%S>, handler(0x%x)"), \ |
|
1189 &name, appUid.iUid )); |
|
1190 __ASSERT_DEBUG( !iDocHandler, CodUiPanic( ECodUiInternal ) ); |
|
1191 __ASSERT_DEBUG( !iDocParams, CodUiPanic( ECodUiInternal ) ); |
|
1192 iDocHandler = CDocumentHandler::NewL(); |
|
1193 iDocHandler->SetExitObserver( this ); |
|
1194 iDocParams = CAiwGenericParamList::NewL(); |
|
1195 User::LeaveIfError |
|
1196 ( iDocHandler->OpenFileEmbeddedL( f, type, *iDocParams ) ); |
|
1197 // Warning: no leave after this point! |
|
1198 iState = EServiceFlow; |
|
1199 done = EFalse; |
|
1200 } |
|
1201 } |
|
1202 else |
|
1203 { |
|
1204 // "Activation key received" |
|
1205 CodDialog::ConfNoteL( R_QTN_DRM_INFO_ACT_KEY_RECEIVED, *iEikEnv ); |
|
1206 } |
|
1207 CleanupStack::PopAndDestroy( &f ); |
|
1208 CLOG(( 2, _L("<- CCodDownloadImpl::RoAcqOkL (%d)"), done )); |
|
1209 return done; |
|
1210 } |
|
1211 |
|
1212 // ---------------------------------------------------------- |
|
1213 // CCodDownloadImpl::RoapFailedL() |
|
1214 // ---------------------------------------------------------- |
|
1215 // |
|
1216 TBool CCodDownloadImpl::RoapFailedL() |
|
1217 { |
|
1218 CLOG(( 2, _L("-> CCodDownloadImpl::RoapFailedL iProgress.iError(%d)"), \ |
|
1219 iProgress.iError )); |
|
1220 __ASSERT_DEBUG( iEikEnv, CodUiPanic( ECodUiInternal ) ); |
|
1221 __ASSERT_DEBUG( !iFota, CodUiPanic( ECodUiInternal ) ); |
|
1222 __ASSERT_DEBUG( iRoap, CodUiPanic( ECodUiInternal ) ); |
|
1223 __ASSERT_DEBUG( iProgress.iError, CodUiPanic( ECodUiInternal ) ); |
|
1224 TBool done( ETrue ); |
|
1225 TInt resId = 0; |
|
1226 const CRoapData* roapData = iEng->GetRoapData(); |
|
1227 if ( roapData ) // Safety code |
|
1228 { |
|
1229 // Some errors need specific message. |
|
1230 switch ( iProgress.iError ) |
|
1231 { |
|
1232 case KErrRoapDomainFull: |
|
1233 { |
|
1234 resId = R_QTN_DRM_INFO_ACCOUNT_IS_FULL; |
|
1235 break; |
|
1236 } |
|
1237 case KErrRoapInvalidDomain: |
|
1238 { |
|
1239 resId = R_QTN_DRM_ACCOUNT_NOT_RECOGNISED; |
|
1240 break; |
|
1241 } |
|
1242 case KErrRoapServer: |
|
1243 { |
|
1244 // Temporary server error. For RoAcq, offer retry; for other |
|
1245 // ROAP-s, fall through to default handling (plain error note). |
|
1246 if ( roapData->iType == Roap::ERoAcquisitionTrigger ) |
|
1247 { |
|
1248 CAknQueryDialog* dialog = CAknQueryDialog::NewL(); |
|
1249 dialog->PrepareLC( R_COD_UI_CONFIRM_NOTE ); |
|
1250 HBufC* prompt = StringLoader::LoadLC |
|
1251 ( R_QTN_DRM_GET_KEY_FAILED_RETRY, iEikEnv ); |
|
1252 dialog->SetPromptL( *prompt ); |
|
1253 CleanupStack::PopAndDestroy( prompt ); |
|
1254 if ( dialog->RunLD() ) |
|
1255 { |
|
1256 ResetProgress(); |
|
1257 iProgress.iState = TCodDownloadProgress::EInProgress; |
|
1258 iEng->Accept( &iStatus ); |
|
1259 SetActive(); |
|
1260 iState = ELoad; |
|
1261 // Do not leave after this point! |
|
1262 done = EFalse; |
|
1263 } |
|
1264 break; |
|
1265 } |
|
1266 // Not RoAcq: fall through to default (error note). |
|
1267 } |
|
1268 default: |
|
1269 { |
|
1270 // Default error message is based on trigger type. |
|
1271 switch ( roapData->iType ) |
|
1272 { |
|
1273 case Roap::ERegistrationTrigger: |
|
1274 { |
|
1275 resId = R_QTN_DRM_INFO_DEVICE_REGIST_FAIL; |
|
1276 break; |
|
1277 } |
|
1278 case Roap::ERoAcquisitionTrigger: |
|
1279 { |
|
1280 resId = R_QTN_DRM_INFO_GETTING_KEY_FAILED; |
|
1281 break; |
|
1282 } |
|
1283 case Roap::EJoinDomainTrigger: |
|
1284 { |
|
1285 if ( roapData->iDomainOperation == |
|
1286 Roap::EJoinDomainOperation ) |
|
1287 { |
|
1288 resId = R_QTN_DRM_INFO_REGISTRATION_FAILED; |
|
1289 } |
|
1290 else |
|
1291 { |
|
1292 resId = R_QTN_DRM_INFO_UPDATE_DOMAIN_FAIL; |
|
1293 } |
|
1294 break; |
|
1295 } |
|
1296 case Roap::ELeaveDomainTrigger: |
|
1297 { |
|
1298 resId = R_QTN_DRM_REMOVE_FR_ACCOUNT_FAIL; |
|
1299 break; |
|
1300 } |
|
1301 case Roap::EMeteringReportTrigger: |
|
1302 { |
|
1303 break; |
|
1304 } |
|
1305 default: |
|
1306 { |
|
1307 __ASSERT_DEBUG( EFalse, \ |
|
1308 CodUiPanic( ECodUiInternal ) ); |
|
1309 } |
|
1310 } |
|
1311 break; |
|
1312 } |
|
1313 } |
|
1314 if( resId ) |
|
1315 { |
|
1316 CodDialog::InfoNoteL( resId, *iEikEnv ); |
|
1317 } |
|
1318 } |
|
1319 CLOG(( 2, _L("<- CCodDownloadImpl::RoapFailedL (%d)"), done )); |
|
1320 return done; |
|
1321 } |
|
1322 |
|
1323 // ---------------------------------------------------------- |
|
1324 // CCodDownloadImpl::ActivateNextUrlL() |
|
1325 // ---------------------------------------------------------- |
|
1326 // |
|
1327 void CCodDownloadImpl::ActivateNextUrlL() |
|
1328 { |
|
1329 CLOG(( 2, _L("-> CCodDownloadImpl::ActivateNextUrlL") )); |
|
1330 __ASSERT_DEBUG( iEikEnv, CodUiPanic( ECodUiInternal ) ); |
|
1331 __ASSERT_DEBUG( !iFota, CodUiPanic( ECodUiInternal ) ); |
|
1332 |
|
1333 if ( iSilentMode || iSuppressNextUrl ) |
|
1334 { |
|
1335 CLOG(( 2, _L("<- CCodDownloadImpl::ActivateNextUrlL (off)") )); |
|
1336 return; |
|
1337 } |
|
1338 |
|
1339 TBool back( EFalse ); |
|
1340 TPtrC8 url( NextUrlAttr( back ) ); |
|
1341 |
|
1342 if ( url.Length() || back ) |
|
1343 { |
|
1344 HBufC8* msg; |
|
1345 if ( url.Length() ) |
|
1346 { |
|
1347 // Activate URL in Browser. |
|
1348 HBufC8* absUrl = |
|
1349 CodUtil::AbsoluteUrlLC( iEng->Data().SourceUri(), url ); |
|
1350 msg = HBufC8::NewL |
|
1351 ( ((TDesC)KCodMsgLaunchBrowserWithUrl).Length() + |
|
1352 absUrl->Length() ); // Not pushed, no leaving calls... |
|
1353 msg->Des().Append( KCodMsgLaunchBrowserWithUrl ); |
|
1354 msg->Des().Append( *absUrl ); |
|
1355 CleanupStack::PopAndDestroy( absUrl ); |
|
1356 CleanupStack::PushL( msg ); // ...until this point! |
|
1357 } |
|
1358 else |
|
1359 { |
|
1360 // Empty URL (back), activate Browser. |
|
1361 msg = HBufC8::NewLC( 0 ); |
|
1362 } |
|
1363 |
|
1364 TApaTaskList taskList( iEikEnv->WsSession() ); |
|
1365 TApaTask task = taskList.FindApp( TUid::Uid( KCodWmlBrowserUid ) ); |
|
1366 if ( task.Exists() ) |
|
1367 { |
|
1368 // Browser is already running, send a message to it. |
|
1369 // (If not running, we don't launch it.) |
|
1370 task.SendMessage( TUid::Uid( 0 ), *msg ); |
|
1371 } |
|
1372 |
|
1373 CleanupStack::PopAndDestroy( msg ); |
|
1374 } |
|
1375 CLOG(( 2, _L("<- CCodDownloadImpl::ActivateNextUrlL") )); |
|
1376 } |
|
1377 |
|
1378 // --------------------------------------------------------- |
|
1379 // CCodDownloadImpl::Done() |
|
1380 // --------------------------------------------------------- |
|
1381 // |
|
1382 void CCodDownloadImpl::Done() |
|
1383 { |
|
1384 CLOG(( 2, \ |
|
1385 _L("-> CCodDownloadImpl::Done state (%d) p.state(%d) p.err(%d)"), |
|
1386 iState, iProgress.iState, iProgress.iError )); |
|
1387 __ASSERT_DEBUG( iProgress.iState > TCodDownloadProgress::EInProgress, \ |
|
1388 CodUiPanic( ECodUiInternal ) ); |
|
1389 iState = EInit; |
|
1390 // State change must come before the EDone callback. |
|
1391 CLOG(( 2, _L("CodEventL(0x%x,EDone)"), &iProxy )); |
|
1392 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EDone ) ); |
|
1393 CLOG(( 2, _L("<- CCodDownloadImpl::Done") )); |
|
1394 } |
|
1395 |
|
1396 // ---------------------------------------------------------- |
|
1397 // CCodDownloadImpl::GetRootPathL() |
|
1398 // ---------------------------------------------------------- |
|
1399 // |
|
1400 void CCodDownloadImpl::GetRootPathL( TDes& aRootPath ) |
|
1401 { |
|
1402 CLOG(( 2, _L("-> CCodDownloadImpl::GetRootPathL") )); |
|
1403 if ( iEikEnv ) |
|
1404 { |
|
1405 CodDialog::GetRootPathL( aRootPath ); |
|
1406 } |
|
1407 else |
|
1408 { |
|
1409 // Without UI we download to phone memory. |
|
1410 #ifdef RD_MULTIPLE_DRIVE |
|
1411 TInt drive; |
|
1412 User::LeaveIfError( |
|
1413 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive ) ); |
|
1414 User::LeaveIfError( PathInfo::GetRootPath( aRootPath, drive ) ); |
|
1415 #else |
|
1416 aRootPath = PathInfo::PhoneMemoryRootPath(); |
|
1417 #endif |
|
1418 } |
|
1419 CLOG(( 2, _L("<- CCodDownloadImpl::GetRootPathL <%S>"), &aRootPath )); |
|
1420 } |
|
1421 |
|
1422 // ---------------------------------------------------------- |
|
1423 // CCodDownloadImpl::StartLoadL() |
|
1424 // ---------------------------------------------------------- |
|
1425 // |
|
1426 void CCodDownloadImpl::StartLoadL( TInt aStatusCode ) |
|
1427 { |
|
1428 CLOG(( 2, _L("CCodDownloadImpl::StartLoadL aStatusCode(%d)"), \ |
|
1429 aStatusCode )); |
|
1430 if ( aStatusCode != KHttp900Success ) |
|
1431 { |
|
1432 // Error report started, update name. |
|
1433 CLOG(( 2, _L("CodEventL(0x%x,ENameChanged)"), &iProxy )); |
|
1434 iObserver.CodEventL( iProxy, MCodDownloadObserver::ENameChanged ); |
|
1435 CLOG(( 2, _L("CodEventL(0x%x,ETypeChanged)"), &iProxy )); |
|
1436 iObserver.CodEventL( iProxy, MCodDownloadObserver::ETypeChanged ); |
|
1437 } |
|
1438 // Network activity started, bring up download list. |
|
1439 CLOG(( 2, _L("CodEventL(0x%x,EAccept)"), &iProxy )); |
|
1440 iObserver.CodEventL ( iProxy, MCodDownloadObserver::EAccept ); |
|
1441 iObserver.CodEventL ( iProxy, MCodDownloadObserver::ENameChanged ); |
|
1442 } |
|
1443 |
|
1444 // ---------------------------------------------------------- |
|
1445 // CCodDownloadImpl::StartCancelL() |
|
1446 // ---------------------------------------------------------- |
|
1447 // |
|
1448 void CCodDownloadImpl::StartCancelL() |
|
1449 { |
|
1450 CLOG(( 2, _L("CCodDownloadImpl::StartCancelL") )); |
|
1451 } |
|
1452 |
|
1453 // ---------------------------------------------------------- |
|
1454 // CCodDownloadImpl::ProgressL() |
|
1455 // ---------------------------------------------------------- |
|
1456 // |
|
1457 void CCodDownloadImpl::ProgressL( TInt aFinalValue, TInt aCurrentValue ) |
|
1458 { |
|
1459 CLOG(( 2, _L("-> CCodDownloadImpl::ProgressL(%d/%d)"), \ |
|
1460 aCurrentValue, aFinalValue )); |
|
1461 iProgress.iBytesCur = aCurrentValue; |
|
1462 iProgress.iBytesMax = aFinalValue; |
|
1463 CLOG(( 2, _L("CodEventL(0x%x,EProgressUpdate)"), &iProxy )); |
|
1464 iObserver.CodEventL( iProxy, MCodDownloadObserver::EProgressUpdate ); |
|
1465 CLOG(( 2, _L("<- CCodDownloadImpl::ProgressL") )); |
|
1466 } |
|
1467 |
|
1468 // ---------------------------------------------------------- |
|
1469 // CCodDownloadImpl::Done() |
|
1470 // ---------------------------------------------------------- |
|
1471 // |
|
1472 void CCodDownloadImpl::Done |
|
1473 ( TInt LOG_ONLY( aStatusCode ), TInt LOG_ONLY( aError ) ) |
|
1474 { |
|
1475 CLOG(( 2, _L("CCodDownloadImpl::Done aStatusCode(%d) aError(%d)"), \ |
|
1476 aStatusCode, aError )); |
|
1477 } |
|
1478 |
|
1479 // ---------------------------------------------------------- |
|
1480 // CCodDownloadImpl::ConfirmConnectL() |
|
1481 // ---------------------------------------------------------- |
|
1482 // |
|
1483 TBool CCodDownloadImpl::ConfirmConnectL() |
|
1484 { |
|
1485 CLOG(( 2, _L("-> CCodDownloadImpl::ConfirmConnectL") )); |
|
1486 TBool connect( EFalse ); // Say no by default. (Applies if no UI present.) |
|
1487 if ( iEikEnv ) |
|
1488 { |
|
1489 connect = CodDialog::ConfirmConnectL(); |
|
1490 } |
|
1491 CLOG(( 2, _L("<- CCodDownloadImpl::ConfirmConnectL(%d)"), connect )); |
|
1492 return connect; |
|
1493 } |
|
1494 |
|
1495 // ---------------------------------------------------------- |
|
1496 // CCodDownloadImpl::StartConnect() |
|
1497 // ---------------------------------------------------------- |
|
1498 // |
|
1499 void CCodDownloadImpl::StartConnect( TUint32 LOG_ONLY( aIap ) ) |
|
1500 { |
|
1501 CLOG(( 2, _L("CCodDownloadImpl::StartConnect aIap(%d)"), aIap )); |
|
1502 } |
|
1503 |
|
1504 // ---------------------------------------------------------- |
|
1505 // CCodDownloadImpl::EndConnect() |
|
1506 // ---------------------------------------------------------- |
|
1507 // |
|
1508 void CCodDownloadImpl::EndConnect() |
|
1509 { |
|
1510 CLOG(( 2, _L("CCodDownloadImpl::EndConnect") )); |
|
1511 } |
|
1512 |
|
1513 // ---------------------------------------------------------- |
|
1514 // CCodDownloadImpl::UserAuthL() |
|
1515 // ---------------------------------------------------------- |
|
1516 // |
|
1517 TBool CCodDownloadImpl::UserAuthL |
|
1518 ( |
|
1519 const TDesC& LOG_ONLY( aHost ), |
|
1520 const TDesC& LOG_ONLY( aRealm ), |
|
1521 TBool LOG_ONLY( aProxyAuth ), |
|
1522 TDes& aUsername, |
|
1523 TDes& aPassword |
|
1524 ) |
|
1525 { |
|
1526 CLOG(( 2, _L("CCodDownloadImpl::UserAuthL") )); |
|
1527 CLOG(( 3, _L(" aHost<%S>"), &aHost )); |
|
1528 CLOG(( 3, _L(" aRealm<%S>"), &aRealm )); |
|
1529 CLOG(( 3, _L(" aProxyAuth(0x%x)"), aProxyAuth )); |
|
1530 // Feature dropped - empty implementation. |
|
1531 aUsername.Zero(); |
|
1532 aPassword.Zero(); |
|
1533 return ETrue; |
|
1534 } |
|
1535 |
|
1536 // ---------------------------------------------------------- |
|
1537 // CCodDownloadImpl::RoapTriggerParsedL() |
|
1538 // ---------------------------------------------------------- |
|
1539 // |
|
1540 void CCodDownloadImpl::RoapTriggerParsedL( const CRoapData& aData ) |
|
1541 { |
|
1542 CLOG(( 2, _L("-> CCodDownloadImpl::RoapTriggerParsedL") )); |
|
1543 iRoap = ETrue; |
|
1544 #ifdef __TEST_COD_LOG |
|
1545 CLOG(( 4, _L(" Trigger type(%d) contextStatus(%d) domainOp(%d)"), \ |
|
1546 aData.iType, aData.iContextStatus, aData.iDomainOperation )); |
|
1547 TPtrC8 ptr; |
|
1548 for ( TInt i = 0; i < aData.iContentIdList.Count(); i++ ) |
|
1549 { |
|
1550 ptr.Set( aData.iContentIdList[i]->Des() ); |
|
1551 CLOG(( 4, _L8(" cid#%d:<%S>"), i, &ptr )); |
|
1552 } |
|
1553 if ( aData.iRiAlias ) |
|
1554 { |
|
1555 ptr.Set( aData.iRiAlias->Des() ); |
|
1556 CLOG(( 4, _L8(" riAlias <%S>"), &ptr )); |
|
1557 } |
|
1558 else |
|
1559 { |
|
1560 CLOG(( 4, _L8(" riAlias NULL") )); |
|
1561 } |
|
1562 #endif /* def __TEST_COD_LOG */ |
|
1563 |
|
1564 if ( aData.iContextStatus == Roap::EInvalidContext ) |
|
1565 { |
|
1566 #ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION |
|
1567 HBufC* header = StringLoader::LoadLC( R_QTN_DRM_MSQ_QRY_TITLE_REGISTRAT ); |
|
1568 HBufC* regtxt = StringLoader::LoadLC( R_QTN_DRM_MSQ_QUERY_REGISTRATION ); |
|
1569 HBufC* moreinfo = StringLoader::LoadLC( R_QTN_DRM_MSQ_QUERY_LINK_MORE_INF ); |
|
1570 |
|
1571 HBufC* regtxt_moreinfo = HBufC::NewLC(regtxt->Length() + moreinfo->Length() + 1 ); |
|
1572 TPtr regPtr( regtxt_moreinfo->Des() ); |
|
1573 regPtr += *regtxt; |
|
1574 regPtr += KNextLine; |
|
1575 regPtr += *moreinfo; |
|
1576 |
|
1577 |
|
1578 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *regtxt_moreinfo ); |
|
1579 dlg->PrepareLC( R_COD_REGISTERCANCEL_QUERY ); |
|
1580 |
|
1581 CAknPopupHeadingPane* hPane = dlg->QueryHeading(); |
|
1582 if ( hPane ) |
|
1583 { |
|
1584 hPane->SetTextL( *header ); |
|
1585 } |
|
1586 |
|
1587 // set link |
|
1588 dlg->SetLinkTextL(*moreinfo); |
|
1589 TCallBack callback(ShowRoapCallback, this); |
|
1590 dlg->SetLink(callback); |
|
1591 |
|
1592 TInt ret = dlg->RunLD(); |
|
1593 if( ret != EAknSoftkeyYes ) |
|
1594 { |
|
1595 CLOG(( 4, _L(" cancelled") )); |
|
1596 User::Leave( KErrCancel ); |
|
1597 } |
|
1598 CleanupStack::PopAndDestroy(4); // header, regtxt, moreinfo and regtxt_moreinfo |
|
1599 #else // RD_DRM_SILENT_RIGHTS_ACQUISITION |
|
1600 // No valid RI context, ROAP will involve device registration. |
|
1601 // User must confirm. |
|
1602 CLOG(( 4, _L(" invalid context") )); |
|
1603 CAknQueryDialog* dialog = CAknQueryDialog::NewL(); |
|
1604 dialog->PrepareLC( R_COD_UI_CONFIRM_NOTE ); |
|
1605 HBufC* prompt; |
|
1606 if ( aData.iRiAlias ) |
|
1607 { |
|
1608 // "Registration with %U needed. Register phone?" |
|
1609 HBufC* riAlias16 = CodUtil::ConvertLC( *aData.iRiAlias ); |
|
1610 prompt = StringLoader::LoadL |
|
1611 ( R_QTN_DRM_QUERY_REGISTER_WITH_U, *riAlias16, iEikEnv ); |
|
1612 CleanupStack::PopAndDestroy( riAlias16 ); |
|
1613 CleanupStack::PushL( prompt ); |
|
1614 } |
|
1615 else |
|
1616 { |
|
1617 // "Registration with content provider needed. Register phone?" |
|
1618 prompt = StringLoader::LoadLC |
|
1619 ( R_QTN_DRM_QUERY_REGISTER_WITH_CP, iEikEnv ); |
|
1620 } |
|
1621 dialog->SetPromptL( *prompt ); |
|
1622 CleanupStack::PopAndDestroy( prompt ); |
|
1623 if ( !dialog->RunLD() ) |
|
1624 { |
|
1625 CLOG(( 4, _L(" cancelled") )); |
|
1626 User::Leave( KErrCancel ); |
|
1627 } |
|
1628 #endif |
|
1629 } |
|
1630 |
|
1631 CLOG(( 2, _L("<- CCodDownloadImpl::RoapTriggerParsedL") )); |
|
1632 } |
|
1633 |
|
1634 // ---------------------------------------------------------- |
|
1635 // CCodDownloadImpl::HandleServerAppExit() |
|
1636 // ---------------------------------------------------------- |
|
1637 // |
|
1638 void CCodDownloadImpl::HandleServerAppExit( TInt /*aReason*/ ) |
|
1639 { |
|
1640 CLOG(( 2, _L("-> CCodDownloadImpl::HandleServerAppExit") )); |
|
1641 TRAP_IGNORE( ActivateNextUrlL() ); |
|
1642 Done(); |
|
1643 CLOG(( 2, _L("<- CCodDownloadImpl::HandleServerAppExit") )); |
|
1644 } |
|
1645 |
|
1646 // ---------------------------------------------------------- |
|
1647 // CCodDownloadImpl::NextUrlAttr() |
|
1648 // ---------------------------------------------------------- |
|
1649 // |
|
1650 TPtrC8 CCodDownloadImpl::NextUrlAttr( TBool& aBack ) const |
|
1651 { |
|
1652 CLOG(( 2, _L("-> CCodDownloadImpl::NextUrlAttr") )); |
|
1653 TPtrC8 url; |
|
1654 aBack = EFalse; |
|
1655 const CCodData& data = iEng->Data(); |
|
1656 if( iCod ) |
|
1657 { |
|
1658 // This is a COD: choose between Next-URL or Next_URLatError. |
|
1659 if ( iEng->GetStatusCode() == KHttp900Success ) |
|
1660 { |
|
1661 url.Set( data.NextUrl() ); |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 url.Set( data.NextUrlAtError() ); |
|
1666 } |
|
1667 // Recognize 'back' or 'local'. |
|
1668 if ( url.Length() ) |
|
1669 { |
|
1670 if ( !url.Compare( KCodReservedWordLocal ) ) |
|
1671 { |
|
1672 // 'local' -> no URL to launch. |
|
1673 url.Set( KNullDesC8 ); |
|
1674 } |
|
1675 else if ( !url.Compare( KCodReservedWordBack ) ) |
|
1676 { |
|
1677 // 'back' -> no URL to launch. |
|
1678 url.Set( KNullDesC8 ); |
|
1679 aBack = ETrue; |
|
1680 } |
|
1681 } |
|
1682 } |
|
1683 else |
|
1684 { |
|
1685 // This is a DD: NextURL goes for success and failure. |
|
1686 url.Set( data.NextUrl() ); |
|
1687 } |
|
1688 |
|
1689 CLOG(( 2, _L8("<- CCodDownloadImpl::NextUrlAttr url<%S> back(%d)"), \ |
|
1690 &url, aBack )); |
|
1691 return url; |
|
1692 } |
|
1693 |
|
1694 // ---------------------------------------------------------- |
|
1695 // CCodAppUi::PdPlayAvailable() |
|
1696 // ---------------------------------------------------------- |
|
1697 // |
|
1698 void CCodDownloadImpl::PdPlayAvailable() |
|
1699 { |
|
1700 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EPdPlayAvailable ) ); |
|
1701 } |
|
1702 |
|
1703 // ---------------------------------------------------------- |
|
1704 // CCodDownloadImpl::UpdateMediaInfoL() |
|
1705 // ---------------------------------------------------------- |
|
1706 // |
|
1707 void CCodDownloadImpl::UpdateMediaInfoL() |
|
1708 { |
|
1709 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EUpdatedMediaInfo ) ); |
|
1710 } |
|
1711 |
|
1712 // ---------------------------------------------------------- |
|
1713 // CCodDownloadImpl::UpdateTrackInfoL() |
|
1714 // ---------------------------------------------------------- |
|
1715 // |
|
1716 void CCodDownloadImpl::UpdateTrackInfoL() |
|
1717 { |
|
1718 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::EUpdatedTrackInfo ) ); |
|
1719 } |
|
1720 |
|
1721 // ---------------------------------------------------------- |
|
1722 // CCodDownloadImpl::WaitForLicenseL() |
|
1723 // ---------------------------------------------------------- |
|
1724 // |
|
1725 void CCodDownloadImpl::WaitForLicenseL() |
|
1726 { |
|
1727 CodDialog::InfoNoteL( R_QTN_BROWSER_DOWNLOADS_WAITING_FOR_LICENSE, *iEikEnv ); |
|
1728 } |
|
1729 |
|
1730 // ---------------------------------------------------------- |
|
1731 // CCodDownloadImpl::UpdatePausable |
|
1732 // ---------------------------------------------------------- |
|
1733 // |
|
1734 void CCodDownloadImpl::UpdatePausable( TBool aPausable ) |
|
1735 { |
|
1736 TRAP_IGNORE( iObserver.CodEventL( iProxy, aPausable ? MCodDownloadObserver::EDownloadPausable |
|
1737 : MCodDownloadObserver::EDownloadNonPausable ) ); |
|
1738 } |
|
1739 |
|
1740 // ---------------------------------------------------------- |
|
1741 // CCodDownloadImpl::MediaObjectNameChanged() |
|
1742 // ---------------------------------------------------------- |
|
1743 // |
|
1744 void CCodDownloadImpl::MediaObjectNameChanged() |
|
1745 { |
|
1746 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::ENameChanged )); |
|
1747 } |
|
1748 |
|
1749 // ---------------------------------------------------------- |
|
1750 // CCodDownloadImpl::ContentTypeChanged() |
|
1751 // ---------------------------------------------------------- |
|
1752 // |
|
1753 void CCodDownloadImpl::ContentTypeChanged() |
|
1754 { |
|
1755 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::ETypeChanged )); |
|
1756 } |
|
1757 |
|
1758 // ---------------------------------------------------------- |
|
1759 // CCodDownloadImpl::SetActiveDownload() |
|
1760 // ---------------------------------------------------------- |
|
1761 // |
|
1762 void CCodDownloadImpl::SetActiveDownload( ) |
|
1763 { |
|
1764 TRAP_IGNORE( iObserver.CodEventL( iProxy, MCodDownloadObserver::ESetActiveDownload )); |
|
1765 } |
|
1766 |
|
1767 EXPORT_C TInt CCodDownloadImpl::ActiveDownload() |
|
1768 { |
|
1769 return iEng->ActiveDownload(); |
|
1770 } |
|
1771 // ---------------------------------------------------------- |
|
1772 // CCodDownloadImpl::HandleRoapPostResponseUrlL() |
|
1773 // ---------------------------------------------------------- |
|
1774 // |
|
1775 void CCodDownloadImpl::HandleRoapPostResponseUrlL( const TDesC8& aPrUrl ) |
|
1776 { |
|
1777 |
|
1778 if(iPostResponseURL) |
|
1779 { |
|
1780 delete iPostResponseURL; |
|
1781 iPostResponseURL = NULL; |
|
1782 } |
|
1783 |
|
1784 iPostResponseURL = aPrUrl.AllocL(); |
|
1785 |
|
1786 iObserver.CodEventL( iProxy, MCodDownloadObserver::EHandlePostResponse ); |
|
1787 } |