browserutilities/downloadmgr/DownloadMgrUiLib/Src/CUserInteractionsUtils.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 44 800203832575
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    13 *
    13 *
    14 * Description:  Supports user interaction dialogs for downloads
    14 * Description:  Supports user interaction dialogs for downloads
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 
    18 // INCLUDE FILES
    20 // INCLUDE FILES
    19 #include    <browser_platform_variant.hrh>
    21 //#include <platform/mw/Browser_platform_variant.hrh>
       
    22 #include    <Browser_platform_variant.hrh>
    20 #include    "CUserInteractionsUtils.h"
    23 #include    "CUserInteractionsUtils.h"
    21 #include    "MDownloadHandlerObserver.h"
    24 #include    "MDownloadHandlerObserver.h"
    22 #include    <cdownloadmgruibase.h>
    25 #include    "CDownloadMgrUiBase.h"
    23 #include    <cdownloadmgruilibregistry.h>
    26 #include    "CDownloadMgrUiLibRegistry.h"
    24 #include    <cdownloadmgruidownloadslist.h>
    27 #include    "CDownloadMgrUiDownloadsList.h"
    25 #include    <cdownloadmgruiuserinteractions.h>
    28 #include    "CDownloadMgrUiUserInteractions.h"
    26 #include    "UiLibLogger.h"
    29 #include    "UiLibLogger.h"
    27 #include    "DMgrUiLibPanic.h"
    30 #include    "DMgrUiLibPanic.h"
    28 #include    <DownloadMgrUiLib.rsg>
    31 #include    <DownloadMgrUiLib.rsg>
    29 #include    <downloadmgrclient.h>
    32 #include    <DownloadMgrClient.h>
    30 #include    <AiwGenericParam.h>
    33 #include    <AiwGenericParam.h>
    31 #include    <DocumentHandler.h>
    34 #include    <DocumentHandler.h>
    32 #include    <coemain.h>
    35 #include    <coemain.h>
    33 #include    <ErrorUI.h>
    36 #include    <ErrorUI.h>
    34 #include    <eikenv.h>
    37 #include    <eikenv.h>
    37 #include    <CAknMemorySelectionDialog.h>
    40 #include    <CAknMemorySelectionDialog.h>
    38 #include    <AknQueryDialog.h>
    41 #include    <AknQueryDialog.h>
    39 #include    <StringLoader.h>
    42 #include    <StringLoader.h>
    40 #include    <AknSoftNotificationParameters.h>
    43 #include    <AknSoftNotificationParameters.h>
    41 #include    <AknSoftNotifier.h>
    44 #include    <AknSoftNotifier.h>
    42 #include    <AknNoteWrappers.h>
    45 #include    <aknnotewrappers.h>
    43 #include    <browserdialogsprovider.h>
    46 #include    <BrowserDialogsProvider.h>
    44 #include    <httpdownloadmgrcommon.h>
    47 #include    <HttpDownloadMgrCommon.h>
    45 #include    <PathInfo.h>
    48 #include    <pathinfo.h>
    46 #include    <aknglobalnote.h>
    49 #include    <AknGlobalNote.h>
    47 #include    <Oma2Agent.h>
    50 #include    <Oma2Agent.h>
    48 #include    <DRMCommon.h>
    51 #include    <DRMCommon.h>
    49 #include	<apmrec.h>
    52 #include	<apmrec.h>
    50 #include	<apgcli.h>
    53 #include	<apgcli.h>
    51 #include    <s32mem.h>
    54 #include    <s32mem.h>
    52 #include    <bautils.h>
    55 #include    "bautils.h"
    53 #include	<etelmm.h>
    56 #include	<etelmm.h>
    54 #include	<MmTsy_names.h>
    57 #include	<mmtsy_names.h>
    55 #include    <rconnmon.h>
    58 #include    <rconnmon.h>
    56 #include    <DcfEntry.h>
    59 #include    <DcfEntry.h>
    57 #include    <DcfRep.h>
    60 #include    <DcfRep.h>
       
    61 
       
    62 // following line is temporary: AVKON dependency removal
       
    63 #undef BRDO_APP_GALLERY_SUPPORTED_FF
    58 
    64 
    59 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    65 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    60 #include    <MGXFileManagerFactory.h>
    66 #include    <MGXFileManagerFactory.h>
    61 #include    <CMGXFileManager.h>
    67 #include    <CMGXFileManager.h>
    62 #endif
    68 #endif
    73 
    79 
    74 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    75 // CUserInteractionsUtils::CUserInteractionsUtils
    81 // CUserInteractionsUtils::CUserInteractionsUtils
    76 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    77 //
    83 //
    78 CUserInteractionsUtils::CUserInteractionsUtils( CDownloadMgrUiBase& aDMgrUiBase, 
    84 CUserInteractionsUtils::CUserInteractionsUtils( CDownloadMgrUiBase& aDMgrUiBase,
    79                                                 MDownloadMgrUiLibRegModel& aRegistryModel )
    85                                                 MDownloadMgrUiLibRegModel& aRegistryModel )
    80 :   iCoeEnv( *CCoeEnv::Static() ), 
    86 :   iCoeEnv( *CCoeEnv::Static() ),
    81     iDMgrUiBase( aDMgrUiBase ),
    87     iDMgrUiBase( aDMgrUiBase ),
    82     iRegistryModel( aRegistryModel ),
    88     iRegistryModel( aRegistryModel ),
    83     iDocHandlerUsesTheUi( EFalse )
    89     iDocHandlerUsesTheUi( EFalse )
    84     {
    90     {
    85     }
    91     }
   110 // -----------------------------------------------------------------------------
   116 // -----------------------------------------------------------------------------
   111 //
   117 //
   112 CUserInteractionsUtils* CUserInteractionsUtils::NewL
   118 CUserInteractionsUtils* CUserInteractionsUtils::NewL
   113 ( CDownloadMgrUiBase& aDMgrUiBase, MDownloadMgrUiLibRegModel& aRegistryModel )
   119 ( CDownloadMgrUiBase& aDMgrUiBase, MDownloadMgrUiLibRegModel& aRegistryModel )
   114     {
   120     {
   115     CUserInteractionsUtils* self = 
   121     CUserInteractionsUtils* self =
   116         new ( ELeave ) CUserInteractionsUtils( aDMgrUiBase, aRegistryModel );
   122         new ( ELeave ) CUserInteractionsUtils( aDMgrUiBase, aRegistryModel );
   117     CleanupStack::PushL( self );
   123     CleanupStack::PushL( self );
   118     self->ConstructL();
   124     self->ConstructL();
   119     CleanupStack::Pop();
   125     CleanupStack::Pop();
   120     return self;
   126     return self;
   134     delete iErrorUi;
   140     delete iErrorUi;
   135     CLOG_WRITE(" iErrorUi OK");
   141     CLOG_WRITE(" iErrorUi OK");
   136     delete iUnderTenFormatter;
   142     delete iUnderTenFormatter;
   137     CLOG_WRITE(" iUnderTenFormatter OK");
   143     CLOG_WRITE(" iUnderTenFormatter OK");
   138     delete iOverTenFormatter;
   144     delete iOverTenFormatter;
   139     CLOG_WRITE(" iOverTenFormatter OK");    
   145     CLOG_WRITE(" iOverTenFormatter OK");
   140     CLOG_LEAVEFN("CUserInteractionsUtils::~CUserInteractionsUtils");
   146     CLOG_LEAVEFN("CUserInteractionsUtils::~CUserInteractionsUtils");
   141     }
   147     }
   142 
   148 
   143 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   144 // CUserInteractionsUtils::ShowErrorNoteL
   150 // CUserInteractionsUtils::ShowErrorNoteL
   145 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   146 //
   152 //
   147 void CUserInteractionsUtils::ShowErrorNoteL( RHttpDownload& aDownload, 
   153 void CUserInteractionsUtils::ShowErrorNoteL( RHttpDownload& aDownload,
   148                                              TInt32 aErrorId )
   154                                              TInt32 aErrorId )
   149     {
   155     {
   150     TInt32 sysErrorId( KErrNone ); // Global (system-wide) error ID
   156     TInt32 sysErrorId( KErrNone ); // Global (system-wide) error ID
   151 
   157 
   152     // DMgr specific error code. See THttpDownloadMgrError.
   158     // DMgr specific error code. See THttpDownloadMgrError.
   240             break;
   246             break;
   241             }
   247             }
   242         case EHttpRestartFailed:
   248         case EHttpRestartFailed:
   243             {
   249             {
   244             // Show error note by ourself
   250             // Show error note by ourself
   245             HBufC* errorString = 
   251             HBufC* errorString =
   246                    iCoeEnv.AllocReadResourceLC( R_DMUL_ERROR_START_FROM_BEGINNING );
   252                    iCoeEnv.AllocReadResourceLC( R_DMUL_ERROR_START_FROM_BEGINNING );
   247             CAknGlobalNote* globalNote = CAknGlobalNote::NewL();
   253             CAknGlobalNote* globalNote = CAknGlobalNote::NewL();
   248             CleanupStack::PushL( globalNote );
   254             CleanupStack::PushL( globalNote );
   249             globalNote->ShowNoteL( EAknGlobalErrorNote, *errorString );
   255             globalNote->ShowNoteL( EAknGlobalErrorNote, *errorString );
   250             CleanupStack::PopAndDestroy( 2, errorString );  // globalNote, errorString
   256             CleanupStack::PopAndDestroy( 2, errorString );  // globalNote, errorString
   259         }
   265         }
   260 
   266 
   261     if ( sysErrorId != KErrNone )
   267     if ( sysErrorId != KErrNone )
   262         {
   268         {
   263         if ( sysErrorId == KErrHttpPartialResponseReceived )
   269         if ( sysErrorId == KErrHttpPartialResponseReceived )
   264             { // FMLK-72653Y : as server closed connection unexpectedly,  
   270             { // FMLK-72653Y : as server closed connection unexpectedly,
   265               // and there is no good error note, use KErrDisconnected instead.
   271               // and there is no good error note, use KErrDisconnected instead.
   266             iErrorUi->ShowGlobalErrorNoteL( KErrDisconnected, CTextResolver::ECtxAutomatic );
   272             iErrorUi->ShowGlobalErrorNoteL( KErrDisconnected, CTextResolver::ECtxAutomatic );
   267             }
   273             }
   268         else
   274         else
   269             {
   275             {
   283 
   289 
   284 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
   285 // CUserInteractionsUtils::IsRecoverableFailL
   291 // CUserInteractionsUtils::IsRecoverableFailL
   286 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   287 //
   293 //
   288 TBool CUserInteractionsUtils::IsRecoverableFailL( RHttpDownload& aDownload, 
   294 TBool CUserInteractionsUtils::IsRecoverableFailL( RHttpDownload& aDownload,
   289                                                   TInt32 aErrorId ) const
   295                                                   TInt32 aErrorId ) const
   290     {
   296     {
   291     TBool recoverable( ETrue );
   297     TBool recoverable( ETrue );
   292 
   298 
   293     // What is the error?
   299     // What is the error?
   296     //
   302     //
   297     // EDlAttrGlobalErrorId gives the system-wide code.
   303     // EDlAttrGlobalErrorId gives the system-wide code.
   298     TInt32 sysErrorId( 0 );
   304     TInt32 sysErrorId( 0 );
   299     User::LeaveIfError( aDownload.GetIntAttribute
   305     User::LeaveIfError( aDownload.GetIntAttribute
   300                       ( EDlAttrGlobalErrorId, sysErrorId ) );
   306                       ( EDlAttrGlobalErrorId, sysErrorId ) );
   301     
   307 
   302     TBool pausable( ETrue );
   308     TBool pausable( ETrue );
   303     User::LeaveIfError( aDownload.GetBoolAttribute( EDlAttrPausable, pausable ) );
   309     User::LeaveIfError( aDownload.GetBoolAttribute( EDlAttrPausable, pausable ) );
   304     if ( errorId == EObjectNotFound )
   310     if ( errorId == EObjectNotFound )
   305          // Other error situations can be added to the list. //
   311          // Other error situations can be added to the list. //
   306         {
   312         {
   307         recoverable = EFalse;
   313         recoverable = EFalse;
   308         }
   314         }
   309     else if ( errorId == ETransactionFailed )
   315     else if ( errorId == ETransactionFailed )
   310         {        
   316         {
   311         if ( sysErrorId == KBadMimeType || sysErrorId == -20000 || sysErrorId == KErrHttpPartialResponseReceived || !pausable )
   317         if ( sysErrorId == KBadMimeType || sysErrorId == -20000 || sysErrorId == KErrHttpPartialResponseReceived || !pausable )
   312         // KBadMimeType and -20000 is from DRMFilter
   318         // KBadMimeType and -20000 is from DRMFilter
   313         // Transaction must be cancelled and download must be deleted
   319         // Transaction must be cancelled and download must be deleted
   314             {
   320             {
   315             recoverable = EFalse;
   321             recoverable = EFalse;
   320             }
   326             }
   321         }
   327         }
   322     else if ( errorId == EGeneral )
   328     else if ( errorId == EGeneral )
   323         {
   329         {
   324         if ( sysErrorId == KErrNoMemory || sysErrorId == KErrDiskFull )
   330         if ( sysErrorId == KErrNoMemory || sysErrorId == KErrDiskFull )
   325         //Memory full or Disk Full can be Recoverable error if Download is Pausable    
   331         //Memory full or Disk Full can be Recoverable error if Download is Pausable
   326             {
   332             {
   327             recoverable = pausable;
   333             recoverable = pausable;
   328             }
   334             }
   329         else 
   335         else
   330             {
   336             {
   331             recoverable = EFalse;
   337             recoverable = EFalse;
   332             }
   338             }
   333         }
   339         }
   334     else
   340     else
   347 void CUserInteractionsUtils::HandleContentL
   353 void CUserInteractionsUtils::HandleContentL
   348 ( RHttpDownload& aDownload, MDownloadHandlerObserver& aHandlerObserver )
   354 ( RHttpDownload& aDownload, MDownloadHandlerObserver& aHandlerObserver )
   349     {
   355     {
   350     CLOG_ENTERFN("CUserInteractionsUtils::HandleContentL");
   356     CLOG_ENTERFN("CUserInteractionsUtils::HandleContentL");
   351 
   357 
   352     __ASSERT_DEBUG( !iRegistryModel.UserInteractions().IsUiBusy(), 
   358     __ASSERT_DEBUG( !iRegistryModel.UserInteractions().IsUiBusy(),
   353                     Panic( EUiLibPanDocHandlerAlreadyRunning ) );
   359                     Panic( EUiLibPanDocHandlerAlreadyRunning ) );
   354                     
   360 
   355     if ( iRegistryModel.UserInteractions().IsUiBusy() )
   361     if ( iRegistryModel.UserInteractions().IsUiBusy() )
   356         {
   362         {
   357         CLOG_WRITE(" IsUiBusy() true");
   363         CLOG_WRITE(" IsUiBusy() true");
   358         }
   364         }
   359     else
   365     else
   360         {
   366         {
   361         iHandledDownload = &aDownload;
   367         iHandledDownload = &aDownload;
   362         iHandlerObserver = &aHandlerObserver;
   368         iHandlerObserver = &aHandlerObserver;
   363 
   369 
   364         // BEGIN: Get attributes for generic params 
   370         // BEGIN: Get attributes for generic params
   365         //=========================
   371         //=========================
   366         //   EDlAttrCurrentUrl
   372         //   EDlAttrCurrentUrl
   367         //=========================
   373         //=========================
   368         HBufC* url = HBufC::NewLC( KMaxUrlLength );
   374         HBufC* url = HBufC::NewLC( KMaxUrlLength );
   369         TPtr urlPtr = url->Des();
   375         TPtr urlPtr = url->Des();
   393         if ( !IsDuplicateL( fileNamePtr ) )
   399         if ( !IsDuplicateL( fileNamePtr ) )
   394             {
   400             {
   395             HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
   401             HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
   396             CAknInformationNote* note = new(ELeave)  CAknInformationNote();
   402             CAknInformationNote* note = new(ELeave)  CAknInformationNote();
   397             note->ExecuteLD(*infoPrompt);
   403             note->ExecuteLD(*infoPrompt);
   398             CleanupStack::PopAndDestroy(infoPrompt);	
   404             CleanupStack::PopAndDestroy(infoPrompt);
   399 
   405 
   400             CleanupStack::PopAndDestroy( fileName ); // fileName
   406             CleanupStack::PopAndDestroy( fileName ); // fileName
   401             CleanupStack::PopAndDestroy( url ); // url            
   407             CleanupStack::PopAndDestroy( url ); // url
   402             return;
   408             return;
   403             }
   409             }
   404 
   410 
   405         //=========================
   411         //=========================
   406         //   EDlAttrContentType
   412         //   EDlAttrContentType
   444             }
   450             }
   445         else
   451         else
   446             {
   452             {
   447             User::Leave( retVal );
   453             User::Leave( retVal );
   448             }
   454             }
   449         // END: Get attributes for generic params 
   455         // END: Get attributes for generic params
   450 
   456 
   451         //Creating generic param list
   457         //Creating generic param list
   452         CAiwGenericParamList* genericParamList = CAiwGenericParamList::NewLC();
   458         CAiwGenericParamList* genericParamList = CAiwGenericParamList::NewLC();
   453 
   459 
   454         TAiwVariant iapVariant( iap );
   460         TAiwVariant iapVariant( iap );
   480             TAiwVariant fileNameVariant( *fileName );
   486             TAiwVariant fileNameVariant( *fileName );
   481             TAiwGenericParam genericParamFileName
   487             TAiwGenericParam genericParamFileName
   482                 ( EGenericParamFile, fileNameVariant );
   488                 ( EGenericParamFile, fileNameVariant );
   483             genericParamList->AppendL( genericParamFileName );
   489             genericParamList->AppendL( genericParamFileName );
   484             }
   490             }
   485         
   491 
   486         CLOG_WRITE_FORMAT(" iDocHandler: %x",iDocHandler);
   492         CLOG_WRITE_FORMAT(" iDocHandler: %x",iDocHandler);
   487     	delete iDocHandler;
   493     	delete iDocHandler;
   488     	iDocHandler = 0;
   494     	iDocHandler = 0;
   489         iDocHandler = CDocumentHandler::NewL();
   495         iDocHandler = CDocumentHandler::NewL();
   490         iDocHandler->SetExitObserver( this );
   496         iDocHandler->SetExitObserver( this );
   491     
   497 
   492         RFile file;
   498         RFile file;
   493         iDocHandler->OpenTempFileL( *fileName, file );
   499         iDocHandler->OpenTempFileL( *fileName, file );
   494         CleanupClosePushL( file );
   500         CleanupClosePushL( file );
   495 
   501 
   496         TDataType dataType( *contentType );
   502         TDataType dataType( *contentType );
   497         TInt docErr( KErrNone );
   503         TInt docErr( KErrNone );
   498         TInt trappedError( KErrNone );
   504         TInt trappedError( KErrNone );
   499         iDocHandlerUsesTheUi = ETrue;
   505         iDocHandlerUsesTheUi = ETrue;
   500         TRAP( trappedError, 
   506         TRAP( trappedError,
   501               docErr = iDocHandler->OpenFileEmbeddedL( file, 
   507               docErr = iDocHandler->OpenFileEmbeddedL( file,
   502                                                        dataType, 
   508                                                        dataType,
   503                                                        *genericParamList ) );
   509                                                        *genericParamList ) );
   504         CLOG_WRITE_FORMAT(" trappedError: %d",trappedError);
   510         CLOG_WRITE_FORMAT(" trappedError: %d",trappedError);
   505         CLOG_WRITE_FORMAT(" docErr: %d",docErr);
   511         CLOG_WRITE_FORMAT(" docErr: %d",docErr);
   506         CleanupStack::PopAndDestroy( &file ); // file
   512         CleanupStack::PopAndDestroy( &file ); // file
   507         CLOG_WRITE(" PopAndDestroy file OK");
   513         CLOG_WRITE(" PopAndDestroy file OK");
   508         
   514 
   509         if ( trappedError || docErr )
   515         if ( trappedError || docErr )
   510             {
   516             {
   511             delete iDocHandler;
   517             delete iDocHandler;
   512     	    iDocHandler = 0;
   518     	    iDocHandler = 0;
   513     	    iDocHandlerUsesTheUi = EFalse;
   519     	    iDocHandlerUsesTheUi = EFalse;
   514     	    // Since we know this is an open file error, we should handle it by calling 
   520     	    // Since we know this is an open file error, we should handle it by calling
   515     	    // ShowErrorNotesL instead of propagating the error 
   521     	    // ShowErrorNotesL instead of propagating the error
   516             if ( trappedError ) 
   522             if ( trappedError )
   517                 {
   523                 {
   518                 ShowErrorNoteL (aDownload, trappedError );
   524                 ShowErrorNoteL (aDownload, trappedError );
   519                 }
   525                 }
   520             else 
   526             else
   521                 {
   527                 {
   522                 ShowErrorNoteL (aDownload, docErr );
   528                 ShowErrorNoteL (aDownload, docErr );
   523                 }            
   529                 }
   524             }
   530             }
   525 
   531 
   526         CleanupStack::PopAndDestroy( genericParamList ); // genericParamList
   532         CleanupStack::PopAndDestroy( genericParamList ); // genericParamList
   527         CleanupStack::PopAndDestroy( refererUri ); // refererUri
   533         CleanupStack::PopAndDestroy( refererUri ); // refererUri
   528         CleanupStack::PopAndDestroy( charset ); // charset
   534         CleanupStack::PopAndDestroy( charset ); // charset
   542     CLOG_ENTERFN("CUserInteractionsUtils::SaveContentL");
   548     CLOG_ENTERFN("CUserInteractionsUtils::SaveContentL");
   543 
   549 
   544     __ASSERT_DEBUG( iMemSelectionDialog == 0, Panic( EUiLibPanNull ) ); // Only one can run
   550     __ASSERT_DEBUG( iMemSelectionDialog == 0, Panic( EUiLibPanNull ) ); // Only one can run
   545 
   551 
   546     TBool boolRet( EFalse );
   552     TBool boolRet( EFalse );
   547     
   553 
   548     if ( !DrmDownloadL( aDownload ) )
   554     if ( !DrmDownloadL( aDownload ) )
   549         {
   555         {
   550         boolRet = SaveContentWithPathSelectionL( aDownload );
   556         boolRet = SaveContentWithPathSelectionL( aDownload );
   551         }
   557         }
   552     else
   558     else
   568             HBufC* dlName = HBufC::NewLC( KMaxPath );
   574             HBufC* dlName = HBufC::NewLC( KMaxPath );
   569             TPtr dlNamePtr = dlName->Des();
   575             TPtr dlNamePtr = dlName->Des();
   570             User::LeaveIfError
   576             User::LeaveIfError
   571                 ( aDownload.GetStringAttribute( EDlAttrName, dlNamePtr ) );
   577                 ( aDownload.GetStringAttribute( EDlAttrName, dlNamePtr ) );
   572             CLOG_WRITE_FORMAT(" EDlAttrName: %S",&dlNamePtr);
   578             CLOG_WRITE_FORMAT(" EDlAttrName: %S",&dlNamePtr);
   573             
   579 
   574             HBufC8* contentType = HBufC8::NewLC( KMaxContentTypeLength );
   580             HBufC8* contentType = HBufC8::NewLC( KMaxContentTypeLength );
   575             TPtr8 contentTypePtr = contentType->Des();
   581             TPtr8 contentTypePtr = contentType->Des();
   576             User::LeaveIfError
   582             User::LeaveIfError
   577                 ( aDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
   583                 ( aDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
   578             CLOG_WRITE(" EDlAttrContentType OK");
   584             CLOG_WRITE(" EDlAttrContentType OK");
   592                                                 dataType,
   598                                                 dataType,
   593                                                 KEntryAttNormal ) );
   599                                                 KEntryAttNormal ) );
   594             CLOG_WRITE_FORMAT(" moveErr: %d",moveErr);
   600             CLOG_WRITE_FORMAT(" moveErr: %d",moveErr);
   595             CLOG_WRITE_FORMAT(" moveRet: %d",moveRet);
   601             CLOG_WRITE_FORMAT(" moveRet: %d",moveRet);
   596 
   602 
   597             // Delete DocHandler, otherwise IsUiBusy returns ETrue.        
   603             // Delete DocHandler, otherwise IsUiBusy returns ETrue.
   598             delete iDocHandler;
   604             delete iDocHandler;
   599             iDocHandler = 0;
   605             iDocHandler = 0;
   600             iDocHandlerUsesTheUi = EFalse;
   606             iDocHandlerUsesTheUi = EFalse;
   601             CleanupStack::PopAndDestroy( contentType ); // contentType
   607             CleanupStack::PopAndDestroy( contentType ); // contentType
   602             contentType = 0;
   608             contentType = 0;
   603             CleanupStack::PopAndDestroy( dlName ); // dlName
   609             CleanupStack::PopAndDestroy( dlName ); // dlName
   604             dlName = 0;
   610             dlName = 0;
   605             CleanupStack::PopAndDestroy( fileName ); // fileName
   611             CleanupStack::PopAndDestroy( fileName ); // fileName
   606             fileName = 0;
   612             fileName = 0;
   607             
   613 
   608             if( moveRet == KUserCancel )
   614             if( moveRet == KUserCancel )
   609                 {
   615                 {
   610                 // The user cancelled the operation.
   616                 // The user cancelled the operation.
   611                 }
   617                 }
   612             else if( moveErr == KErrNone )
   618             else if( moveErr == KErrNone )
   643 
   649 
   644     TBool boolRet( EFalse );
   650     TBool boolRet( EFalse );
   645 
   651 
   646     // Select memory
   652     // Select memory
   647     iMemSelectionDialog = CAknMemorySelectionDialog::NewL
   653     iMemSelectionDialog = CAknMemorySelectionDialog::NewL
   648         ( ECFDDialogTypeSave, R_DMUL_MEMORY_SELECTION_DLG, 
   654         ( ECFDDialogTypeSave, R_DMUL_MEMORY_SELECTION_DLG,
   649           /*aShowUnavailableDrives*/EFalse );
   655           /*aShowUnavailableDrives*/EFalse );
   650     CLOG_WRITE(" CAknMemorySelectionDialog::NewL OK");
   656     CLOG_WRITE(" CAknMemorySelectionDialog::NewL OK");
   651     CAknMemorySelectionDialog::TMemory mem( CAknMemorySelectionDialog::EPhoneMemory );
   657     CAknMemorySelectionDialog::TMemory mem( CAknMemorySelectionDialog::EPhoneMemory );
   652     boolRet = iMemSelectionDialog->ExecuteL( mem );
   658     boolRet = iMemSelectionDialog->ExecuteL( mem );
   653     CLOG_WRITE_FORMAT(" MEM boolRet: %d",boolRet);
   659     CLOG_WRITE_FORMAT(" MEM boolRet: %d",boolRet);
   654     delete iMemSelectionDialog;
   660     delete iMemSelectionDialog;
   655     iMemSelectionDialog = 0;
   661     iMemSelectionDialog = 0;
   656     
   662 
   657     if ( boolRet )
   663     if ( boolRet )
   658         {
   664         {
   659         CLOG_WRITE_FORMAT(" mem: %d",(TInt)mem);
   665         CLOG_WRITE_FORMAT(" mem: %d",(TInt)mem);
   660         TBool useMmc = (mem == CAknMemorySelectionDialog::EMemoryCard);
   666         TBool useMmc = (mem == CAknMemorySelectionDialog::EMemoryCard);
   661         
   667 
   662         __ASSERT_DEBUG( iFileSelectionDialog == 0, Panic( EUiLibPanNull ) ); // Only one can run
   668         __ASSERT_DEBUG( iFileSelectionDialog == 0, Panic( EUiLibPanNull ) ); // Only one can run
   663 
   669 
   664         HBufC* fileName = HBufC::NewLC( KMaxPath );
   670         HBufC* fileName = HBufC::NewLC( KMaxPath );
   665         TPtr fileNamePtr = fileName->Des();
   671         TPtr fileNamePtr = fileName->Des();
   666         User::LeaveIfError
   672         User::LeaveIfError
   667             ( aDownload.GetStringAttribute( EDlAttrName, fileNamePtr ) );
   673             ( aDownload.GetStringAttribute( EDlAttrName, fileNamePtr ) );
   668         CLOG_WRITE(" EDlAttrName OK");
   674         CLOG_WRITE(" EDlAttrName OK");
   669 
   675 
   670         // Select folder
   676         // Select folder
   671         TInt resourceId = useMmc ? R_DMUL_MMC_FILE_SELECTION_DLG : 
   677         TInt resourceId = useMmc ? R_DMUL_MMC_FILE_SELECTION_DLG :
   672                                    R_DMUL_FILE_SELECTION_DLG;
   678                                    R_DMUL_FILE_SELECTION_DLG;
   673         iFileSelectionDialog = CAknFileSelectionDialog::NewL
   679         iFileSelectionDialog = CAknFileSelectionDialog::NewL
   674                              ( ECFDDialogTypeSave, resourceId );
   680                              ( ECFDDialogTypeSave, resourceId );
   675         CLOG_WRITE(" CAknFileSelectionDialog::NewL OK");
   681         CLOG_WRITE(" CAknFileSelectionDialog::NewL OK");
   676         TPath selectedPath( KNullDesC );
   682         TPath selectedPath( KNullDesC );
   677         // Execute dialog - it calls CActiveScheduler::Start(), so be careful 
   683         // Execute dialog - it calls CActiveScheduler::Start(), so be careful
   678         // when using data members after ExecuteLD!
   684         // when using data members after ExecuteLD!
   679         // TODO introduce deleted, as it uses data after executeld.
   685         // TODO introduce deleted, as it uses data after executeld.
   680         boolRet = iFileSelectionDialog->ExecuteL( selectedPath );
   686         boolRet = iFileSelectionDialog->ExecuteL( selectedPath );
   681         CLOG_WRITE_FORMAT(" FILE boolRet: %d",boolRet);
   687         CLOG_WRITE_FORMAT(" FILE boolRet: %d",boolRet);
   682         delete iFileSelectionDialog;
   688         delete iFileSelectionDialog;
   694                 ( aDownload.SetStringAttribute( EDlAttrDestFilename, *fileName ) );
   700                 ( aDownload.SetStringAttribute( EDlAttrDestFilename, *fileName ) );
   695             CLOG_WRITE(" EDlAttrDestFilename OK");
   701             CLOG_WRITE(" EDlAttrDestFilename OK");
   696             User::LeaveIfError( aDownload.Move() );
   702             User::LeaveIfError( aDownload.Move() );
   697             CLOG_WRITE(" Move OK");
   703             CLOG_WRITE(" Move OK");
   698             }
   704             }
   699             
   705 
   700         CleanupStack::PopAndDestroy( fileName ); // fileName
   706         CleanupStack::PopAndDestroy( fileName ); // fileName
   701         }
   707         }
   702 
   708 
   703     CLOG_LEAVEFN("CUserInteractionsUtils::SaveContentWithPathSelectionL");
   709     CLOG_LEAVEFN("CUserInteractionsUtils::SaveContentWithPathSelectionL");
   704     return boolRet;
   710     return boolRet;
   806             }
   812             }
   807         }
   813         }
   808     CleanupStack::PopAndDestroy( 2, original ); // nameBuf, original
   814     CleanupStack::PopAndDestroy( 2, original ); // nameBuf, original
   809     return ret;
   815     return ret;
   810     }
   816     }
   811     
   817 
   812 // -----------------------------------------------------------------------------
   818 // -----------------------------------------------------------------------------
   813 // CUserInteractionsUtils::IsDuplicateL
   819 // CUserInteractionsUtils::IsDuplicateL
   814 // -----------------------------------------------------------------------------
   820 // -----------------------------------------------------------------------------
   815 //
   821 //
   816 TBool CUserInteractionsUtils::IsDuplicateL( const TPtrC& aFileName )
   822 TBool CUserInteractionsUtils::IsDuplicateL( const TPtrC& aFileName )
   859 // -----------------------------------------------------------------------------
   865 // -----------------------------------------------------------------------------
   860 //
   866 //
   861 TBool CUserInteractionsUtils::DeleteWithUserConfirmL( RHttpDownload& aDownload )
   867 TBool CUserInteractionsUtils::DeleteWithUserConfirmL( RHttpDownload& aDownload )
   862     {
   868     {
   863     CLOG_ENTERFN("CUserInteractionsUtils::DeleteWithUserConfirmL");
   869     CLOG_ENTERFN("CUserInteractionsUtils::DeleteWithUserConfirmL");
   864     
   870 
   865     TInt32 numMediaObjects(0);
   871     TInt32 numMediaObjects(0);
   866     aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects );
   872     aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects );
   867     
   873 
   868     HBufC* fileName = HBufC::NewLC( KMaxPath );
   874     HBufC* fileName = HBufC::NewLC( KMaxPath );
   869     TPtr fileNamePtr = fileName->Des();
   875     TPtr fileNamePtr = fileName->Des();
   870     
   876 
   871     // In case of album, show the album name. Otherwise show file name.
   877     // In case of album, show the album name. Otherwise show file name.
   872     TInt err(KErrNone);
   878     TInt err(KErrNone);
   873     if (numMediaObjects > 1)
   879     if (numMediaObjects > 1)
   874         {
   880         {
   875         err = aDownload.GetStringAttribute( EDlAttrAlbumName, fileNamePtr );
   881         err = aDownload.GetStringAttribute( EDlAttrAlbumName, fileNamePtr );
   876         }
   882         }
   877     else
   883     else
   878         {
   884         {
   879         err = aDownload.GetStringAttribute( EDlAttrName, fileNamePtr );
   885         err = aDownload.GetStringAttribute( EDlAttrName, fileNamePtr );
   880         }
   886         }
   881         
   887 
   882     if ( err != KErrNone && err != KErrNotFound )
   888     if ( err != KErrNone && err != KErrNotFound )
   883         {
   889         {
   884         User::LeaveIfError( err );
   890         User::LeaveIfError( err );
   885         }
   891         }
   886     TBool fileNameSet = ( err == KErrNone );
   892     TBool fileNameSet = ( err == KErrNone );
   891 
   897 
   892     HBufC* prompt = StringLoader::LoadLC( R_DMUL_DOWNLOAD_DEL_CONF, *fileName );
   898     HBufC* prompt = StringLoader::LoadLC( R_DMUL_DOWNLOAD_DEL_CONF, *fileName );
   893     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
   899     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
   894     delete iDeleteConfirmDlg;
   900     delete iDeleteConfirmDlg;
   895     iDeleteConfirmDlg = dlg;
   901     iDeleteConfirmDlg = dlg;
   896     // Execute dialog - it calls CActiveScheduler::Start(), so be careful 
   902     // Execute dialog - it calls CActiveScheduler::Start(), so be careful
   897     // when using data members after ExecuteLD!
   903     // when using data members after ExecuteLD!
   898     TInt resp = iDeleteConfirmDlg->ExecuteLD
   904     TInt resp = iDeleteConfirmDlg->ExecuteLD
   899                     ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt );
   905                     ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt );
   900     iDeleteConfirmDlg = 0;
   906     iDeleteConfirmDlg = 0;
   901     CleanupStack::PopAndDestroy( 2, fileName ); // prompt, fileName
   907     CleanupStack::PopAndDestroy( 2, fileName ); // prompt, fileName
   902 
   908 
   903     if ( resp ) // We have to check only that the value is non-zero
   909     if ( resp ) // We have to check only that the value is non-zero
   904         {
   910         {
   905 
   911 
   906         aDownload.GetBoolAttribute( EDlAttrCodDownload,iCodDownload );	
   912         aDownload.GetBoolAttribute( EDlAttrCodDownload,iCodDownload );
   907         
   913 
   908 	   
   914 
   909         if(iCodDownload)
   915         if(iCodDownload)
   910 			{
   916 			{
   911 			
   917 
   912 			#ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   918 			#ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   913 			CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
   919 			CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
   914 	        CEikonEnv::Static()->FsSession() );
   920 	        CEikonEnv::Static()->FsSession() );
   915 	        
   921 
   916 	        #endif
   922 	        #endif
   917 	        
   923 
   918 	        //Assume that all files to be deleted are valid.
   924 	        //Assume that all files to be deleted are valid.
   919 	        TBool fileNotFound = EFalse;
   925 	        TBool fileNotFound = EFalse;
   920 	        
   926 
   921 			for(TInt i = 1; i <= numMediaObjects; i++)
   927 			for(TInt i = 1; i <= numMediaObjects; i++)
   922 		    	{
   928 		    	{
   923                 HBufC* fileName = HBufC::NewLC( KMaxPath );
   929                 HBufC* fileName = HBufC::NewLC( KMaxPath );
   924                 TPtr fileNamePtr = fileName->Des();
   930                 TPtr fileNamePtr = fileName->Des();
   925                 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename,i,fileNamePtr ));		    			    	
   931                 User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename,i,fileNamePtr ));
   926                 RFs rfs;
   932                 RFs rfs;
   927                 User::LeaveIfError( rfs.Connect() );
   933                 User::LeaveIfError( rfs.Connect() );
   928                 CleanupClosePushL<RFs>( rfs );
   934                 CleanupClosePushL<RFs>( rfs );
   929                 TFindFile file(rfs);
   935                 TFindFile file(rfs);
   930                 TPtrC ptr(KNullDesC);
   936                 TPtrC ptr(KNullDesC);
   934                     //Found out that at least one file is not found
   940                     //Found out that at least one file is not found
   935                     fileNotFound =ETrue;
   941                     fileNotFound =ETrue;
   936                     }
   942                     }
   937 
   943 
   938                 rfs.Delete( fileNamePtr );
   944                 rfs.Delete( fileNamePtr );
   939                 
   945 
   940                 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   946                 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   941                 // Notify Media Gallery about new media file
   947                 // Notify Media Gallery about new media file
   942                 if( fileNamePtr.Length() > 0 )
   948                 if( fileNamePtr.Length() > 0 )
   943                    {
   949                    {
   944                    TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) );
   950                    TRAP_IGNORE( mgFileManager->UpdateL( fileNamePtr ) );
   946                    }
   952                    }
   947                 else
   953                 else
   948                    {
   954                    {
   949                    TRAP_IGNORE( mgFileManager->UpdateL() );
   955                    TRAP_IGNORE( mgFileManager->UpdateL() );
   950                    }
   956                    }
   951                  
   957 
   952                  #else
   958                  #else
   953                     if( fileNamePtr.Length() > 0 )
   959                     if( fileNamePtr.Length() > 0 )
   954                    {
   960                    {
   955                    TRAP_IGNORE( UpdateDCFRepositoryL( fileNamePtr ) );
   961                    TRAP_IGNORE( UpdateDCFRepositoryL( fileNamePtr ) );
   956                    }
   962                    }
   957                   
   963 
   958                  #endif  
   964                  #endif
   959                    
   965 
   960                 CleanupStack::PopAndDestroy( &rfs );
   966                 CleanupStack::PopAndDestroy( &rfs );
   961                 CleanupStack::PopAndDestroy( fileName );    
   967                 CleanupStack::PopAndDestroy( fileName );
   962                 }
   968                 }
   963                 
   969 
   964                 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   970                 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   965                 delete mgFileManager;
   971                 delete mgFileManager;
   966                 mgFileManager = NULL;
   972                 mgFileManager = NULL;
   967                 #endif
   973                 #endif
   968                 
   974 
   969                 //Inform the user that atleast one file not found.	
   975                 //Inform the user that atleast one file not found.
   970 	   		    if(fileNotFound)
   976 	   		    if(fileNotFound)
   971 	   		        {
   977 	   		        {
   972                     HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
   978                     HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
   973                     CAknInformationNote* note = new(ELeave)  CAknInformationNote();
   979                     CAknInformationNote* note = new(ELeave)  CAknInformationNote();
   974                     note->ExecuteLD(*infoPrompt);
   980                     note->ExecuteLD(*infoPrompt);
   975                     CleanupStack::PopAndDestroy(infoPrompt);	   		   				
   981                     CleanupStack::PopAndDestroy(infoPrompt);
   976 	   		        }
   982 	   		        }
   977 			}    
   983 			}
   978 			
   984 
   979         User::LeaveIfError( aDownload.Delete() );
   985         User::LeaveIfError( aDownload.Delete() );
   980         CLOG_LEAVEFN("CUserInteractionsUtils::DeleteWithUserConfirmL");
   986         CLOG_LEAVEFN("CUserInteractionsUtils::DeleteWithUserConfirmL");
   981         return ETrue; // Deleted
   987         return ETrue; // Deleted
   982         }
   988         }
   983     else
   989     else
  1005 // -----------------------------------------------------------------------------
  1011 // -----------------------------------------------------------------------------
  1006 //
  1012 //
  1007 TBool CUserInteractionsUtils::CancelWithUserConfirmL( RHttpDownload& aDownload )
  1013 TBool CUserInteractionsUtils::CancelWithUserConfirmL( RHttpDownload& aDownload )
  1008     {
  1014     {
  1009     CLOG_ENTERFN("CUserInteractionsUtils::CancelWithUserConfirmL");
  1015     CLOG_ENTERFN("CUserInteractionsUtils::CancelWithUserConfirmL");
  1010     
  1016 
  1011     HBufC* fileName = HBufC::NewLC( KMaxPath );
  1017     HBufC* fileName = HBufC::NewLC( KMaxPath );
  1012     TPtr fileNamePtr = fileName->Des();
  1018     TPtr fileNamePtr = fileName->Des();
  1013     TInt err = aDownload.GetStringAttribute( EDlAttrName, fileNamePtr );
  1019     TInt err = aDownload.GetStringAttribute( EDlAttrName, fileNamePtr );
  1014     if ( err != KErrNone && err != KErrNotFound )
  1020     if ( err != KErrNone && err != KErrNotFound )
  1015         {
  1021         {
  1023 
  1029 
  1024     HBufC* prompt = StringLoader::LoadLC( R_DMUL_DOWNLOAD_CAN_CONF, *fileName );
  1030     HBufC* prompt = StringLoader::LoadLC( R_DMUL_DOWNLOAD_CAN_CONF, *fileName );
  1025     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
  1031     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
  1026     delete iCancelConfirmDlg;
  1032     delete iCancelConfirmDlg;
  1027     iCancelConfirmDlg = dlg;
  1033     iCancelConfirmDlg = dlg;
  1028     // Execute dialog - it calls CActiveScheduler::Start(), so be careful 
  1034     // Execute dialog - it calls CActiveScheduler::Start(), so be careful
  1029     // when using data members after ExecuteLD!
  1035     // when using data members after ExecuteLD!
  1030     TInt resp = iCancelConfirmDlg->ExecuteLD
  1036     TInt resp = iCancelConfirmDlg->ExecuteLD
  1031                     ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt );
  1037                     ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt );
  1032     iCancelConfirmDlg = 0;
  1038     iCancelConfirmDlg = 0;
  1033     CleanupStack::PopAndDestroy( 2, fileName ); // prompt, fileName
  1039     CleanupStack::PopAndDestroy( 2, fileName ); // prompt, fileName
  1043         // Do nothing.
  1049         // Do nothing.
  1044         CLOG_LEAVEFN("CUserInteractionsUtils::CancelWithUserConfirmL");
  1050         CLOG_LEAVEFN("CUserInteractionsUtils::CancelWithUserConfirmL");
  1045         return EFalse;
  1051         return EFalse;
  1046         }
  1052         }
  1047     }
  1053     }
  1048     
  1054 
  1049 // -----------------------------------------------------------------------------
  1055 // -----------------------------------------------------------------------------
  1050 // CUserInteractionsUtils::CancelAllWithUserConfirmL
  1056 // CUserInteractionsUtils::CancelAllWithUserConfirmL
  1051 // -----------------------------------------------------------------------------
  1057 // -----------------------------------------------------------------------------
  1052 //
  1058 //
  1053 TBool CUserInteractionsUtils::CancelAllWithUserConfirmL( RHttpDownload& /* aDownload */)
  1059 TBool CUserInteractionsUtils::CancelAllWithUserConfirmL( RHttpDownload& /* aDownload */)
  1056 
  1062 
  1057     HBufC* prompt = StringLoader::LoadLC( R_DMUL_EXIT_CONF_PLUR );
  1063     HBufC* prompt = StringLoader::LoadLC( R_DMUL_EXIT_CONF_PLUR );
  1058     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
  1064     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
  1059     delete iCancelConfirmDlg;
  1065     delete iCancelConfirmDlg;
  1060     iCancelConfirmDlg = dlg;
  1066     iCancelConfirmDlg = dlg;
  1061     // Execute dialog - it calls CActiveScheduler::Start(), so be careful 
  1067     // Execute dialog - it calls CActiveScheduler::Start(), so be careful
  1062     // when using data members after ExecuteLD!
  1068     // when using data members after ExecuteLD!
  1063     TInt resp = iCancelConfirmDlg->ExecuteLD
  1069     TInt resp = iCancelConfirmDlg->ExecuteLD
  1064                     ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt );
  1070                     ( R_DMUL_DOWNLOAD_YESNO_CONF_Q, *prompt );
  1065     iCancelConfirmDlg = 0;
  1071     iCancelConfirmDlg = 0;
  1066     CleanupStack::PopAndDestroy(); // prompt
  1072     CleanupStack::PopAndDestroy(); // prompt
  1067     
  1073 
  1068     if ( resp ) // We have to check only that the value is non-zero
  1074     if ( resp ) // We have to check only that the value is non-zero
  1069         {
  1075         {
  1070         TInt count = iRegistryModel.DownloadMgr().CurrentDownloads().Count();
  1076         TInt count = iRegistryModel.DownloadMgr().CurrentDownloads().Count();
  1071         TInt32 dlState;
  1077         TInt32 dlState;
  1072         TInt i = 0;
  1078         TInt i = 0;
  1084 		       }
  1090 		       }
  1085             else if(dlState  == EHttpDlFailed )
  1091             else if(dlState  == EHttpDlFailed )
  1086 		       {
  1092 		       {
  1087 		       dlState  = EHttpDlMultipleMOFailed;
  1093 		       dlState  = EHttpDlMultipleMOFailed;
  1088 		       }
  1094 		       }
  1089            
  1095 
  1090             if(dlState == EHttpDlInprogress || dlState == EHttpDlPaused )
  1096             if(dlState == EHttpDlInprogress || dlState == EHttpDlPaused )
  1091         	    {
  1097         	    {
  1092         	    i--;
  1098         	    i--;
  1093         	    count--;
  1099         	    count--;
  1094         	    User::LeaveIfError( (iRegistryModel.DownloadMgr().CurrentDownloads().At(i))->Delete());
  1100         	    User::LeaveIfError( (iRegistryModel.DownloadMgr().CurrentDownloads().At(i))->Delete());
  1126     CLOG_ENTERFN("CUserInteractionsUtils::ShowMediaRemovedNoteL");
  1132     CLOG_ENTERFN("CUserInteractionsUtils::ShowMediaRemovedNoteL");
  1127     if ( iMediaRemovedNote == 0 )
  1133     if ( iMediaRemovedNote == 0 )
  1128         {
  1134         {
  1129         HBufC* value = iCoeEnv.AllocReadResourceLC
  1135         HBufC* value = iCoeEnv.AllocReadResourceLC
  1130                         ( R_DMUL_ERROR_EXT_MEM_REMOVED );
  1136                         ( R_DMUL_ERROR_EXT_MEM_REMOVED );
  1131         iMediaRemovedNote = 
  1137         iMediaRemovedNote =
  1132             new (ELeave) CAknInformationNote( &iMediaRemovedNote );
  1138             new (ELeave) CAknInformationNote( &iMediaRemovedNote );
  1133         iMediaRemovedNote->ExecuteLD( *value );
  1139         iMediaRemovedNote->ExecuteLD( *value );
  1134         CleanupStack::PopAndDestroy( value ); // value
  1140         CleanupStack::PopAndDestroy( value ); // value
  1135         }
  1141         }
  1136     CLOG_LEAVEFN("CUserInteractionsUtils::ShowMediaRemovedNoteL");
  1142     CLOG_LEAVEFN("CUserInteractionsUtils::ShowMediaRemovedNoteL");
  1157 //
  1163 //
  1158 TBool CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL
  1164 TBool CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL
  1159     ( RHttpDownload& aDownload )
  1165     ( RHttpDownload& aDownload )
  1160     {
  1166     {
  1161     CLOG_ENTERFN("CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL");
  1167     CLOG_ENTERFN("CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL");
  1162     
  1168 
  1163     HBufC* username = 0;
  1169     HBufC* username = 0;
  1164     HBufC* password = 0;
  1170     HBufC* password = 0;
  1165 
  1171 
  1166     // Get the authentication scheme
  1172     // Get the authentication scheme
  1167     TInt32 authScheme(0);
  1173     TInt32 authScheme(0);
  1191         User::LeaveIfError( getErr );
  1197         User::LeaveIfError( getErr );
  1192         }
  1198         }
  1193 
  1199 
  1194     // Execute a wait dialog
  1200     // Execute a wait dialog
  1195     TBool resp = iDialogsProv->DialogUserAuthenticationLC
  1201     TBool resp = iDialogsProv->DialogUserAuthenticationLC
  1196             ( *url, *realm, *userName, username, password, 
  1202             ( *url, *realm, *userName, username, password,
  1197               authScheme == EAuthBasic );
  1203               authScheme == EAuthBasic );
  1198 
  1204 
  1199     if ( resp )
  1205     if ( resp )
  1200         {
  1206         {
  1201         if ( authScheme == EAuthBasic && BrowserSettingSecWarningL() )
  1207         if ( authScheme == EAuthBasic && BrowserSettingSecWarningL() )
  1214 
  1220 
  1215     CleanupStack::PopAndDestroy( 2 ); // username, password
  1221     CleanupStack::PopAndDestroy( 2 ); // username, password
  1216     CleanupStack::PopAndDestroy( realm ); // realm
  1222     CleanupStack::PopAndDestroy( realm ); // realm
  1217     CleanupStack::PopAndDestroy( url ); // url
  1223     CleanupStack::PopAndDestroy( url ); // url
  1218     CleanupStack::PopAndDestroy( userName ); // userName
  1224     CleanupStack::PopAndDestroy( userName ); // userName
  1219     
  1225 
  1220     CLOG_LEAVEFN("CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL");
  1226     CLOG_LEAVEFN("CUserInteractionsUtils::GetAndSetHttpAuthCredentialsL");
  1221     return ( resp );
  1227     return ( resp );
  1222     }
  1228     }
  1223 
  1229 
  1224 // -----------------------------------------------------------------------------
  1230 // -----------------------------------------------------------------------------
  1227 //
  1233 //
  1228 TBool CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL
  1234 TBool CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL
  1229     ( RHttpDownload& aDownload )
  1235     ( RHttpDownload& aDownload )
  1230     {
  1236     {
  1231     CLOG_ENTERFN("CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL");
  1237     CLOG_ENTERFN("CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL");
  1232     
  1238 
  1233     HBufC* username = 0;
  1239     HBufC* username = 0;
  1234     HBufC* password = 0;
  1240     HBufC* password = 0;
  1235 
  1241 
  1236     // Get the authentication scheme
  1242     // Get the authentication scheme
  1237     TInt32 authScheme(0);
  1243     TInt32 authScheme(0);
  1253     User::LeaveIfError( aDownload.GetStringAttribute
  1259     User::LeaveIfError( aDownload.GetStringAttribute
  1254                 ( EDlAttrProxyRealm, realmPtr ) );
  1260                 ( EDlAttrProxyRealm, realmPtr ) );
  1255 
  1261 
  1256     // Execute a wait dialog
  1262     // Execute a wait dialog
  1257     TBool resp = iDialogsProv->DialogUserAuthenticationLC
  1263     TBool resp = iDialogsProv->DialogUserAuthenticationLC
  1258             ( *url, *realm, *userName, username, password, 
  1264             ( *url, *realm, *userName, username, password,
  1259               authScheme == EAuthBasic );
  1265               authScheme == EAuthBasic );
  1260 
  1266 
  1261     if ( resp )
  1267     if ( resp )
  1262         {
  1268         {
  1263         if ( authScheme == EAuthBasic && BrowserSettingSecWarningL() )
  1269         if ( authScheme == EAuthBasic && BrowserSettingSecWarningL() )
  1276 
  1282 
  1277     CleanupStack::PopAndDestroy( 2 ); // username, password
  1283     CleanupStack::PopAndDestroy( 2 ); // username, password
  1278     CleanupStack::PopAndDestroy( realm ); // realm
  1284     CleanupStack::PopAndDestroy( realm ); // realm
  1279     CleanupStack::PopAndDestroy( url ); // url
  1285     CleanupStack::PopAndDestroy( url ); // url
  1280     CleanupStack::PopAndDestroy( userName ); // userName
  1286     CleanupStack::PopAndDestroy( userName ); // userName
  1281     
  1287 
  1282     CLOG_LEAVEFN("CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL");
  1288     CLOG_LEAVEFN("CUserInteractionsUtils::GetAndSetProxyAuthCredentialsL");
  1283     return ( resp );
  1289     return ( resp );
  1284     }
  1290     }
  1285 
  1291 
  1286 // -----------------------------------------------------------------------------
  1292 // -----------------------------------------------------------------------------
  1311 
  1317 
  1312     resp = iDialogsProv->DialogConfirmL
  1318     resp = iDialogsProv->DialogConfirmL
  1313            ( KNullDesC, *message, *okMsg, *cancelMsg );
  1319            ( KNullDesC, *message, *okMsg, *cancelMsg );
  1314 
  1320 
  1315     // Clean up the basic authentication dialog memory
  1321     // Clean up the basic authentication dialog memory
  1316     CleanupStack::PopAndDestroy( 3, message ); 
  1322     CleanupStack::PopAndDestroy( 3, message );
  1317         // message, okMsg, cancelMsg
  1323         // message, okMsg, cancelMsg
  1318 
  1324 
  1319     return resp;
  1325     return resp;
  1320     }
  1326     }
  1321 
  1327 
  1331         }
  1337         }
  1332     }
  1338     }
  1333 
  1339 
  1334 // -----------------------------------------------------------------------------
  1340 // -----------------------------------------------------------------------------
  1335 // CUserInteractionsUtils::BrowserSettingSecWarningL
  1341 // CUserInteractionsUtils::BrowserSettingSecWarningL
  1336 // This method must behave the same as 
  1342 // This method must behave the same as
  1337 // CBrowserSettings::GetHttpSecurityWarnings().
  1343 // CBrowserSettings::GetHttpSecurityWarnings().
  1338 // See CBrowserSettings !
  1344 // See CBrowserSettings !
  1339 // -----------------------------------------------------------------------------
  1345 // -----------------------------------------------------------------------------
  1340 //
  1346 //
  1341 TBool CUserInteractionsUtils::BrowserSettingSecWarningL()
  1347 TBool CUserInteractionsUtils::BrowserSettingSecWarningL()
  1346 
  1352 
  1347 // -----------------------------------------------------------------------------
  1353 // -----------------------------------------------------------------------------
  1348 // CUserInteractionsUtils::InitializeSoftNotifStndL
  1354 // CUserInteractionsUtils::InitializeSoftNotifStndL
  1349 // -----------------------------------------------------------------------------
  1355 // -----------------------------------------------------------------------------
  1350 //
  1356 //
  1351 void CUserInteractionsUtils::InitializeSoftNotifStndL( TVwsViewId aViewId, 
  1357 void CUserInteractionsUtils::InitializeSoftNotifStndL( TVwsViewId aViewId,
  1352                                                        TUid aCustomMessageId, 
  1358                                                        TUid aCustomMessageId,
  1353                                                        const TDesC8& aViewActivationMsg ) const
  1359                                                        const TDesC8& aViewActivationMsg ) const
  1354     {
  1360     {
  1355     CLOG_ENTERFN("CUserInteractionsUtils::InitializeSoftNotifStndL");
  1361     CLOG_ENTERFN("CUserInteractionsUtils::InitializeSoftNotifStndL");
  1356 
  1362 
  1357     CAknSoftNotificationParameters* params = 
  1363     CAknSoftNotificationParameters* params =
  1358         CAknSoftNotificationParameters::NewL
  1364         CAknSoftNotificationParameters::NewL
  1359         (
  1365         (
  1360         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_STND, KMinimumSoftNotePriority, 
  1366         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_STND, KMinimumSoftNotePriority,
  1361         R_AVKON_SOFTKEYS_YES_NO__YES, 
  1367         R_AVKON_SOFTKEYS_YES_NO__YES,
  1362         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, 
  1368         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId,
  1363         EAknSoftkeyYes, aViewActivationMsg 
  1369         EAknSoftkeyYes, aViewActivationMsg
  1364         );
  1370         );
  1365     CLOG_WRITE(" params OK");
  1371     CLOG_WRITE(" params OK");
  1366     CleanupStack::PushL( params );
  1372     CleanupStack::PushL( params );
  1367 
  1373 
  1368     iSoftNotifier->AddCustomNotificationL( *params );
  1374     iSoftNotifier->AddCustomNotificationL( *params );
  1374 
  1380 
  1375 // -----------------------------------------------------------------------------
  1381 // -----------------------------------------------------------------------------
  1376 // CUserInteractionsUtils::InitializeSoftNotifEmbL
  1382 // CUserInteractionsUtils::InitializeSoftNotifEmbL
  1377 // -----------------------------------------------------------------------------
  1383 // -----------------------------------------------------------------------------
  1378 //
  1384 //
  1379 void CUserInteractionsUtils::InitializeSoftNotifEmbL( TVwsViewId aViewId, 
  1385 void CUserInteractionsUtils::InitializeSoftNotifEmbL( TVwsViewId aViewId,
  1380                                                       TUid aCustomMessageId, 
  1386                                                       TUid aCustomMessageId,
  1381                                                       const TDesC8& aViewActivationMsg ) const
  1387                                                       const TDesC8& aViewActivationMsg ) const
  1382     {
  1388     {
  1383     CLOG_ENTERFN("CUserInteractionsUtils::InitializeSoftNotifEmbL");
  1389     CLOG_ENTERFN("CUserInteractionsUtils::InitializeSoftNotifEmbL");
  1384 
  1390 
  1385     CAknSoftNotificationParameters* params = 
  1391     CAknSoftNotificationParameters* params =
  1386         CAknSoftNotificationParameters::NewL
  1392         CAknSoftNotificationParameters::NewL
  1387         (
  1393         (
  1388         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_EMB, KMinimumSoftNotePriority, 
  1394         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_EMB, KMinimumSoftNotePriority,
  1389         R_AVKON_SOFTKEYS_YES_NO__YES, 
  1395         R_AVKON_SOFTKEYS_YES_NO__YES,
  1390         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, 
  1396         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId,
  1391         EAknSoftkeyYes, aViewActivationMsg 
  1397         EAknSoftkeyYes, aViewActivationMsg
  1392         );
  1398         );
  1393     CLOG_WRITE(" params OK");
  1399     CLOG_WRITE(" params OK");
  1394     CleanupStack::PushL( params );
  1400     CleanupStack::PushL( params );
  1395 
  1401 
  1396     iSoftNotifier->AddCustomNotificationL( *params );
  1402     iSoftNotifier->AddCustomNotificationL( *params );
  1402 
  1408 
  1403 // -----------------------------------------------------------------------------
  1409 // -----------------------------------------------------------------------------
  1404 // CUserInteractionsUtils::CancelSoftNotifStndL
  1410 // CUserInteractionsUtils::CancelSoftNotifStndL
  1405 // -----------------------------------------------------------------------------
  1411 // -----------------------------------------------------------------------------
  1406 //
  1412 //
  1407 void CUserInteractionsUtils::CancelSoftNotifStndL( TVwsViewId aViewId, 
  1413 void CUserInteractionsUtils::CancelSoftNotifStndL( TVwsViewId aViewId,
  1408                                                   TUid aCustomMessageId, 
  1414                                                   TUid aCustomMessageId,
  1409                                                   const TDesC8& aViewActivationMsg ) const
  1415                                                   const TDesC8& aViewActivationMsg ) const
  1410     {
  1416     {
  1411     CLOG_ENTERFN("CUserInteractionsUtils::CancelSoftNotifStndL");
  1417     CLOG_ENTERFN("CUserInteractionsUtils::CancelSoftNotifStndL");
  1412 
  1418 
  1413     CAknSoftNotificationParameters* params = 
  1419     CAknSoftNotificationParameters* params =
  1414         CAknSoftNotificationParameters::NewL
  1420         CAknSoftNotificationParameters::NewL
  1415         (
  1421         (
  1416         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_STND, KMinimumSoftNotePriority, 
  1422         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_STND, KMinimumSoftNotePriority,
  1417         R_AVKON_SOFTKEYS_YES_NO__YES, 
  1423         R_AVKON_SOFTKEYS_YES_NO__YES,
  1418         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, 
  1424         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId,
  1419         EAknSoftkeyYes, aViewActivationMsg 
  1425         EAknSoftkeyYes, aViewActivationMsg
  1420         );
  1426         );
  1421     CLOG_WRITE(" params OK");
  1427     CLOG_WRITE(" params OK");
  1422     CleanupStack::PushL( params );
  1428     CleanupStack::PushL( params );
  1423 
  1429 
  1424     //TODO From avkon sources it seems that it identifies the soft notification
  1430     //TODO From avkon sources it seems that it identifies the soft notification
  1425     // with the AVKON_NOTE resource ID, which is the same in case of 
  1431     // with the AVKON_NOTE resource ID, which is the same in case of
  1426     // all UI Lib clients!!
  1432     // all UI Lib clients!!
  1427     iSoftNotifier->CancelCustomSoftNotificationL( *params );
  1433     iSoftNotifier->CancelCustomSoftNotificationL( *params );
  1428 
  1434 
  1429     CleanupStack::PopAndDestroy( params ); // params
  1435     CleanupStack::PopAndDestroy( params ); // params
  1430 
  1436 
  1433 
  1439 
  1434 // -----------------------------------------------------------------------------
  1440 // -----------------------------------------------------------------------------
  1435 // CUserInteractionsUtils::CancelSoftNotifEmbL
  1441 // CUserInteractionsUtils::CancelSoftNotifEmbL
  1436 // -----------------------------------------------------------------------------
  1442 // -----------------------------------------------------------------------------
  1437 //
  1443 //
  1438 void CUserInteractionsUtils::CancelSoftNotifEmbL( TVwsViewId aViewId, 
  1444 void CUserInteractionsUtils::CancelSoftNotifEmbL( TVwsViewId aViewId,
  1439                                                  TUid aCustomMessageId, 
  1445                                                  TUid aCustomMessageId,
  1440                                                  const TDesC8& aViewActivationMsg ) const
  1446                                                  const TDesC8& aViewActivationMsg ) const
  1441     {
  1447     {
  1442     CLOG_ENTERFN("CUserInteractionsUtils::CancelSoftNotifEmbL");
  1448     CLOG_ENTERFN("CUserInteractionsUtils::CancelSoftNotifEmbL");
  1443 
  1449 
  1444     CAknSoftNotificationParameters* params = 
  1450     CAknSoftNotificationParameters* params =
  1445         CAknSoftNotificationParameters::NewL
  1451         CAknSoftNotificationParameters::NewL
  1446         (
  1452         (
  1447         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_EMB, KMinimumSoftNotePriority, 
  1453         iDMgrUiBase.ResourceFileName(), R_DMUL_GSN_EMB, KMinimumSoftNotePriority,
  1448         R_AVKON_SOFTKEYS_YES_NO__YES, 
  1454         R_AVKON_SOFTKEYS_YES_NO__YES,
  1449         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId, 
  1455         CAknNoteDialog::EConfirmationTone, aViewId, aCustomMessageId,
  1450         EAknSoftkeyYes, aViewActivationMsg 
  1456         EAknSoftkeyYes, aViewActivationMsg
  1451         );
  1457         );
  1452     CLOG_WRITE(" params OK");
  1458     CLOG_WRITE(" params OK");
  1453     CleanupStack::PushL( params );
  1459     CleanupStack::PushL( params );
  1454 
  1460 
  1455     iSoftNotifier->CancelCustomSoftNotificationL( *params );
  1461     iSoftNotifier->CancelCustomSoftNotificationL( *params );
  1476     CancelDeleteConfirmationDialog();
  1482     CancelDeleteConfirmationDialog();
  1477     CancelCancelConfirmationDialog();
  1483     CancelCancelConfirmationDialog();
  1478     CancelMediaRemovedNote();
  1484     CancelMediaRemovedNote();
  1479     CancelCredentialsQueries();
  1485     CancelCredentialsQueries();
  1480     CancelSecurityWarning();
  1486     CancelSecurityWarning();
  1481     // The soft notifications should not be cancelled here, 
  1487     // The soft notifications should not be cancelled here,
  1482     // because they are used in a different context.
  1488     // because they are used in a different context.
  1483     }
  1489     }
  1484 
  1490 
  1485 // -----------------------------------------------------------------------------
  1491 // -----------------------------------------------------------------------------
  1486 // CUserInteractionsUtils::InfoNoteL
  1492 // CUserInteractionsUtils::InfoNoteL
  1498 // -----------------------------------------------------------------------------
  1504 // -----------------------------------------------------------------------------
  1499 //
  1505 //
  1500 void CUserInteractionsUtils::InfoNoteL( TInt aDialogResourceId, const TDesC& aPrompt )
  1506 void CUserInteractionsUtils::InfoNoteL( TInt aDialogResourceId, const TDesC& aPrompt )
  1501     {
  1507     {
  1502     CLOG_ENTERFN("CUserInteractionsUtils::InfoNoteL");
  1508     CLOG_ENTERFN("CUserInteractionsUtils::InfoNoteL");
  1503     
  1509 
  1504     CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog
  1510     CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog
  1505 								( REINTERPRET_CAST( CEikDialog**, &dialog ) );
  1511 								( REINTERPRET_CAST( CEikDialog**, &dialog ) );
  1506 	CLOG_WRITE(" new");
  1512 	CLOG_WRITE(" new");
  1507     dialog->PrepareLC( aDialogResourceId ) ;
  1513     dialog->PrepareLC( aDialogResourceId ) ;
  1508     CLOG_WRITE(" PrepareLC");
  1514     CLOG_WRITE(" PrepareLC");
  1509     dialog->SetCurrentLabelL( EGeneralNote, aPrompt );
  1515     dialog->SetCurrentLabelL( EGeneralNote, aPrompt );
  1510     CLOG_WRITE(" SetCurrentLabelL");
  1516     CLOG_WRITE(" SetCurrentLabelL");
  1511     dialog->RunDlgLD( CAknNoteDialog::ELongTimeout, CAknNoteDialog::ENoTone );
  1517     dialog->RunDlgLD( CAknNoteDialog::ELongTimeout, CAknNoteDialog::ENoTone );
  1512     
  1518 
  1513     CLOG_LEAVEFN("CUserInteractionsUtils::InfoNoteL");
  1519     CLOG_LEAVEFN("CUserInteractionsUtils::InfoNoteL");
  1514     }
  1520     }
  1515 
  1521 
  1516 // -----------------------------------------------------------------------------
  1522 // -----------------------------------------------------------------------------
  1517 // CUserInteractionsUtils::IsUiBusy
  1523 // CUserInteractionsUtils::IsUiBusy
  1563 
  1569 
  1564     DRMCommon::TContentProtection prot;
  1570     DRMCommon::TContentProtection prot;
  1565     HBufC8* mimeType = 0;
  1571     HBufC8* mimeType = 0;
  1566     HBufC8* contentURI = 0;
  1572     HBufC8* contentURI = 0;
  1567     TUint dataLength = 0;
  1573     TUint dataLength = 0;
  1568     TInt err = drmCommon->GetFileInfo( *fileName, 
  1574     TInt err = drmCommon->GetFileInfo( *fileName,
  1569         prot, mimeType, contentURI, dataLength );
  1575         prot, mimeType, contentURI, dataLength );
  1570     
  1576 
  1571     if ( err == DRMCommon::EVersionNotSupported || 
  1577     if ( err == DRMCommon::EVersionNotSupported ||
  1572          ( err == DRMCommon::EOk && ( !mimeType || !contentURI ) ) )
  1578          ( err == DRMCommon::EOk && ( !mimeType || !contentURI ) ) )
  1573         {
  1579         {
  1574         isCorruptedDcf = ETrue;
  1580         isCorruptedDcf = ETrue;
  1575         }
  1581         }
  1576         
  1582 
  1577     delete mimeType;
  1583     delete mimeType;
  1578     delete contentURI;
  1584     delete contentURI;
  1579     CleanupStack::PopAndDestroy( fileName );
  1585     CleanupStack::PopAndDestroy( fileName );
  1580     CleanupStack::PopAndDestroy( drmCommon );
  1586     CleanupStack::PopAndDestroy( drmCommon );
  1581 
  1587 
  1608 
  1614 
  1609     DRMCommon::TContentProtection prot;
  1615     DRMCommon::TContentProtection prot;
  1610     HBufC8* mimeType = 0;
  1616     HBufC8* mimeType = 0;
  1611     HBufC8* contentURI = 0;
  1617     HBufC8* contentURI = 0;
  1612     TUint dataLength = 0;
  1618     TUint dataLength = 0;
  1613     TInt err = drmCommon->GetFileInfo( *fileName, 
  1619     TInt err = drmCommon->GetFileInfo( *fileName,
  1614         prot, mimeType, contentURI, dataLength );
  1620         prot, mimeType, contentURI, dataLength );
  1615     
  1621 
  1616     if ( err == DRMCommon::EOk )
  1622     if ( err == DRMCommon::EOk )
  1617         {
  1623         {
  1618         if ( !mimeType || !contentURI )
  1624         if ( !mimeType || !contentURI )
  1619             {
  1625             {
  1620             isBadMimeInDcfL = ETrue;
  1626             isBadMimeInDcfL = ETrue;
  1624             // The MIME type in the DCF is also DCF, which is wrong.
  1630             // The MIME type in the DCF is also DCF, which is wrong.
  1625             // It should contain the real mime type.
  1631             // It should contain the real mime type.
  1626             isBadMimeInDcfL = ETrue;
  1632             isBadMimeInDcfL = ETrue;
  1627             }
  1633             }
  1628         }
  1634         }
  1629         
  1635 
  1630     delete mimeType;
  1636     delete mimeType;
  1631     delete contentURI;
  1637     delete contentURI;
  1632     CleanupStack::PopAndDestroy( fileName );
  1638     CleanupStack::PopAndDestroy( fileName );
  1633     CleanupStack::PopAndDestroy( drmCommon );
  1639     CleanupStack::PopAndDestroy( drmCommon );
  1634 
  1640 
  1649         iHandledDownload = 0;
  1655         iHandledDownload = 0;
  1650         }
  1656         }
  1651     CLOG_LEAVEFN("CUserInteractionsUtils::DownloadHasBeenDeleted");
  1657     CLOG_LEAVEFN("CUserInteractionsUtils::DownloadHasBeenDeleted");
  1652     }
  1658     }
  1653 
  1659 
  1654  
  1660 
  1655 // -----------------------------------------------------------------------------
  1661 // -----------------------------------------------------------------------------
  1656 // CUserInteractionsUtils::LaunchPdAppL
  1662 // CUserInteractionsUtils::LaunchPdAppL
  1657 // -----------------------------------------------------------------------------
  1663 // -----------------------------------------------------------------------------
  1658 //
  1664 //
  1659 void CUserInteractionsUtils::LaunchPdAppL( RHttpDownload& aDownload, const TBool aProgressively )
  1665 void CUserInteractionsUtils::LaunchPdAppL( RHttpDownload& aDownload, const TBool aProgressively )
  1660     {
  1666     {
  1661     CLOG_ENTERFN("CUserInteractionsEventHandler::LaunchPdAppL");
  1667     CLOG_ENTERFN("CUserInteractionsEventHandler::LaunchPdAppL");
  1662 
  1668 
  1663     // Get the PD player application's UID for the download
  1669     // Get the PD player application's UID for the download
  1664     TUid pdPlayerUid = { 0 };    
  1670     TUid pdPlayerUid = { 0 };
  1665     HBufC8* contentType = ContentTypeL( aDownload, ETrue, KFirstMoIndex );
  1671     HBufC8* contentType = ContentTypeL( aDownload, ETrue, KFirstMoIndex );
  1666     TDataType dataType( *contentType );
  1672     TDataType dataType( *contentType );
  1667     delete contentType;
  1673     delete contentType;
  1668     contentType = NULL;
  1674     contentType = NULL;
  1669 
  1675 
  1670     CDocumentHandler* docHandler = CDocumentHandler::NewLC();
  1676     CDocumentHandler* docHandler = CDocumentHandler::NewLC();
  1671     TBool pdSupported = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid );
  1677     TBool pdSupported = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid );
  1672     CleanupStack::PopAndDestroy( docHandler ); // docHandler
  1678     CleanupStack::PopAndDestroy( docHandler ); // docHandler
  1673     
  1679 
  1674     if ( pdSupported )
  1680     if ( pdSupported )
  1675         {
  1681         {
       
  1682 
       
  1683         TInt downloadCnt = iRegistryModel.DownloadCount();
       
  1684         TBool isProg(EFalse);
       
  1685 
       
  1686         const CDownloadArray& downloads = iRegistryModel.DownloadMgr().CurrentDownloads();
       
  1687 
       
  1688         for ( TInt i = 0; i < downloadCnt ;i++ )
       
  1689 			{
       
  1690         	RHttpDownload* dl = downloads.At(i); //current download
       
  1691         	dl->GetBoolAttribute( EDlAttrProgressive, isProg );
       
  1692         	if (isProg )
       
  1693 				{
       
  1694                 dl->SetBoolAttribute( EDlAttrProgressive, EFalse );
       
  1695                 }
       
  1696 			}
       
  1697 
  1676         TInt32 numMediaObjects = 0;
  1698         TInt32 numMediaObjects = 0;
  1677         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) );
  1699         User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) );
  1678         
  1700 
  1679         // Pack download ID into EGenericParamDownloadId.
  1701         // Pack download ID into EGenericParamDownloadId.
  1680         TInt32 downloadID( -1 );
  1702         TInt32 downloadID( -1 );
  1681         TInt32 activeDownloadID(-1);
  1703         TInt32 activeDownloadID(-1);
  1682         if ( aProgressively )
  1704         if ( aProgressively )
  1683             {
  1705             {
  1684             User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrId, downloadID ) );        	
  1706             User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrId, downloadID ) );
  1685             User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, activeDownloadID ) );       	
  1707             User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrActiveDownload, activeDownloadID ) );
  1686             }
  1708             }
  1687 
  1709 
  1688         
  1710 
  1689         CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC();
  1711         CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC();
  1690         TAiwVariant downloadIdVariant( downloadID );
  1712         TAiwVariant downloadIdVariant( downloadID );
  1691         TAiwGenericParam genericParam( EGenericParamDownloadId, downloadIdVariant );
  1713         TAiwGenericParam genericParam( EGenericParamDownloadId, downloadIdVariant );
  1692         genParList->AppendL( genericParam );
  1714         genParList->AppendL( genericParam );
  1693 
  1715 
  1697 		    // Get first track's name in case of album
  1719 		    // Get first track's name in case of album
  1698 		if (numMediaObjects > KFirstMoIndex)
  1720 		if (numMediaObjects > KFirstMoIndex)
  1699 		    User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, KFirstMoIndex, fileNamePtr ) );
  1721 		    User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, KFirstMoIndex, fileNamePtr ) );
  1700 		else
  1722 		else
  1701 		    User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  1723 		    User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  1702 		
  1724 
  1703         // check if file exists, if does not , don't continue
  1725         // check if file exists, if does not , don't continue
  1704         if ( !IsDuplicateL( fileNamePtr ) )
  1726         if ( !IsDuplicateL( fileNamePtr ) )
  1705             {
  1727             {
  1706             HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
  1728             HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_FILE_NOT_FOUND);
  1707             CAknInformationNote* note = new(ELeave)  CAknInformationNote();
  1729             CAknInformationNote* note = new(ELeave)  CAknInformationNote();
  1708             note->ExecuteLD(*infoPrompt);
  1730             note->ExecuteLD(*infoPrompt);
  1709             CleanupStack::PopAndDestroy(infoPrompt);	
  1731             CleanupStack::PopAndDestroy(infoPrompt);
  1710 
  1732 
  1711     		CleanupStack::PopAndDestroy( fileName );
  1733     		CleanupStack::PopAndDestroy( fileName );
  1712             CleanupStack::PopAndDestroy( genParList );
  1734             CleanupStack::PopAndDestroy( genParList );
  1713 
  1735 
  1714             return;
  1736             return;
  1715             }
  1737             }
  1716 		
  1738 
  1717 
  1739 
  1718 		TAiwVariant fileNameVariant( fileNamePtr );
  1740 		TAiwVariant fileNameVariant( fileNamePtr );
  1719 		TAiwGenericParam fileNameParam( EGenericParamFile, fileNameVariant );
  1741 		TAiwGenericParam fileNameParam( EGenericParamFile, fileNameVariant );
  1720 		genParList->AppendL( fileNameParam ); 	
  1742 		genParList->AppendL( fileNameParam );
  1721         
  1743 
  1722     	
  1744 
  1723     	// Since we don't have the EGenericParamId for track index we are using EGenericParamUnspecified.
  1745     	// Since we don't have the EGenericParamId for track index we are using EGenericParamUnspecified.
  1724     	// Once we get the generic parameter for the id in future,this will be changed.
  1746     	// Once we get the generic parameter for the id in future,this will be changed.
  1725         TAiwVariant activeIndexVariant( activeDownloadID );
  1747         TAiwVariant activeIndexVariant( activeDownloadID );
  1726         TAiwGenericParam activeIndexParam( EGenericParamUnspecified, activeIndexVariant );
  1748         TAiwGenericParam activeIndexParam( EGenericParamUnspecified, activeIndexVariant );
  1727         genParList->AppendL( activeIndexParam );       
  1749         genParList->AppendL( activeIndexParam );
  1728         
  1750 
  1729         HBufC8* param8 = HBufC8::NewLC( KMinLength ); // Must be large enough!!
  1751         HBufC8* param8 = HBufC8::NewLC( KMinLength ); // Must be large enough!!
  1730         TPtr8 paramPtr8 = param8->Des();
  1752         TPtr8 paramPtr8 = param8->Des();
  1731         RDesWriteStream writeStream( paramPtr8 );
  1753         RDesWriteStream writeStream( paramPtr8 );
  1732 
  1754 
  1733         genParList->ExternalizeL( writeStream );
  1755         genParList->ExternalizeL( writeStream );
  1737 
  1759 
  1738 		//Instead of Selecting topmost task matching the UID from all the tasks, opening the standalone application
  1760 		//Instead of Selecting topmost task matching the UID from all the tasks, opening the standalone application
  1739         CAknTaskList *taskList = CAknTaskList::NewL(CEikonEnv::Static()->WsSession());
  1761         CAknTaskList *taskList = CAknTaskList::NewL(CEikonEnv::Static()->WsSession());
  1740         TApaTask task = taskList->FindRootApp(pdPlayerUid);
  1762         TApaTask task = taskList->FindRootApp(pdPlayerUid);
  1741         TInt result = aDownload.SetBoolAttribute( EDlAttrProgressive, ETrue );
  1763         TInt result = aDownload.SetBoolAttribute( EDlAttrProgressive, ETrue );
  1742     
  1764 
  1743         if ( task.Exists() )
  1765         if ( task.Exists() )
  1744             {
  1766             {
  1745             task.BringToForeground();
  1767             task.BringToForeground();
  1746             // 8-bit buffer is required. 
  1768             // 8-bit buffer is required.
  1747             task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
  1769             task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
  1748             }
  1770             }
  1749         else 
  1771         else
  1750             {
  1772             {
  1751             HBufC* param = HBufC::NewLC( param8->Length() );
  1773             HBufC* param = HBufC::NewLC( param8->Length() );
  1752             param->Des().Copy( *param8 );
  1774             param->Des().Copy( *param8 );
  1753             
  1775 
  1754             RApaLsSession appArcSession;
  1776             RApaLsSession appArcSession;
  1755             User::LeaveIfError( appArcSession.Connect() );
  1777             User::LeaveIfError( appArcSession.Connect() );
  1756             CleanupClosePushL( appArcSession );
  1778             CleanupClosePushL( appArcSession );
  1757             TThreadId id;
  1779             TThreadId id;
  1758             User::LeaveIfError
  1780             User::LeaveIfError
  1759                 (
  1781                 (
  1760                     appArcSession.StartDocument( *param, pdPlayerUid, id )
  1782                     appArcSession.StartDocument( *param, pdPlayerUid, id )
  1761                 );
  1783                 );
  1762                      
  1784 
  1763             CleanupStack::PopAndDestroy( &appArcSession );
  1785             CleanupStack::PopAndDestroy( &appArcSession );
  1764             CleanupStack::PopAndDestroy( param );
  1786             CleanupStack::PopAndDestroy( param );
  1765             }
  1787             }
  1766         
  1788 
  1767         //Store the information whether progressive play is launched or not
  1789         //Store the information whether progressive play is launched or not
  1768         iRegistryModel.UserInteractions().SetProgressiveDownloadLaunched( ETrue );
  1790         iRegistryModel.UserInteractions().SetProgressiveDownloadLaunched( ETrue );
  1769         if( aProgressively )
  1791         if( aProgressively )
  1770             {
  1792             {
  1771             User::LeaveIfError( aDownload.SetIntAttribute( EDlAttrActivePlayedDownload, activeDownloadID ) );
  1793             User::LeaveIfError( aDownload.SetIntAttribute( EDlAttrActivePlayedDownload, activeDownloadID ) );
  1772             }   
  1794             }
  1773 
  1795 
  1774         CleanupStack::PopAndDestroy( param8 );
  1796         CleanupStack::PopAndDestroy( param8 );
  1775 		CleanupStack::PopAndDestroy( fileName );
  1797 		CleanupStack::PopAndDestroy( fileName );
  1776         CleanupStack::PopAndDestroy( genParList );
  1798         CleanupStack::PopAndDestroy( genParList );
  1777         }
  1799         }
  1778     
  1800 
  1779     CLOG_LEAVEFN("CUserInteractionsEventHandler::LaunchPdAppL");    
  1801     CLOG_LEAVEFN("CUserInteractionsEventHandler::LaunchPdAppL");
  1780     }
  1802     }
  1781 
  1803 
  1782 
  1804 
  1783 #ifdef __DMGR_PD_TESTHARNESS
  1805 #ifdef __DMGR_PD_TESTHARNESS
  1784 // -----------------------------------------------------------------------------
  1806 // -----------------------------------------------------------------------------
  1805     TPtr fileNamePtr = fileName->Des();
  1827     TPtr fileNamePtr = fileName->Des();
  1806     User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  1828     User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) );
  1807 
  1829 
  1808     TAiwVariant fileNameVariant( fileNamePtr );
  1830     TAiwVariant fileNameVariant( fileNamePtr );
  1809     TAiwGenericParam fileNameParam( EGenericParamFile, fileNameVariant );
  1831     TAiwGenericParam fileNameParam( EGenericParamFile, fileNameVariant );
  1810     genParList->AppendL( fileNameParam );	
  1832     genParList->AppendL( fileNameParam );
  1811 
  1833 
  1812     HBufC8* param8 = HBufC8::NewLC( KMinLength );
  1834     HBufC8* param8 = HBufC8::NewLC( KMinLength );
  1813     TPtr8 paramPtr8 = param8->Des();
  1835     TPtr8 paramPtr8 = param8->Des();
  1814     RDesWriteStream writeStream( paramPtr8 );
  1836     RDesWriteStream writeStream( paramPtr8 );
  1815 
  1837 
  1822     TApaTask task = taskList.FindApp( KTestPdPlayerUid );
  1844     TApaTask task = taskList.FindApp( KTestPdPlayerUid );
  1823     TInt result = aDownload.SetBoolAttribute( EDlAttrProgressive, ETrue );
  1845     TInt result = aDownload.SetBoolAttribute( EDlAttrProgressive, ETrue );
  1824 
  1846 
  1825     if ( task.Exists() )
  1847     if ( task.Exists() )
  1826         {
  1848         {
  1827         // 8-bit buffer is required. 
  1849         // 8-bit buffer is required.
  1828         task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
  1850         task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
  1829         task.BringToForeground();
  1851         task.BringToForeground();
  1830         }
  1852         }
  1831     else 
  1853     else
  1832         {
  1854         {
  1833         HBufC* param = HBufC::NewLC( param8->Length() );
  1855         HBufC* param = HBufC::NewLC( param8->Length() );
  1834         param->Des().Copy( *param8 );
  1856         param->Des().Copy( *param8 );
  1835         
  1857 
  1836         RApaLsSession appArcSession;
  1858         RApaLsSession appArcSession;
  1837         User::LeaveIfError( appArcSession.Connect() );
  1859         User::LeaveIfError( appArcSession.Connect() );
  1838         CleanupClosePushL( appArcSession );
  1860         CleanupClosePushL( appArcSession );
  1839         TThreadId id;
  1861         TThreadId id;
  1840 
  1862 
  1841         User::LeaveIfError(appArcSession.StartDocument( *param, KTestPdPlayerUid, id ));
  1863         User::LeaveIfError(appArcSession.StartDocument( *param, KTestPdPlayerUid, id ));
  1842 	
  1864 
  1843         CleanupStack::PopAndDestroy( &appArcSession );
  1865         CleanupStack::PopAndDestroy( &appArcSession );
  1844         CleanupStack::PopAndDestroy( param );
  1866         CleanupStack::PopAndDestroy( param );
  1845         }
  1867         }
  1846 
  1868 
  1847     CleanupStack::PopAndDestroy( param8 );
  1869     CleanupStack::PopAndDestroy( param8 );
  1848     CleanupStack::PopAndDestroy( fileName );
  1870     CleanupStack::PopAndDestroy( fileName );
  1849     CleanupStack::PopAndDestroy( genParList );
  1871     CleanupStack::PopAndDestroy( genParList );
  1850     
  1872 
  1851     CLOG_LEAVEFN("CUserInteractionsEventHandler::TestLaunchPdAppL");
  1873     CLOG_LEAVEFN("CUserInteractionsEventHandler::TestLaunchPdAppL");
  1852     }
  1874     }
  1853     
  1875 
  1854 #endif // __DMGR_PD_TESTHARNESS
  1876 #endif // __DMGR_PD_TESTHARNESS
  1855 
  1877 
  1856 
  1878 
  1857 // -----------------------------------------------------------------------------
  1879 // -----------------------------------------------------------------------------
  1858 // CUserInteractionsUtils::HandleServerAppExit
  1880 // CUserInteractionsUtils::HandleServerAppExit
  1861 void CUserInteractionsUtils::HandleServerAppExit( TInt aReason )
  1883 void CUserInteractionsUtils::HandleServerAppExit( TInt aReason )
  1862     {
  1884     {
  1863     CLOG_ENTERFN("CUserInteractionsUtils::HandleServerAppExit");
  1885     CLOG_ENTERFN("CUserInteractionsUtils::HandleServerAppExit");
  1864     CLOG_WRITE_FORMAT(" aReason: %d", aReason);
  1886     CLOG_WRITE_FORMAT(" aReason: %d", aReason);
  1865 
  1887 
  1866     // DocHandler has finished its task. 
  1888     // DocHandler has finished its task.
  1867     iDocHandlerUsesTheUi = EFalse;
  1889     iDocHandlerUsesTheUi = EFalse;
  1868     // Schedule the next download:
  1890     // Schedule the next download:
  1869 #ifdef _DEBUG
  1891 #ifdef _DEBUG
  1870     TRAPD( scheduleErr, iRegistryModel.UserInteractions().SchedulePostponedDownloadL() );
  1892     TRAPD( scheduleErr, iRegistryModel.UserInteractions().SchedulePostponedDownloadL() );
  1871     CLOG_WRITE_FORMAT(" scheduleErr: %d", scheduleErr);
  1893     CLOG_WRITE_FORMAT(" scheduleErr: %d", scheduleErr);
  1872 #else
  1894 #else
  1873     TRAP_IGNORE( iRegistryModel.UserInteractions().SchedulePostponedDownloadL() );
  1895     TRAP_IGNORE( iRegistryModel.UserInteractions().SchedulePostponedDownloadL() );
  1874 #endif // _DEBUG
  1896 #endif // _DEBUG
  1875     
  1897 
  1876     if ( iHandlerObserver )
  1898     if ( iHandlerObserver )
  1877         {
  1899         {
  1878         iHandlerObserver->NotifyHandlerExit( iHandledDownload, aReason );
  1900         iHandlerObserver->NotifyHandlerExit( iHandledDownload, aReason );
  1879         }
  1901         }
  1880         
  1902 
  1881     CLOG_LEAVEFN("CUserInteractionsUtils::HandleServerAppExit");
  1903     CLOG_LEAVEFN("CUserInteractionsUtils::HandleServerAppExit");
  1882     }
  1904     }
  1883 
  1905 
  1884 // -----------------------------------------------------------------------------
  1906 // -----------------------------------------------------------------------------
  1885 // CUserInteractionsUtils::IsNetworkPdCompatibleL()
  1907 // CUserInteractionsUtils::IsNetworkPdCompatibleL()
  1896 #if !defined( __WINS__ )
  1918 #if !defined( __WINS__ )
  1897 	// this initialization needed for identifying 3G networks
  1919 	// this initialization needed for identifying 3G networks
  1898     RTelServer  telServer;
  1920     RTelServer  telServer;
  1899     RMobilePhone    mobilePhone;
  1921     RMobilePhone    mobilePhone;
  1900 
  1922 
  1901     RMobilePhone::TMobilePhoneNetworkMode networkMode;	
  1923     RMobilePhone::TMobilePhoneNetworkMode networkMode;
  1902     User::LeaveIfError( telServer.Connect() );
  1924     User::LeaveIfError( telServer.Connect() );
  1903     User::LeaveIfError( telServer.LoadPhoneModule( KMmTsyModuleName ) );
  1925     User::LeaveIfError( telServer.LoadPhoneModule( KMmTsyModuleName ) );
  1904 
  1926 
  1905     TInt numPhones;
  1927     TInt numPhones;
  1906     User::LeaveIfError( telServer.EnumeratePhones( numPhones ) );
  1928     User::LeaveIfError( telServer.EnumeratePhones( numPhones ) );
  1946         TInt32 browserTerminate( 1 );
  1968         TInt32 browserTerminate( 1 );
  1947         CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC();
  1969         CAiwGenericParamList* genParList = CAiwGenericParamList::NewLC();
  1948         TAiwVariant terminateVariant( browserTerminate );
  1970         TAiwVariant terminateVariant( browserTerminate );
  1949         TAiwGenericParam genericParamTerm( EGenericParamTerminate, terminateVariant );
  1971         TAiwGenericParam genericParamTerm( EGenericParamTerminate, terminateVariant );
  1950         genParList->AppendL( genericParamTerm );
  1972         genParList->AppendL( genericParamTerm );
  1951         
  1973 
  1952         HBufC8* param8 = HBufC8::NewLC( KMinLength ); // Must be large enough!!
  1974         HBufC8* param8 = HBufC8::NewLC( KMinLength ); // Must be large enough!!
  1953         TPtr8 paramPtr8 = param8->Des();
  1975         TPtr8 paramPtr8 = param8->Des();
  1954         RDesWriteStream writeStream( paramPtr8 );
  1976         RDesWriteStream writeStream( paramPtr8 );
  1955 
  1977 
  1956         genParList->ExternalizeL( writeStream );
  1978         genParList->ExternalizeL( writeStream );
  1957 
  1979 
  1958         writeStream.CommitL();
  1980         writeStream.CommitL();
  1959         writeStream.Close();
  1981         writeStream.Close();
  1960         
  1982 
  1961 		TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
  1983 		TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
  1962 	    
  1984 
  1963 	    TBool isProgressive (EFalse);
  1985 	    TBool isProgressive (EFalse);
  1964  	    TInt downloadCnt = iRegistryModel.DownloadCount();
  1986  	    TInt downloadCnt = iRegistryModel.DownloadCount();
  1965  	    const CDownloadArray& downloads = iRegistryModel.DownloadMgr().CurrentDownloads();
  1987  	    const CDownloadArray& downloads = iRegistryModel.DownloadMgr().CurrentDownloads();
  1966  	    TInt j ;
  1988  	    TInt j ;
  1967  	    for( j = 0; j < downloadCnt; ++j )
  1989  	    for( j = 0; j < downloadCnt; ++j )
  1968  	        {
  1990  	        {
  1969  	        RHttpDownload* dl = downloads.At(j); // current download
  1991  	        RHttpDownload* dl = downloads.At(j); // current download
  1970  	        dl->GetBoolAttribute( EDlAttrProgressive, isProgressive );
  1992  	        dl->GetBoolAttribute( EDlAttrProgressive, isProgressive );
  1971  	        if(isProgressive)
  1993  	        if(isProgressive)
  1972  	            {
  1994  	            {
  1973  	            break;                
  1995  	            break;
  1974  	            }
  1996  	            }
  1975  	        } 
  1997  	        }
  1976 	    for( TInt i = 0; i < KDocPDAppUidCount; i++ )
  1998 	    for( TInt i = 0; i < KDocPDAppUidCount; i++ )
  1977 	    {
  1999 	    {
  1978 			TUid KTestPdPlayerUid = {KDocPDAppUidList[ i ]};
  2000 			TUid KTestPdPlayerUid = {KDocPDAppUidList[ i ]};
  1979 			TApaTask task = taskList.FindApp(KTestPdPlayerUid );		// task for MP app    
  2001 			TApaTask task = taskList.FindApp(KTestPdPlayerUid );		// task for MP app
  1980 			if ( task.Exists() && ( isProgressive || aProgressiveDownloadLaunched ) )
  2002 			if ( task.Exists() && ( isProgressive || aProgressiveDownloadLaunched ) )
  1981 				{
  2003 				{
  1982 				if ( isProgressive )
  2004 				if ( isProgressive )
  1983 				    {    
  2005 				    {
  1984 				    RHttpDownload* dl = downloads.At(j); // current download
  2006 				    RHttpDownload* dl = downloads.At(j); // current download
  1985                     //This Atribute will tell if MP called Delete  				
  2007                     //This Atribute will tell if MP called Delete
  1986 				    //on exit of Browser				
  2008 				    //on exit of Browser
  1987  	                dl->SetBoolAttribute( EDlAttrProgressive, EFalse );
  2009  	                dl->SetBoolAttribute( EDlAttrProgressive, EFalse );
  1988 				    }
  2010 				    }
  1989 				// 8-bit buffer is required. 
  2011 				// 8-bit buffer is required.
  1990 				task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
  2012 				task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
  1991 				task.BringToForeground();
  2013 				task.BringToForeground();
  1992 				}
  2014 				}
  1993 		}
  2015 		}
  1994         CleanupStack::PopAndDestroy( param8 );
  2016         CleanupStack::PopAndDestroy( param8 );
  1995         CleanupStack::PopAndDestroy( genParList );
  2017         CleanupStack::PopAndDestroy( genParList );
  1996     
  2018 
  1997         CLOG_LEAVEFN("CUserInteractionsEventHandler::SendMsgTerminateToPdAppsL");    
  2019         CLOG_LEAVEFN("CUserInteractionsEventHandler::SendMsgTerminateToPdAppsL");
  1998 
  2020 
  1999     }
  2021     }
  2000 
  2022 
  2001 
  2023 
  2002 // -----------------------------------------------------------------------------
  2024 // -----------------------------------------------------------------------------
  2010     // Connection monitor
  2032     // Connection monitor
  2011     RConnectionMonitor connMon;
  2033     RConnectionMonitor connMon;
  2012     CleanupClosePushL( connMon );
  2034     CleanupClosePushL( connMon );
  2013     User::LeaveIfError( connMon.ConnectL() );
  2035     User::LeaveIfError( connMon.ConnectL() );
  2014 
  2036 
  2015     TConnMonIapInfoBuf infoBuf; 
  2037     TConnMonIapInfoBuf infoBuf;
  2016     infoBuf().iCount = 0;      
  2038     infoBuf().iCount = 0;
  2017     
  2039 
  2018     // Get WLAN IAPs to infoBuf
  2040     // Get WLAN IAPs to infoBuf
  2019     connMon.GetPckgAttribute( EBearerIdWLAN ,0 , KIapAvailability, infoBuf, status );
  2041     connMon.GetPckgAttribute( EBearerIdWLAN ,0 , KIapAvailability, infoBuf, status );
  2020     User::WaitForRequest( status );    
  2042     User::WaitForRequest( status );
  2021 
  2043 
  2022     CleanupStack::PopAndDestroy( &connMon ); 
  2044     CleanupStack::PopAndDestroy( &connMon );
  2023 
  2045 
  2024     if ( !status.Int() && infoBuf().iCount )
  2046     if ( !status.Int() && infoBuf().iCount )
  2025         {
  2047         {
  2026         return ETrue;
  2048         return ETrue;
  2027         } 
  2049         }
  2028     
  2050 
  2029     return EFalse;
  2051     return EFalse;
  2030     }    
  2052     }
  2031 
  2053 
  2032 // ------------------------------------------------------------
  2054 // ------------------------------------------------------------
  2033 // CUserInteractionsUtils::CanLaunchAsProgDownload()
  2055 // CUserInteractionsUtils::CanLaunchAsProgDownload()
  2034 // Check if several conditions are met for Progressive Playback 
  2056 // Check if several conditions are met for Progressive Playback
  2035 // ------------------------------------------------------------
  2057 // ------------------------------------------------------------
  2036 // 
  2058 //
  2037 TBool CUserInteractionsUtils::CanLaunchAsProgDownload(
  2059 TBool CUserInteractionsUtils::CanLaunchAsProgDownload(
  2038     RHttpDownload& aDownload,
  2060     RHttpDownload& aDownload,
  2039     CDownloadMgrUiDownloadsList& dlList,
  2061     CDownloadMgrUiDownloadsList& dlList,
  2040     TBool isOma2Dl )
  2062     TBool isOma2Dl )
  2041     {
  2063     {
  2065     return progDlOk;
  2087     return progDlOk;
  2066     }
  2088     }
  2067 
  2089 
  2068 // ---------------------------------------------------------
  2090 // ---------------------------------------------------------
  2069 // CUserInteractionsUtils::UpdateDCFRepositoryL()
  2091 // CUserInteractionsUtils::UpdateDCFRepositoryL()
  2070 // Update saved file to DCFRepository  
  2092 // Update saved file to DCFRepository
  2071 // ---------------------------------------------------------
  2093 // ---------------------------------------------------------
  2072 // 
  2094 //
  2073 void CUserInteractionsUtils::UpdateDCFRepositoryL(
  2095 void CUserInteractionsUtils::UpdateDCFRepositoryL(
  2074     const TDesC& aFileName )
  2096     const TDesC& aFileName )
  2075     {
  2097     {
  2076     CLOG_ENTERFN( "CUserInteractionsUtils::UpdateDCFRepositoryL" );
  2098     CLOG_ENTERFN( "CUserInteractionsUtils::UpdateDCFRepositoryL" );
  2077     CLOG_WRITE_FORMAT( " :aFileName=%S", &aFileName );
  2099     CLOG_WRITE_FORMAT( " :aFileName=%S", &aFileName );
  2078     CDcfEntry* dcfEntry = NULL;
  2100     CDcfEntry* dcfEntry = NULL;
  2079     dcfEntry = CDcfEntry::NewL();    
  2101     dcfEntry = CDcfEntry::NewL();
  2080     CleanupStack::PushL( dcfEntry );
  2102     CleanupStack::PushL( dcfEntry );
  2081     
  2103 
  2082     CDcfRep* dcfRep = NULL;
  2104     CDcfRep* dcfRep = NULL;
  2083     dcfRep = CDcfRep::NewL();
  2105     dcfRep = CDcfRep::NewL();
  2084     CleanupStack::PushL( dcfRep );
  2106     CleanupStack::PushL( dcfRep );
  2085 
  2107 
  2086     dcfEntry->SetLocationL( aFileName, 0 );    
  2108     dcfEntry->SetLocationL( aFileName, 0 );
  2087     CLOG_WRITE(" : SetLocationL OK");
  2109     CLOG_WRITE(" : SetLocationL OK");
  2088     dcfRep->UpdateL( dcfEntry );
  2110     dcfRep->UpdateL( dcfEntry );
  2089     CLOG_WRITE(" :UpdateL OK");
  2111     CLOG_WRITE(" :UpdateL OK");
  2090     CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep
  2112     CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep
  2091     CLOG_LEAVEFN("CUserInteractionsUtils::UpdateDCFRepositoryL");
  2113     CLOG_LEAVEFN("CUserInteractionsUtils::UpdateDCFRepositoryL");
  2092     }              
  2114     }
  2093     
  2115 
  2094 // ---------------------------------------------------------
  2116 // ---------------------------------------------------------
  2095 // CUserInteractionsUtils::IsCodDownload()
  2117 // CUserInteractionsUtils::IsCodDownload()
  2096 // return true if its a COD DL  
  2118 // return true if its a COD DL
  2097 // ---------------------------------------------------------
  2119 // ---------------------------------------------------------
  2098 // 
  2120 //
  2099 TBool CUserInteractionsUtils::IsCodDownload()
  2121 TBool CUserInteractionsUtils::IsCodDownload()
  2100     {
  2122     {
  2101     return iCodDownload;
  2123     return iCodDownload;
  2102     }                
  2124     }
  2103 
  2125 
  2104 // End of file.
  2126 // End of file.