browserutilities/downloadmgr/DownloadMgrUiLib/Src/UserInteractionsEventHandler.cpp
changeset 65 5bfc169077b2
parent 37 cb62a4f66ebe
child 68 92a765b5b3e7
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    13 *
    13 *
    14 * Description:  User Interactions event handler
    14 * Description:  User Interactions event handler
    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    "UserInteractionsEventHandler.h"
    23 #include    "UserInteractionsEventHandler.h"
    21 #include    "CUserInteractionsUtils.h"
    24 #include    "CUserInteractionsUtils.h"
    22 #include    "ProgressInfoCreator.h"
    25 #include    "ProgressInfoCreator.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    <bldvariant.hrh>
    31 #include    <bldvariant.hrh>
    29 #include    <DownloadMgrUiLib.rsg>
    32 #include    <DownloadMgrUiLib.rsg>
    30 #include    <aknlists.h>
    33 #include    <aknlists.h>
    36 #include    <exterror.h>
    39 #include    <exterror.h>
    37 #include    <etelpckt.h>
    40 #include    <etelpckt.h>
    38 #include    <AknNoteDialog.h>
    41 #include    <AknNoteDialog.h>
    39 #include    <UriUtils.h>
    42 #include    <UriUtils.h>
    40 
    43 
       
    44 
       
    45 // following line is temporary: AVKON dependency removal
       
    46 #undef BRDO_APP_GALLERY_SUPPORTED_FF
       
    47 
    41 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    48 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    42 #include    <MGXFileManagerFactory.h>
    49 #include    <MGXFileManagerFactory.h>
    43 #include    <CMGXFileManager.h>
    50 #include    <CMGXFileManager.h>
    44 #endif
    51 #endif
    45 
    52 
    67 // -----------------------------------------------------------------------------
    74 // -----------------------------------------------------------------------------
    68 // CUserInteractionsEventHandler::CUserInteractionsEventHandler
    75 // CUserInteractionsEventHandler::CUserInteractionsEventHandler
    69 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    70 //
    77 //
    71 CUserInteractionsEventHandler::CUserInteractionsEventHandler
    78 CUserInteractionsEventHandler::CUserInteractionsEventHandler
    72     ( RHttpDownload& aDownload, THttpDownloadEvent aEvent, 
    79     ( RHttpDownload& aDownload, THttpDownloadEvent aEvent,
    73       MDownloadMgrUiLibRegModel& aRegistryModel, 
    80       MDownloadMgrUiLibRegModel& aRegistryModel,
    74       CAsyncEventHandlerArray& aOwner,
    81       CAsyncEventHandlerArray& aOwner,
    75       CUserInteractionsUtils& aUiUtils )
    82       CUserInteractionsUtils& aUiUtils )
    76 :   CAsyncEventHandlerBase( aDownload, aEvent, aRegistryModel, aOwner ),
    83 :   CAsyncEventHandlerBase( aDownload, aEvent, aRegistryModel, aOwner ),
    77     iUiUtils( aUiUtils ),
    84     iUiUtils( aUiUtils ),
    78     iDownloadConfirmationShown( EFalse )
    85     iDownloadConfirmationShown( EFalse )
   119    	TBool isSpaceBelowCL( EFalse );
   126    	TBool isSpaceBelowCL( EFalse );
   120 
   127 
   121     RFs fs;
   128     RFs fs;
   122     User::LeaveIfError( fs.Connect() );
   129     User::LeaveIfError( fs.Connect() );
   123     CleanupClosePushL( fs );
   130     CleanupClosePushL( fs );
   124     
   131 
   125     TInt bytesToWrite = aSize;
   132     TInt bytesToWrite = aSize;
   126     if (bytesToWrite < 0)
   133     if (bytesToWrite < 0)
   127         bytesToWrite = 0;
   134         bytesToWrite = 0;
   128 
   135 
   129 #ifdef RD_MULTIPLE_DRIVE
   136 #ifdef RD_MULTIPLE_DRIVE
   161 	TRAP_IGNORE( isSpaceBelowCL = SysUtil::DiskSpaceBelowCriticalLevelL(
   168 	TRAP_IGNORE( isSpaceBelowCL = SysUtil::DiskSpaceBelowCriticalLevelL(
   162                                             &fs,
   169                                             &fs,
   163                                             bytesToWrite,
   170                                             bytesToWrite,
   164                                             selectedDrive ) );
   171                                             selectedDrive ) );
   165 
   172 
   166     // If there is error, then isSpaceBelowCL is untouched and 
   173     // If there is error, then isSpaceBelowCL is untouched and
   167     // contains the right value. Otherwise it also contains 
   174     // contains the right value. Otherwise it also contains
   168     // the right value.
   175     // the right value.
   169     CLOG_WRITE_FORMAT(" DiskSpace: isSpaceBelowCL: %d",isSpaceBelowCL);
   176     CLOG_WRITE_FORMAT(" DiskSpace: isSpaceBelowCL: %d",isSpaceBelowCL);
   170 
   177 
   171 #else
   178 #else
   172 	isSpaceBelowCL = SysUtil::DiskSpaceBelowCriticalLevelL( &fs, 
   179 	isSpaceBelowCL = SysUtil::DiskSpaceBelowCriticalLevelL( &fs,
   173 			                                bytesToWrite,
   180 			                                bytesToWrite,
   174                                             EDriveC );
   181                                             EDriveC );
   175     CLOG_WRITE_FORMAT(" C: isSpaceBelowCL: %d",isSpaceBelowCL);
   182     CLOG_WRITE_FORMAT(" C: isSpaceBelowCL: %d",isSpaceBelowCL);
   176 
   183 
   177     if ( isSpaceBelowCL )
   184     if ( isSpaceBelowCL )
   178         {
   185         {
   179         // Check MMC
   186         // Check MMC
   180         TRAP_IGNORE( isSpaceBelowCL = 
   187         TRAP_IGNORE( isSpaceBelowCL =
   181                      SysUtil::MMCSpaceBelowCriticalLevelL( &fs, bytesToWrite ) );
   188                      SysUtil::MMCSpaceBelowCriticalLevelL( &fs, bytesToWrite ) );
   182         // If there is error, then isSpaceBelowCL is untouched and 
   189         // If there is error, then isSpaceBelowCL is untouched and
   183         // contains the right value. Otherwise it also contains 
   190         // contains the right value. Otherwise it also contains
   184         // the right value.
   191         // the right value.
   185         CLOG_WRITE_FORMAT(" MMC: isSpaceBelowCL: %d",isSpaceBelowCL);
   192         CLOG_WRITE_FORMAT(" MMC: isSpaceBelowCL: %d",isSpaceBelowCL);
   186         }
   193         }
   187 #endif
   194 #endif
   188 
   195 
   220         */
   227         */
   221 
   228 
   222         User::LeaveIfError( aDownload.GetIntAttribute
   229         User::LeaveIfError( aDownload.GetIntAttribute
   223                           ( EDlAttrMultipleMOLength, totalLength ) );
   230                           ( EDlAttrMultipleMOLength, totalLength ) );
   224         CLOG_WRITE_FORMAT(" EDlAttrMultipleMOLength: %d",totalLength);
   231         CLOG_WRITE_FORMAT(" EDlAttrMultipleMOLength: %d",totalLength);
   225         
   232 
   226         User::LeaveIfError( aDownload.GetIntAttribute
   233         User::LeaveIfError( aDownload.GetIntAttribute
   227                           ( EDlAttrMultipleMODownloadedSize, downloadedSize ) );
   234                           ( EDlAttrMultipleMODownloadedSize, downloadedSize ) );
   228         CLOG_WRITE_FORMAT(" EDlAttrMultipleMODownloadedSizes: %d",downloadedSize);
   235         CLOG_WRITE_FORMAT(" EDlAttrMultipleMODownloadedSizes: %d",downloadedSize);
   229 
   236 
   230         HBufC8* contentType = iUiUtils.ContentTypeL( aDownload, ETrue );
   237         HBufC8* contentType = iUiUtils.ContentTypeL( aDownload, ETrue );
   231         CleanupStack::PushL( contentType );
   238         CleanupStack::PushL( contentType );
   232 
   239 
   233         // Don't show the confirmation query if the downloading 
   240         // Don't show the confirmation query if the downloading
   234         // already finished
   241         // already finished
   235         if ( downloadedSize == totalLength )
   242         if ( downloadedSize == totalLength )
   236             {
   243             {
   237             ret = ETrue;
   244             ret = ETrue;
   238             }
   245             }
   239         else if ( 0 <= totalLength && totalLength < KDownloadConfSizeLimit )
   246         else if ( 0 <= totalLength && totalLength < KDownloadConfSizeLimit )
   240             {
   247             {
   241             ret = ETrue;
   248             ret = ETrue;
   242             }
   249             }
   243         // GGUO-775RXR for widgets we don't need to have download confirmation either             
   250         // GGUO-775RXR for widgets we don't need to have download confirmation either
   244         else if ( contentType->Compare( KWidgetMimeType) == 0 ) 
   251         else if ( contentType->Compare( KWidgetMimeType) == 0 )
   245             {
   252             {
   246             ret = ETrue;                                
   253             ret = ETrue;
   247             }                                            
   254             }
   248         else
   255         else
   249             {
   256             {
   250             ret = ShowDownloadConfirmationL( aDownload, aCbaResource );
   257             ret = ShowDownloadConfirmationL( aDownload, aCbaResource );
   251             }
   258             }
   252         CleanupStack::PopAndDestroy( contentType );            
   259         CleanupStack::PopAndDestroy( contentType );
   253         }
   260         }
   254 
   261 
   255     CLOG_LEAVEFN("CUserInteractionsEventHandler::ShowDownloadConfirmationL aForce");
   262     CLOG_LEAVEFN("CUserInteractionsEventHandler::ShowDownloadConfirmationL aForce");
   256     return ret;
   263     return ret;
   257     }
   264     }
   258 // -----------------------------------------------------------------------------
   265 // -----------------------------------------------------------------------------
   259 // CUserInteractionsEventHandler::ShowDownloadConfirmationL
   266 // CUserInteractionsEventHandler::ShowDownloadConfirmationL
   260 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   261 //
   268 //
   262 // Cod we used the following order
   269 // Cod we used the following order
   263 // 		name/size/type/price(optional)/description(no)/vendor(no) 
   270 // 		name/size/type/price(optional)/description(no)/vendor(no)
   264 
   271 
   265 TBool CUserInteractionsEventHandler::ShowDownloadConfirmationL
   272 TBool CUserInteractionsEventHandler::ShowDownloadConfirmationL
   266     ( RHttpDownload& aDownload, TInt aCbaResource )
   273     ( RHttpDownload& aDownload, TInt aCbaResource )
   267     {
   274     {
   268     CLOG_ENTERFN("CUserInteractionsEventHandler::ShowDownloadConfirmationL");
   275     CLOG_ENTERFN("CUserInteractionsEventHandler::ShowDownloadConfirmationL");
   284     listBox->ScrollBarFrame()->SetScrollBarVisibilityL
   291     listBox->ScrollBarFrame()->SetScrollBarVisibilityL
   285         ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   292         ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   286 
   293 
   287     MDesCArray* itemList = listBox->Model()->ItemTextArray();
   294     MDesCArray* itemList = listBox->Model()->ItemTextArray();
   288     CDesCArray* itemArray = (CDesCArray*)itemList;
   295     CDesCArray* itemArray = (CDesCArray*)itemList;
   289     
   296 
   290     //-------------------------------------------
   297     //-------------------------------------------
   291     // Header
   298     // Header
   292     //
   299     //
   293     HBufC* header = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_TITLE ); //"Download"
   300     HBufC* header = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_TITLE ); //"Download"
   294     popupList->SetTitleL( *header );
   301     popupList->SetTitleL( *header );
   313 #else
   320 #else
   314     if ( DiskSpaceBelowCriticalLevelL( (TInt)contentSize ) )
   321     if ( DiskSpaceBelowCriticalLevelL( (TInt)contentSize ) )
   315 #endif
   322 #endif
   316         {
   323         {
   317         // Not enough free disk space!
   324         // Not enough free disk space!
   318         HBufC* notEnoughSpace = 
   325         HBufC* notEnoughSpace =
   319             StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_NOT_ENOUGH_MEM );        
   326             StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_NOT_ENOUGH_MEM );
   320         itemArray->AppendL( *notEnoughSpace );
   327         itemArray->AppendL( *notEnoughSpace );
   321         CleanupStack::PopAndDestroy( notEnoughSpace );  // notEnoughSpace
   328         CleanupStack::PopAndDestroy( notEnoughSpace );  // notEnoughSpace
   322         // and disable OK button
   329         // and disable OK button
   323         popupList->ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOk, EFalse );
   330         popupList->ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOk, EFalse );
   324         }
   331         }
   326     //-------------------------------------------
   333     //-------------------------------------------
   327     // Supported?  no need - this was confirmed earlier
   334     // Supported?  no need - this was confirmed earlier
   328     //
   335     //
   329 
   336 
   330     //-------------------------------------------
   337     //-------------------------------------------
   331     // Add name here 
   338     // Add name here
   332     // name/size/type/price(optional)/description(no)/vendor(no) 
   339     // name/size/type/price(optional)/description(no)/vendor(no)
   333    HBufC* nameHeader = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_NAME );
   340    HBufC* nameHeader = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_NAME );
   334    HBufC* dlName = HBufC::NewLC( KMaxPath );            
   341    HBufC* dlName = HBufC::NewLC( KMaxPath );
   335    TPtr dlNamePtr = dlName->Des();
   342    TPtr dlNamePtr = dlName->Des();
   336    User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrName, dlNamePtr ) );
   343    User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrName, dlNamePtr ) );
   337 
   344 
   338    itemText = FormatListBoxItemLC( *nameHeader, *dlName );
   345    itemText = FormatListBoxItemLC( *nameHeader, *dlName );
   339    itemArray->AppendL( *itemText );
   346    itemArray->AppendL( *itemText );
   340    CleanupStack::PopAndDestroy( 3, nameHeader ); // itemText, sizeHeader
   347    CleanupStack::PopAndDestroy( 3, nameHeader ); // itemText, sizeHeader
   341    dlName = NULL; 
   348    dlName = NULL;
   342    itemText = NULL;
   349    itemText = NULL;
   343    nameHeader = NULL;
   350    nameHeader = NULL;
   344 
   351 
   345     //-------------------------------------------
   352     //-------------------------------------------
   346     // Content Size
   353     // Content Size
   366     itemText = NULL;
   373     itemText = NULL;
   367     sizeHeader = NULL;
   374     sizeHeader = NULL;
   368 
   375 
   369     //-------------------------------------------
   376     //-------------------------------------------
   370     // Application Name - only show if Supported
   377     // Application Name - only show if Supported
   371     //  
   378     //
   372     HBufC* handlerHeader = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_OPENWITH );
   379     HBufC* handlerHeader = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_OPENWITH );
   373 
   380 
   374     RApaLsSession apaLs;
   381     RApaLsSession apaLs;
   375     User::LeaveIfError( apaLs.Connect() );
   382     User::LeaveIfError( apaLs.Connect() );
   376     CleanupClosePushL( apaLs );
   383     CleanupClosePushL( apaLs );
   377     TUid appUid;
   384     TUid appUid;
   378     HBufC8* contentType = iUiUtils.ContentTypeL( aDownload, ETrue );
   385     HBufC8* contentType = iUiUtils.ContentTypeL( aDownload, ETrue );
   379     CleanupStack::PushL( contentType );
   386     CleanupStack::PushL( contentType );
   380     
   387 
   381     #ifdef _DEBUG
   388     #ifdef _DEBUG
   382     HBufC* contType = HBufC::NewL( contentType->Length() );
   389     HBufC* contType = HBufC::NewL( contentType->Length() );
   383     TPtr ptr = contType->Des();
   390     TPtr ptr = contType->Des();
   384     ptr.Copy( *contentType );
   391     ptr.Copy( *contentType );
   385     CLOG_WRITE_FORMAT(" contentType: %S",&ptr);
   392     CLOG_WRITE_FORMAT(" contentType: %S",&ptr);
   386     delete contType;
   393     delete contType;
   387     contType = NULL;
   394     contType = NULL;
   388     #endif // _DEBUG
   395     #endif // _DEBUG
   389     
   396 
   390     User::LeaveIfError( apaLs.AppForDataType( TDataType(*contentType), appUid ) );
   397     User::LeaveIfError( apaLs.AppForDataType( TDataType(*contentType), appUid ) );
   391     HBufC* handlerName = ConstructHandlerAppNameLC( appUid, apaLs );
   398     HBufC* handlerName = ConstructHandlerAppNameLC( appUid, apaLs );
   392 
   399 
   393     itemText = FormatListBoxItemLC( *handlerHeader, *handlerName );
   400     itemText = FormatListBoxItemLC( *handlerHeader, *handlerName );
   394     CleanupStack::PopAndDestroy( itemText );
   401     CleanupStack::PopAndDestroy( itemText );
   395     
   402 
   396     CleanupStack::PopAndDestroy( handlerName );
   403     CleanupStack::PopAndDestroy( handlerName );
   397     CleanupStack::Pop( contentType ); // Still needed - push later again
   404     CleanupStack::Pop( contentType ); // Still needed - push later again
   398     CleanupStack::PopAndDestroy( &apaLs );
   405     CleanupStack::PopAndDestroy( &apaLs );
   399     CleanupStack::PopAndDestroy( handlerHeader );
   406     CleanupStack::PopAndDestroy( handlerHeader );
   400     itemText = NULL;
   407     itemText = NULL;
   401     handlerName = NULL;
   408     handlerName = NULL;
   402     handlerHeader = NULL;
   409     handlerHeader = NULL;
   403     CleanupStack::PushL( contentType );
   410     CleanupStack::PushL( contentType );
   404     
   411 
   405     
   412 
   406     //-------------------------------------------
   413     //-------------------------------------------
   407     // MIME Content Type
   414     // MIME Content Type
   408     //
   415     //
   409     HBufC* typeHeader = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_FILETYPE );
   416     HBufC* typeHeader = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_FILETYPE );
   410 
   417 
   414         // 8 bit -> 16 bit conversion
   421         // 8 bit -> 16 bit conversion
   415         typeString = HBufC::NewLC( contentType->Length() );
   422         typeString = HBufC::NewLC( contentType->Length() );
   416         typeString->Des().Copy( *contentType );
   423         typeString->Des().Copy( *contentType );
   417         }
   424         }
   418     else
   425     else
   419         {       
   426         {
   420         typeString = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_UNKNOWN );
   427         typeString = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_UNKNOWN );
   421         }
   428         }
   422 
   429 
   423     itemText = FormatListBoxItemLC( *typeHeader, *typeString );
   430     itemText = FormatListBoxItemLC( *typeHeader, *typeString );
   424     itemArray->AppendL( *itemText );
   431     itemArray->AppendL( *itemText );
   428     typeString = NULL;
   435     typeString = NULL;
   429     typeHeader = NULL;
   436     typeHeader = NULL;
   430     contentType = NULL;
   437     contentType = NULL;
   431 
   438 
   432     //-------------------------------------------
   439     //-------------------------------------------
   433     // Price: since dm has no info, we don't need this at all here 
   440     // Price: since dm has no info, we don't need this at all here
   434     //
   441     //
   435 
   442 
   436     //-------------------------------------------
   443     //-------------------------------------------
   437     // Description: since dm has no info, we don't need this at all here 
   444     // Description: since dm has no info, we don't need this at all here
   438     //
   445     //
   439 
   446 
   440     //-------------------------------------------
   447     //-------------------------------------------
   441     // Vendor: since dm has no info, we don't need this at all here 
   448     // Vendor: since dm has no info, we don't need this at all here
   442     //
   449     //
   443 
   450 
   444     // Show popup list - it calls CActiveScheduler::Start(), so be careful 
   451     // Show popup list - it calls CActiveScheduler::Start(), so be careful
   445     // when using data members after ExecuteLD!
   452     // when using data members after ExecuteLD!
   446     iDownloadConfirmationShown = ETrue;
   453     iDownloadConfirmationShown = ETrue;
   447     iPopupList = popupList;
   454     iPopupList = popupList;
   448     TBool deleted( EFalse );
   455     TBool deleted( EFalse );
   449     iDownloadConfirmationDeletedPtr = &deleted;
   456     iDownloadConfirmationDeletedPtr = &deleted;
   450     TInt pressedOk = popupList->ExecuteLD();
   457     TInt pressedOk = popupList->ExecuteLD();
   451     CleanupStack::Pop( popupList );    // popupList 
   458     CleanupStack::Pop( popupList );    // popupList
   452     if ( !deleted )
   459     if ( !deleted )
   453         {
   460         {
   454         // We can use members only in this case!
   461         // We can use members only in this case!
   455         iDownloadConfirmationShown = EFalse;
   462         iDownloadConfirmationShown = EFalse;
   456         iPopupList = NULL;
   463         iPopupList = NULL;
   461 
   468 
   462     CLOG_WRITE_FORMAT(" pressedOk: %d",pressedOk);
   469     CLOG_WRITE_FORMAT(" pressedOk: %d",pressedOk);
   463     CLOG_LEAVEFN("CUserInteractionsEventHandler::ShowDownloadConfirmationL");
   470     CLOG_LEAVEFN("CUserInteractionsEventHandler::ShowDownloadConfirmationL");
   464     return (TBool)pressedOk;
   471     return (TBool)pressedOk;
   465     }
   472     }
   466     
   473 
   467 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   468 // CUserInteractionsEventHandler::ConstructHandlerAppNameLC
   475 // CUserInteractionsEventHandler::ConstructHandlerAppNameLC
   469 // -----------------------------------------------------------------------------
   476 // -----------------------------------------------------------------------------
   470 //
   477 //
   471 HBufC* CUserInteractionsEventHandler::ConstructHandlerAppNameLC
   478 HBufC* CUserInteractionsEventHandler::ConstructHandlerAppNameLC
   472     ( const TUid& aAppUid, RApaLsSession& aApaLs )
   479     ( const TUid& aAppUid, RApaLsSession& aApaLs )
   473     {
   480     {
   474     CLOG_ENTERFN("CUserInteractionsEventHandler::ConstructHandlerAppNameLC");
   481     CLOG_ENTERFN("CUserInteractionsEventHandler::ConstructHandlerAppNameLC");
   475     
   482 
   476     HBufC* handlerName = NULL;
   483     HBufC* handlerName = NULL;
   477     if ( aAppUid == TUid::Null() )
   484     if ( aAppUid == TUid::Null() )
   478         {
   485         {
   479         // No handler found
   486         // No handler found
   480         handlerName = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_UNKNOWN );
   487         handlerName = StringLoader::LoadLC( R_DMUL_DOWNLOADCONF_UNKNOWN );
   484         TApaAppInfo appInfo;
   491         TApaAppInfo appInfo;
   485         User::LeaveIfError( aApaLs.GetAppInfo( appInfo, aAppUid ) );
   492         User::LeaveIfError( aApaLs.GetAppInfo( appInfo, aAppUid ) );
   486         CLOG_WRITE_FORMAT(" appInfo.iFullName: %S",&appInfo.iFullName);
   493         CLOG_WRITE_FORMAT(" appInfo.iFullName: %S",&appInfo.iFullName);
   487         CLOG_WRITE_FORMAT(" appInfo.iCaption: %S",&appInfo.iCaption);
   494         CLOG_WRITE_FORMAT(" appInfo.iCaption: %S",&appInfo.iCaption);
   488         CLOG_WRITE_FORMAT(" appInfo.iShortCaption: %S",&appInfo.iShortCaption);
   495         CLOG_WRITE_FORMAT(" appInfo.iShortCaption: %S",&appInfo.iShortCaption);
   489         // In many cases there is long caption. We should use short caption only 
   496         // In many cases there is long caption. We should use short caption only
   490         // if it is empty. They say that sometimes the long caption is not empty, 
   497         // if it is empty. They say that sometimes the long caption is not empty,
   491         // but it contains only a space (0x20). In this case we must use the short.
   498         // but it contains only a space (0x20). In this case we must use the short.
   492         // For safety reasons, we will check the whole long caption, if it 
   499         // For safety reasons, we will check the whole long caption, if it
   493         // contains only space characters.
   500         // contains only space characters.
   494         const TDesC& longCap = appInfo.iCaption;
   501         const TDesC& longCap = appInfo.iCaption;
   495         TBool longCapIsEmpty = (longCap.Length() == 0);
   502         TBool longCapIsEmpty = (longCap.Length() == 0);
   496         if ( longCapIsEmpty == EFalse )
   503         if ( longCapIsEmpty == EFalse )
   497             {
   504             {
   520             {
   527             {
   521             // Using long caption
   528             // Using long caption
   522             handlerName = appInfo.iCaption.AllocLC();
   529             handlerName = appInfo.iCaption.AllocLC();
   523             }
   530             }
   524         }
   531         }
   525         
   532 
   526     CLOG_LEAVEFN("CUserInteractionsEventHandler::ConstructHandlerAppNameLC");
   533     CLOG_LEAVEFN("CUserInteractionsEventHandler::ConstructHandlerAppNameLC");
   527     return handlerName;
   534     return handlerName;
   528     }
   535     }
   529 
   536 
   530 // -----------------------------------------------------------------------------
   537 // -----------------------------------------------------------------------------
   532 // -----------------------------------------------------------------------------
   539 // -----------------------------------------------------------------------------
   533 //
   540 //
   534 HBufC* CUserInteractionsEventHandler::FormatListBoxItemLC
   541 HBufC* CUserInteractionsEventHandler::FormatListBoxItemLC
   535     ( const TDesC& aFirst, const TDesC& aSecond )
   542     ( const TDesC& aFirst, const TDesC& aSecond )
   536     {
   543     {
   537     HBufC* res = HBufC::NewLC( aFirst.Length() + 
   544     HBufC* res = HBufC::NewLC( aFirst.Length() +
   538                                aSecond.Length() + 
   545                                aSecond.Length() +
   539                                KListBoxSeparator().Length() );
   546                                KListBoxSeparator().Length() );
   540     res->Des().Copy( aFirst );
   547     res->Des().Copy( aFirst );
   541     res->Des().Append( KListBoxSeparator );
   548     res->Des().Append( KListBoxSeparator );
   542     res->Des().Append( aSecond );
   549     res->Des().Append( aSecond );
   543     return res;
   550     return res;
   552     CLOG_ENTERFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   559     CLOG_ENTERFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   553 
   560 
   554     // GET - download is in progress - user can cancel
   561     // GET - download is in progress - user can cancel
   555     if( iEvent.iProgressState == EHttpProgCodDownloadStarted && iEvent.iDownloadState == EHttpDlInprogress )
   562     if( iEvent.iProgressState == EHttpProgCodDownloadStarted && iEvent.iDownloadState == EHttpDlInprogress )
   556         {
   563         {
   557         iRegistryModel.DownloadsList().CancelDisplayingDownloadsList();                                          
   564         iRegistryModel.DownloadsList().CancelDisplayingDownloadsList();
   558         }
   565         }
   559     if ( iEvent.iProgressState == EHttpContTypeRecognitionAvail )
   566     if ( iEvent.iProgressState == EHttpContTypeRecognitionAvail )
   560         {
   567         {
   561         // Don't show confirmation query for COD downloads
   568         // Don't show confirmation query for COD downloads
   562         TBool isCodDownload( EFalse );
   569         TBool isCodDownload( EFalse );
   574             TPtr8 contentTypePtr = contentType->Des();
   581             TPtr8 contentTypePtr = contentType->Des();
   575             User::LeaveIfError
   582             User::LeaveIfError
   576                 ( iDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
   583                 ( iDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
   577             if( 0 == contentType->Compare( KMultiPartMimeType ) )
   584             if( 0 == contentType->Compare( KMultiPartMimeType ) )
   578                 {
   585                 {
   579                 // Don't show confirmation query yet, but 
   586                 // Don't show confirmation query yet, but
   580                 // observe EHttpProgSupportedMultiPart.
   587                 // observe EHttpProgSupportedMultiPart.
   581                 }
   588                 }
   582             else
   589             else
   583                 {
   590                 {
   584                 iUiUtils.IsContentTypeSupportedL( iDownload );
   591                 iUiUtils.IsContentTypeSupportedL( iDownload );
   585                 TBool suppressDownloadConfirmation( EFalse );
   592                 TBool suppressDownloadConfirmation( EFalse );
   586                 iRegistryModel.UserInteractions().GetBoolAttributeL
   593                 iRegistryModel.UserInteractions().GetBoolAttributeL
   587                     ( CDownloadMgrUiUserInteractions::EAttrSuppressDownloadConfirmation, 
   594                     ( CDownloadMgrUiUserInteractions::EAttrSuppressDownloadConfirmation,
   588                       suppressDownloadConfirmation );
   595                       suppressDownloadConfirmation );
   589                 CLOG_WRITE_FORMAT(" suppressDownloadConfirmation: %d", 
   596                 CLOG_WRITE_FORMAT(" suppressDownloadConfirmation: %d",
   590                                     suppressDownloadConfirmation);
   597                                     suppressDownloadConfirmation);
   591 
   598 
   592                 if ( suppressDownloadConfirmation )
   599                 if ( suppressDownloadConfirmation )
   593                     {
   600                     {
   594                     // Nothing to do.
   601                     // Nothing to do.
   612                         }
   619                         }
   613                     else
   620                     else
   614                         {
   621                         {
   615                         userConfirms = ShowDownloadConfirmationL
   622                         userConfirms = ShowDownloadConfirmationL
   616                             ( iDownload, R_AVKON_SOFTKEYS_OK_CANCEL__OK, EFalse );
   623                             ( iDownload, R_AVKON_SOFTKEYS_OK_CANCEL__OK, EFalse );
   617                                              
   624 
   618                         // executes a wait dialog! Check if this is deleted meanwhile
   625                         // executes a wait dialog! Check if this is deleted meanwhile
   619                         if ( aThisDeleted )
   626                         if ( aThisDeleted )
   620                             {
   627                             {
   621                             CLOG_WRITE_FORMAT(" this deleted: %x", this);
   628                             CLOG_WRITE_FORMAT(" this deleted: %x", this);
   622                             CLOG_LEAVEFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   629                             CLOG_LEAVEFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   623                             CleanupStack::PopAndDestroy( contentType );
       
   624                             return;
   630                             return;
   625                             }
   631                             }
   626                             
   632 
   627                         if ( userConfirms )
   633                         if ( userConfirms )
   628                             {
   634                             {
   629                             TBool isLaunchType( EFalse );
   635                             TBool isLaunchType( EFalse );
   630                             if( iUiUtils.DrmDownloadL( iDownload ) )
   636                             if( iUiUtils.DrmDownloadL( iDownload ) )
   631                                 {
   637                                 {
   644                                     EDlAttrAction, ELaunch ) );
   650                                     EDlAttrAction, ELaunch ) );
   645                                 }
   651                                 }
   646                             else
   652                             else
   647                                 {
   653                                 {
   648                                 //part of error PNIO-73GEM3.Sis file progress should be visible to user
   654                                 //part of error PNIO-73GEM3.Sis file progress should be visible to user
   649                                 if( (KSisxApplication().Find( contentTypePtr)!= KErrNotFound) || 
   655                                 if( (KSisxApplication().Find( contentTypePtr)!= KErrNotFound) ||
   650                                     (KPipApplication().Find( contentTypePtr)!= KErrNotFound) ||
   656                                     (KPipApplication().Find( contentTypePtr)!= KErrNotFound) ||
   651                                     (KWidgetMimeType().Find( contentTypePtr)!= KErrNotFound) ||
   657                                     (KWidgetMimeType().Find( contentTypePtr)!= KErrNotFound) ||
   652                                     (KSharingConfig().Find( contentTypePtr)!= KErrNotFound) )
   658                                     (KSharingConfig().Find( contentTypePtr)!= KErrNotFound) )
   653                                     {
   659                                     {
   654                                     isLaunchType = ETrue;
   660                                     isLaunchType = ETrue;
   655                                     User::LeaveIfError( iDownload.SetIntAttribute(
   661                                     User::LeaveIfError( iDownload.SetIntAttribute(
   656                                         EDlAttrAction, ELaunch ) );                                    
   662                                         EDlAttrAction, ELaunch ) );
   657                                     }
   663                                     }
   658                                 // Open the download list if there is no more 
   664                                 // Open the download list if there is no more
   659                                 // download confirmation shown:
   665                                 // download confirmation shown:
   660                                 if ( iRegistryModel.UserInteractions().
   666                                 if ( iRegistryModel.UserInteractions().
   661                                     DownloadConfirmationsShown() == 0 )
   667                                     DownloadConfirmationsShown() == 0 )
   662                                     {
   668                                     {
   663                                     if ( iRegistryModel.DownloadsListInstalled() )
   669                                     if ( iRegistryModel.DownloadsListInstalled() )
   676                             }
   682                             }
   677                         }
   683                         }
   678                      }
   684                      }
   679                     if (userConfirms)
   685                     if (userConfirms)
   680 					{
   686 					{
   681                    
   687 
   682 	#ifdef __DMGR_PD_TESTHARNESS
   688 	#ifdef __DMGR_PD_TESTHARNESS
   683                         iUiUtils.TestLaunchPdAppL(iDownload);
   689                         iUiUtils.TestLaunchPdAppL(iDownload);
   684 	#else	           
   690 	#else
   685  		//#ifdef RD_BROWSER_PROGRESSIVE_DOWNLOAD	               
   691  		//#ifdef RD_BROWSER_PROGRESSIVE_DOWNLOAD
   686 
   692 
   687                         // check if it's PdLaunch action 
   693                         // check if it's PdLaunch action
   688 		                TInt32 action(0);
   694 		                TInt32 action(0);
   689                         User::LeaveIfError( iDownload.GetIntAttribute( EDlAttrAction, action ) );                    
   695                         User::LeaveIfError( iDownload.GetIntAttribute( EDlAttrAction, action ) );
   690                         if( (action & EPdLaunch) && 
   696                         if( (action & EPdLaunch) &&
   691                             iUiUtils.CanLaunchAsProgDownload( iDownload, iRegistryModel.DownloadsList(),EFalse ))
   697                             iUiUtils.CanLaunchAsProgDownload( iDownload, iRegistryModel.DownloadsList(),EFalse ))
   692                             {
   698                             {
   693       						CLOG_WRITE( " launchPdAppL(iDownload)" );
   699       						CLOG_WRITE( " launchPdAppL(iDownload)" );
   694 						    iUiUtils.LaunchPdAppL(iDownload, ETrue);
   700 						    iUiUtils.LaunchPdAppL(iDownload, ETrue);
   695 						    }
   701 						    }
   696 		//#endif	//RD_BROWSER_PROGRESSIVE_DOWNLOAD
   702 		//#endif	//RD_BROWSER_PROGRESSIVE_DOWNLOAD
   697 	#endif	//__DMGR_PD_TESTHARNESS	
   703 	#endif	//__DMGR_PD_TESTHARNESS
   698 					}
   704 					}
   699                 }
   705                 }
   700             CleanupStack::PopAndDestroy( contentType ); // contentType
   706             CleanupStack::PopAndDestroy( contentType ); // contentType
   701             }
   707             }
   702         }
   708         }
   705         TBool isCodPdAvailable( EFalse );
   711         TBool isCodPdAvailable( EFalse );
   706         User::LeaveIfError( iDownload.GetBoolAttribute
   712         User::LeaveIfError( iDownload.GetBoolAttribute
   707                           ( EDlAttrCodPdAvailable, isCodPdAvailable ) );
   713                           ( EDlAttrCodPdAvailable, isCodPdAvailable ) );
   708         if ( isCodPdAvailable )
   714         if ( isCodPdAvailable )
   709             {
   715             {
   710 			
   716 
   711 			#ifdef __DMGR_PD_TESTHARNESS
   717 			#ifdef __DMGR_PD_TESTHARNESS
   712 				iUiUtils.TestLaunchPdAppL(iDownload);
   718 				iUiUtils.TestLaunchPdAppL(iDownload);
   713 			#else
   719 			#else
   714 	            // check if it's PdLaunch action 
   720 	            // check if it's PdLaunch action
   715 	            TInt32 action(0);
   721 	            TInt32 action(0);
   716                 User::LeaveIfError( iDownload.GetIntAttribute( EDlAttrAction, action ) );                    
   722                 User::LeaveIfError( iDownload.GetIntAttribute( EDlAttrAction, action ) );
   717 				if ( (action & EPdLaunch) && 
   723 				if ( (action & EPdLaunch) &&
   718                     iUiUtils.CanLaunchAsProgDownload( iDownload, iRegistryModel.DownloadsList(),ETrue ))
   724                     iUiUtils.CanLaunchAsProgDownload( iDownload, iRegistryModel.DownloadsList(),ETrue ))
   719 					{
   725 					{
   720 					iUiUtils.LaunchPdAppL(iDownload, ETrue);
   726 					iUiUtils.LaunchPdAppL(iDownload, ETrue);
   721 					}
   727 					}
   722 			#endif	//__DMGR_PD_TESTHARNESS
   728 			#endif	//__DMGR_PD_TESTHARNESS
   723 			}
   729 			}
   724         }        
   730         }
   725     else if ( iEvent.iProgressState == EHttpProgCodDescriptorAccepted )
   731     else if ( iEvent.iProgressState == EHttpProgCodDescriptorAccepted )
   726         {
   732         {
   727         // COD load accepted. Download is turned to visible, and 
   733         // COD load accepted. Download is turned to visible, and
   728         // downloads list is shown.
   734         // downloads list is shown.
   729         User::LeaveIfError( iDownload.SetBoolAttribute
   735         User::LeaveIfError( iDownload.SetBoolAttribute
   730                           ( EDlAttrHidden, EFalse ) );
   736                           ( EDlAttrHidden, EFalse ) );
   731         CLOG_WRITE(" SetBoolAttribute EDlAttrHidden OK");
   737         CLOG_WRITE(" SetBoolAttribute EDlAttrHidden OK");
   732         // If this download's ServiceFlow was running, it's not more 
   738         // If this download's ServiceFlow was running, it's not more
   733         // a ServiceFlow, thus the next postponed download can be 
   739         // a ServiceFlow, thus the next postponed download can be
   734         // scheduled.
   740         // scheduled.
   735         if ( iRegistryModel.UserInteractions().IsCodServiceFlowRunning( iDownload ) )
   741         if ( iRegistryModel.UserInteractions().IsCodServiceFlowRunning( iDownload ) )
   736             {
   742             {
   737             iRegistryModel.UserInteractions().SchedulePostponedDownloadL();
   743             iRegistryModel.UserInteractions().SchedulePostponedDownloadL();
   738             }
   744             }
   745         }
   751         }
   746     else if ( iEvent.iProgressState == EHttpProgCodLoadEnd )
   752     else if ( iEvent.iProgressState == EHttpProgCodLoadEnd )
   747         {
   753         {
   748         // UI state must be checked before we set download to hidden!
   754         // UI state must be checked before we set download to hidden!
   749         TBool isUiBusyNow = iRegistryModel.UserInteractions().IsUiBusy();
   755         TBool isUiBusyNow = iRegistryModel.UserInteractions().IsUiBusy();
   750         // COD load has ended. Download is turned to hidden, removed from 
   756         // COD load has ended. Download is turned to hidden, removed from
   751         // downloads list, and restarted (ServiceFlow).
   757         // downloads list, and restarted (ServiceFlow).
   752         CLOG_WRITE(" SetBoolAttribute EDlAttrHidden OK");
   758         CLOG_WRITE(" SetBoolAttribute EDlAttrHidden OK");
   753 
   759 
   754         // Restart if possible - start ServiceFlow.
   760         // Restart if possible - start ServiceFlow.
   755         // (UserInteractions must be installed...)
   761         // (UserInteractions must be installed...)
   756         if ( isUiBusyNow )
   762         if ( isUiBusyNow )
   757             {
   763             {
   758             // Not possible to do it. Postpone the Service Flow and 
   764             // Not possible to do it. Postpone the Service Flow and
   759             // invoke when no more handler is running.
   765             // invoke when no more handler is running.
   760             // The download is already hidden!
   766             // The download is already hidden!
   761             iRegistryModel.UserInteractions().PostponeCodHandlingL( iDownload );
   767             iRegistryModel.UserInteractions().PostponeCodHandlingL( iDownload );
   762              //Download will be handled when the UI becomes free.
   768              //Download will be handled when the UI becomes free.
   763             }
   769             }
   781             }
   787             }
   782         else
   788         else
   783             {
   789             {
   784             TBool suppressDownloadConfirmation( EFalse );
   790             TBool suppressDownloadConfirmation( EFalse );
   785             iRegistryModel.UserInteractions().GetBoolAttributeL
   791             iRegistryModel.UserInteractions().GetBoolAttributeL
   786                 ( CDownloadMgrUiUserInteractions::EAttrSuppressDownloadConfirmation, 
   792                 ( CDownloadMgrUiUserInteractions::EAttrSuppressDownloadConfirmation,
   787                   suppressDownloadConfirmation );
   793                   suppressDownloadConfirmation );
   788             CLOG_WRITE_FORMAT(" suppressDownloadConfirmation: %d", 
   794             CLOG_WRITE_FORMAT(" suppressDownloadConfirmation: %d",
   789                                 suppressDownloadConfirmation);
   795                                 suppressDownloadConfirmation);
   790 
   796 
   791             if ( suppressDownloadConfirmation )
   797             if ( suppressDownloadConfirmation )
   792                 {
   798                 {
   793                 // Nothing to do.
   799                 // Nothing to do.
   794                 }
   800                 }
   795             else
   801             else
   796                 {
   802                 {
   797                 TBool userConfirms = ShowDownloadConfirmationL
   803                 TBool userConfirms = ShowDownloadConfirmationL
   798                     ( iDownload, R_AVKON_SOFTKEYS_OK_CANCEL__OK, EFalse );
   804                     ( iDownload, R_AVKON_SOFTKEYS_OK_CANCEL__OK, EFalse );
   799                                      
   805 
   800                 // executes a wait dialog! Check if this is deleted meanwhile
   806                 // executes a wait dialog! Check if this is deleted meanwhile
   801                 if ( aThisDeleted )
   807                 if ( aThisDeleted )
   802                     {
   808                     {
   803                     CLOG_WRITE_FORMAT(" this deleted: %x", this);
   809                     CLOG_WRITE_FORMAT(" this deleted: %x", this);
   804                     CLOG_LEAVEFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   810                     CLOG_LEAVEFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   805                     return;
   811                     return;
   806                     }
   812                     }
   807                     
   813 
   808                 if ( userConfirms )
   814                 if ( userConfirms )
   809                     {
   815                     {
   810                     // Open the download list if there is no more 
   816                     // Open the download list if there is no more
   811                     // download confirmation shown:
   817                     // download confirmation shown:
   812                     if ( iRegistryModel.UserInteractions().
   818                     if ( iRegistryModel.UserInteractions().
   813                                         DownloadConfirmationsShown() == 0 )
   819                                         DownloadConfirmationsShown() == 0 )
   814                         {
   820                         {
   815                         if ( iRegistryModel.DownloadsListInstalled() )
   821                         if ( iRegistryModel.DownloadsListInstalled() )
   830         }
   836         }
   831 
   837 
   832     CLOG_LEAVEFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   838     CLOG_LEAVEFN("CUserInteractionsEventHandler::HandleInProgressStateL");
   833     }
   839     }
   834 
   840 
   835     
   841 
   836 // -----------------------------------------------------------------------------
   842 // -----------------------------------------------------------------------------
   837 // CUserInteractionsEventHandler::HandlePausedStateL
   843 // CUserInteractionsEventHandler::HandlePausedStateL
   838 // -----------------------------------------------------------------------------
   844 // -----------------------------------------------------------------------------
   839 //
   845 //
   840 void CUserInteractionsEventHandler::HandlePausedStateL( TBool& aThisDeleted )
   846 void CUserInteractionsEventHandler::HandlePausedStateL( TBool& aThisDeleted )
   854             }
   860             }
   855         else
   861         else
   856             {
   862             {
   857             TBool suppressDownloadConfirmation( EFalse );
   863             TBool suppressDownloadConfirmation( EFalse );
   858             iRegistryModel.UserInteractions().GetBoolAttributeL
   864             iRegistryModel.UserInteractions().GetBoolAttributeL
   859                 ( CDownloadMgrUiUserInteractions::EAttrSuppressDownloadConfirmation, 
   865                 ( CDownloadMgrUiUserInteractions::EAttrSuppressDownloadConfirmation,
   860                   suppressDownloadConfirmation );
   866                   suppressDownloadConfirmation );
   861             CLOG_WRITE_FORMAT(" suppressDownloadConfirmation: %d", 
   867             CLOG_WRITE_FORMAT(" suppressDownloadConfirmation: %d",
   862                                 suppressDownloadConfirmation);
   868                                 suppressDownloadConfirmation);
   863 
   869 
   864             if ( suppressDownloadConfirmation )
   870             if ( suppressDownloadConfirmation )
   865                 {
   871                 {
   866                 // Nothing to do, just resume the download.
   872                 // Nothing to do, just resume the download.
   878                     {
   884                     {
   879                     CLOG_WRITE_FORMAT(" this deleted: %x", this);
   885                     CLOG_WRITE_FORMAT(" this deleted: %x", this);
   880                     CLOG_LEAVEFN("CUserInteractionsEventHandler::HandlePausedStateL");
   886                     CLOG_LEAVEFN("CUserInteractionsEventHandler::HandlePausedStateL");
   881                     return;
   887                     return;
   882                     }
   888                     }
   883                     
   889 
   884                 // Open Downloads List if user confirms:
   890                 // Open Downloads List if user confirms:
   885                 if ( userConfirms )
   891                 if ( userConfirms )
   886                     {
   892                     {
   887                     // Resume the download:
   893                     // Resume the download:
   888                     User::LeaveIfError( iDownload.Start() );
   894                     User::LeaveIfError( iDownload.Start() );
   889                     // and open the download list if there is no more 
   895                     // and open the download list if there is no more
   890                     // download confirmation shown:
   896                     // download confirmation shown:
   891                     if ( iRegistryModel.UserInteractions().
   897                     if ( iRegistryModel.UserInteractions().
   892                                         DownloadConfirmationsShown() == 0 )
   898                                         DownloadConfirmationsShown() == 0 )
   893                         {
   899                         {
   894                         if ( iRegistryModel.DownloadsListInstalled() )
   900                         if ( iRegistryModel.DownloadsListInstalled() )
   925         CLOG_WRITE(" Move has started");
   931         CLOG_WRITE(" Move has started");
   926         }
   932         }
   927     else if ( iEvent.iProgressState == EHttpProgContentFileMoved || iEvent.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
   933     else if ( iEvent.iProgressState == EHttpProgContentFileMoved || iEvent.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
   928         {
   934         {
   929         // An asynchronous move has ended.
   935         // An asynchronous move has ended.
   930         
   936 
   931         CLOG_WRITE(" Move has ended");
   937         CLOG_WRITE(" Move has ended");
   932         // After successful moving, display updated download list
   938         // After successful moving, display updated download list
   933         iRegistryModel.DownloadsList().DisplayDownloadsListL( iDownload );
   939         iRegistryModel.DownloadsList().DisplayDownloadsListL( iDownload );
   934         // Notify Media Gallery about new media file
   940         // Notify Media Gallery about new media file
   935         // first get path to gallery where file was moved
   941         // first get path to gallery where file was moved
   936         HBufC* fileName = HBufC::NewLC( KMaxPath );
   942         HBufC* fileName = HBufC::NewLC( KMaxPath );
   937         TPtr fileNamePtr = fileName->Des();
   943         TPtr fileNamePtr = fileName->Des();
   938         TInt attErr = iDownload.GetStringAttribute( 
   944         TInt attErr = iDownload.GetStringAttribute(
   939             EDlAttrDestFilename, fileNamePtr );
   945             EDlAttrDestFilename, fileNamePtr );
   940         CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr);
   946         CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr);
   941         TBool havePath = (attErr == KErrNone) && (fileNamePtr.Length() > 0);
   947         TBool havePath = (attErr == KErrNone) && (fileNamePtr.Length() > 0);
   942         
   948 
   943         #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   949         #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   944         //
   950         //
   945         CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
   951         CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(
   946             CEikonEnv::Static()->FsSession() );
   952             CEikonEnv::Static()->FsSession() );
   947         if( havePath )
   953         if( havePath )
   951             }
   957             }
   952         else
   958         else
   953             {
   959             {
   954             TRAP_IGNORE( mgFileManager->UpdateL() );
   960             TRAP_IGNORE( mgFileManager->UpdateL() );
   955             }
   961             }
   956         
   962 
   957         delete mgFileManager;
   963         delete mgFileManager;
   958         mgFileManager = NULL;
   964         mgFileManager = NULL;
   959         
   965 
   960         #else
   966         #else
   961          if( havePath )
   967          if( havePath )
   962             {
   968             {
   963             TRAP_IGNORE( iUiUtils.UpdateDCFRepositoryL( fileNamePtr ) );
   969             TRAP_IGNORE( iUiUtils.UpdateDCFRepositoryL( fileNamePtr ) );
   964             }
   970             }
   965         #endif    
   971         #endif
   966         
   972 
   967         CleanupStack::PopAndDestroy( fileName );
   973         CleanupStack::PopAndDestroy( fileName );
   968         
   974 
   969         }
   975         }
   970     else
   976     else
   971         {
   977         {
   972         // Normal completed state. Handling depends on EDlAttrAction
   978         // Normal completed state. Handling depends on EDlAttrAction
   973         TInt32 action(0);
   979         TInt32 action(0);
   990             TInt err = iDownload.GetBoolAttribute
   996             TInt err = iDownload.GetBoolAttribute
   991                 ( EDlAttrProgressive, isProgressive );
   997                 ( EDlAttrProgressive, isProgressive );
   992             CLOG_WRITE_FORMAT(" EDlAttrProgressive err: %d",err);
   998             CLOG_WRITE_FORMAT(" EDlAttrProgressive err: %d",err);
   993             // 'err' is ignored.
   999             // 'err' is ignored.
   994             CLOG_WRITE_FORMAT(" EDlAttrProgressive: %d", isProgressive);
  1000             CLOG_WRITE_FORMAT(" EDlAttrProgressive: %d", isProgressive);
   995             
  1001 
   996             // check if move is already issued
  1002             // check if move is already issued
   997             TBool isMoveIssued = EFalse;
  1003             TBool isMoveIssued = EFalse;
   998             TInt32 progState(0);
  1004             TInt32 progState(0);
   999             User::LeaveIfError( iDownload.GetIntAttribute
  1005             User::LeaveIfError( iDownload.GetIntAttribute
  1000                             ( EDlAttrProgressState, progState ) );
  1006                             ( EDlAttrProgressState, progState ) );
  1001             
  1007 
  1002             if(progState == EHttpProgMovingContentFile) isMoveIssued = ETrue;    
  1008             if(progState == EHttpProgMovingContentFile) isMoveIssued = ETrue;
  1003 
  1009 
  1004             if( isCodDownload )
  1010             if( isCodDownload )
  1005                 {
  1011                 {
  1006                 HBufC8* contentType = HBufC8::NewLC( KMaxContentTypeLength );
  1012                 HBufC8* contentType = HBufC8::NewLC( KMaxContentTypeLength );
  1007                 TPtr8 contentTypePtr = contentType->Des();
  1013                 TPtr8 contentTypePtr = contentType->Des();
  1008                 User::LeaveIfError
  1014                 User::LeaveIfError
  1009                     ( iDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) ); 
  1015                     ( iDownload.GetStringAttribute( EDlAttrContentType, contentTypePtr ) );
  1010                 if( !contentType->Compare(KRoapMimeType))
  1016                 if( !contentType->Compare(KRoapMimeType))
  1011                     {
  1017                     {
  1012                     User::LeaveIfError
  1018                     User::LeaveIfError
  1013                     ( iDownload.Delete());
  1019                     ( iDownload.Delete());
  1014                     }
  1020                     }
  1015                 CleanupStack::PopAndDestroy( contentType );    
  1021                 CleanupStack::PopAndDestroy( contentType );
  1016                 }
  1022                 }
  1017              else if( isProgressive || isMoveIssued )
  1023              else if( isProgressive || isMoveIssued )
  1018                 {
  1024                 {
  1019                 //do not move
  1025                 //do not move
  1020                 
  1026 
  1021                 }
  1027                 }
  1022              else
  1028              else
  1023                 {
  1029                 {
  1024                 // Move content to the location defined by KDownloadPath
  1030                 // Move content to the location defined by KDownloadPath
  1025 
  1031 
  1048                     if( lastSlashPos != KErrNotFound )
  1054                     if( lastSlashPos != KErrNotFound )
  1049                         {
  1055                         {
  1050                         fileNamePtr.Delete( 0, lastSlashPos );
  1056                         fileNamePtr.Delete( 0, lastSlashPos );
  1051                         }
  1057                         }
  1052                     }
  1058                     }
  1053             
  1059 
  1054                 // Setting RootPath for new Destination file
  1060                 // Setting RootPath for new Destination file
  1055                 fileNamePtr.Insert( 0, rootPath );
  1061                 fileNamePtr.Insert( 0, rootPath );
  1056                 // Setting KDownloadPath
  1062                 // Setting KDownloadPath
  1057                 fileNamePtr.Insert( rootPath.Length(), KDownloadPath );
  1063                 fileNamePtr.Insert( rootPath.Length(), KDownloadPath );
  1058 #else
  1064 #else
  1059                 
  1065 
  1060                 TParse p;
  1066                 TParse p;
  1061                 p.SetNoWild(fileNamePtr, NULL, NULL);
  1067                 p.SetNoWild(fileNamePtr, NULL, NULL);
  1062                 TDriveUnit currentDrive(fileNamePtr);
  1068                 TDriveUnit currentDrive(fileNamePtr);
  1063                 TFileName rootPath;
  1069                 TFileName rootPath;
  1064                 User::LeaveIfError( PathInfo::GetRootPath( rootPath, currentDrive ) );
  1070                 User::LeaveIfError( PathInfo::GetRootPath( rootPath, currentDrive ) );
  1065                 
  1071 
  1066                 TPtrC namePtr = p.NameAndExt();
  1072                 TPtrC namePtr = p.NameAndExt();
  1067                 fileNamePtr.Format( _L("%S%S\\%S"), &rootPath,
  1073                 fileNamePtr.Format( _L("%S%S\\%S"), &rootPath,
  1068                                                     &KDownloadPath,
  1074                                                     &KDownloadPath,
  1069                                                     &namePtr );
  1075                                                     &namePtr );
  1070 #endif
  1076 #endif
  1097           	    CleanupStack::PopAndDestroy( fileName ); // fileName
  1103           	    CleanupStack::PopAndDestroy( fileName ); // fileName
  1098                 }
  1104                 }
  1099             }
  1105             }
  1100         else if ( action & EPdLaunch )
  1106         else if ( action & EPdLaunch )
  1101         {
  1107         {
  1102         	// do nothing since PdLaunch was already launched during the progress 
  1108         	// do nothing since PdLaunch was already launched during the progress
  1103         }
  1109         }
  1104         else
  1110         else
  1105             {
  1111             {
  1106             // Defaulting to Launch
  1112             // Defaulting to Launch
  1107             iRegistryModel.UserInteractions().HandleDownloadL( iDownload );
  1113             iRegistryModel.UserInteractions().HandleDownloadL( iDownload );
  1125     User::LeaveIfError( iDownload.GetBoolAttribute
  1131     User::LeaveIfError( iDownload.GetBoolAttribute
  1126                       ( EDlAttrCodDownload, isCodDownload ) );
  1132                       ( EDlAttrCodDownload, isCodDownload ) );
  1127     CLOG_WRITE_FORMAT("EDlAttrCodDownload: %d",isCodDownload);
  1133     CLOG_WRITE_FORMAT("EDlAttrCodDownload: %d",isCodDownload);
  1128     if ( isCodDownload )
  1134     if ( isCodDownload )
  1129         {
  1135         {
  1130         // If the ServiceFlow of the download was running, but failed, 
  1136         // If the ServiceFlow of the download was running, but failed,
  1131         // schedule the next download for running. 
  1137         // schedule the next download for running.
  1132         // UserInteractions is assumed to be installed.
  1138         // UserInteractions is assumed to be installed.
  1133         // Do not delete the download yet (because IsCodServiceFlowRunning needs it)!
  1139         // Do not delete the download yet (because IsCodServiceFlowRunning needs it)!
  1134         if ( iRegistryModel.UserInteractions().IsCodServiceFlowRunning( iDownload ) )
  1140         if ( iRegistryModel.UserInteractions().IsCodServiceFlowRunning( iDownload ) )
  1135             {
  1141             {
  1136             iRegistryModel.UserInteractions().SchedulePostponedDownloadL();
  1142             iRegistryModel.UserInteractions().SchedulePostponedDownloadL();
  1166             // Do not handle it.
  1172             // Do not handle it.
  1167             }
  1173             }
  1168         else
  1174         else
  1169             {
  1175             {
  1170             TBool errorHandled( EFalse );
  1176             TBool errorHandled( EFalse );
  1171             
  1177 
  1172             if ( !errorHandled )
  1178             if ( !errorHandled )
  1173                 {
  1179                 {
  1174                 iUiUtils.ShowErrorNoteL( iDownload, errorId );
  1180                 iUiUtils.ShowErrorNoteL( iDownload, errorId );
  1175                 // This component is responsible for deleting 
  1181                 // This component is responsible for deleting
  1176                 // not recoverable downloads
  1182                 // not recoverable downloads
  1177                 if ( iUiUtils.IsRecoverableFailL( iDownload, errorId ) )
  1183                 if ( iUiUtils.IsRecoverableFailL( iDownload, errorId ) )
  1178                     {
  1184                     {
  1179                     // Do nothing.
  1185                     // Do nothing.
  1180                     }
  1186                     }
  1229             CleanupStack::PopAndDestroy( converted );
  1235             CleanupStack::PopAndDestroy( converted );
  1230             }
  1236             }
  1231         CleanupStack::PopAndDestroy( url );
  1237         CleanupStack::PopAndDestroy( url );
  1232         }
  1238         }
  1233 
  1239 
  1234     // iDownload can now been deleted        
  1240     // iDownload can now been deleted
  1235     User::LeaveIfError( iDownload.Delete() );
  1241     User::LeaveIfError( iDownload.Delete() );
  1236     CLOG_WRITE(" Delete OK");
  1242     CLOG_WRITE(" Delete OK");
  1237 
  1243 
  1238     HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_CANCELLED, *dlName );
  1244     HBufC* infoPrompt = StringLoader::LoadLC( R_DMUL_ERROR_CANCELLED, *dlName );
  1239     CLOG_WRITE(" StringLoader OK");
  1245     CLOG_WRITE(" StringLoader OK");
  1240     
  1246 
  1241     CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog();
  1247     CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog();
  1242     dlg->PrepareLC( R_DMUL_DOWNLOAD_OK_INFO );
  1248     dlg->PrepareLC( R_DMUL_DOWNLOAD_OK_INFO );
  1243     dlg->SetTextL( *infoPrompt );
  1249     dlg->SetTextL( *infoPrompt );
  1244     dlg->RunLD();
  1250     dlg->RunLD();
  1245     CLOG_WRITE(" RunLD OK");
  1251     CLOG_WRITE(" RunLD OK");
  1270 
  1276 
  1271     // This RunL may show wait dialogs. Use an indicator for if this is deleted
  1277     // This RunL may show wait dialogs. Use an indicator for if this is deleted
  1272     TBool deleted( EFalse );
  1278     TBool deleted( EFalse );
  1273     iDeletedPtr = &deleted;
  1279     iDeletedPtr = &deleted;
  1274 
  1280 
  1275     // Incase of completed and moved downloads, subsession will be closed and whole download info will be cached client side. 
  1281     // Incase of completed and moved downloads, subsession will be closed and whole download info will be cached client side.
  1276     // No need to check for subsession close    
  1282     // No need to check for subsession close
  1277     if(!(iEvent.iDownloadState == EHttpDlMultipleMOCompleted && (iEvent.iProgressState == EHttpProgContentFileMoved || iEvent.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )))
  1283     if(!(iEvent.iDownloadState == EHttpDlMultipleMOCompleted && (iEvent.iProgressState == EHttpProgContentFileMoved || iEvent.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )))
  1278         {
  1284         {
  1279         // Due to the postponed event handling, it may happen that somebody already 
  1285         // Due to the postponed event handling, it may happen that somebody already
  1280         // closed the download meanwhile. Check if it is still alive:
  1286         // closed the download meanwhile. Check if it is still alive:
  1281         if ( iDownload.SubSessionHandle() == 0 )
  1287         if ( iDownload.SubSessionHandle() == 0 )
  1282             {
  1288             {
  1283             // No, it's already closed!! Do nothing.
  1289             // No, it's already closed!! Do nothing.
  1284             // Necessary task done in RunL. This object is no more necessary.
  1290             // Necessary task done in RunL. This object is no more necessary.
  1286             delete this;
  1292             delete this;
  1287             CLOG_LEAVEFN("CUserInteractionsEventHandler::RunL");
  1293             CLOG_LEAVEFN("CUserInteractionsEventHandler::RunL");
  1288             return;
  1294             return;
  1289             }
  1295             }
  1290         }
  1296         }
  1291     
  1297 
  1292     switch ( iEvent.iDownloadState )
  1298     switch ( iEvent.iDownloadState )
  1293         {
  1299         {
  1294         //---------------------------------------------
  1300         //---------------------------------------------
  1295         case EHttpDlCreated:
  1301         case EHttpDlCreated:
  1296         //---------------------------------------------
  1302         //---------------------------------------------
  1351     if ( !deleted )
  1357     if ( !deleted )
  1352         {
  1358         {
  1353         // Necessary task done in RunL. This object is no more necessary.
  1359         // Necessary task done in RunL. This object is no more necessary.
  1354         delete this;
  1360         delete this;
  1355         }
  1361         }
  1356     
  1362 
  1357     CLOG_LEAVEFN("CUserInteractionsEventHandler::RunL");
  1363     CLOG_LEAVEFN("CUserInteractionsEventHandler::RunL");
  1358     }
  1364     }
  1359 
  1365 
  1360 // -----------------------------------------------------------------------------
  1366 // -----------------------------------------------------------------------------
  1361 // CUserInteractionsEventHandler::RunError
  1367 // CUserInteractionsEventHandler::RunError