|
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: Supports user interaction dialogs for downloads |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CUserInteractionsUtils.h" |
|
22 #include "MDownloadHandlerObserver.h" |
|
23 #include "CDownloadMgrUiBase.h" |
|
24 #include "CDownloadMgrUiLibRegistry.h" |
|
25 #include "CDownloadMgrUiDownloadsList.h" |
|
26 #include "CDownloadMgrUiUserInteractions.h" |
|
27 #include "UiLibLogger.h" |
|
28 #include "DMgrUiLibPanic.h" |
|
29 #include <DownloadMgrUiLib.rsg> |
|
30 #include <DownloadMgrClient.h> |
|
31 #include <AiwGenericParam.h> |
|
32 #include <DocumentHandler.h> |
|
33 #include <coemain.h> |
|
34 #include <ErrorUI.h> |
|
35 #include <eikenv.h> |
|
36 #include <apmstd.h> |
|
37 #include <CAknFileSelectionDialog.h> |
|
38 #include <CAknMemorySelectionDialog.h> |
|
39 #include <AknQueryDialog.h> |
|
40 #include <StringLoader.h> |
|
41 #include <AknSoftNotificationParameters.h> |
|
42 #include <AknSoftNotifier.h> |
|
43 #include <AknNoteWrappers.h> |
|
44 #include <BrowserDialogsProvider.h> |
|
45 #include <HttpDownloadMgrCommon.h> |
|
46 #include <PathInfo.h> |
|
47 #include <aknglobalnote.h> |
|
48 #include <Oma2Agent.h> |
|
49 #include <DRMCommon.h> |
|
50 #include <apmrec.h> |
|
51 #include <apgcli.h> |
|
52 #include <s32mem.h> |
|
53 #include "bautils.h" |
|
54 #include <etelmm.h> |
|
55 #include <MmTsy_names.h> |
|
56 #include <rconnmon.h> |
|
57 #include <DcfEntry.h> |
|
58 #include <DcfRep.h> |
|
59 #include <MGXFileManagerFactory.h> |
|
60 #include <CMGXFileManager.h> |
|
61 |
|
62 // LOCAL CONSTANTS AND MACROS |
|
63 const TInt KErrorUiHttpStatusBase = -25000; |
|
64 const TInt KMinimumSoftNotePriority = 1000; |
|
65 #define GLOBAL_HTTP_ERROR( err ) ( KErrorUiHttpStatusBase - err ) |
|
66 |
|
67 const TInt FilenameSuffixMaxLength = 16; // Extra space for localization |
|
68 const TInt FilenameSuffixMaxValue = 9999;// Maximum file number |
|
69 |
|
70 // ============================ MEMBER FUNCTIONS =============================== |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CUserInteractionsUtils::CUserInteractionsUtils |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CUserInteractionsUtils::CUserInteractionsUtils( CDownloadMgrUiBase& aDMgrUiBase, |
|
77 MDownloadMgrUiLibRegModel& aRegistryModel ) |
|
78 : iCoeEnv( *CCoeEnv::Static() ), |
|
79 iDMgrUiBase( aDMgrUiBase ), |
|
80 iRegistryModel( aRegistryModel ), |
|
81 iDocHandlerUsesTheUi( EFalse ) |
|
82 { |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CUserInteractionsUtils::ConstructL |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CUserInteractionsUtils::ConstructL() |
|
90 { |
|
91 CLOG_ENTERFN("CUserInteractionsUtils::ConstructL"); |
|
92 iDialogsProv = CBrowserDialogsProvider::NewL( 0 ); |
|
93 CLOG_WRITE(" iDialogsProv OK"); |
|
94 iSoftNotifier = CAknSoftNotifier::NewL(); |
|
95 CLOG_WRITE(" iSoftNotifier OK"); |
|
96 iErrorUi = CErrorUI::NewL(); |
|
97 |
|
98 iUnderTenFormatter = StringLoader::LoadL( R_QTN_IV_NAME_SUFFIX_UNDER_TEN_FORMATTER ); |
|
99 iOverTenFormatter = StringLoader::LoadL( R_QTN_IV_NAME_SUFFIX_OVER_TEN_FORMATTER ); |
|
100 iSearchChar = (*iUnderTenFormatter)[0]; |
|
101 iCodDownload = EFalse; |
|
102 |
|
103 CLOG_LEAVEFN("CUserInteractionsUtils::ConstructL"); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CUserInteractionsUtils::NewL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 CUserInteractionsUtils* CUserInteractionsUtils::NewL |
|
111 ( CDownloadMgrUiBase& aDMgrUiBase, MDownloadMgrUiLibRegModel& aRegistryModel ) |
|
112 { |
|
113 CUserInteractionsUtils* self = |
|
114 new ( ELeave ) CUserInteractionsUtils( aDMgrUiBase, aRegistryModel ); |
|
115 CleanupStack::PushL( self ); |
|
116 self->ConstructL(); |
|
117 CleanupStack::Pop(); |
|
118 return self; |
|
119 } |
|
120 |
|
121 // Destructor |
|
122 CUserInteractionsUtils::~CUserInteractionsUtils() |
|
123 { |
|
124 CLOG_ENTERFN("CUserInteractionsUtils::~CUserInteractionsUtils"); |
|
125 // Cancel all executing dialogs/notes/controls |
|
126 CancelAllDialogs(); |
|
127 CLOG_WRITE(" CancelAllDialogs OK"); |
|
128 delete iDocHandler; |
|
129 CLOG_WRITE(" iDocHandler OK"); |
|
130 delete iSoftNotifier; |
|
131 CLOG_WRITE(" iSoftNotifier OK"); |
|
132 delete iErrorUi; |
|
133 CLOG_WRITE(" iErrorUi OK"); |
|
134 delete iUnderTenFormatter; |
|
135 CLOG_WRITE(" iUnderTenFormatter OK"); |
|
136 delete iOverTenFormatter; |
|
137 CLOG_WRITE(" iOverTenFormatter OK"); |
|
138 CLOG_LEAVEFN("CUserInteractionsUtils::~CUserInteractionsUtils"); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CUserInteractionsUtils::ShowErrorNoteL |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CUserInteractionsUtils::ShowErrorNoteL( RHttpDownload& aDownload, |
|
146 TInt32 aErrorId ) |
|
147 { |
|
148 TInt32 sysErrorId( KErrNone ); // Global (system-wide) error ID |
|
149 |
|
150 // DMgr specific error code. See THttpDownloadMgrError. |
|
151 // Convert it to Symbian OS system-wide error code. |
|
152 switch ( aErrorId ) |
|
153 { |
|
154 case EGeneral: |
|
155 { |
|
156 // EDlAttrGlobalErrorId gives the system-wide code. |
|
157 User::LeaveIfError( aDownload.GetIntAttribute |
|
158 ( EDlAttrGlobalErrorId, sysErrorId ) ); |
|
159 break; |
|
160 } |
|
161 case EInternal: |
|
162 { |
|
163 sysErrorId = KErrGeneral; |
|
164 break; |
|
165 } |
|
166 case EContentFileIntegrity: |
|
167 { |
|
168 sysErrorId = KErrCorrupt; |
|
169 break; |
|
170 } |
|
171 case EDiskFull: |
|
172 { |
|
173 sysErrorId = KErrDiskFull; |
|
174 break; |
|
175 } |
|
176 case EConnectionFailed: |
|
177 case ETransactionFailed: |
|
178 case EMoveFailed: |
|
179 { |
|
180 // EDlAttrGlobalErrorId gives the system-wide code. |
|
181 User::LeaveIfError( aDownload.GetIntAttribute |
|
182 ( EDlAttrGlobalErrorId, sysErrorId ) ); |
|
183 break; |
|
184 } |
|
185 case EDestFileWriteFailed: |
|
186 { |
|
187 sysErrorId = KErrWrite; |
|
188 break; |
|
189 } |
|
190 case EMMCRemoved: |
|
191 { |
|
192 sysErrorId = KErrNotFound; |
|
193 break; |
|
194 } |
|
195 case EBadUrl: |
|
196 { |
|
197 sysErrorId = GLOBAL_HTTP_ERROR(414); |
|
198 break; |
|
199 } |
|
200 case EWrongDestFilename: |
|
201 { |
|
202 sysErrorId = KErrArgument; |
|
203 break; |
|
204 } |
|
205 case EDestFileInUse: |
|
206 { |
|
207 sysErrorId = KErrAccessDenied; |
|
208 break; |
|
209 } |
|
210 case EHttpUnhandled: |
|
211 { |
|
212 // EDlAttrGlobalErrorId gives the system-wide code. |
|
213 User::LeaveIfError( aDownload.GetIntAttribute |
|
214 ( EDlAttrGlobalErrorId, sysErrorId ) ); |
|
215 break; |
|
216 } |
|
217 // Don't show error notification in the following cases: |
|
218 case EHttpAuthenticationFailed: |
|
219 case EProxyAuthenticationFailed: |
|
220 { |
|
221 sysErrorId = KErrNone; |
|
222 break; |
|
223 } |
|
224 case EObjectNotFound: |
|
225 { |
|
226 // Convert to global http error code. |
|
227 sysErrorId = GLOBAL_HTTP_ERROR(404); |
|
228 break; |
|
229 } |
|
230 case EPartialContentModified: |
|
231 { |
|
232 sysErrorId = GLOBAL_HTTP_ERROR(412); |
|
233 break; |
|
234 } |
|
235 case EContentExpired: |
|
236 { |
|
237 sysErrorId = GLOBAL_HTTP_ERROR(205); |
|
238 break; |
|
239 } |
|
240 case EHttpRestartFailed: |
|
241 { |
|
242 // Show error note by ourself |
|
243 HBufC* errorString = |
|
244 iCoeEnv.AllocReadResourceLC( R_DMUL_ERROR_START_FROM_BEGINNING ); |
|
245 CAknGlobalNote* globalNote = CAknGlobalNote::NewL(); |
|
246 CleanupStack::PushL( globalNote ); |
|
247 globalNote->ShowNoteL( EAknGlobalErrorNote, *errorString ); |
|
248 CleanupStack::PopAndDestroy( 2, errorString ); // globalNote, errorString |
|
249 sysErrorId = KErrNone; // Do not use errorui |
|
250 break; |
|
251 } |
|
252 default: |
|
253 { |
|
254 sysErrorId = KErrGeneral; |
|
255 break; |
|
256 } |
|
257 } |
|
258 |
|
259 if ( sysErrorId != KErrNone ) |
|
260 { |
|
261 if ( sysErrorId == KErrHttpPartialResponseReceived ) |
|
262 { // FMLK-72653Y : as server closed connection unexpectedly, |
|
263 // and there is no good error note, use KErrDisconnected instead. |
|
264 iErrorUi->ShowGlobalErrorNoteL( KErrDisconnected, CTextResolver::ECtxAutomatic ); |
|
265 } |
|
266 else |
|
267 { |
|
268 iErrorUi->ShowGlobalErrorNoteL( sysErrorId, CTextResolver::ECtxAutomatic ); |
|
269 } |
|
270 } |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CUserInteractionsUtils::ShowErrorNoteL |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void CUserInteractionsUtils::ShowErrorNoteL( TInt aErrorId ) |
|
278 { |
|
279 iErrorUi->ShowGlobalErrorNoteL( aErrorId, CTextResolver::ECtxAutomatic ); |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CUserInteractionsUtils::IsRecoverableFailL |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TBool CUserInteractionsUtils::IsRecoverableFailL( RHttpDownload& aDownload, |
|
287 TInt32 aErrorId ) const |
|
288 { |
|
289 TBool recoverable( ETrue ); |
|
290 |
|
291 // What is the error? |
|
292 TInt32 errorId( aErrorId ); // DMgr specific error ID |
|
293 CLOG_WRITE_FORMAT("Fail reason: %d", errorId); |
|
294 // |
|
295 // EDlAttrGlobalErrorId gives the system-wide code. |
|
296 TInt32 sysErrorId( 0 ); |
|
297 User::LeaveIfError( aDownload.GetIntAttribute |
|
298 ( EDlAttrGlobalErrorId, sysErrorId ) ); |
|
299 |
|
300 TBool pausable( ETrue ); |
|
301 User::LeaveIfError( aDownload.GetBoolAttribute( EDlAttrPausable, pausable ) ); |
|
302 if ( errorId == EObjectNotFound ) |
|
303 // Other error situations can be added to the list. // |
|
304 { |
|
305 recoverable = EFalse; |
|
306 } |
|
307 else if ( errorId == ETransactionFailed ) |
|
308 { |
|
309 if ( sysErrorId == KBadMimeType || sysErrorId == -20000 || sysErrorId == KErrHttpPartialResponseReceived || !pausable ) |
|
310 // KBadMimeType and -20000 is from DRMFilter |
|
311 // Transaction must be cancelled and download must be deleted |
|
312 { |
|
313 recoverable = EFalse; |
|
314 } |
|
315 else |
|
316 { |
|
317 recoverable = ETrue; |
|
318 } |
|
319 } |
|
320 else if ( errorId == EGeneral ) |
|
321 { |
|
322 if ( sysErrorId == KErrNoMemory || sysErrorId == KErrDiskFull ) |
|
323 //Memory full or Disk Full can be Recoverable error if Download is Pausable |
|
324 { |
|
325 recoverable = pausable; |
|
326 } |
|
327 else |
|
328 { |
|
329 recoverable = EFalse; |
|
330 } |
|
331 } |
|
332 else |
|
333 { |
|
334 recoverable = EFalse; |
|
335 } |
|
336 |
|
337 CLOG_WRITE_FORMAT("IsRecoverableFailL: %d", (TInt)recoverable); |
|
338 return recoverable; |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CUserInteractionsUtils::HandleContentL |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void CUserInteractionsUtils::HandleContentL |
|
346 ( RHttpDownload& aDownload, MDownloadHandlerObserver& aHandlerObserver ) |
|
347 { |
|
348 CLOG_ENTERFN("CUserInteractionsUtils::HandleContentL"); |
|
349 |
|
350 __ASSERT_DEBUG( !iRegistryModel.UserInteractions().IsUiBusy(), |
|
351 Panic( EUiLibPanDocHandlerAlreadyRunning ) ); |
|
352 |
|
353 if ( iRegistryModel.UserInteractions().IsUiBusy() ) |
|
354 { |
|
355 CLOG_WRITE(" IsUiBusy() true"); |
|
356 } |
|
357 else |
|
358 { |
|
359 iHandledDownload = &aDownload; |
|
360 iHandlerObserver = &aHandlerObserver; |
|
361 |
|
362 // BEGIN: Get attributes for generic params |
|
363 //========================= |
|
364 // EDlAttrCurrentUrl |
|
365 //========================= |
|
366 HBufC* url = HBufC::NewLC( KMaxUrlLength ); |
|
367 TPtr urlPtr = url->Des(); |
|
368 User::LeaveIfError |
|
369 ( aDownload.GetStringAttribute( EDlAttrCurrentUrl, urlPtr ) ); |
|
370 CLOG_WRITE_FORMAT(" EDlAttrCurrentUrl: %S",url); |
|
371 //========================= |
|
372 // EDlAttrDestFilename |
|
373 //========================= |
|
374 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
375 TPtr fileNamePtr = fileName->Des(); |
|
376 TInt32 numMediaObjects = 0; |
|
377 User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) ); |
|
378 if (numMediaObjects > KFirstMoIndex) |
|
379 { |
|
380 User::LeaveIfError |
|
381 ( aDownload.GetStringAttribute( EDlAttrDestFilename, KFirstMoIndex, fileNamePtr ) ); |
|
382 } |
|
383 else |
|
384 { |
|
385 User::LeaveIfError |
|
386 ( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); |
|
387 } |
|
388 CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr); |
|
389 |
|
390 // check if file exists, if does not , don't continue |
|
391 if ( !IsDuplicateL( fileNamePtr ) ) |
|
392 { |
|
393 HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND); |
|
394 CAknInformationNote* note = new(ELeave) CAknInformationNote(); |
|
395 note->ExecuteLD(*infoPrompt); |
|
396 CleanupStack::PopAndDestroy(infoPrompt); |
|
397 |
|
398 CleanupStack::PopAndDestroy( fileName ); // fileName |
|
399 CleanupStack::PopAndDestroy( url ); // url |
|
400 return; |
|
401 } |
|
402 |
|
403 //========================= |
|
404 // EDlAttrContentType |
|
405 //========================= |
|
406 HBufC8* contentType = ContentTypeL(aDownload, ETrue, KFirstMoIndex); |
|
407 |
|
408 //========================= |
|
409 // EDlMgrIap |
|
410 //========================= |
|
411 TInt32 iap; |
|
412 User::LeaveIfError |
|
413 ( iRegistryModel.DownloadMgr().GetIntAttribute( EDlMgrIap, iap ) ); |
|
414 CLOG_WRITE_FORMAT(" EDlMgrIap: %d",iap); |
|
415 //========================= |
|
416 // EDlAttrCharSet |
|
417 //========================= |
|
418 HBufC* charset = HBufC::NewLC( KMaxDefAttrLength ); |
|
419 TPtr charsetPtr = charset->Des(); |
|
420 TInt retVal = aDownload.GetStringAttribute( EDlAttrCharSet, charsetPtr ); |
|
421 CLOG_WRITE_FORMAT(" EDlAttrCharSet retVal: %d",retVal); |
|
422 if( ( KErrNotFound == retVal ) || ( KErrNone == retVal ) ) |
|
423 { |
|
424 // The Char Set is either found or not found but we don't care!!! |
|
425 CLOG_WRITE_FORMAT(" EDlAttrCharSet: %S",charset); |
|
426 } |
|
427 else |
|
428 { |
|
429 User::Leave( retVal ); |
|
430 } |
|
431 //========================= |
|
432 // EDlAttrRequestReferer |
|
433 //========================= |
|
434 HBufC* refererUri = HBufC::NewLC( KMaxUrlLength ); |
|
435 TPtr refererUriPtr = refererUri->Des(); |
|
436 retVal = aDownload.GetStringAttribute( EDlAttrRequestReferer, refererUriPtr ); |
|
437 CLOG_WRITE_FORMAT(" EDlAttrRequestReferer retVal: %d",retVal); |
|
438 if( ( KErrNotFound == retVal ) || ( KErrNone == retVal ) ) |
|
439 { |
|
440 // The Char Set is either found or not found but we don't care!!! |
|
441 CLOG_WRITE_FORMAT(" refererUri: %S",refererUri); |
|
442 } |
|
443 else |
|
444 { |
|
445 User::Leave( retVal ); |
|
446 } |
|
447 // END: Get attributes for generic params |
|
448 |
|
449 //Creating generic param list |
|
450 CAiwGenericParamList* genericParamList = CAiwGenericParamList::NewLC(); |
|
451 |
|
452 TAiwVariant iapVariant( iap ); |
|
453 TAiwGenericParam genericParamIap( EGenericParamAccessPoint, iapVariant ); |
|
454 genericParamList->AppendL( genericParamIap ); |
|
455 |
|
456 if( url->Length() ) |
|
457 { |
|
458 TAiwVariant urlVariant( *url ); |
|
459 TAiwGenericParam genericParamUrl( EGenericParamURL, urlVariant ); |
|
460 genericParamList->AppendL( genericParamUrl ); |
|
461 } |
|
462 if( charset->Length() ) |
|
463 { |
|
464 TAiwVariant charSetVariant( *charset ); |
|
465 TAiwGenericParam genericParamCharSet |
|
466 ( EGenericParamCharSet, charSetVariant ); |
|
467 genericParamList->AppendL( genericParamCharSet ); |
|
468 } |
|
469 if( refererUri->Length() ) |
|
470 { |
|
471 TAiwVariant refUriVariant( *refererUri ); |
|
472 TAiwGenericParam genericParamRefUri |
|
473 ( EGenericParamReferringURI, refUriVariant ); |
|
474 genericParamList->AppendL( genericParamRefUri ); |
|
475 } |
|
476 if( fileName->Length() ) |
|
477 { |
|
478 TAiwVariant fileNameVariant( *fileName ); |
|
479 TAiwGenericParam genericParamFileName |
|
480 ( EGenericParamFile, fileNameVariant ); |
|
481 genericParamList->AppendL( genericParamFileName ); |
|
482 } |
|
483 |
|
484 CLOG_WRITE_FORMAT(" iDocHandler: %x",iDocHandler); |
|
485 delete iDocHandler; |
|
486 iDocHandler = 0; |
|
487 iDocHandler = CDocumentHandler::NewL(); |
|
488 iDocHandler->SetExitObserver( this ); |
|
489 |
|
490 RFile file; |
|
491 iDocHandler->OpenTempFileL( *fileName, file ); |
|
492 CleanupClosePushL( file ); |
|
493 |
|
494 TDataType dataType( *contentType ); |
|
495 TInt docErr( KErrNone ); |
|
496 TInt trappedError( KErrNone ); |
|
497 iDocHandlerUsesTheUi = ETrue; |
|
498 TRAP( trappedError, |
|
499 docErr = iDocHandler->OpenFileEmbeddedL( file, |
|
500 dataType, |
|
501 *genericParamList ) ); |
|
502 CLOG_WRITE_FORMAT(" trappedError: %d",trappedError); |
|
503 CLOG_WRITE_FORMAT(" docErr: %d",docErr); |
|
504 CleanupStack::PopAndDestroy( &file ); // file |
|
505 CLOG_WRITE(" PopAndDestroy file OK"); |
|
506 |
|
507 if ( trappedError || docErr ) |
|
508 { |
|
509 delete iDocHandler; |
|
510 iDocHandler = 0; |
|
511 iDocHandlerUsesTheUi = EFalse; |
|
512 // Since we know this is an open file error, we should handle it by calling |
|
513 // ShowErrorNotesL instead of propagating the error |
|
514 if ( trappedError ) |
|
515 { |
|
516 ShowErrorNoteL (aDownload, trappedError ); |
|
517 } |
|
518 else |
|
519 { |
|
520 ShowErrorNoteL (aDownload, docErr ); |
|
521 } |
|
522 } |
|
523 |
|
524 CleanupStack::PopAndDestroy( genericParamList ); // genericParamList |
|
525 CleanupStack::PopAndDestroy( refererUri ); // refererUri |
|
526 CleanupStack::PopAndDestroy( charset ); // charset |
|
527 CleanupStack::PopAndDestroy( fileName ); // fileName |
|
528 CleanupStack::PopAndDestroy( url ); // url |
|
529 } |
|
530 |
|
531 CLOG_LEAVEFN("CUserInteractionsUtils::HandleContentL"); |
|
532 } |
|
533 |
|
534 // ----------------------------------------------------------------------------- |
|
535 // CUserInteractionsUtils::SaveContentL |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 TBool CUserInteractionsUtils::SaveContentL( RHttpDownload& aDownload ) |
|
539 { |
|
540 CLOG_ENTERFN("CUserInteractionsUtils::SaveContentL"); |
|
541 |
|
542 __ASSERT_DEBUG( iMemSelectionDialog == 0, Panic( EUiLibPanNull ) ); // Only one can run |
|
543 |
|
544 TBool boolRet( EFalse ); |
|
545 |
|
546 if ( !DrmDownloadL( aDownload ) ) |
|
547 { |
|
548 boolRet = SaveContentWithPathSelectionL( aDownload ); |
|
549 } |
|
550 else |
|
551 { |
|
552 // DRM download, but... |
|
553 if ( !IsContentTypeSupportedL( aDownload ) ) |
|
554 { |
|
555 boolRet = SaveContentWithPathSelectionL( aDownload ); |
|
556 } |
|
557 else |
|
558 { |
|
559 // We can use DocHandler's MoveL |
|
560 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
561 TPtr fileNamePtr = fileName->Des(); |
|
562 User::LeaveIfError |
|
563 ( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); |
|
564 CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr); |
|
565 |
|
566 HBufC* dlName = HBufC::NewLC( KMaxPath ); |
|
567 TPtr dlNamePtr = dlName->Des(); |
|
568 User::LeaveIfError |
|
569 ( aDownload.GetStringAttribute( EDlAttrName, dlNamePtr ) ); |
|
570 CLOG_WRITE_FORMAT(" EDlAttrName: %S",&dlNamePtr); |
|
571 |
|
572 HBufC8* contentType = HBufC8::NewLC( KMaxContentTypeLength ); |
|
573 TPtr8 contentTypePtr = contentType->Des(); |
|
574 User::LeaveIfError |
|
575 ( aDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) ); |
|
576 CLOG_WRITE(" EDlAttrContentType OK"); |
|
577 TDataType dataType( *contentType ); |
|
578 |
|
579 CLOG_WRITE_FORMAT(" iDocHandler: %x",iDocHandler); |
|
580 delete iDocHandler; |
|
581 iDocHandler = 0; |
|
582 iDocHandler = CDocumentHandler::NewL(); |
|
583 CLOG_WRITE(" DocHandler constructed"); |
|
584 |
|
585 TInt moveRet(0); |
|
586 iDocHandlerUsesTheUi = ETrue; |
|
587 // MoveL is synchronous |
|
588 TRAPD( moveErr, moveRet = iDocHandler->MoveL( *fileName, |
|
589 *dlName, |
|
590 dataType, |
|
591 KEntryAttNormal ) ); |
|
592 CLOG_WRITE_FORMAT(" moveErr: %d",moveErr); |
|
593 CLOG_WRITE_FORMAT(" moveRet: %d",moveRet); |
|
594 |
|
595 // Delete DocHandler, otherwise IsUiBusy returns ETrue. |
|
596 delete iDocHandler; |
|
597 iDocHandler = 0; |
|
598 iDocHandlerUsesTheUi = EFalse; |
|
599 CleanupStack::PopAndDestroy( contentType ); // contentType |
|
600 contentType = 0; |
|
601 CleanupStack::PopAndDestroy( dlName ); // dlName |
|
602 dlName = 0; |
|
603 CleanupStack::PopAndDestroy( fileName ); // fileName |
|
604 fileName = 0; |
|
605 |
|
606 if( moveRet == KUserCancel ) |
|
607 { |
|
608 // The user cancelled the operation. |
|
609 } |
|
610 else if( moveErr == KErrNone ) |
|
611 { |
|
612 boolRet = ETrue; |
|
613 // The download can be deleted |
|
614 User::LeaveIfError( aDownload.Delete() ); |
|
615 CLOG_WRITE(" Delete OK"); |
|
616 } |
|
617 else if( moveErr == KDRMErrPreviewRights ) |
|
618 { |
|
619 // Launch from the download directory |
|
620 } |
|
621 else |
|
622 { |
|
623 // Leave with the error |
|
624 User::Leave( moveErr ); |
|
625 } |
|
626 } |
|
627 } |
|
628 |
|
629 CLOG_LEAVEFN("CUserInteractionsUtils::SaveContentL"); |
|
630 return boolRet; |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // CUserInteractionsUtils::SaveContentWithPathSelectionL |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 TBool CUserInteractionsUtils::SaveContentWithPathSelectionL |
|
638 ( RHttpDownload& aDownload ) |
|
639 { |
|
640 CLOG_ENTERFN("CUserInteractionsUtils::SaveContentWithPathSelectionL"); |
|
641 |
|
642 TBool boolRet( EFalse ); |
|
643 |
|
644 // Select memory |
|
645 iMemSelectionDialog = CAknMemorySelectionDialog::NewL |
|
646 ( ECFDDialogTypeSave, R_DMUL_MEMORY_SELECTION_DLG, |
|
647 /*aShowUnavailableDrives*/EFalse ); |
|
648 CLOG_WRITE(" CAknMemorySelectionDialog::NewL OK"); |
|
649 CAknMemorySelectionDialog::TMemory mem( CAknMemorySelectionDialog::EPhoneMemory ); |
|
650 boolRet = iMemSelectionDialog->ExecuteL( mem ); |
|
651 CLOG_WRITE_FORMAT(" MEM boolRet: %d",boolRet); |
|
652 delete iMemSelectionDialog; |
|
653 iMemSelectionDialog = 0; |
|
654 |
|
655 if ( boolRet ) |
|
656 { |
|
657 CLOG_WRITE_FORMAT(" mem: %d",(TInt)mem); |
|
658 TBool useMmc = (mem == CAknMemorySelectionDialog::EMemoryCard); |
|
659 |
|
660 __ASSERT_DEBUG( iFileSelectionDialog == 0, Panic( EUiLibPanNull ) ); // Only one can run |
|
661 |
|
662 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
663 TPtr fileNamePtr = fileName->Des(); |
|
664 User::LeaveIfError |
|
665 ( aDownload.GetStringAttribute( EDlAttrName, fileNamePtr ) ); |
|
666 CLOG_WRITE(" EDlAttrName OK"); |
|
667 |
|
668 // Select folder |
|
669 TInt resourceId = useMmc ? R_DMUL_MMC_FILE_SELECTION_DLG : |
|
670 R_DMUL_FILE_SELECTION_DLG; |
|
671 iFileSelectionDialog = CAknFileSelectionDialog::NewL |
|
672 ( ECFDDialogTypeSave, resourceId ); |
|
673 CLOG_WRITE(" CAknFileSelectionDialog::NewL OK"); |
|
674 TPath selectedPath( KNullDesC ); |
|
675 // Execute dialog - it calls CActiveScheduler::Start(), so be careful |
|
676 // when using data members after ExecuteLD! |
|
677 // TODO introduce deleted, as it uses data after executeld. |
|
678 boolRet = iFileSelectionDialog->ExecuteL( selectedPath ); |
|
679 CLOG_WRITE_FORMAT(" FILE boolRet: %d",boolRet); |
|
680 delete iFileSelectionDialog; |
|
681 iFileSelectionDialog = 0; |
|
682 |
|
683 if ( boolRet ) |
|
684 { |
|
685 // Folder selected. Move file there. |
|
686 fileNamePtr.Insert( 0, selectedPath ); |
|
687 CLOG_WRITE_FORMAT(" fileName before EnsureUniqueFileNameL: %S", fileName); |
|
688 TPtr fname = fileName->Des(); |
|
689 EnsureUniqueFileNameL( fname ); |
|
690 CLOG_WRITE_FORMAT(" fileName after EnsureUniqueFileNameL: %S", fileName); |
|
691 User::LeaveIfError |
|
692 ( aDownload.SetStringAttribute( EDlAttrDestFilename, *fileName ) ); |
|
693 CLOG_WRITE(" EDlAttrDestFilename OK"); |
|
694 User::LeaveIfError( aDownload.Move() ); |
|
695 CLOG_WRITE(" Move OK"); |
|
696 } |
|
697 |
|
698 CleanupStack::PopAndDestroy( fileName ); // fileName |
|
699 } |
|
700 |
|
701 CLOG_LEAVEFN("CUserInteractionsUtils::SaveContentWithPathSelectionL"); |
|
702 return boolRet; |
|
703 } |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // CUserInteractionsUtils::EnsureUniqueFileNameL |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 void CUserInteractionsUtils::EnsureUniqueFileNameL( TPtr& aFileName ) |
|
710 { |
|
711 TInt counter( 0 ); |
|
712 while ( IsDuplicateL( aFileName ) ) |
|
713 { |
|
714 if ( !GenerateNewNameL( aFileName, counter ) ) |
|
715 { |
|
716 break; |
|
717 } |
|
718 } |
|
719 } |
|
720 |
|
721 // ----------------------------------------------------------------------------- |
|
722 // CUserInteractionsUtils::GenerateNewNameL |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 TBool CUserInteractionsUtils::GenerateNewNameL( TPtr& aFileName, TInt& aCounter ) |
|
726 { |
|
727 HBufC* original = aFileName.AllocLC(); |
|
728 TParsePtrC parse( *original ); |
|
729 HBufC* nameBuf = HBufC::NewLC( KMaxFileName ); |
|
730 TPtr name = nameBuf->Des(); |
|
731 name = parse.Name(); |
|
732 TInt counter( aCounter ); |
|
733 TBool found( EFalse ); |
|
734 TInt len = name.Length(); |
|
735 TInt i = len - 1; |
|
736 TBool ret( ETrue ); |
|
737 |
|
738 // Search starting from the end |
|
739 for ( ; i >= 0; --i ) |
|
740 { |
|
741 if ( name[i] == iSearchChar ) |
|
742 { |
|
743 found = ETrue; |
|
744 break; |
|
745 } |
|
746 } |
|
747 if ( aCounter == 0 && found && i > 0 |
|
748 && i <= len - iUnderTenFormatter->Length() ) |
|
749 { |
|
750 // Existing counter, parse the count |
|
751 TPtrC oldCounter = name.Right( len - i ); |
|
752 TLex lex( oldCounter ); |
|
753 if ( lex.Val( counter ) ) |
|
754 { |
|
755 counter = 0; |
|
756 } |
|
757 aCounter = counter; |
|
758 } |
|
759 else if ( !found ) |
|
760 { |
|
761 // No counter found |
|
762 i = len; |
|
763 } |
|
764 ++counter; |
|
765 ++aCounter; |
|
766 if ( counter > FilenameSuffixMaxValue ) |
|
767 { |
|
768 // Count too high, can't generate new name |
|
769 ret = EFalse; |
|
770 } |
|
771 else |
|
772 { |
|
773 TBuf<FilenameSuffixMaxLength> number; |
|
774 HBufC* formatter = iUnderTenFormatter; |
|
775 if ( counter >= 10 ) |
|
776 { |
|
777 formatter = iOverTenFormatter; |
|
778 } |
|
779 StringLoader::Format( number, *formatter, -1, counter ); |
|
780 // Check for length, the full path must not get too long |
|
781 TPtrC driveAndPath = parse.DriveAndPath(); |
|
782 TPtrC ext = parse.Ext(); |
|
783 TInt pathLen = driveAndPath.Length() + i + number.Length() |
|
784 + ext.Length(); |
|
785 TInt maxLen = aFileName.MaxLength(); |
|
786 if ( pathLen > maxLen ) |
|
787 { |
|
788 i -= pathLen - maxLen; |
|
789 } |
|
790 if ( i < 1 ) |
|
791 { |
|
792 // At least one character from the old name must be included |
|
793 ret = EFalse; |
|
794 } |
|
795 else |
|
796 { |
|
797 name.SetLength( i ); |
|
798 name.Append( number ); |
|
799 |
|
800 aFileName.Zero(); |
|
801 aFileName.Append( driveAndPath ); |
|
802 aFileName.Append( name ); |
|
803 aFileName.Append( ext ); |
|
804 } |
|
805 } |
|
806 CleanupStack::PopAndDestroy( 2, original ); // nameBuf, original |
|
807 return ret; |
|
808 } |
|
809 |
|
810 // ----------------------------------------------------------------------------- |
|
811 // CUserInteractionsUtils::IsDuplicateL |
|
812 // ----------------------------------------------------------------------------- |
|
813 // |
|
814 TBool CUserInteractionsUtils::IsDuplicateL( const TPtrC& aFileName ) |
|
815 { |
|
816 TBool result( EFalse ); |
|
817 RFs rfs; |
|
818 User::LeaveIfError( rfs.Connect() ); |
|
819 CleanupClosePushL<RFs>( rfs ); |
|
820 result = BaflUtils::FileExists( rfs, aFileName ); |
|
821 CleanupStack::PopAndDestroy( &rfs ); |
|
822 return result; |
|
823 } |
|
824 |
|
825 // ----------------------------------------------------------------------------- |
|
826 // CUserInteractionsUtils::CancelMemorySelectionDialog |
|
827 // ----------------------------------------------------------------------------- |
|
828 // |
|
829 void CUserInteractionsUtils::CancelMemorySelectionDialog() |
|
830 { |
|
831 CLOG_ENTERFN("CUserInteractionsUtils::CancelMemorySelectionDialog"); |
|
832 if ( iMemSelectionDialog ) |
|
833 { |
|
834 delete iMemSelectionDialog; |
|
835 iMemSelectionDialog = 0; |
|
836 } |
|
837 CLOG_LEAVEFN("CUserInteractionsUtils::CancelMemorySelectionDialog"); |
|
838 } |
|
839 |
|
840 // ----------------------------------------------------------------------------- |
|
841 // CUserInteractionsUtils::CancelFileSelectionDialog |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void CUserInteractionsUtils::CancelFileSelectionDialog() |
|
845 { |
|
846 CLOG_ENTERFN("CUserInteractionsUtils::CancelFileSelectionDialog"); |
|
847 if ( iFileSelectionDialog ) |
|
848 { |
|
849 delete iFileSelectionDialog; |
|
850 iFileSelectionDialog = 0; |
|
851 } |
|
852 CLOG_LEAVEFN("CUserInteractionsUtils::CancelFileSelectionDialog"); |
|
853 } |
|
854 |
|
855 // ----------------------------------------------------------------------------- |
|
856 // CUserInteractionsUtils::DeleteWithUserConfirmL |
|
857 // ----------------------------------------------------------------------------- |
|
858 // |
|
859 TBool CUserInteractionsUtils::DeleteWithUserConfirmL( RHttpDownload& aDownload ) |
|
860 { |
|
861 CLOG_ENTERFN("CUserInteractionsUtils::DeleteWithUserConfirmL"); |
|
862 |
|
863 TInt32 numMediaObjects(0); |
|
864 aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ); |
|
865 |
|
866 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
867 TPtr fileNamePtr = fileName->Des(); |
|
868 |
|
869 // In case of album, show the album name. Otherwise show file name. |
|
870 TInt err(KErrNone); |
|
871 if (numMediaObjects > 1) |
|
872 { |
|
873 err = aDownload.GetStringAttribute( EDlAttrAlbumName, fileNamePtr ); |
|
874 } |
|
875 else |
|
876 { |
|
877 err = aDownload.GetStringAttribute( EDlAttrName, fileNamePtr ); |
|
878 } |
|
879 |
|
880 if ( err != KErrNone && err != KErrNotFound ) |
|
881 { |
|
882 User::LeaveIfError( err ); |
|
883 } |
|
884 TBool fileNameSet = ( err == KErrNone ); |
|
885 if ( !fileNameSet ) |
|
886 { |
|
887 fileNamePtr.Copy( _L("Filename unknown") );//TODO what to write out? |
|
888 } |
|
889 |
|
890 HBufC* prompt = StringLoader::LoadLC( R_DMUL_DOWNLOAD_DEL_CONF, *fileName ); |
|
891 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
892 delete iDeleteConfirmDlg; |
|
893 iDeleteConfirmDlg = dlg; |
|
894 // Execute dialog - it calls CActiveScheduler::Start(), so be careful |
|
895 // when using data members after ExecuteLD! |
|
896 TInt resp = iDeleteConfirmDlg->ExecuteLD |
|
897 ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt ); |
|
898 iDeleteConfirmDlg = 0; |
|
899 CleanupStack::PopAndDestroy( 2, fileName ); // prompt, fileName |
|
900 |
|
901 if ( resp ) // We have to check only that the value is non-zero |
|
902 { |
|
903 |
|
904 aDownload.GetBoolAttribute( EDlAttrCodDownload,iCodDownload ); |
|
905 |
|
906 |
|
907 if(iCodDownload) |
|
908 { |
|
909 CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL( |
|
910 CEikonEnv::Static()->FsSession() ); |
|
911 |
|
912 //Assume that all files to be deleted are valid. |
|
913 TBool fileNotFound = EFalse; |
|
914 |
|
915 for(TInt i = 1; i <= numMediaObjects; i++) |
|
916 { |
|
917 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
918 TPtr fileNamePtr = fileName->Des(); |
|
919 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename,i,fileNamePtr )); |
|
920 RFs rfs; |
|
921 User::LeaveIfError( rfs.Connect() ); |
|
922 CleanupClosePushL<RFs>( rfs ); |
|
923 TFindFile file(rfs); |
|
924 TPtrC ptr(KNullDesC); |
|
925 TInt found = file.FindByPath(fileNamePtr,&ptr); //when second parameter to the API is Null then the it searches for the file in the Dir specified in the first parameter |
|
926 if(found == KErrNotFound) |
|
927 { |
|
928 //Found out that at least one file is not found |
|
929 fileNotFound =ETrue; |
|
930 } |
|
931 |
|
932 rfs.Delete( fileNamePtr ); |
|
933 // Notify Media Gallery about new media file |
|
934 if( fileNamePtr.Length() > 0 ) |
|
935 { |
|
936 TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) ); |
|
937 TRAP_IGNORE( UpdateDCFRepositoryL( fileNamePtr ) ); |
|
938 } |
|
939 else |
|
940 { |
|
941 TRAP_IGNORE( mgFileManager->UpdateL() ); |
|
942 } |
|
943 CleanupStack::PopAndDestroy( &rfs ); |
|
944 CleanupStack::PopAndDestroy( fileName ); |
|
945 } |
|
946 delete mgFileManager; |
|
947 mgFileManager = NULL; |
|
948 |
|
949 //Inform the user that atleast one file not found. |
|
950 if(fileNotFound) |
|
951 { |
|
952 HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND); |
|
953 CAknInformationNote* note = new(ELeave) CAknInformationNote(); |
|
954 note->ExecuteLD(*infoPrompt); |
|
955 CleanupStack::PopAndDestroy(infoPrompt); |
|
956 } |
|
957 } |
|
958 |
|
959 User::LeaveIfError( aDownload.Delete() ); |
|
960 CLOG_LEAVEFN("CUserInteractionsUtils::DeleteWithUserConfirmL"); |
|
961 return ETrue; // Deleted |
|
962 } |
|
963 else |
|
964 { |
|
965 // Do nothing. |
|
966 CLOG_LEAVEFN("CUserInteractionsUtils::DeleteWithUserConfirmL"); |
|
967 return EFalse; |
|
968 } |
|
969 } |
|
970 |
|
971 // ----------------------------------------------------------------------------- |
|
972 // CUserInteractionsUtils::CancelDeleteConfirmationDialog |
|
973 // ----------------------------------------------------------------------------- |
|
974 // |
|
975 void CUserInteractionsUtils::CancelDeleteConfirmationDialog() |
|
976 { |
|
977 CLOG_ENTERFN("CUserInteractionsUtils::CancelDeleteConfirmationDialog"); |
|
978 delete iDeleteConfirmDlg; |
|
979 iDeleteConfirmDlg = 0; |
|
980 CLOG_LEAVEFN("CUserInteractionsUtils::CancelDeleteConfirmationDialog"); |
|
981 } |
|
982 |
|
983 // ----------------------------------------------------------------------------- |
|
984 // CUserInteractionsUtils::CancelWithUserConfirmL |
|
985 // ----------------------------------------------------------------------------- |
|
986 // |
|
987 TBool CUserInteractionsUtils::CancelWithUserConfirmL( RHttpDownload& aDownload ) |
|
988 { |
|
989 CLOG_ENTERFN("CUserInteractionsUtils::CancelWithUserConfirmL"); |
|
990 |
|
991 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
992 TPtr fileNamePtr = fileName->Des(); |
|
993 TInt err = aDownload.GetStringAttribute( EDlAttrName, fileNamePtr ); |
|
994 if ( err != KErrNone && err != KErrNotFound ) |
|
995 { |
|
996 User::LeaveIfError( err ); |
|
997 } |
|
998 TBool fileNameSet = ( err == KErrNone ); |
|
999 if ( !fileNameSet ) |
|
1000 { |
|
1001 fileNamePtr.Copy( _L("Filename unknown") );//TODO what to write out? |
|
1002 } |
|
1003 |
|
1004 HBufC* prompt = StringLoader::LoadLC( R_DMUL_DOWNLOAD_CAN_CONF, *fileName ); |
|
1005 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
1006 delete iCancelConfirmDlg; |
|
1007 iCancelConfirmDlg = dlg; |
|
1008 // Execute dialog - it calls CActiveScheduler::Start(), so be careful |
|
1009 // when using data members after ExecuteLD! |
|
1010 TInt resp = iCancelConfirmDlg->ExecuteLD |
|
1011 ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt ); |
|
1012 iCancelConfirmDlg = 0; |
|
1013 CleanupStack::PopAndDestroy( 2, fileName ); // prompt, fileName |
|
1014 |
|
1015 if ( resp ) // We have to check only that the value is non-zero |
|
1016 { |
|
1017 User::LeaveIfError( aDownload.Delete() ); |
|
1018 CLOG_LEAVEFN("CUserInteractionsUtils::CancelWithUserConfirmL"); |
|
1019 return ETrue; // Cancelled |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 // Do nothing. |
|
1024 CLOG_LEAVEFN("CUserInteractionsUtils::CancelWithUserConfirmL"); |
|
1025 return EFalse; |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // CUserInteractionsUtils::CancelAllWithUserConfirmL |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 TBool CUserInteractionsUtils::CancelAllWithUserConfirmL( RHttpDownload& /* aDownload */) |
|
1034 { |
|
1035 CLOG_ENTERFN("CUserInteractionsUtils::CancelAllWithUserConfirmL"); |
|
1036 |
|
1037 HBufC* prompt = StringLoader::LoadLC( R_DMUL_EXIT_CONF_PLUR ); |
|
1038 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
1039 delete iCancelConfirmDlg; |
|
1040 iCancelConfirmDlg = dlg; |
|
1041 // Execute dialog - it calls CActiveScheduler::Start(), so be careful |
|
1042 // when using data members after ExecuteLD! |
|
1043 TInt resp = iCancelConfirmDlg->ExecuteLD |
|
1044 ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt ); |
|
1045 iCancelConfirmDlg = 0; |
|
1046 CleanupStack::PopAndDestroy(); // prompt |
|
1047 |
|
1048 if ( resp ) // We have to check only that the value is non-zero |
|
1049 { |
|
1050 TInt count = iRegistryModel.DownloadMgr().CurrentDownloads().Count(); |
|
1051 TInt32 dlState; |
|
1052 for(TInt i = 0; i < count; i++) |
|
1053 { |
|
1054 (iRegistryModel.DownloadMgr().CurrentDownloads().At(i))->GetIntAttribute(EDlAttrState, dlState); |
|
1055 |
|
1056 //add fix for the bug JERI-7P8CF2, if checking against EHttpDlMultipleMOCompleted EHttpDlMultipleMOFailed |
|
1057 //Changes for the bug JERI-7P8CF2 |
|
1058 //Changes made in the server side to fix for the video center receiving unexpected events |
|
1059 //Reassigning these events back to the changes done in server side |
|
1060 if(dlState == EHttpDlCompleted ) |
|
1061 { |
|
1062 dlState = EHttpDlMultipleMOCompleted; |
|
1063 } |
|
1064 else if(dlState == EHttpDlFailed ) |
|
1065 { |
|
1066 dlState = EHttpDlMultipleMOFailed; |
|
1067 } |
|
1068 |
|
1069 if(dlState == EHttpDlInprogress || dlState == EHttpDlPaused ) |
|
1070 { |
|
1071 User::LeaveIfError( (iRegistryModel.DownloadMgr().CurrentDownloads().At(i))->Delete()); |
|
1072 i--; |
|
1073 count--; |
|
1074 } |
|
1075 } |
|
1076 CLOG_LEAVEFN("CUserInteractionsUtils::CancelAllWithUserConfirmL"); |
|
1077 return ETrue; // Cancelled |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 // Do nothing. |
|
1082 CLOG_LEAVEFN("CUserInteractionsUtils::CancelAllWithUserConfirmL"); |
|
1083 return EFalse; |
|
1084 } |
|
1085 } |
|
1086 |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 // CUserInteractionsUtils::CancelCancelConfirmationDialog |
|
1089 // ----------------------------------------------------------------------------- |
|
1090 // |
|
1091 void CUserInteractionsUtils::CancelCancelConfirmationDialog() |
|
1092 { |
|
1093 CLOG_ENTERFN("CUserInteractionsUtils::CancelCancelConfirmationDialog"); |
|
1094 delete iCancelConfirmDlg; |
|
1095 iCancelConfirmDlg = 0; |
|
1096 CLOG_LEAVEFN("CUserInteractionsUtils::CancelCancelConfirmationDialog"); |
|
1097 } |
|
1098 |
|
1099 // ----------------------------------------------------------------------------- |
|
1100 // CUserInteractionsUtils::ShowMediaRemovedNoteL |
|
1101 // ----------------------------------------------------------------------------- |
|
1102 // |
|
1103 void CUserInteractionsUtils::ShowMediaRemovedNoteL() |
|
1104 { |
|
1105 CLOG_ENTERFN("CUserInteractionsUtils::ShowMediaRemovedNoteL"); |
|
1106 if ( iMediaRemovedNote == 0 ) |
|
1107 { |
|
1108 HBufC* value = iCoeEnv.AllocReadResourceLC |
|
1109 ( R_DMUL_ERROR_EXT_MEM_REMOVED ); |
|
1110 iMediaRemovedNote = |
|
1111 new (ELeave) CAknInformationNote( &iMediaRemovedNote ); |
|
1112 iMediaRemovedNote->ExecuteLD( *value ); |
|
1113 CleanupStack::PopAndDestroy( value ); // value |
|
1114 } |
|
1115 CLOG_LEAVEFN("CUserInteractionsUtils::ShowMediaRemovedNoteL"); |
|
1116 } |
|
1117 |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // CUserInteractionsUtils::CancelMediaRemovedNote |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // |
|
1122 void CUserInteractionsUtils::CancelMediaRemovedNote() |
|
1123 { |
|
1124 CLOG_ENTERFN("CUserInteractionsUtils::CancelMediaRemovedNote"); |
|
1125 if ( iMediaRemovedNote != 0 ) |
|
1126 { |
|
1127 delete iMediaRemovedNote; |
|
1128 iMediaRemovedNote = 0; |
|
1129 } |
|
1130 CLOG_LEAVEFN("CUserInteractionsUtils::CancelMediaRemovedNote"); |
|
1131 } |
|
1132 |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL |
|
1135 // ----------------------------------------------------------------------------- |
|
1136 // |
|
1137 TBool CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL |
|
1138 ( RHttpDownload& aDownload ) |
|
1139 { |
|
1140 CLOG_ENTERFN("CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL"); |
|
1141 |
|
1142 HBufC* username = 0; |
|
1143 HBufC* password = 0; |
|
1144 |
|
1145 // Get the authentication scheme |
|
1146 TInt32 authScheme(0); |
|
1147 User::LeaveIfError( aDownload.GetIntAttribute |
|
1148 ( EDlAttrAuthScheme, authScheme ) ); |
|
1149 CLOG_WRITE_FORMAT(" EDlAttrAuthScheme: %d",authScheme); |
|
1150 |
|
1151 // Get the default (already set) username and other stuff |
|
1152 HBufC* userName = HBufC::NewLC( KMaxDefAttrLength ); |
|
1153 TPtr userNamePtr = userName->Des(); |
|
1154 TInt getErr = aDownload.GetStringAttribute |
|
1155 ( EDlAttrUsername, userNamePtr ); |
|
1156 if ( getErr != KErrNone && getErr != KErrNotFound ) |
|
1157 { // KErrNotFound is also allowed. In this case it has not been set. |
|
1158 User::LeaveIfError( getErr ); |
|
1159 } |
|
1160 HBufC* url = HBufC::NewLC( KMaxUrlLength ); |
|
1161 TPtr urlPtr = url->Des(); |
|
1162 User::LeaveIfError( aDownload.GetStringAttribute |
|
1163 ( EDlAttrReqUrl, urlPtr ) ); |
|
1164 // URL must be set! |
|
1165 HBufC* realm = HBufC::NewLC( KMaxRealmLength ); |
|
1166 TPtr realmPtr = realm->Des(); |
|
1167 getErr = aDownload.GetStringAttribute( EDlAttrRealm, realmPtr ); |
|
1168 if ( getErr != KErrNone && getErr != KErrNotFound ) |
|
1169 { // KErrNotFound is also allowed. In this case it has not been set. |
|
1170 User::LeaveIfError( getErr ); |
|
1171 } |
|
1172 |
|
1173 // Execute a wait dialog |
|
1174 TBool resp = iDialogsProv->DialogUserAuthenticationLC |
|
1175 ( *url, *realm, *userName, username, password, |
|
1176 authScheme == EAuthBasic ); |
|
1177 |
|
1178 if ( resp ) |
|
1179 { |
|
1180 if ( authScheme == EAuthBasic && BrowserSettingSecWarningL() ) |
|
1181 { |
|
1182 resp = DisplaySecurityWarningL(); |
|
1183 } |
|
1184 if ( resp ) |
|
1185 { |
|
1186 // Set credentials... |
|
1187 User::LeaveIfError( aDownload.SetStringAttribute |
|
1188 ( EDlAttrUsername, *username ) ); |
|
1189 User::LeaveIfError( aDownload.SetStringAttribute |
|
1190 ( EDlAttrPassword, *password ) ); |
|
1191 } |
|
1192 } |
|
1193 |
|
1194 CleanupStack::PopAndDestroy( 2 ); // username, password |
|
1195 CleanupStack::PopAndDestroy( realm ); // realm |
|
1196 CleanupStack::PopAndDestroy( url ); // url |
|
1197 CleanupStack::PopAndDestroy( userName ); // userName |
|
1198 |
|
1199 CLOG_LEAVEFN("CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL"); |
|
1200 return ( resp ); |
|
1201 } |
|
1202 |
|
1203 // ----------------------------------------------------------------------------- |
|
1204 // CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL |
|
1205 // ----------------------------------------------------------------------------- |
|
1206 // |
|
1207 TBool CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL |
|
1208 ( RHttpDownload& aDownload ) |
|
1209 { |
|
1210 CLOG_ENTERFN("CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL"); |
|
1211 |
|
1212 HBufC* username = 0; |
|
1213 HBufC* password = 0; |
|
1214 |
|
1215 // Get the authentication scheme |
|
1216 TInt32 authScheme(0); |
|
1217 User::LeaveIfError( aDownload.GetIntAttribute |
|
1218 ( EDlAttrAuthScheme, authScheme ) ); |
|
1219 CLOG_WRITE_FORMAT(" EDlAttrAuthScheme: %d",authScheme); |
|
1220 |
|
1221 // Get the default (already set) username and other stuff |
|
1222 HBufC* userName = HBufC::NewLC( KMaxDefAttrLength ); |
|
1223 TPtr userNamePtr = userName->Des(); |
|
1224 User::LeaveIfError( aDownload.GetStringAttribute |
|
1225 ( EDlAttrProxyUsername, userNamePtr ) ); |
|
1226 HBufC* url = HBufC::NewLC( KMaxUrlLength ); |
|
1227 TPtr urlPtr = url->Des(); |
|
1228 User::LeaveIfError( aDownload.GetStringAttribute |
|
1229 ( EDlAttrReqUrl, urlPtr ) ); |
|
1230 HBufC* realm = HBufC::NewLC( KMaxRealmLength ); |
|
1231 TPtr realmPtr = realm->Des(); |
|
1232 User::LeaveIfError( aDownload.GetStringAttribute |
|
1233 ( EDlAttrProxyRealm, realmPtr ) ); |
|
1234 |
|
1235 // Execute a wait dialog |
|
1236 TBool resp = iDialogsProv->DialogUserAuthenticationLC |
|
1237 ( *url, *realm, *userName, username, password, |
|
1238 authScheme == EAuthBasic ); |
|
1239 |
|
1240 if ( resp ) |
|
1241 { |
|
1242 if ( authScheme == EAuthBasic && BrowserSettingSecWarningL() ) |
|
1243 { |
|
1244 resp = DisplaySecurityWarningL(); |
|
1245 } |
|
1246 if ( resp ) |
|
1247 { |
|
1248 // Set credentials... |
|
1249 User::LeaveIfError( aDownload.SetStringAttribute |
|
1250 ( EDlAttrProxyUsername, *username ) ); |
|
1251 User::LeaveIfError( aDownload.SetStringAttribute |
|
1252 ( EDlAttrProxyPassword, *password ) ); |
|
1253 } |
|
1254 } |
|
1255 |
|
1256 CleanupStack::PopAndDestroy( 2 ); // username, password |
|
1257 CleanupStack::PopAndDestroy( realm ); // realm |
|
1258 CleanupStack::PopAndDestroy( url ); // url |
|
1259 CleanupStack::PopAndDestroy( userName ); // userName |
|
1260 |
|
1261 CLOG_LEAVEFN("CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL"); |
|
1262 return ( resp ); |
|
1263 } |
|
1264 |
|
1265 // ----------------------------------------------------------------------------- |
|
1266 // CUserInteractionsUtils::CancelCredentialsQueries |
|
1267 // ----------------------------------------------------------------------------- |
|
1268 // |
|
1269 void CUserInteractionsUtils::CancelCredentialsQueries() |
|
1270 { |
|
1271 if ( iDialogsProv ) |
|
1272 { |
|
1273 iDialogsProv->CancelAll(); |
|
1274 } |
|
1275 } |
|
1276 |
|
1277 // ----------------------------------------------------------------------------- |
|
1278 // CUserInteractionsUtils::DisplaySecurityWarningL |
|
1279 // ----------------------------------------------------------------------------- |
|
1280 // |
|
1281 TBool CUserInteractionsUtils::DisplaySecurityWarningL() |
|
1282 { |
|
1283 TBool resp = EFalse; |
|
1284 |
|
1285 // Set up the message text |
|
1286 HBufC* message = StringLoader::LoadLC |
|
1287 ( R_DMUL_QUERY_BASIC_AUTHENTICATION ); |
|
1288 HBufC* okMsg = StringLoader::LoadLC( R_DMUL_OK_BUTTON ); |
|
1289 HBufC* cancelMsg = StringLoader::LoadLC( R_DMUL_CANCEL_BUTTON ); |
|
1290 |
|
1291 resp = iDialogsProv->DialogConfirmL |
|
1292 ( KNullDesC, *message, *okMsg, *cancelMsg ); |
|
1293 |
|
1294 // Clean up the basic authentication dialog memory |
|
1295 CleanupStack::PopAndDestroy( 3, message ); |
|
1296 // message, okMsg, cancelMsg |
|
1297 |
|
1298 return resp; |
|
1299 } |
|
1300 |
|
1301 // ----------------------------------------------------------------------------- |
|
1302 // CUserInteractionsUtils::CancelSecurityWarning |
|
1303 // ----------------------------------------------------------------------------- |
|
1304 // |
|
1305 void CUserInteractionsUtils::CancelSecurityWarning() |
|
1306 { |
|
1307 if ( iDialogsProv ) |
|
1308 { |
|
1309 iDialogsProv->CancelAll(); |
|
1310 } |
|
1311 } |
|
1312 |
|
1313 // ----------------------------------------------------------------------------- |
|
1314 // CUserInteractionsUtils::BrowserSettingSecWarningL |
|
1315 // This method must behave the same as |
|
1316 // CBrowserSettings::GetHttpSecurityWarnings(). |
|
1317 // See CBrowserSettings ! |
|
1318 // ----------------------------------------------------------------------------- |
|
1319 // |
|
1320 TBool CUserInteractionsUtils::BrowserSettingSecWarningL() |
|
1321 { |
|
1322 //todo |
|
1323 return 1; |
|
1324 } |
|
1325 |
|
1326 // ----------------------------------------------------------------------------- |
|
1327 // CUserInteractionsUtils::InitializeSoftNotifStndL |
|
1328 // ----------------------------------------------------------------------------- |
|
1329 // |
|
1330 void CUserInteractionsUtils::InitializeSoftNotifStndL( TVwsViewId aViewId, |
|
1331 TUid aCustomMessageId, |
|
1332 const TDesC8& aViewActivationMsg ) const |
|
1333 { |
|
1334 CLOG_ENTERFN("CUserInteractionsUtils::InitializeSoftNotifStndL"); |
|
1335 |
|
1336 CAknSoftNotificationParameters* params = |
|
1337 CAknSoftNotificationParameters::NewL |
|
1338 ( |
|
1339 iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_STND, KMinimumSoftNotePriority, |
|
1340 R_AVKON_SOFTKEYS_YES_NO__YES, |
|
1341 CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, |
|
1342 EAknSoftkeyYes, aViewActivationMsg |
|
1343 ); |
|
1344 CLOG_WRITE(" params OK"); |
|
1345 CleanupStack::PushL( params ); |
|
1346 |
|
1347 iSoftNotifier->AddCustomNotificationL( *params ); |
|
1348 |
|
1349 CleanupStack::PopAndDestroy( params ); // params |
|
1350 |
|
1351 CLOG_LEAVEFN("CUserInteractionsUtils::InitializeSoftNotifStndL"); |
|
1352 } |
|
1353 |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // CUserInteractionsUtils::InitializeSoftNotifEmbL |
|
1356 // ----------------------------------------------------------------------------- |
|
1357 // |
|
1358 void CUserInteractionsUtils::InitializeSoftNotifEmbL( TVwsViewId aViewId, |
|
1359 TUid aCustomMessageId, |
|
1360 const TDesC8& aViewActivationMsg ) const |
|
1361 { |
|
1362 CLOG_ENTERFN("CUserInteractionsUtils::InitializeSoftNotifEmbL"); |
|
1363 |
|
1364 CAknSoftNotificationParameters* params = |
|
1365 CAknSoftNotificationParameters::NewL |
|
1366 ( |
|
1367 iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_EMB, KMinimumSoftNotePriority, |
|
1368 R_AVKON_SOFTKEYS_YES_NO__YES, |
|
1369 CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, |
|
1370 EAknSoftkeyYes, aViewActivationMsg |
|
1371 ); |
|
1372 CLOG_WRITE(" params OK"); |
|
1373 CleanupStack::PushL( params ); |
|
1374 |
|
1375 iSoftNotifier->AddCustomNotificationL( *params ); |
|
1376 |
|
1377 CleanupStack::PopAndDestroy( params ); // params |
|
1378 |
|
1379 CLOG_LEAVEFN("CUserInteractionsUtils::InitializeSoftNotifEmbL"); |
|
1380 } |
|
1381 |
|
1382 // ----------------------------------------------------------------------------- |
|
1383 // CUserInteractionsUtils::CancelSoftNotifStndL |
|
1384 // ----------------------------------------------------------------------------- |
|
1385 // |
|
1386 void CUserInteractionsUtils::CancelSoftNotifStndL( TVwsViewId aViewId, |
|
1387 TUid aCustomMessageId, |
|
1388 const TDesC8& aViewActivationMsg ) const |
|
1389 { |
|
1390 CLOG_ENTERFN("CUserInteractionsUtils::CancelSoftNotifStndL"); |
|
1391 |
|
1392 CAknSoftNotificationParameters* params = |
|
1393 CAknSoftNotificationParameters::NewL |
|
1394 ( |
|
1395 iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_STND, KMinimumSoftNotePriority, |
|
1396 R_AVKON_SOFTKEYS_YES_NO__YES, |
|
1397 CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, |
|
1398 EAknSoftkeyYes, aViewActivationMsg |
|
1399 ); |
|
1400 CLOG_WRITE(" params OK"); |
|
1401 CleanupStack::PushL( params ); |
|
1402 |
|
1403 //TODO From avkon sources it seems that it identifies the soft notification |
|
1404 // with the AVKON_NOTE resource ID, which is the same in case of |
|
1405 // all UI Lib clients!! |
|
1406 iSoftNotifier->CancelCustomSoftNotificationL( *params ); |
|
1407 |
|
1408 CleanupStack::PopAndDestroy( params ); // params |
|
1409 |
|
1410 CLOG_LEAVEFN("CUserInteractionsUtils::CancelSoftNotifStndL"); |
|
1411 } |
|
1412 |
|
1413 // ----------------------------------------------------------------------------- |
|
1414 // CUserInteractionsUtils::CancelSoftNotifEmbL |
|
1415 // ----------------------------------------------------------------------------- |
|
1416 // |
|
1417 void CUserInteractionsUtils::CancelSoftNotifEmbL( TVwsViewId aViewId, |
|
1418 TUid aCustomMessageId, |
|
1419 const TDesC8& aViewActivationMsg ) const |
|
1420 { |
|
1421 CLOG_ENTERFN("CUserInteractionsUtils::CancelSoftNotifEmbL"); |
|
1422 |
|
1423 CAknSoftNotificationParameters* params = |
|
1424 CAknSoftNotificationParameters::NewL |
|
1425 ( |
|
1426 iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_EMB, KMinimumSoftNotePriority, |
|
1427 R_AVKON_SOFTKEYS_YES_NO__YES, |
|
1428 CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, |
|
1429 EAknSoftkeyYes, aViewActivationMsg |
|
1430 ); |
|
1431 CLOG_WRITE(" params OK"); |
|
1432 CleanupStack::PushL( params ); |
|
1433 |
|
1434 iSoftNotifier->CancelCustomSoftNotificationL( *params ); |
|
1435 |
|
1436 CleanupStack::PopAndDestroy( params ); // params |
|
1437 |
|
1438 CLOG_LEAVEFN("CUserInteractionsUtils::CancelSoftNotifEmbL"); |
|
1439 } |
|
1440 |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 // CUserInteractionsUtils::CancelAllDialogs |
|
1443 // ----------------------------------------------------------------------------- |
|
1444 // |
|
1445 void CUserInteractionsUtils::CancelAllDialogs() |
|
1446 { |
|
1447 if ( iDialogsProv ) |
|
1448 { |
|
1449 iDialogsProv->CancelAll(); |
|
1450 delete iDialogsProv; |
|
1451 iDialogsProv = 0; |
|
1452 } |
|
1453 CancelMemorySelectionDialog(); |
|
1454 CancelFileSelectionDialog(); |
|
1455 CancelDeleteConfirmationDialog(); |
|
1456 CancelCancelConfirmationDialog(); |
|
1457 CancelMediaRemovedNote(); |
|
1458 CancelCredentialsQueries(); |
|
1459 CancelSecurityWarning(); |
|
1460 // The soft notifications should not be cancelled here, |
|
1461 // because they are used in a different context. |
|
1462 } |
|
1463 |
|
1464 // ----------------------------------------------------------------------------- |
|
1465 // CUserInteractionsUtils::InfoNoteL |
|
1466 // ----------------------------------------------------------------------------- |
|
1467 // |
|
1468 void CUserInteractionsUtils::InfoNoteL( TInt aDialogResourceId, const TInt aPromptResourceId ) |
|
1469 { |
|
1470 HBufC* prompt = StringLoader::LoadLC( aPromptResourceId ); |
|
1471 InfoNoteL( aDialogResourceId, *prompt ); |
|
1472 CleanupStack::PopAndDestroy(); // prompt |
|
1473 } |
|
1474 |
|
1475 // ----------------------------------------------------------------------------- |
|
1476 // CUserInteractionsUtils::InfoNoteL |
|
1477 // ----------------------------------------------------------------------------- |
|
1478 // |
|
1479 void CUserInteractionsUtils::InfoNoteL( TInt aDialogResourceId, const TDesC& aPrompt ) |
|
1480 { |
|
1481 CLOG_ENTERFN("CUserInteractionsUtils::InfoNoteL"); |
|
1482 |
|
1483 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog |
|
1484 ( REINTERPRET_CAST( CEikDialog**, &dialog ) ); |
|
1485 CLOG_WRITE(" new"); |
|
1486 dialog->PrepareLC( aDialogResourceId ) ; |
|
1487 CLOG_WRITE(" PrepareLC"); |
|
1488 dialog->SetCurrentLabelL( EGeneralNote, aPrompt ); |
|
1489 CLOG_WRITE(" SetCurrentLabelL"); |
|
1490 dialog->RunDlgLD( CAknNoteDialog::ELongTimeout, CAknNoteDialog::ENoTone ); |
|
1491 |
|
1492 CLOG_LEAVEFN("CUserInteractionsUtils::InfoNoteL"); |
|
1493 } |
|
1494 |
|
1495 // ----------------------------------------------------------------------------- |
|
1496 // CUserInteractionsUtils::IsUiBusy |
|
1497 // ----------------------------------------------------------------------------- |
|
1498 // |
|
1499 TBool CUserInteractionsUtils::IsUiBusy() const |
|
1500 { |
|
1501 CLOG_ENTERFN("CUserInteractionsUtils::IsUiBusy"); |
|
1502 CLOG_WRITE_FORMAT(" MS: %x", iMemSelectionDialog); |
|
1503 CLOG_WRITE_FORMAT(" FS: %x", iFileSelectionDialog); |
|
1504 CLOG_LEAVEFN("CUserInteractionsUtils::IsUiBusy"); |
|
1505 return (IsDocHandlerRunning() || iMemSelectionDialog!=0 || iFileSelectionDialog!=0); |
|
1506 } |
|
1507 |
|
1508 // ----------------------------------------------------------------------------- |
|
1509 // CUserInteractionsUtils::IsDocHandlerRunning |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // |
|
1512 TBool CUserInteractionsUtils::IsDocHandlerRunning() const |
|
1513 { |
|
1514 CLOG_ENTERFN("CUserInteractionsUtils::IsDocHandlerRunning"); |
|
1515 CLOG_WRITE_FORMAT(" %x", iDocHandler); |
|
1516 CLOG_WRITE_FORMAT(" %d", iDocHandlerUsesTheUi); |
|
1517 CLOG_LEAVEFN("CUserInteractionsUtils::IsDocHandlerRunning"); |
|
1518 return iDocHandlerUsesTheUi; |
|
1519 } |
|
1520 |
|
1521 // ----------------------------------------------------------------------------- |
|
1522 // CUserInteractionsUtils::IsCorruptedDcfL |
|
1523 // ----------------------------------------------------------------------------- |
|
1524 // |
|
1525 TBool CUserInteractionsUtils::IsCorruptedDcfL |
|
1526 ( RHttpDownload& aDownload ) const |
|
1527 { |
|
1528 CLOG_ENTERFN("CUserInteractionsUtils::IsCorruptedDcfL"); |
|
1529 TBool isCorruptedDcf( EFalse ); |
|
1530 |
|
1531 DRMCommon* drmCommon = DRMCommon::NewL(); |
|
1532 CLOG_WRITE(" DRMCommon::NewL OK"); |
|
1533 CleanupStack::PushL( drmCommon ); |
|
1534 User::LeaveIfError( drmCommon->Connect() ); |
|
1535 CLOG_WRITE(" Connect OK"); |
|
1536 |
|
1537 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
1538 TPtr fileNamePtr = fileName->Des(); |
|
1539 User::LeaveIfError |
|
1540 ( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); |
|
1541 CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr); |
|
1542 |
|
1543 DRMCommon::TContentProtection prot; |
|
1544 HBufC8* mimeType = 0; |
|
1545 HBufC8* contentURI = 0; |
|
1546 TUint dataLength = 0; |
|
1547 TInt err = drmCommon->GetFileInfo( *fileName, |
|
1548 prot, mimeType, contentURI, dataLength ); |
|
1549 |
|
1550 if ( err == DRMCommon::EVersionNotSupported || |
|
1551 ( err == DRMCommon::EOk && ( !mimeType || !contentURI ) ) ) |
|
1552 { |
|
1553 isCorruptedDcf = ETrue; |
|
1554 } |
|
1555 |
|
1556 delete mimeType; |
|
1557 delete contentURI; |
|
1558 CleanupStack::PopAndDestroy( fileName ); |
|
1559 CleanupStack::PopAndDestroy( drmCommon ); |
|
1560 |
|
1561 CLOG_WRITE_FORMAT(" ret: %d",isCorruptedDcf); |
|
1562 CLOG_LEAVEFN("CUserInteractionsUtils::IsCorruptedDcfL"); |
|
1563 return isCorruptedDcf; |
|
1564 } |
|
1565 |
|
1566 // ----------------------------------------------------------------------------- |
|
1567 // CUserInteractionsUtils::IsBadMimeInDcfL |
|
1568 // ----------------------------------------------------------------------------- |
|
1569 // |
|
1570 TBool CUserInteractionsUtils::IsBadMimeInDcfL |
|
1571 ( RHttpDownload& aDownload ) const |
|
1572 { |
|
1573 CLOG_ENTERFN("CUserInteractionsUtils::IsBadMimeInDcfL"); |
|
1574 TBool isBadMimeInDcfL( EFalse ); |
|
1575 |
|
1576 DRMCommon* drmCommon = DRMCommon::NewL(); |
|
1577 CLOG_WRITE(" DRMCommon::NewL OK"); |
|
1578 CleanupStack::PushL( drmCommon ); |
|
1579 User::LeaveIfError( drmCommon->Connect() ); |
|
1580 CLOG_WRITE(" Connect OK"); |
|
1581 |
|
1582 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
1583 TPtr fileNamePtr = fileName->Des(); |
|
1584 User::LeaveIfError |
|
1585 ( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); |
|
1586 CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr); |
|
1587 |
|
1588 DRMCommon::TContentProtection prot; |
|
1589 HBufC8* mimeType = 0; |
|
1590 HBufC8* contentURI = 0; |
|
1591 TUint dataLength = 0; |
|
1592 TInt err = drmCommon->GetFileInfo( *fileName, |
|
1593 prot, mimeType, contentURI, dataLength ); |
|
1594 |
|
1595 if ( err == DRMCommon::EOk ) |
|
1596 { |
|
1597 if ( !mimeType || !contentURI ) |
|
1598 { |
|
1599 isBadMimeInDcfL = ETrue; |
|
1600 } |
|
1601 else if ( mimeType->CompareF( KOma1DcfContentType ) == KErrNone ) |
|
1602 { |
|
1603 // The MIME type in the DCF is also DCF, which is wrong. |
|
1604 // It should contain the real mime type. |
|
1605 isBadMimeInDcfL = ETrue; |
|
1606 } |
|
1607 } |
|
1608 |
|
1609 delete mimeType; |
|
1610 delete contentURI; |
|
1611 CleanupStack::PopAndDestroy( fileName ); |
|
1612 CleanupStack::PopAndDestroy( drmCommon ); |
|
1613 |
|
1614 CLOG_WRITE_FORMAT(" ret: %d",isBadMimeInDcfL); |
|
1615 CLOG_LEAVEFN("CUserInteractionsUtils::IsBadMimeInDcfL"); |
|
1616 return isBadMimeInDcfL; |
|
1617 } |
|
1618 |
|
1619 // ----------------------------------------------------------------------------- |
|
1620 // CUserInteractionsUtils::DownloadHasBeenDeleted |
|
1621 // ----------------------------------------------------------------------------- |
|
1622 // |
|
1623 void CUserInteractionsUtils::DownloadHasBeenDeleted( RHttpDownload* aDownload ) |
|
1624 { |
|
1625 CLOG_ENTERFN("CUserInteractionsUtils::DownloadHasBeenDeleted"); |
|
1626 if ( iHandledDownload == aDownload ) |
|
1627 { |
|
1628 iHandledDownload = 0; |
|
1629 } |
|
1630 CLOG_LEAVEFN("CUserInteractionsUtils::DownloadHasBeenDeleted"); |
|
1631 } |
|
1632 |
|
1633 |
|
1634 // ----------------------------------------------------------------------------- |
|
1635 // CUserInteractionsUtils::LaunchPdAppL |
|
1636 // ----------------------------------------------------------------------------- |
|
1637 // |
|
1638 void CUserInteractionsUtils::LaunchPdAppL( RHttpDownload& aDownload, const TBool aProgressively ) |
|
1639 { |
|
1640 CLOG_ENTERFN("CUserInteractionsEventHandler::LaunchPdAppL"); |
|
1641 |
|
1642 // Get the PD player application's UID for the download |
|
1643 TUid pdPlayerUid = { 0 }; |
|
1644 HBufC8* contentType = ContentTypeL( aDownload, ETrue, KFirstMoIndex ); |
|
1645 TDataType dataType( *contentType ); |
|
1646 delete contentType; |
|
1647 contentType = NULL; |
|
1648 |
|
1649 CDocumentHandler* docHandler = CDocumentHandler::NewLC(); |
|
1650 TBool pdSupported = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid ); |
|
1651 CleanupStack::PopAndDestroy( docHandler ); // docHandler |
|
1652 |
|
1653 if ( pdSupported ) |
|
1654 { |
|
1655 |
|
1656 TInt downloadCnt = iRegistryModel.DownloadCount(); |
|
1657 TBool isProg(EFalse); |
|
1658 |
|
1659 const CDownloadArray& downloads = iRegistryModel.DownloadMgr().CurrentDownloads(); |
|
1660 |
|
1661 for ( TInt i = 0; i < downloadCnt ;i++ ) |
|
1662 { |
|
1663 RHttpDownload* dl = downloads.At(i); //current download |
|
1664 dl->GetBoolAttribute( EDlAttrProgressive, isProg ); |
|
1665 if (isProg ) |
|
1666 { |
|
1667 dl->SetBoolAttribute( EDlAttrProgressive, EFalse ); |
|
1668 } |
|
1669 } |
|
1670 |
|
1671 TInt32 numMediaObjects = 0; |
|
1672 User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) ); |
|
1673 |
|
1674 // Pack download ID into EGenericParamDownloadId. |
|
1675 TInt32 downloadID( -1 ); |
|
1676 TInt32 activeDownloadID(-1); |
|
1677 if ( aProgressively ) |
|
1678 { |
|
1679 User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrId, downloadID ) ); |
|
1680 User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, activeDownloadID ) ); |
|
1681 } |
|
1682 |
|
1683 |
|
1684 CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC(); |
|
1685 TAiwVariant downloadIdVariant( downloadID ); |
|
1686 TAiwGenericParam genericParam( EGenericParamDownloadId, downloadIdVariant ); |
|
1687 genParList->AppendL( genericParam ); |
|
1688 |
|
1689 // Pack fileName into EGenericParamFile |
|
1690 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
1691 TPtr fileNamePtr = fileName->Des(); |
|
1692 // Get first track's name in case of album |
|
1693 if (numMediaObjects > KFirstMoIndex) |
|
1694 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, KFirstMoIndex, fileNamePtr ) ); |
|
1695 else |
|
1696 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); |
|
1697 |
|
1698 // check if file exists, if does not , don't continue |
|
1699 if ( !IsDuplicateL( fileNamePtr ) ) |
|
1700 { |
|
1701 HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND); |
|
1702 CAknInformationNote* note = new(ELeave) CAknInformationNote(); |
|
1703 note->ExecuteLD(*infoPrompt); |
|
1704 CleanupStack::PopAndDestroy(infoPrompt); |
|
1705 |
|
1706 CleanupStack::PopAndDestroy( fileName ); |
|
1707 CleanupStack::PopAndDestroy( genParList ); |
|
1708 |
|
1709 return; |
|
1710 } |
|
1711 |
|
1712 |
|
1713 TAiwVariant fileNameVariant( fileNamePtr ); |
|
1714 TAiwGenericParam fileNameParam( EGenericParamFile, fileNameVariant ); |
|
1715 genParList->AppendL( fileNameParam ); |
|
1716 |
|
1717 |
|
1718 // Since we don't have the EGenericParamId for track index we are using EGenericParamUnspecified. |
|
1719 // Once we get the generic parameter for the id in future,this will be changed. |
|
1720 TAiwVariant activeIndexVariant( activeDownloadID ); |
|
1721 TAiwGenericParam activeIndexParam( EGenericParamUnspecified, activeIndexVariant ); |
|
1722 genParList->AppendL( activeIndexParam ); |
|
1723 |
|
1724 HBufC8* param8 = HBufC8::NewLC( KMinLength ); // Must be large enough!! |
|
1725 TPtr8 paramPtr8 = param8->Des(); |
|
1726 RDesWriteStream writeStream( paramPtr8 ); |
|
1727 |
|
1728 genParList->ExternalizeL( writeStream ); |
|
1729 |
|
1730 writeStream.CommitL(); |
|
1731 writeStream.Close(); |
|
1732 |
|
1733 //Instead of Selecting topmost task matching the UID from all the tasks, opening the standalone application |
|
1734 CAknTaskList *taskList = CAknTaskList::NewL(CEikonEnv::Static()->WsSession()); |
|
1735 TApaTask task = taskList->FindRootApp(pdPlayerUid); |
|
1736 TInt result = aDownload.SetBoolAttribute( EDlAttrProgressive, ETrue ); |
|
1737 |
|
1738 if ( task.Exists() ) |
|
1739 { |
|
1740 task.BringToForeground(); |
|
1741 // 8-bit buffer is required. |
|
1742 task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used |
|
1743 } |
|
1744 else |
|
1745 { |
|
1746 HBufC* param = HBufC::NewLC( param8->Length() ); |
|
1747 param->Des().Copy( *param8 ); |
|
1748 |
|
1749 RApaLsSession appArcSession; |
|
1750 User::LeaveIfError( appArcSession.Connect() ); |
|
1751 CleanupClosePushL( appArcSession ); |
|
1752 TThreadId id; |
|
1753 User::LeaveIfError |
|
1754 ( |
|
1755 appArcSession.StartDocument( *param, pdPlayerUid, id ) |
|
1756 ); |
|
1757 if( aProgressively ) |
|
1758 { |
|
1759 User::LeaveIfError( aDownload.SetIntAttribute( EDlAttrActivePlayedDownload, activeDownloadID ) ); |
|
1760 } |
|
1761 CleanupStack::PopAndDestroy( &appArcSession ); |
|
1762 CleanupStack::PopAndDestroy( param ); |
|
1763 } |
|
1764 |
|
1765 CleanupStack::PopAndDestroy( param8 ); |
|
1766 CleanupStack::PopAndDestroy( fileName ); |
|
1767 CleanupStack::PopAndDestroy( genParList ); |
|
1768 } |
|
1769 |
|
1770 CLOG_LEAVEFN("CUserInteractionsEventHandler::LaunchPdAppL"); |
|
1771 } |
|
1772 |
|
1773 |
|
1774 #ifdef __DMGR_PD_TESTHARNESS |
|
1775 // ----------------------------------------------------------------------------- |
|
1776 // CUserInteractionsEventHandler::TestLaunchPdAppL |
|
1777 // ----------------------------------------------------------------------------- |
|
1778 // |
|
1779 void CUserInteractionsUtils::TestLaunchPdAppL( RHttpDownload& aDownload ) |
|
1780 { |
|
1781 CLOG_ENTERFN("CUserInteractionsEventHandler::TestLaunchPdAppL"); |
|
1782 |
|
1783 const TUid KTestPdPlayerUid = { 0x01FFDAAC }; |
|
1784 |
|
1785 // Pack download ID into EGenericParamDownloadId |
|
1786 TInt32 downloadID( 0 ); |
|
1787 User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrId, downloadID ) ); |
|
1788 |
|
1789 CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC(); |
|
1790 TAiwVariant downloadIdVariant( downloadID ); |
|
1791 TAiwGenericParam downloadIdParam( EGenericParamDownloadId, downloadIdVariant ); |
|
1792 genParList->AppendL( downloadIdParam ); |
|
1793 |
|
1794 // Pack fileName into EGenericParamFile |
|
1795 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
1796 TPtr fileNamePtr = fileName->Des(); |
|
1797 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); |
|
1798 |
|
1799 TAiwVariant fileNameVariant( fileNamePtr ); |
|
1800 TAiwGenericParam fileNameParam( EGenericParamFile, fileNameVariant ); |
|
1801 genParList->AppendL( fileNameParam ); |
|
1802 |
|
1803 HBufC8* param8 = HBufC8::NewLC( KMinLength ); |
|
1804 TPtr8 paramPtr8 = param8->Des(); |
|
1805 RDesWriteStream writeStream( paramPtr8 ); |
|
1806 |
|
1807 genParList->ExternalizeL( writeStream ); |
|
1808 |
|
1809 writeStream.CommitL(); |
|
1810 writeStream.Close(); |
|
1811 |
|
1812 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
1813 TApaTask task = taskList.FindApp( KTestPdPlayerUid ); |
|
1814 TInt result = aDownload.SetBoolAttribute( EDlAttrProgressive, ETrue ); |
|
1815 |
|
1816 if ( task.Exists() ) |
|
1817 { |
|
1818 // 8-bit buffer is required. |
|
1819 task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used |
|
1820 task.BringToForeground(); |
|
1821 } |
|
1822 else |
|
1823 { |
|
1824 HBufC* param = HBufC::NewLC( param8->Length() ); |
|
1825 param->Des().Copy( *param8 ); |
|
1826 |
|
1827 RApaLsSession appArcSession; |
|
1828 User::LeaveIfError( appArcSession.Connect() ); |
|
1829 CleanupClosePushL( appArcSession ); |
|
1830 TThreadId id; |
|
1831 |
|
1832 User::LeaveIfError(appArcSession.StartDocument( *param, KTestPdPlayerUid, id )); |
|
1833 |
|
1834 CleanupStack::PopAndDestroy( &appArcSession ); |
|
1835 CleanupStack::PopAndDestroy( param ); |
|
1836 } |
|
1837 |
|
1838 CleanupStack::PopAndDestroy( param8 ); |
|
1839 CleanupStack::PopAndDestroy( fileName ); |
|
1840 CleanupStack::PopAndDestroy( genParList ); |
|
1841 |
|
1842 CLOG_LEAVEFN("CUserInteractionsEventHandler::TestLaunchPdAppL"); |
|
1843 } |
|
1844 |
|
1845 #endif // __DMGR_PD_TESTHARNESS |
|
1846 |
|
1847 |
|
1848 // ----------------------------------------------------------------------------- |
|
1849 // CUserInteractionsUtils::HandleServerAppExit |
|
1850 // ----------------------------------------------------------------------------- |
|
1851 // |
|
1852 void CUserInteractionsUtils::HandleServerAppExit( TInt aReason ) |
|
1853 { |
|
1854 CLOG_ENTERFN("CUserInteractionsUtils::HandleServerAppExit"); |
|
1855 CLOG_WRITE_FORMAT(" aReason: %d", aReason); |
|
1856 |
|
1857 // DocHandler has finished its task. |
|
1858 iDocHandlerUsesTheUi = EFalse; |
|
1859 // Schedule the next download: |
|
1860 #ifdef _DEBUG |
|
1861 TRAPD( scheduleErr, iRegistryModel.UserInteractions().SchedulePostponedDownloadL() ); |
|
1862 CLOG_WRITE_FORMAT(" scheduleErr: %d", scheduleErr); |
|
1863 #else |
|
1864 TRAP_IGNORE( iRegistryModel.UserInteractions().SchedulePostponedDownloadL() ); |
|
1865 #endif // _DEBUG |
|
1866 |
|
1867 if ( iHandlerObserver ) |
|
1868 { |
|
1869 iHandlerObserver->NotifyHandlerExit( iHandledDownload, aReason ); |
|
1870 } |
|
1871 |
|
1872 CLOG_LEAVEFN("CUserInteractionsUtils::HandleServerAppExit"); |
|
1873 } |
|
1874 |
|
1875 // ----------------------------------------------------------------------------- |
|
1876 // CUserInteractionsUtils::IsNetworkPdCompatibleL() |
|
1877 // ----------------------------------------------------------------------------- |
|
1878 // |
|
1879 TBool CUserInteractionsUtils::IsNetworkPdCompatibleL() const |
|
1880 { |
|
1881 CLOG_ENTERFN("CUserInteractionsEventHandler::IsNetworkPdCompatibleL"); |
|
1882 // This method must not be called if 2G/3G distinction is not supported; |
|
1883 // the RMobilePhone-related classes are not open in that case. |
|
1884 |
|
1885 TBool isNetworkPdCompatible( EFalse ); |
|
1886 |
|
1887 #if !defined( __WINS__ ) |
|
1888 // this initialization needed for identifying 3G networks |
|
1889 RTelServer telServer; |
|
1890 RMobilePhone mobilePhone; |
|
1891 |
|
1892 RMobilePhone::TMobilePhoneNetworkMode networkMode; |
|
1893 User::LeaveIfError( telServer.Connect() ); |
|
1894 User::LeaveIfError( telServer.LoadPhoneModule( KMmTsyModuleName ) ); |
|
1895 |
|
1896 TInt numPhones; |
|
1897 User::LeaveIfError( telServer.EnumeratePhones( numPhones ) ); |
|
1898 if( numPhones <= 0 ) |
|
1899 { |
|
1900 User::Leave( KErrCorrupt ); |
|
1901 } |
|
1902 |
|
1903 RTelServer::TPhoneInfo phoneInfo; |
|
1904 User::LeaveIfError( telServer.GetPhoneInfo( 0, phoneInfo ) ); |
|
1905 User::LeaveIfError( mobilePhone.Open( telServer, phoneInfo.iName ) ); |
|
1906 User::LeaveIfError( mobilePhone.Initialise() ); |
|
1907 |
|
1908 User::LeaveIfError( mobilePhone.GetCurrentMode( networkMode ) ); |
|
1909 |
|
1910 TBool isWlan = GetWlanAvailabilityL(); |
|
1911 if( (networkMode != RMobilePhone::ENetworkModeGsm) || (networkMode == RMobilePhone::ENetworkModeGsm && isWlan)) |
|
1912 { |
|
1913 isNetworkPdCompatible = ETrue; |
|
1914 } |
|
1915 |
|
1916 mobilePhone.Close(); |
|
1917 telServer.Close(); |
|
1918 |
|
1919 isNetworkPdCompatible = ETrue; |
|
1920 #else |
|
1921 isNetworkPdCompatible = ETrue; |
|
1922 #endif |
|
1923 CLOG_LEAVEFN("CUserInteractionsEventHandler::IsNetworkPdCompatibleL"); |
|
1924 return isNetworkPdCompatible; |
|
1925 } |
|
1926 |
|
1927 |
|
1928 // ----------------------------------------------------------------------------- |
|
1929 // CUserInteractionsUtils::SendMsgTerminateToPdAppsL |
|
1930 // ----------------------------------------------------------------------------- |
|
1931 // |
|
1932 |
|
1933 void CUserInteractionsUtils::SendMsgTerminateToPdAppsL() |
|
1934 { |
|
1935 CLOG_ENTERFN("CUserInteractionsEventHandler::SendMsgTerminateToPdAppsL"); |
|
1936 // Pack EGenericParamTerminate. |
|
1937 TInt32 browserTerminate( 1 ); |
|
1938 CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC(); |
|
1939 TAiwVariant terminateVariant( browserTerminate ); |
|
1940 TAiwGenericParam genericParamTerm( EGenericParamTerminate, terminateVariant ); |
|
1941 genParList->AppendL( genericParamTerm ); |
|
1942 |
|
1943 HBufC8* param8 = HBufC8::NewLC( KMinLength ); // Must be large enough!! |
|
1944 TPtr8 paramPtr8 = param8->Des(); |
|
1945 RDesWriteStream writeStream( paramPtr8 ); |
|
1946 |
|
1947 genParList->ExternalizeL( writeStream ); |
|
1948 |
|
1949 writeStream.CommitL(); |
|
1950 writeStream.Close(); |
|
1951 |
|
1952 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
1953 |
|
1954 TBool isProgressive (EFalse); |
|
1955 TInt downloadCnt = iRegistryModel.DownloadCount(); |
|
1956 const CDownloadArray& downloads = iRegistryModel.DownloadMgr().CurrentDownloads(); |
|
1957 TInt j ; |
|
1958 for( j = 0; j < downloadCnt; ++j ) |
|
1959 { |
|
1960 RHttpDownload* dl = downloads.At(j); // current download |
|
1961 dl->GetBoolAttribute( EDlAttrProgressive, isProgressive ); |
|
1962 if(isProgressive) |
|
1963 { |
|
1964 break; |
|
1965 } |
|
1966 } |
|
1967 for( TInt i = 0; i < KDocPDAppUidCount; i++ ) |
|
1968 { |
|
1969 TUid KTestPdPlayerUid = {KDocPDAppUidList[ i ]}; |
|
1970 TApaTask task = taskList.FindApp(KTestPdPlayerUid ); // task for MP app |
|
1971 if ( task.Exists() && isProgressive ) |
|
1972 { |
|
1973 RHttpDownload* dl = downloads.At(j); // current download |
|
1974 //This Atribute will tell if MP called Delete |
|
1975 //on exit of Browser |
|
1976 dl->SetBoolAttribute( EDlAttrProgressive, EFalse ); |
|
1977 // 8-bit buffer is required. |
|
1978 task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used |
|
1979 task.BringToForeground(); |
|
1980 } |
|
1981 } |
|
1982 CleanupStack::PopAndDestroy( param8 ); |
|
1983 CleanupStack::PopAndDestroy( genParList ); |
|
1984 |
|
1985 CLOG_LEAVEFN("CUserInteractionsEventHandler::SendMsgTerminateToPdAppsL"); |
|
1986 |
|
1987 } |
|
1988 |
|
1989 |
|
1990 // ----------------------------------------------------------------------------- |
|
1991 // CUserInteractionsUtils::GetWlanAvailabilityL |
|
1992 // ----------------------------------------------------------------------------- |
|
1993 // |
|
1994 TBool CUserInteractionsUtils::GetWlanAvailabilityL() const |
|
1995 { |
|
1996 TRequestStatus status( KRequestPending ); |
|
1997 |
|
1998 // Connection monitor |
|
1999 RConnectionMonitor connMon; |
|
2000 CleanupClosePushL( connMon ); |
|
2001 User::LeaveIfError( connMon.ConnectL() ); |
|
2002 |
|
2003 TConnMonIapInfoBuf infoBuf; |
|
2004 infoBuf().iCount = 0; |
|
2005 |
|
2006 // Get WLAN IAPs to infoBuf |
|
2007 connMon.GetPckgAttribute( EBearerIdWLAN ,0 , KIapAvailability, infoBuf, status ); |
|
2008 User::WaitForRequest( status ); |
|
2009 |
|
2010 CleanupStack::PopAndDestroy( &connMon ); |
|
2011 |
|
2012 if ( !status.Int() && infoBuf().iCount ) |
|
2013 { |
|
2014 return ETrue; |
|
2015 } |
|
2016 |
|
2017 return EFalse; |
|
2018 } |
|
2019 |
|
2020 // ------------------------------------------------------------ |
|
2021 // CUserInteractionsUtils::CanLaunchAsProgDownload() |
|
2022 // Check if several conditions are met for Progressive Playback |
|
2023 // ------------------------------------------------------------ |
|
2024 // |
|
2025 TBool CUserInteractionsUtils::CanLaunchAsProgDownload( |
|
2026 RHttpDownload& aDownload, |
|
2027 CDownloadMgrUiDownloadsList& dlList, |
|
2028 TBool isOma2Dl ) |
|
2029 { |
|
2030 CLOG_ENTERFN( "CUserInteractionsUtils::CanLaunchAsProgDownload" ); |
|
2031 TBool progDlOk( !dlList.IsOneProgressive() && IsNetworkPdCompatibleL() ); |
|
2032 // if OMA 2 download, no need to check for DRM rights on the phone, as license was already acquired. |
|
2033 if( progDlOk && !isOma2Dl ) |
|
2034 { |
|
2035 TBool isDrmDl = DrmDownloadL( aDownload ); |
|
2036 CLOG_WRITE_FORMAT( " :isDrmDl=%d", isDrmDl ); |
|
2037 if( isDrmDl ) |
|
2038 { |
|
2039 TBool prevRights( EFalse ); |
|
2040 progDlOk = DrmRightsOnThePhoneL( aDownload, prevRights ); |
|
2041 CLOG_WRITE_FORMAT( " :prevRights=%d", prevRights ); |
|
2042 } |
|
2043 } |
|
2044 TInt32 pdTrack(0); |
|
2045 aDownload.GetIntAttribute(EDlAttrActivePlayedDownload,pdTrack); |
|
2046 if( pdTrack ) |
|
2047 { |
|
2048 //SomeTrack is already being played |
|
2049 progDlOk = EFalse; |
|
2050 } |
|
2051 CLOG_WRITE_FORMAT( " :progDlOk=%d", progDlOk ); |
|
2052 CLOG_LEAVEFN( "CUserInteractionsUtils::CanLaunchAsProgDownload" ); |
|
2053 return progDlOk; |
|
2054 } |
|
2055 |
|
2056 // --------------------------------------------------------- |
|
2057 // CUserInteractionsUtils::UpdateDCFRepositoryL() |
|
2058 // Update saved file to DCFRepository |
|
2059 // --------------------------------------------------------- |
|
2060 // |
|
2061 void CUserInteractionsUtils::UpdateDCFRepositoryL( |
|
2062 const TDesC& aFileName ) |
|
2063 { |
|
2064 CLOG_ENTERFN( "CUserInteractionsUtils::UpdateDCFRepositoryL" ); |
|
2065 CLOG_WRITE_FORMAT( " :aFileName=%S", &aFileName ); |
|
2066 CDcfEntry* dcfEntry = NULL; |
|
2067 dcfEntry = CDcfEntry::NewL(); |
|
2068 CleanupStack::PushL( dcfEntry ); |
|
2069 |
|
2070 CDcfRep* dcfRep = NULL; |
|
2071 dcfRep = CDcfRep::NewL(); |
|
2072 CleanupStack::PushL( dcfRep ); |
|
2073 |
|
2074 dcfEntry->SetLocationL( aFileName, 0 ); |
|
2075 CLOG_WRITE(" : SetLocationL OK"); |
|
2076 dcfRep->UpdateL( dcfEntry ); |
|
2077 CLOG_WRITE(" :UpdateL OK"); |
|
2078 CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep |
|
2079 CLOG_LEAVEFN("CUserInteractionsUtils::UpdateDCFRepositoryL"); |
|
2080 } |
|
2081 |
|
2082 // --------------------------------------------------------- |
|
2083 // CUserInteractionsUtils::IsCodDownload() |
|
2084 // return true if its a COD DL |
|
2085 // --------------------------------------------------------- |
|
2086 // |
|
2087 TBool CUserInteractionsUtils::IsCodDownload() |
|
2088 { |
|
2089 return iCodDownload; |
|
2090 } |
|
2091 |
|
2092 // End of file. |