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