browserutilities/downloadmgr/DownloadMgrUiLib/Src/CDownloadsListArray.cpp
branchRCL_3
changeset 94 919f36ff910f
parent 93 79859ed3eea9
equal deleted inserted replaced
93:79859ed3eea9 94:919f36ff910f
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 //#include <platform/mw/Browser_platform_variant.hrh>
    21 #include    <browser_platform_variant.hrh>
    22 #include    <Browser_platform_variant.hrh>
       
    23 #include    "CDownloadsListArray.h"
    22 #include    "CDownloadsListArray.h"
    24 #include    "ProgressInfoCreator.h"
    23 #include    "ProgressInfoCreator.h"
    25 #include    "DMgrUiLibPanic.h"
    24 #include    "DMgrUiLibPanic.h"
    26 #include    "UiLibLogger.h"
    25 #include    "UiLibLogger.h"
    27 #include    <DownloadMgrUiLib.rsg>
    26 #include    <DownloadMgrUiLib.rsg>
    33 #include    <data_caging_path_literals.hrh>
    32 #include    <data_caging_path_literals.hrh>
    34 #include    <f32file.h>
    33 #include    <f32file.h>
    35 #include    <AknsUtils.h>
    34 #include    <AknsUtils.h>
    36 #include    <DocumentHandler.h>
    35 #include    <DocumentHandler.h>
    37 
    36 
    38 // following line is temporary: AVKON dependency removal
       
    39 #undef BRDO_APP_GALLERY_SUPPORTED_FF
       
    40 
       
    41 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    37 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
    42 #include    <MediaGalleryUid.h>
    38 #include    <MediaGalleryUid.h>
    43 #endif
    39 #endif
    44 
    40 
    45 #include    "CDownloadUtils.h"
    41 #include    "CDownloadUtils.h"
    46 #include    <HttpDownloadMgrCommon.h>
    42 #include    <httpdownloadmgrcommon.h>
    47 #include    "CUserInteractionsUtils.h"
    43 #include    "CUserInteractionsUtils.h"
    48 
    44 
    49 
    45 
    50 // LOCAL CONSTANTS AND MACROS
    46 // LOCAL CONSTANTS AND MACROS
    51 LOCAL_D const TInt KArrayGranularity = 16;
    47 LOCAL_D const TInt KArrayGranularity = 16;
    68     iDownloadState( KErrNotFound ),
    64     iDownloadState( KErrNotFound ),
    69     iFullSize( KErrNotFound ),
    65     iFullSize( KErrNotFound ),
    70     iDownloadedSize( KErrNotFound ),
    66     iDownloadedSize( KErrNotFound ),
    71     iIconIndex( KErrNotFound ),
    67     iIconIndex( KErrNotFound ),
    72     iPausable( EFalse ),
    68     iPausable( EFalse ),
    73     iIsOnExternalMemory( EFalse ),
       
    74     iProgressState( KErrNotFound ),
    69     iProgressState( KErrNotFound ),
    75     iNumMediaObjects( KErrNotFound )
    70     iNumMediaObjects( KErrNotFound ),
       
    71     iExternalMemoryStatus( KDriveAttLocal )
    76     {
    72     {
    77     }
    73     }
    78 
    74 
    79 // ============================ MEMBER FUNCTIONS ===============================
    75 // ============================ MEMBER FUNCTIONS ===============================
    80 
    76 
   111     CLOG_WRITE(" iCompletedString OK");
   107     CLOG_WRITE(" iCompletedString OK");
   112     iSavedToGalleryString = iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_CONTENT_SAVED_TO_GALLERY );
   108     iSavedToGalleryString = iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_CONTENT_SAVED_TO_GALLERY );
   113     CLOG_WRITE(" iSavedToGalleryString OK");
   109     CLOG_WRITE(" iSavedToGalleryString OK");
   114 	iSavedToDownloadsFolderString=  iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_CONTENT_SAVED_TO_DOWNLOADS_FOLDER);
   110 	iSavedToDownloadsFolderString=  iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_CONTENT_SAVED_TO_DOWNLOADS_FOLDER);
   115 	CLOG_WRITE(" iSavedToGalleryDownload OK");
   111 	CLOG_WRITE(" iSavedToGalleryDownload OK");
   116 
   112 	
   117 	#ifndef BRDO_APP_GALLERY_SUPPORTED_FF
   113 	#ifndef BRDO_APP_GALLERY_SUPPORTED_FF
   118 	    iFileSavedString = iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_FILE_SAVED );
   114 	    iFileSavedString = iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_FILE_SAVED );
   119 	    iFilesSavedString = iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_FILES_SAVED );
   115 	    iFilesSavedString = iCoeEnv.AllocReadResourceL( R_DMUL_DOWNLOAD_FILES_SAVED );
   120 	#endif
   116 	#endif
   121 
   117 
   122 
   118 	
   123     iNullDesC = KNullDesC().AllocL();
   119     iNullDesC = KNullDesC().AllocL();
   124     CLOG_WRITE(" iNullDesC OK");
   120     CLOG_WRITE(" iNullDesC OK");
   125     User::LeaveIfError( iApaLsSess.Connect() );
   121     User::LeaveIfError( iApaLsSess.Connect() );
   126     CLOG_WRITE(" iApaLsSess OK");
   122     CLOG_WRITE(" iApaLsSess OK");
   127 
   123     
   128 
   124         
   129     //whether the platform supports gallery app or not; defined in browser_platfrom_variant.hrh
   125     //whether the platform supports gallery app or not; defined in browser_platfrom_variant.hrh
   130     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   126     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   131     iPlatformSupportsGallery = ETrue;
   127     iPlatformSupportsGallery = ETrue;
   132     #endif
   128     #endif
   133 
   129     
   134 
   130 
   135     // Initialize the UiLib' mbm file name:
   131     // Initialize the UiLib' mbm file name:
   136     TParse* fileParser = new (ELeave) TParse;
   132     TParse* fileParser = new (ELeave) TParse;
   137     CleanupStack::PushL( fileParser );
   133     CleanupStack::PushL( fileParser );
   138 
   134 
   139     fileParser->Set( KDownloadMgrUiLibMbmFileNameAndDriveZ, &KDC_APP_BITMAP_DIR, NULL );
   135     fileParser->Set( KDownloadMgrUiLibMbmFileNameAndDriveZ, &KDC_APP_BITMAP_DIR, NULL ); 
   140     TUint attValue(0);
   136     TUint attValue(0);
   141     TInt fileErr = iCoeEnv.FsSession().Att( fileParser->FullName(), attValue );
   137     TInt fileErr = iCoeEnv.FsSession().Att( fileParser->FullName(), attValue );
   142     CLOG_WRITE_FORMAT(" fileErr Z: %d",fileErr);
   138     CLOG_WRITE_FORMAT(" fileErr Z: %d",fileErr);
   143     User::LeaveIfError( fileErr );
   139     User::LeaveIfError( fileErr );
   144     iMbmResourceFileName = HBufC::NewMaxL( fileParser->FullName().Length() );
   140     iMbmResourceFileName = HBufC::NewMaxL( fileParser->FullName().Length() );
   145     iMbmResourceFileName->Des().Copy( fileParser->FullName() );
   141     iMbmResourceFileName->Des().Copy( fileParser->FullName() );
   146     CLOG_WRITE_FORMAT(" iMbmResourceFileName: %S",iMbmResourceFileName);
   142     CLOG_WRITE_FORMAT(" iMbmResourceFileName: %S",iMbmResourceFileName);
   147 
   143 
   148     CleanupStack::PopAndDestroy( fileParser ); // fileParser
   144     CleanupStack::PopAndDestroy( fileParser ); // fileParser 
   149     fileParser = NULL;
   145     fileParser = NULL;
   150 
   146 
   151     AddDefaultIconsL();
   147     AddDefaultIconsL();
   152 
   148 
   153     CLOG_LEAVEFN("CDownloadsListArray::ConstructL");
   149     CLOG_LEAVEFN("CDownloadsListArray::ConstructL");
   181     {
   177     {
   182         iListBoxIconArray->ResetAndDestroy();
   178         iListBoxIconArray->ResetAndDestroy();
   183         delete iListBoxIconArray;
   179         delete iListBoxIconArray;
   184         iListBoxIconArray = 0;
   180         iListBoxIconArray = 0;
   185     }
   181     }
   186 
   182     
   187 
   183       
   188     delete iUiDataArray;
   184     delete iUiDataArray;
   189     iUiDataArray = 0;
   185     iUiDataArray = 0;
   190     delete iDownloadArray;
   186     delete iDownloadArray;
   191     iDownloadArray = 0;
   187     iDownloadArray = 0;
   192     delete iCompletedString;
   188     delete iCompletedString;
   193     iCompletedString = 0;
   189     iCompletedString = 0;
   194 	delete iSavedToGalleryString;
   190 	delete iSavedToGalleryString;
   195 	iSavedToGalleryString = 0;
   191 	iSavedToGalleryString = 0;
   196 	delete iSavedToDownloadsFolderString;
   192 	delete iSavedToDownloadsFolderString;
   197 	iSavedToDownloadsFolderString=0;
   193 	iSavedToDownloadsFolderString=0;
   198 
   194 	
   199 	#ifndef BRDO_APP_GALLERY_SUPPORTED_FF
   195 	#ifndef BRDO_APP_GALLERY_SUPPORTED_FF
   200 	    delete iFileSavedString;
   196 	    delete iFileSavedString;
   201 	    iFileSavedString = 0;
   197 	    iFileSavedString = 0;
   202 	    delete iFilesSavedString;
   198 	    delete iFilesSavedString;
   203 	    iFilesSavedString = 0;
   199 	    iFilesSavedString = 0;
   204 	#endif
   200 	#endif
   205 
   201 	
   206     delete iNullDesC;
   202     delete iNullDesC;
   207     iNullDesC = 0;
   203     iNullDesC = 0;
   208     iApaLsSess.Close();
   204     iApaLsSess.Close();
   209     CLOG_WRITE(" iApaLsSess.Close");
   205     CLOG_WRITE(" iApaLsSess.Close");
   210     delete iMbmResourceFileName;
   206     delete iMbmResourceFileName;
   231 TInt CDownloadsListArray::AppendL
   227 TInt CDownloadsListArray::AppendL
   232     ( const TDownloadUiData& aDownloadUiData, const RHttpDownload& aDownload )
   228     ( const TDownloadUiData& aDownloadUiData, const RHttpDownload& aDownload )
   233     {
   229     {
   234     TInt itemIndex( KErrNotFound );
   230     TInt itemIndex( KErrNotFound );
   235 
   231 
   236     __ASSERT_DEBUG( Find( aDownload, itemIndex ) == KErrNotFound,
   232     __ASSERT_DEBUG( Find( aDownload, itemIndex ) == KErrNotFound, 
   237                     Panic( EUiLibPanAlreadyExistWhenAppend ) );
   233                     Panic( EUiLibPanAlreadyExistWhenAppend ) );
   238 
   234 
   239     #ifdef _DEBUG
   235     #ifdef _DEBUG
   240     TInt findErr = Find( aDownload, itemIndex ) ;
   236     TInt findErr = Find( aDownload, itemIndex ) ;
   241     CLOG_WRITE_FORMAT(" findErr: %d",findErr);
   237     CLOG_WRITE_FORMAT(" findErr: %d",findErr);
   242     CLOG_WRITE_FORMAT(" itemIndex: %d",itemIndex);
   238     CLOG_WRITE_FORMAT(" itemIndex: %d",itemIndex);
   243     #endif // _DEBUG
   239     #endif // _DEBUG
   244 
   240     
   245     // Append at the end:
   241     // Append at the end:
   246     // Reserve space in order that appending to all the arrays be atomic.
   242     // Reserve space in order that appending to all the arrays be atomic.
   247     // Use iListBoxTextArray->Count() for SetReserveL, because thus we can
   243     // Use iListBoxTextArray->Count() for SetReserveL, because thus we can 
   248     // eliminate that subsequent SetReserveL reserve unnecessary
   244     // eliminate that subsequent SetReserveL reserve unnecessary 
   249     // place if iListBoxTextArray->AppendL() LEAVEs.
   245     // place if iListBoxTextArray->AppendL() LEAVEs.
   250     iDownloadArray->SetReserveL( iListBoxTextArray->Count() + 1 );
   246     iDownloadArray->SetReserveL( iListBoxTextArray->Count() + 1 );
   251     iUiDataArray->SetReserveL( iListBoxTextArray->Count() + 1 );
   247     iUiDataArray->SetReserveL( iListBoxTextArray->Count() + 1 );
   252     iListBoxTextArray->AppendL( LBTextFromUiData( aDownloadUiData ) );
   248     iListBoxTextArray->AppendL( LBTextFromUiData( aDownloadUiData ) );
   253     // iListBoxTextArray->AppendL did not leave and the following
   249     // iListBoxTextArray->AppendL did not leave and the following 
   254     // will not leave, because of SetReserveL()'s:
   250     // will not leave, because of SetReserveL()'s:
   255     iDownloadArray->AppendL( (RHttpDownload*)&aDownload );
   251     iDownloadArray->AppendL( (RHttpDownload*)&aDownload );
   256     iUiDataArray->AppendL( aDownloadUiData );
   252     iUiDataArray->AppendL( aDownloadUiData );
   257     itemIndex = Count() - 1;
   253     itemIndex = Count() - 1;
   258 
   254 
   264 // -----------------------------------------------------------------------------
   260 // -----------------------------------------------------------------------------
   265 //
   261 //
   266 void CDownloadsListArray::UpdateL( TInt aIndex, const TDownloadUiData& aDownloadUiData )
   262 void CDownloadsListArray::UpdateL( TInt aIndex, const TDownloadUiData& aDownloadUiData )
   267     {
   263     {
   268     // Two steps: update UI data and the list item text.
   264     // Two steps: update UI data and the list item text.
   269     // Because updating the list text array can leave and the two
   265     // Because updating the list text array can leave and the two 
   270     // array must be consistent, this operation must be atomic, this is
   266     // array must be consistent, this operation must be atomic, this is 
   271     // why we apply the operations in the following order:
   267     // why we apply the operations in the following order:
   272     // Insert the new text, and when it succeeds, remove the old (which is shifted).
   268     // Insert the new text, and when it succeeds, remove the old (which is shifted).
   273     // No need to modify iDownloadArray, because that does not change.
   269     // No need to modify iDownloadArray, because that does not change.
   274     iListBoxTextArray->InsertL( aIndex, LBTextFromUiData( aDownloadUiData ) );
   270     iListBoxTextArray->InsertL( aIndex, LBTextFromUiData( aDownloadUiData ) );
   275     iListBoxTextArray->Delete( (aIndex+1) ); // Old item was shifted.
   271     iListBoxTextArray->Delete( (aIndex+1) ); // Old item was shifted.
   301 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   302 //
   298 //
   303 void CDownloadsListArray::Delete( TInt aIndex )
   299 void CDownloadsListArray::Delete( TInt aIndex )
   304     {
   300     {
   305     // Delete the indicated record from all arrays:
   301     // Delete the indicated record from all arrays:
   306 
   302     
   307     iDownloadArray->Delete( aIndex );
   303     iDownloadArray->Delete( aIndex );
   308     iUiDataArray->Delete( aIndex );
   304     iUiDataArray->Delete( aIndex );
   309     iListBoxTextArray->Delete( aIndex );
   305     iListBoxTextArray->Delete( aIndex );
   310 
   306 
   311     iDownloadArray->Compress();
   307     iDownloadArray->Compress();
   355     TInt spaceNeeded = LBTextLength( aDownloadUiData );
   351     TInt spaceNeeded = LBTextLength( aDownloadUiData );
   356 
   352 
   357     // Realloc a bigger buffer if needed
   353     // Realloc a bigger buffer if needed
   358     if ( iNewItemText && ( spaceNeeded <= iNewItemText->Length() ) )
   354     if ( iNewItemText && ( spaceNeeded <= iNewItemText->Length() ) )
   359         {
   355         {
   360         // No need to reallocate a bigger buffer.
   356         // No need to reallocate a bigger buffer. 
   361         // The existing iNewItemText will be good.
   357         // The existing iNewItemText will be good. 
   362         }
   358         }
   363     else
   359     else
   364         {
   360         {
   365         // Allocate a new (bigger) buffer (delete the old)
   361         // Allocate a new (bigger) buffer (delete the old)
   366         delete iNewItemText;
   362         delete iNewItemText;
   367         iNewItemText = 0;
   363         iNewItemText = 0;
   368         iNewItemText = HBufC::New( spaceNeeded );
   364         iNewItemText = HBufC::New( spaceNeeded );
   369         }
   365         }
   370 
   366     
   371     // Non-leaving function - couldn't call NewL!
   367     // Non-leaving function - couldn't call NewL!
   372     if ( iNewItemText )
   368     if ( iNewItemText )
   373         {
   369         {
   374         TPtr newItemTextPtr = iNewItemText->Des();
   370         TPtr newItemTextPtr = iNewItemText->Des();
   375         newItemTextPtr.SetLength( 0 );
   371         newItemTextPtr.SetLength( 0 );
   376         //
   372         //        
   377         iTempBuf.Zero();
   373         iTempBuf.Zero();
   378         iTempBuf.Num( aDownloadUiData.iIconIndex );
   374         iTempBuf.Num( aDownloadUiData.iIconIndex );
   379         newItemTextPtr.Append( iTempBuf ); // Add icon array index
   375         newItemTextPtr.Append( iTempBuf ); // Add icon array index
   380         newItemTextPtr.Append( KCharTab );
   376         newItemTextPtr.Append( KCharTab );
   381         //
   377         //
   386         else
   382         else
   387             {
   383             {
   388             newItemTextPtr.Append( KNullDesC );
   384             newItemTextPtr.Append( KNullDesC );
   389             }
   385             }
   390         newItemTextPtr.Append( KCharTab );
   386         newItemTextPtr.Append( KCharTab );
   391 
   387         
   392         // If its album download, format display string cur track/total tracks
   388         // If its album download, format display string cur track/total tracks
   393 
   389        
   394         if ((aDownloadUiData.iNumMediaObjects > 1) &&
   390         if ((aDownloadUiData.iNumMediaObjects > 1) &&
   395             (EHttpDlMultipleMOCompleted != aDownloadUiData.iDownloadState))
   391             (EHttpDlMultipleMOCompleted != aDownloadUiData.iDownloadState))
   396             {
   392             {
   397             TBuf<KMaxIndexStringLength> indexStr;
   393             TBuf<KMaxIndexStringLength> indexStr;
   398             indexStr.Format( KIndexString, aDownloadUiData.iActiveMoIndex, aDownloadUiData.iNumMediaObjects );
   394             indexStr.Format( KIndexString, aDownloadUiData.iActiveMoIndex, aDownloadUiData.iNumMediaObjects );
   399             newItemTextPtr.Append( indexStr );
   395             newItemTextPtr.Append( indexStr ); 
   400             }
   396             }
   401 
   397                     
   402         iProgressInfoRes.Zero();
   398         iProgressInfoRes.Zero();
   403 
   399 
   404 		if ( aDownloadUiData.iDownloadState == EHttpDlMultipleMOCompleted )
   400 		if ( aDownloadUiData.iDownloadState == EHttpDlMultipleMOCompleted ) 
   405 		    {
   401 		    { 
   406  		    if ( aDownloadUiData.iProgressState == EHttpProgContentFileMoved || aDownloadUiData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
   402  		    if ( aDownloadUiData.iProgressState == EHttpProgContentFileMoved || aDownloadUiData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
   407 			    {
   403 			    {
   408 			    if ( iPlatformSupportsGallery )
   404 			    if ( iPlatformSupportsGallery )
   409 			        {
   405 			        {
   410 			    	TBool supported( EFalse );
   406 			    	TBool supported( EFalse );
   411                     TRAP_IGNORE(supported = IsSupportedL(aDownloadUiData));
   407                     TRAP_IGNORE(supported = IsSupportedL(aDownloadUiData)); 
   412  				    if( supported )
   408  				    if( supported )
   413 				        {
   409 				        {
   414 				        iProgressInfoRes.Copy
   410 				        iProgressInfoRes.Copy
   415 					                    ( iSavedToGalleryString->Left( KMaxDownloadItemTextPartLength ) );
   411 					                    ( iSavedToGalleryString->Left( KMaxDownloadItemTextPartLength ) );				    
   416 				        }
   412 				        }
   417 				    else
   413 				    else
   418                         {
   414                         {
   419                 	    iProgressInfoRes.Copy
   415                 	    iProgressInfoRes.Copy
   420 			                            ( iSavedToDownloadsFolderString->Left( KMaxDownloadItemTextPartLength ) );
   416 			                            ( iSavedToDownloadsFolderString->Left( KMaxDownloadItemTextPartLength ) );                      
   421                         }
   417                         }
   422 			        }
   418 			        }
   423 			    else
   419 			    else
   424 			        {
   420 			        {
   425 			        if (aDownloadUiData.iNumMediaObjects > 1)
   421 			        if (aDownloadUiData.iNumMediaObjects > 1)
   426 			            {
   422 			            {
   427 			        	iProgressInfoRes.Copy
   423 			        	iProgressInfoRes.Copy
   428 			                            ( iFilesSavedString->Left( KMaxDownloadItemTextPartLength ) );
   424 			                            ( iFilesSavedString->Left( KMaxDownloadItemTextPartLength ) );                      
   429 			            }
   425 			            }
   430 			        else
   426 			        else
   431 			            {
   427 			            {
   432 			        	iProgressInfoRes.Copy
   428 			        	iProgressInfoRes.Copy
   433 			                            ( iFileSavedString->Left( KMaxDownloadItemTextPartLength ) );
   429 			                            ( iFileSavedString->Left( KMaxDownloadItemTextPartLength ) );                      
   434 			            }
   430 			            }     
   435                     }
   431                     }    
   436 			    }
   432 			    }				
   437 	        else
   433 	        else
   438     	        {
   434     	        {
   439                 iProgressInfoRes.Copy
   435                 iProgressInfoRes.Copy
   440 		    	        ( iCompletedString->Left( KMaxDownloadItemTextPartLength ) );
   436 		    	        ( iCompletedString->Left( KMaxDownloadItemTextPartLength ) );  	
   441 				}
   437 				}
   442 			}
   438 			}
   443         else
   439         else
   444             {
   440             {
   445             if ( aDownloadUiData.iFullSize <= 0 )
   441             if ( aDownloadUiData.iFullSize <= 0 )
   446                 {
   442                 {
   447                 iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize,
   443                 iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize, 
   448                                                     iProgressInfoRes );
   444                                                     iProgressInfoRes );
   449                 }
   445                 }
   450             else
   446             else
   451                 {
   447                 {
   452                 iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize,
   448                 iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize, 
   453                                                     aDownloadUiData.iFullSize,
   449                                                     aDownloadUiData.iFullSize, 
   454                                                     iProgressInfoRes );
   450                                                     iProgressInfoRes );
   455                 }
   451                 }
   456             }
   452             }
   457         //
   453         //
   458         newItemTextPtr.Append( iProgressInfoRes );
   454         newItemTextPtr.Append( iProgressInfoRes );
   459         newItemTextPtr.Append( KCharTab );
   455         newItemTextPtr.Append( KCharTab );
   460         //
   456         //
   461         if ( aDownloadUiData.iDownloadState == EHttpDlCreated || // User must be able to start it via Resume.
   457         if ( aDownloadUiData.iDownloadState == EHttpDlCreated || // User must be able to start it via Resume.
   462              aDownloadUiData.iDownloadState == EHttpDlPaused ||
   458              aDownloadUiData.iDownloadState == EHttpDlPaused || 
   463              aDownloadUiData.iDownloadState == EHttpDlMultipleMOFailed ) // User must be able to restart it.
   459              aDownloadUiData.iDownloadState == EHttpDlMultipleMOFailed ) // User must be able to restart it.
   464             {
   460             {
   465             // Add a "Paused" icon.
   461             // Add a "Paused" icon.
   466             iTempBuf.Zero();
   462             iTempBuf.Zero();
   467             iTempBuf.Num( iPausedIconIndex );
   463             iTempBuf.Num( iPausedIconIndex );
   468             newItemTextPtr.Append( iTempBuf ); // iPausedIconIndex in literal form
   464             newItemTextPtr.Append( iTempBuf ); // iPausedIconIndex in literal form
   469             }
   465             }
   470         newItemTextPtr.Append( KCharTab );
   466         newItemTextPtr.Append( KCharTab );
   471         //
   467         //
   472         if ( aDownloadUiData.iIsOnExternalMemory )
   468         if ( KDriveAttLocal != aDownloadUiData.iExternalMemoryStatus )	
   473             {
   469             {
   474             // Add an "External memory" icon.
   470             // Add an "External memory" icon.
   475             iTempBuf.Zero();
   471             iTempBuf.Zero();
   476             iTempBuf.Num( iExternalMemoryIconIndex );
   472             if ( KDriveAttRemovable == aDownloadUiData.iExternalMemoryStatus )
       
   473                 iTempBuf.Num( iExternalMemoryIconIndex );
       
   474             else
       
   475                 iTempBuf.Num( iInternalMassMemoryIconIndex );
   477             newItemTextPtr.Append( iTempBuf ); // iExternalMemoryIconIndex in literal form
   476             newItemTextPtr.Append( iTempBuf ); // iExternalMemoryIconIndex in literal form
   478             }
   477             }
   479         }
   478         }
   480     return iNewItemText ? (TPtrC)*iNewItemText : (TPtrC)*iNullDesC;
   479     return iNewItemText ? (TPtrC)*iNewItemText : (TPtrC)*iNullDesC;
   481     }
   480     }
   486 // -----------------------------------------------------------------------------
   485 // -----------------------------------------------------------------------------
   487 //
   486 //
   488 TInt CDownloadsListArray::LBTextLength( const TDownloadUiData& aDownloadUiData )
   487 TInt CDownloadsListArray::LBTextLength( const TDownloadUiData& aDownloadUiData )
   489     {
   488     {
   490     TInt ret(0);
   489     TInt ret(0);
   491 
   490     
   492     iTempBuf.Zero();
   491     iTempBuf.Zero();
   493     iTempBuf.Num( aDownloadUiData.iIconIndex );
   492     iTempBuf.Num( aDownloadUiData.iIconIndex );
   494     ret += iTempBuf.Length();
   493     ret += iTempBuf.Length();
   495     ret += KCharTab().Length();
   494     ret += KCharTab().Length();
   496     ret += aDownloadUiData.iName.Length();
   495     ret += aDownloadUiData.iName.Length();
   497     ret += KCharTab().Length();
   496     ret += KCharTab().Length();
   498 
   497     
   499     if( aDownloadUiData.iNumMediaObjects > 1 )
   498     if( aDownloadUiData.iNumMediaObjects > 1 )
   500         {
   499         {
   501         TBuf<KMaxIndexStringLength> indexStr;
   500         TBuf<KMaxIndexStringLength> indexStr;
   502         indexStr.Format( KIndexString, aDownloadUiData.iActiveMoIndex, aDownloadUiData.iNumMediaObjects );
   501         indexStr.Format( KIndexString, aDownloadUiData.iActiveMoIndex, aDownloadUiData.iNumMediaObjects );
   503         ret += indexStr.Length();
   502         ret += indexStr.Length();
   504         }
   503         }
   505 
   504        
   506     iProgressInfoRes.Zero();
   505     iProgressInfoRes.Zero();
   507 	if ( aDownloadUiData.iDownloadState == EHttpDlMultipleMOCompleted )
   506 	if ( aDownloadUiData.iDownloadState == EHttpDlMultipleMOCompleted ) 
   508 	    {
   507 	    { 
   509 		if ( aDownloadUiData.iProgressState == EHttpProgContentFileMoved || aDownloadUiData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
   508 		if ( aDownloadUiData.iProgressState == EHttpProgContentFileMoved || aDownloadUiData.iProgressState == EHttpProgContentFileMovedAndDestFNChanged )
   510 		    {
   509 		    {
   511 		    if ( iPlatformSupportsGallery )
   510 		    if ( iPlatformSupportsGallery )
   512 		        {
   511 		        {
   513 		        TBool supported( EFalse );
   512 		        TBool supported( EFalse );
   514                 TRAP_IGNORE(supported=IsSupportedL(aDownloadUiData));
   513                 TRAP_IGNORE(supported=IsSupportedL(aDownloadUiData));  
   515 		        if( supported )
   514 		        if( supported )
   516 		            {
   515 		            {
   517 		            iProgressInfoRes.Copy
   516 		            iProgressInfoRes.Copy
   518 				                    ( iSavedToGalleryString->Left( KMaxDownloadItemTextPartLength ) );
   517 				                    ( iSavedToGalleryString->Left( KMaxDownloadItemTextPartLength ) );
   519 		            }
   518 		            }
   520 		        else
   519 		        else
   521 		            {
   520 		            {
   522             	    iProgressInfoRes.Copy
   521             	    iProgressInfoRes.Copy
   523 			                        ( iSavedToDownloadsFolderString->Left( KMaxDownloadItemTextPartLength ) );
   522 			                        ( iSavedToDownloadsFolderString->Left( KMaxDownloadItemTextPartLength ) );  
   524 		            }
   523 		            }
   525 		        }
   524 		        }
   526 		    else
   525 		    else
   527 		        {
   526 		        {
   528 		        if (aDownloadUiData.iNumMediaObjects > 1)
   527 		        if (aDownloadUiData.iNumMediaObjects > 1)
   529 			        {
   528 			        {
   530 			        iProgressInfoRes.Copy
   529 			        iProgressInfoRes.Copy
   531 			                        ( iFilesSavedString->Left( KMaxDownloadItemTextPartLength ) );
   530 			                        ( iFilesSavedString->Left( KMaxDownloadItemTextPartLength ) );                      
   532 			        }
   531 			        }
   533 			    else
   532 			    else
   534 			        {
   533 			        {
   535 			       	iProgressInfoRes.Copy
   534 			       	iProgressInfoRes.Copy
   536 			                        ( iFileSavedString->Left( KMaxDownloadItemTextPartLength ) );
   535 			                        ( iFileSavedString->Left( KMaxDownloadItemTextPartLength ) );                      
   537 			        }
   536 			        }    
   538 		        }
   537 		        }    
   539 			}
   538 			}
   540 		else
   539 		else
   541 		    {
   540 		    {
   542             iProgressInfoRes.Copy
   541             iProgressInfoRes.Copy
   543 			                 ( iCompletedString->Left( KMaxDownloadItemTextPartLength ) );
   542 			                 ( iCompletedString->Left( KMaxDownloadItemTextPartLength ) );  	
   544 		    }
   543 		    }
   545         }
   544         }
   546      //finished  here
   545      //finished  here   
   547     else
   546     else
   548         {
   547         {
   549         if ( aDownloadUiData.iFullSize <= 0 )
   548         if ( aDownloadUiData.iFullSize <= 0 )
   550             {
   549             {
   551             iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize,
   550             iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize, 
   552                                                 iProgressInfoRes );
   551                                                 iProgressInfoRes );
   553             }
   552             }
   554         else
   553         else
   555             {
   554             {
   556             iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize,
   555             iProgressInfoCreator->ProgressInfo( aDownloadUiData.iDownloadedSize, 
   557                                                 aDownloadUiData.iFullSize,
   556                                                 aDownloadUiData.iFullSize, 
   558                                                 iProgressInfoRes );
   557                                                 iProgressInfoRes );
   559             }
   558             }
   560         }
   559         }
   561     ret += iProgressInfoRes.Length();
   560     ret += iProgressInfoRes.Length();
   562     ret += KCharTab().Length();
   561     ret += KCharTab().Length();
   563     //
   562     //
   564     if ( aDownloadUiData.iDownloadState == EHttpDlCreated || // User must be able to start it via Resume.
   563     if ( aDownloadUiData.iDownloadState == EHttpDlCreated || // User must be able to start it via Resume.
   565          aDownloadUiData.iDownloadState == EHttpDlPaused ||
   564          aDownloadUiData.iDownloadState == EHttpDlPaused || 
   566          aDownloadUiData.iDownloadState == EHttpDlMultipleMOFailed ) // User must be able to restart it.
   565          aDownloadUiData.iDownloadState == EHttpDlMultipleMOFailed ) // User must be able to restart it.
   567         {
   566         {
   568         iTempBuf.Zero();
   567         iTempBuf.Zero();
   569         iTempBuf.Num( iPausedIconIndex );
   568         iTempBuf.Num( iPausedIconIndex );
   570         ret += iTempBuf.Length();
   569         ret += iTempBuf.Length();
   571         }
   570         }
   572     //
   571     //
   573     ret += KCharTab().Length();
   572     ret += KCharTab().Length();
   574     //
   573     //
   575     if ( aDownloadUiData.iIsOnExternalMemory )
   574     if ( KDriveAttLocal != aDownloadUiData.iExternalMemoryStatus )
   576         {
   575         {
   577         iTempBuf.Zero();
   576         iTempBuf.Zero();
   578         iTempBuf.Num( iExternalMemoryIconIndex );
   577         if ( KDriveAttRemovable == aDownloadUiData.iExternalMemoryStatus )
       
   578             iTempBuf.Num( iExternalMemoryIconIndex );
       
   579         else
       
   580             iTempBuf.Num( iInternalMassMemoryIconIndex );
   579         ret += iTempBuf.Length();
   581         ret += iTempBuf.Length();
   580         }
   582         }
   581 
   583 
   582 
   584 
   583     return ret;
   585     return ret;
   584     }
   586     }
   585 
   587     
   586 // -----------------------------------------------------------------------------
   588 // -----------------------------------------------------------------------------
   587 // CDownloadsListArray::AddDefaultIconsL
   589 // CDownloadsListArray::AddDefaultIconsL
   588 // -----------------------------------------------------------------------------
   590 // -----------------------------------------------------------------------------
   589 //
   591 //
   590 void CDownloadsListArray::AddDefaultIconsL()
   592 void CDownloadsListArray::AddDefaultIconsL()
   591     {
   593     {
   592     CLOG_ENTERFN("CDownloadsListArray::AddDefaultIconsL");
   594     CLOG_ENTERFN("CDownloadsListArray::AddDefaultIconsL");
   593 
   595     
   594     // iPausedIconIndex
   596     // iPausedIconIndex
   595     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
   597     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
   596     TAknsItemID id = KAknsIIDQgnIndiPaused;
   598     TAknsItemID id = KAknsIIDQgnIndiPaused;
   597     CGulIcon* gulIcon = AknsUtils::CreateGulIconL( skins, id,
   599     CGulIcon* gulIcon = AknsUtils::CreateGulIconL( skins, id, 
   598                                    *iMbmResourceFileName,
   600                                    *iMbmResourceFileName, 
   599                                    EMbmDownloadmgruilibQgn_indi_paused,
   601                                    EMbmDownloadmgruilibQgn_indi_paused, 
   600                                    EMbmDownloadmgruilibQgn_indi_paused_mask );
   602                                    EMbmDownloadmgruilibQgn_indi_paused_mask );
   601     CleanupStack::PushL( gulIcon );
   603     CleanupStack::PushL( gulIcon );
   602 
   604 
   603     iPausedIconIndex = AppendL( gulIcon );
   605     iPausedIconIndex = AppendL( gulIcon );
   604     CLOG_WRITE_FORMAT(" iPausedIconIndex: %d",iPausedIconIndex);
   606     CLOG_WRITE_FORMAT(" iPausedIconIndex: %d",iPausedIconIndex);
   605 
   607 
   606     CleanupStack::Pop( gulIcon ); // gulIcon
   608     CleanupStack::Pop( gulIcon ); // gulIcon
   607 
   609 
   608     // iExternalMemoryIconIndex
   610     // iExternalMemoryIconIndex
   609     TAknsItemID id2 = KAknsIIDQgnIndiBrowserMmcAdd;
   611     TAknsItemID id2 = KAknsIIDQgnIndiBrowserMmcAdd;
   610     CGulIcon* gulIcon2 = AknsUtils::CreateGulIconL( skins, id2,
   612     CGulIcon* gulIcon2 = AknsUtils::CreateGulIconL( skins, id2, 
   611                                    *iMbmResourceFileName,
   613                                    *iMbmResourceFileName, 
   612                                    EMbmDownloadmgruilibQgn_indi_browser_mmc_add,
   614                                    EMbmDownloadmgruilibQgn_indi_browser_mmc_add, 
   613                                    EMbmDownloadmgruilibQgn_indi_browser_mmc_add_mask );
   615                                    EMbmDownloadmgruilibQgn_indi_browser_mmc_add_mask );
   614     CleanupStack::PushL( gulIcon2 );
   616     CleanupStack::PushL( gulIcon2 );
   615 
   617 
   616     iExternalMemoryIconIndex = AppendL( gulIcon2 );
   618     iExternalMemoryIconIndex = AppendL( gulIcon2 );
   617     CLOG_WRITE_FORMAT(" iExternalMemoryIconIndex: %d",iExternalMemoryIconIndex);
   619     CLOG_WRITE_FORMAT(" iExternalMemoryIconIndex: %d",iExternalMemoryIconIndex);
   618 
   620 
   619     CleanupStack::Pop( gulIcon2 ); // gulIcon2
   621     CleanupStack::Pop( gulIcon2 ); // gulIcon2
   620 
   622     
       
   623     // iInternalMassMemoryIconIndex
       
   624     TAknsItemID id3 = KAknsIIDQgnPropMemcMsTab;
       
   625     CGulIcon* gulIcon3 = AknsUtils::CreateGulIconL( skins, id3, 
       
   626                                    *iMbmResourceFileName, 
       
   627                                    EMbmDownloadmgruilibQgn_prop_memc_ms_tab, 
       
   628                                    EMbmDownloadmgruilibQgn_prop_memc_ms_tab_mask );
       
   629     CleanupStack::PushL( gulIcon3 );
       
   630 
       
   631     iInternalMassMemoryIconIndex = AppendL( gulIcon3 );
       
   632     CLOG_WRITE_FORMAT(" iExternalMemoryIconIndex: %d",iInternalMassMemoryIconIndex);
       
   633 
       
   634     CleanupStack::Pop( gulIcon3 ); // gulIcon3    
       
   635     
   621     CLOG_LEAVEFN("CDownloadsListArray::AddDefaultIconsL");
   636     CLOG_LEAVEFN("CDownloadsListArray::AddDefaultIconsL");
   622     }
   637     }
   623 
   638 
   624 // -----------------------------------------------------------------------------
   639 // -----------------------------------------------------------------------------
   625 // CDownloadsListArray::AddHandlerAppIconL
   640 // CDownloadsListArray::AddHandlerAppIconL
   632     // Find the appropriate application that we associate with the content type
   647     // Find the appropriate application that we associate with the content type
   633     TUid appUid( TUid::Uid(0) );
   648     TUid appUid( TUid::Uid(0) );
   634     TBool appFound = FindHandlerApp( aContentType, appUid );
   649     TBool appFound = FindHandlerApp( aContentType, appUid );
   635     CLOG_WRITE_FORMAT(" appFound: %d",appFound);
   650     CLOG_WRITE_FORMAT(" appFound: %d",appFound);
   636 
   651 
   637     // Use Media Gallery's icon instead of Image Viewer, because IV's icon
   652     // Use Media Gallery's icon instead of Image Viewer, because IV's icon 
   638     // does not support skins, but MG's icon does support it.
   653     // does not support skins, but MG's icon does support it.
   639 
   654     
   640 
   655   
   641 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
   656 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF    
   642 
   657 
   643     if ( appFound && appUid == TUid::Uid(KImageViewerHandler) )
   658     if ( appFound && appUid == TUid::Uid(KImageViewerHandler) )
   644         {
   659         {
   645         appUid = TUid::Uid(KMediaGalleryUID3);
   660         appUid = TUid::Uid(KMediaGalleryUID3);
   646         }
   661         }
   685 
   700 
   686 // -----------------------------------------------------------------------------
   701 // -----------------------------------------------------------------------------
   687 // CDownloadsListArray::LoadAppIconLC
   702 // CDownloadsListArray::LoadAppIconLC
   688 // -----------------------------------------------------------------------------
   703 // -----------------------------------------------------------------------------
   689 //
   704 //
   690 void CDownloadsListArray::LoadAppIconLC( TUid aAppUid,
   705 void CDownloadsListArray::LoadAppIconLC( TUid aAppUid, 
   691                                          CFbsBitmap*& aBitmap,
   706                                          CFbsBitmap*& aBitmap, 
   692                                          CFbsBitmap*& aMask )
   707                                          CFbsBitmap*& aMask )
   693     {
   708     {
   694     CLOG_ENTERFN("CDownloadsListArray::LoadAppIconLC");
   709     CLOG_ENTERFN("CDownloadsListArray::LoadAppIconLC");
   695 
   710 
   696     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
   711     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
   697     TAknsItemID id;
   712     TAknsItemID id;
   698 
   713 
   699     if ( aAppUid == TUid::Uid(0) )
   714     if ( aAppUid == TUid::Uid(0) )
   700         {
   715         {
   701         // Indicate that the content is unsupported, that is no
   716         // Indicate that the content is unsupported, that is no 
   702         // viewer application that could handle the content.
   717         // viewer application that could handle the content.
   703         id = KAknsIIDQgnMenuUnknownLst;
   718         id = KAknsIIDQgnMenuUnknownLst;
   704         AknsUtils::CreateIconLC( skins, id, aBitmap, aMask,
   719         AknsUtils::CreateIconLC( skins, id, aBitmap, aMask, 
   705                                  *iMbmResourceFileName,
   720                                  *iMbmResourceFileName, 
   706                                  EMbmDownloadmgruilibQgn_menu_unknown_lst,
   721                                  EMbmDownloadmgruilibQgn_menu_unknown_lst, 
   707                                  EMbmDownloadmgruilibQgn_menu_unknown_lst_mask );
   722                                  EMbmDownloadmgruilibQgn_menu_unknown_lst_mask );
   708         }
   723         }
   709     else
   724     else
   710         {
   725         {
   711         // Load the application's icon
   726         // Load the application's icon
   712         AknsUtils::CreateAppIconLC( skins, aAppUid,
   727         AknsUtils::CreateAppIconLC( skins, aAppUid, 
   713                                     EAknsAppIconTypeList,
   728                                     EAknsAppIconTypeList,
   714                                     aBitmap, aMask );
   729                                     aBitmap, aMask );
   715         }
   730         }
   716 
   731 
   717     CLOG_LEAVEFN("CDownloadsListArray::LoadAppIconLC");
   732     CLOG_LEAVEFN("CDownloadsListArray::LoadAppIconLC");
   718     }
   733     }
   719 
   734 
   720 
   735    
   721 
   736 
   722 TBool  CDownloadsListArray::IsSupportedL(const TDownloadUiData& aDownloadUiData)
   737 TBool  CDownloadsListArray::IsSupportedL(const TDownloadUiData& aDownloadUiData)
   723     {
   738     {
   724 
   739    
   725     TBool supported;
   740     TBool supported;  
   726     HBufC* fullName = HBufC::NewLC(KMaxFileName); //TODO: change len
   741     HBufC* fullName = HBufC::NewLC(KMaxFileName); //TODO: change len
   727     TPtr fileName( fullName->Des() );
   742     TPtr fileName( fullName->Des() );
   728     fileName.Append(aDownloadUiData.iName);
   743     fileName.Append(aDownloadUiData.iName);
   729     HBufC8* contentType = HBufC8::NewLC(KMaxPath);
   744     HBufC8* contentType = HBufC8::NewLC(KMaxPath);
   730     TPtr8 mimeTypePtr = contentType->Des();
   745     TPtr8 mimeTypePtr = contentType->Des();
   731     mimeTypePtr.Copy(aDownloadUiData.iContentType);
   746     mimeTypePtr.Copy(aDownloadUiData.iContentType);
   732     if(!mimeTypePtr.Compare(KSisFileMimeType))
   747     if(!mimeTypePtr.Compare(KSisFileMimeType))
   733         {
   748         {
   734             mimeTypePtr.Copy(KOctetStreamMimeType);
   749             mimeTypePtr.Copy(KOctetStreamMimeType);
   735         }
   750         }
   736     else if(!mimeTypePtr.Compare(KDrmMessageMimeType))
   751     else if(!mimeTypePtr.Compare(KDrmMessageMimeType)) 
   737         {
   752         {
   738             mimeTypePtr.Copy(KDrmMessageMimeTypeDrmDcf);
   753             mimeTypePtr.Copy(KDrmMessageMimeTypeDrmDcf);
   739         }
   754         }
   740     TDataType mimeSupported(mimeTypePtr);
   755     TDataType mimeSupported(mimeTypePtr);
   741     CDocumentHandler *docHandler=CDocumentHandler::NewLC();
   756     CDocumentHandler *docHandler=CDocumentHandler::NewLC();
   742     docHandler->CheckFileNameExtension(fileName, mimeSupported );
   757     docHandler->CheckFileNameExtension(fileName, mimeSupported );
   743     TRAPD(err,supported = docHandler->CanOpenL(mimeSupported));
   758     TRAPD(err,supported = docHandler->CanOpenL(mimeSupported));
   744     if(err == KMimeNotSupported || !(CDownloadUtils::IsGallerySupported(aDownloadUiData.iContentType)))
   759     if(err == KMimeNotSupported || !(CDownloadUtils::IsGallerySupported(aDownloadUiData.iContentType)))
   745         {
   760         {
   746             supported = EFalse;
   761             supported = EFalse;
   747 
   762             
   748         }
   763         }
   749     else
   764     else
   750         {
   765         {
   751             supported = ETrue;
   766             supported = ETrue;
   752         }
   767         }  
   753     CleanupStack::PopAndDestroy(docHandler);
   768     CleanupStack::PopAndDestroy(docHandler);
   754     CleanupStack::PopAndDestroy( contentType);
   769     CleanupStack::PopAndDestroy( contentType); 
   755     CleanupStack::PopAndDestroy(fullName);
   770     CleanupStack::PopAndDestroy(fullName);
   756     return supported;
   771     return supported;
   757 
   772         
   758     }
   773     }
   759 
   774 
   760 
   775 
   761 // End of file.
   776 // End of file.
   762 
   777 
       
   778