diff -r fcdfafb36fe7 -r aecbbf00d063 commonuis/CommonDialogs/src/CAknFileSelectionModel.cpp --- a/commonuis/CommonDialogs/src/CAknFileSelectionModel.cpp Thu Aug 19 10:11:06 2010 +0300 +++ b/commonuis/CommonDialogs/src/CAknFileSelectionModel.cpp Tue Aug 31 15:28:30 2010 +0300 @@ -31,21 +31,29 @@ #include "MAknFileFilter.h" #include "AknCFDUtility.h" #include "CAknDataCagingFilter.h" -#include "commondialogsdata.hrh" + // CONSTANTS -_LIT( KImageHeader, "%d\t" ); -const TInt KFileExtNameSize = 10; const TInt KEntryArrayGranularity( 10 ); const TInt KFilterArrayGranularity( 2 ); -const TInt KIndexDataLen = 6; -// Store file ext name and right icon index -class TCFDFileTypes - { -public: - TBuf iFileType; - TInt iIconIndex; - }; +_LIT( KCFDMimeTypeImage, "image/*" ); +_LIT( KCFDMimeTypeImageGms, "image/x-ota-bitmap" ); +_LIT( KCFDMimeTypeRam, "audio/x-pn-realaudio-plugin" ); // = link +_LIT( KCFDMimeTypeAudioVoiceRec, "audio/amr*" ); +_LIT( KCFDMimeTypeAudioVoiceRec2, "application/vnd.nokia.ringing-tone" ); +_LIT( KCFDMimeTypeAudio, "audio/*" ); // = other sound files +_LIT( KCFDMimeTypePlaylist, "audio/*mpegurl*" ); +_LIT( KCFDMimeTypeVideo, "video/*" ); +_LIT( KCFDMimeTypeVideoRealMedia, "application/*n-realmedia" ); +_LIT( KCFDMimeTypeVideoSdp, "application/sdp" ); +_LIT( KCFDMimeTypeGame, "application/*game*" ); +_LIT( KCFDMimeTypeNote, "text/*" ); +_LIT( KCFDMimeTypeJava, "application/java-archive" ); +_LIT( KCFDMimeTypeFlash, "application/x-shockwave-flash" ); + +_LIT( KCFDFileExtSis, ".sis" ); +_LIT( KCFDFileExtSisx, ".sisx"); +_LIT( KCFDFileExtMid, ".mid" ); // ============================ MEMBER FUNCTIONS =============================== @@ -57,7 +65,8 @@ // CAknFileSelectionModel::CAknFileSelectionModel( const TCommonDialogType& aDialogType, CCoeEnv& aCoeEnv ) - : iDirectoryLevel( 0 ), + : iImageIndexArray( KEntryArrayGranularity ), + iDirectoryLevel( 0 ), iDialogType( aDialogType ), iCoeEnv( aCoeEnv ) { @@ -70,47 +79,19 @@ // void CAknFileSelectionModel::ConstructL() { + User::LeaveIfError( iApaSession.Connect() ); iLocalizer = CDirectoryLocalizer::NewL(); iEntryArray = new( ELeave ) CArrayPakFlat( KEntryArrayGranularity ); iFilterArray = new( ELeave ) CArrayPtrSeg( KFilterArrayGranularity ); - iFileTypeArray = new ( ELeave ) CArrayFixFlat( KEntryArrayGranularity ); - - // Directories should be shown in front of files in list, - // create two arrays to save it respectively - iLocalFileNameArray = new ( ELeave ) CDesC16ArraySeg( KEntryArrayGranularity ); - iLocalDirNameArray = new ( ELeave ) CDesC16ArraySeg( KEntryArrayGranularity ); - - TResourceReader reader; - iCoeEnv.CreateResourceReaderLC( reader, R_CDF_FILE_TYPE_ICON_SET ); - ReadFileExtNameAndIconIndexL( reader ); - CleanupStack::PopAndDestroy();//reader - - iStringBuf = HBufC::NewL(KMaxPath); - + iItemWithImageIndex = HBufC::NewL(KMaxPath); User::LeaveIfError( iFs.Connect() ); iRootFolderText = iCoeEnv.AllocReadResourceL( R_CFD_QTN_FLDR_ROOT_LEVEL ); + AddFilterL( CAknDataCagingFilter::NewLC() ); CleanupStack::Pop(); //caging filter } // ----------------------------------------------------------------------------- -// CAknFileSelectionModel::ReadFileExtNameAndIconIndexL -// -// ----------------------------------------------------------------------------- -// -void CAknFileSelectionModel::ReadFileExtNameAndIconIndexL( TResourceReader& aReader ) - { - // File icon will be selected by file extname. - TInt count( aReader.ReadInt16() ); - for ( TInt i = 0; i < count; i++ ) - { - TCFDFileTypes type; - type.iFileType.Copy( aReader.ReadTPtrC() ); - type.iIconIndex = aReader.ReadInt32(); - iFileTypeArray->AppendL( type ); - } - } -// ----------------------------------------------------------------------------- // CAknFileSelectionModel::NewL // // ----------------------------------------------------------------------------- @@ -130,23 +111,10 @@ CAknFileSelectionModel::~CAknFileSelectionModel() { delete iRootFolderText; + iImageIndexArray.Close(); iFs.Close(); - if ( iFileTypeArray ) - { - iFileTypeArray->Reset(); - delete iFileTypeArray; - } - if ( iLocalFileNameArray ) - { - iLocalFileNameArray->Reset(); - delete iLocalFileNameArray; - } - if ( iLocalDirNameArray ) - { - iLocalDirNameArray->Reset(); - delete iLocalDirNameArray; - } - delete iStringBuf; + + delete iItemWithImageIndex; if ( iFilterArray ) { @@ -160,6 +128,8 @@ } delete iLocalizer; + + iApaSession.Close(); } @@ -201,6 +171,9 @@ // Set as current path iCurrentPath = iParse; + // Reset directory level + iDirectoryLevel = 0; + errorCode = UpdateItemListL(); @@ -217,8 +190,8 @@ // TInt CAknFileSelectionModel::AddFolderL( const TDesC& aFolder ) { - // Open new sub-folder, directory level is increased - iDirectoryLevel++; + // Cache the directory level because SetPath resets it + TInt level( iDirectoryLevel ); // The engine only supports adding one folder at a time if ( AknCFDUtility::DirectoryCount( aFolder ) != 1 ) @@ -243,6 +216,8 @@ return errorCode; } + iDirectoryLevel = ++level; + return errorCode; } @@ -295,11 +270,9 @@ // TInt CAknFileSelectionModel::UpdateItemListL() { - // Clear array contents iEntryArray->Reset(); - iLocalDirNameArray->Reset(); - iLocalFileNameArray->Reset(); - + iImageIndexArray.Reset(); + CDir* entryArray = ReadDirectory( iCurrentPath.DriveAndPath() ); if ( !entryArray ) { @@ -308,113 +281,160 @@ CleanupStack::PushL( entryArray ); TInt itemCount( entryArray->Count() ); - // entry index in iEntryArray - TInt entryIndex = 0; - for ( TInt i( 0 ); i < itemCount; i++ ) // Add entry or not + if ( itemCount > 0 ) { - TEntry entry = ( *entryArray )[i]; - if ( EntryIsAccepted( entry ) ) + TInt filterCount( iFilterArray->Count() ); + TInt filterIndex; + TBool accepted; + CDesC16Array* desC16FoldersArray = new ( ELeave ) + CDesC16ArrayFlat( KEntryArrayGranularity ); + CleanupStack::PushL( desC16FoldersArray ); + CDesC16Array* desC16FilesArray = new ( ELeave ) + CDesC16ArrayFlat( KEntryArrayGranularity ); + CleanupStack::PushL( desC16FilesArray ); + CArrayPakFlat* tmpFoldersArray = new( ELeave ) + CArrayPakFlat( KEntryArrayGranularity ); + CleanupStack::PushL( tmpFoldersArray ); + CArrayPakFlat* tmpFilesArray = new( ELeave ) + CArrayPakFlat( KEntryArrayGranularity ); + CleanupStack::PushL( tmpFilesArray ); + + tmpFoldersArray->Reset(); + desC16FoldersArray->Reset(); + tmpFilesArray->Reset(); + desC16FilesArray->Reset(); + + for ( TInt i( 0 ); i < itemCount; i++ ) // Generate filtered list { - // Add entry - if ( entry.IsDir() ) + accepted = ETrue; // If there are no filters, accept the entry + TEntry entry = ( *entryArray )[i]; + filterIndex = 0; + // Go thru the filters while the entry is accepted + while( ( filterIndex < filterCount ) && ( accepted ) ) { - // Entry is a directory - TFileTypeIcon folderIcon( EFolderIcon ); - - if( !AknCFDUtility::IsRemoteDrive( iCurrentPath.Drive() ) ) + accepted = iFilterArray->At( filterIndex )->Accept( + iCurrentPath.DriveAndPath(), entry ); + filterIndex++; + } + if ( accepted ) // Directory entry has passed all filters + { + // Add filename to filtered list + if ( entry.IsDir() ) { - if ( ContainsSubfolders( entry.iName ) ) - { - folderIcon = ESubFolderIcon; - } - else if ( !ContainsFiles( entry.iName ) ) - { - folderIcon = EFolderEmptyIcon; - } + desC16FoldersArray->AppendL( GetLocalizedName( entry.iName ) ); + tmpFoldersArray->AppendL( entry, sizeof( TEntry ) ); + } + else + { + desC16FilesArray->AppendL( GetLocalizedName( entry.iName ) ); + tmpFilesArray->AppendL( entry, sizeof( TEntry ) ); } - // List item uses localized name and icon index to show itself, - // common dialogs need to give user the entry's iName, list item - // need to bind unique entry. For sorting list and binding entry, - // save icon index, localized name and right entry index of iEntryArray - // in the element of iLocalDirNameArray and iLocalFileNameArray - TFileName name( GetLocalizedName( entry.iName ) ); - // Append icon index number at the end of entry's localized name - name.AppendNumFixedWidth( folderIcon, EDecimal, KIndexDataLen ); - // Append entry index number of iEntryArray in the end - name.AppendNumFixedWidth( entryIndex, EDecimal, KIndexDataLen ); - iLocalDirNameArray->AppendL( name ); } - else + } + + TInt entryCount = 0; + TInt index; + TKeyArrayPak key( _FOFF( TEntry, iName ), ECmpCollated ); + + // Add folder entries + desC16FoldersArray->Sort( ECmpCollated ); + entryCount = desC16FoldersArray->MdcaCount(); + for( TInt j( 0 ); j < entryCount; j++ ) + { + for( TInt k( 0 ); k < entryCount; k++ ) { - TInt icon(EUnknowTypeIcon); - icon = GetIconForFileL( entry.iName ); - TFileName name( GetLocalizedName( entry.iName ) ); - name.AppendNumFixedWidth( icon, EDecimal, KIndexDataLen ); - name.AppendNumFixedWidth( entryIndex, EDecimal, KIndexDataLen ); - iLocalFileNameArray->AppendL( name ); + if( ( *desC16FoldersArray )[j] == + GetLocalizedName( ( *tmpFoldersArray )[k].iName ) && + iEntryArray->Find( ( *tmpFoldersArray )[k], key, index ) != 0 ) + { + TEntry tmpEntry = ( *tmpFoldersArray )[k]; + + iEntryArray->AppendL( tmpEntry, sizeof( TEntry ) ); + + // Entry is a directory + TFileTypeIcon folderIcon( EFolderIcon ); + + if( !AknCFDUtility::IsRemoteDrive( iCurrentPath.Drive() ) ) + { + if ( ContainsSubfolders( tmpEntry.iName ) ) + { + folderIcon = ESubFolderIcon; + } + else if ( !ContainsFiles( tmpEntry.iName ) ) + { + folderIcon = EFolderEmptyIcon; + } + } + iImageIndexArray.Append( folderIcon ); + + break; + } } - entryIndex++; - iEntryArray->AppendL( entry, sizeof( TEntry ) ); } + + // Add file entries + desC16FilesArray->Sort( ECmpCollated ); + entryCount = desC16FilesArray->MdcaCount(); + for( TInt j( 0 ); j < entryCount; j++ ) + { + for( TInt k( 0 ); k < entryCount; k++ ) + { + if( ( *desC16FilesArray )[j] == + GetLocalizedName( ( *tmpFilesArray )[k].iName ) && + iEntryArray->Find( ( *tmpFilesArray )[k], key, index ) != 0 ) + { + TEntry tmpFile = ( *tmpFilesArray )[k]; + + iEntryArray->AppendL( tmpFile, sizeof( TEntry ) ); + + // Entry is a file + AppendIconForFileL( tmpFile.iName ); + + break; + } + } + } + + CleanupStack::PopAndDestroy( tmpFilesArray ); + CleanupStack::PopAndDestroy( tmpFoldersArray ); + CleanupStack::Pop( desC16FilesArray ); + desC16FilesArray->Reset(); + delete desC16FilesArray; + CleanupStack::Pop( desC16FoldersArray ); + desC16FoldersArray->Reset(); + delete desC16FoldersArray; } CleanupStack::PopAndDestroy( entryArray ); - // Sort list item to show - iLocalDirNameArray->Sort( ECmpCollated ); - iLocalFileNameArray->Sort( ECmpCollated ); + if ( AknCFDUtility::DirectoriesOnly( iDialogType ) ) { // Set the current folder name as first item. - TPtr folder = iStringBuf->Des(); - folder = iCurrentPath.DriveAndPath(); + // Current folder is for example "E:\Images\Holiday\" + // Remove trailing backslash, we get "E:\Images\Holiday" + // Parse the path with TParse and ask for NameAndExt(). + // TParse interpretes "Holiday" as file name and returns it. + + HBufC * bufFolder = HBufC::NewLC(KMaxPath); + * bufFolder = iCurrentPath.DriveAndPath() ; + TPtr folder = bufFolder->Des(); + AknCFDUtility::RemoveTrailingBackslash( folder ); // ignore error + TParsePtr parsedFolder(folder); + folder = parsedFolder.NameAndExt(); - TFileName name(folder); - TEntry folderEntry; - folderEntry.iName = name; - if ( iDirectoryLevel == 0 ) - { - name = iRootFolderText->Des(); - } - else - { - folder = iCurrentPath.DriveAndPath(); - iLocalizer->SetFullPath( folder ); - if( iLocalizer->IsLocalized() ) - { - name = iLocalizer->LocalizedName(); - } - } - name.AppendNumFixedWidth( EThisFolderIcon, EDecimal, KIndexDataLen ); - name.AppendNumFixedWidth( entryIndex, EDecimal, KIndexDataLen ); - iLocalDirNameArray->InsertL( 0, name ); - iEntryArray->AppendL( folderEntry, sizeof(TEntry) ); + iFolderEntry.iName = folder; + iEntryArray->InsertL( 0, iFolderEntry, sizeof( TEntry ) ); + iImageIndexArray.Insert( EThisFolderIcon, 0 ); + + CleanupStack::PopAndDestroy(); //bufFolder } + return iEntryArray->Count(); } // ----------------------------------------------------------------------------- -// CAknFileSelectionModel::EntryIsAccepted -// ----------------------------------------------------------------------------- -// -TBool CAknFileSelectionModel::EntryIsAccepted( const TEntry& aEntry ) const - { - TInt filterCount( iFilterArray->Count() ); - // Go through the filters while the entry is accepted - for ( TInt i = 0 ; i < filterCount ; ++i ) - { - if ( !( iFilterArray->At( i )->Accept( - iCurrentPath.DriveAndPath(), aEntry ) ) ) - { - // Some filter does not accept this entry - return EFalse; - } - } - return ETrue; - } - -// ----------------------------------------------------------------------------- // CAknFileSelectionModel::Entry // // @@ -422,20 +442,7 @@ // const TEntry& CAknFileSelectionModel::Entry( const TInt& aIndex ) const { - TInt index = aIndex; - // List item sequence is arranged in MdcaPoint() - if ( aIndex < iLocalDirNameArray->Count() ) - { - // Get right entry index of iEntryArray - TLex lex((*iLocalDirNameArray)[aIndex].Right(KIndexDataLen)); - lex.Val( index ); - } - else - { - TLex lex((*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Right(KIndexDataLen)); - lex.Val( index ); - } - return iEntryArray->At( index ); + return iEntryArray->At( aIndex ); } // ----------------------------------------------------------------------------- @@ -512,33 +519,60 @@ // TPtrC CAknFileSelectionModel::MdcaPoint( TInt aIndex ) const { - // List items sequence follows the sequence of sorted array - TPtr listItem = iStringBuf->Des(); - TInt icon(0); - if ( aIndex < iLocalDirNameArray->Count() ) + TEntry entry = iEntryArray->At( aIndex ); // reference + TParsePtrC parsedEntry( entry.iName ); + TPtrC fileName( parsedEntry.NameAndExt() ); + TInt entryType( iImageIndexArray[ aIndex ] ); + + TPtr itemWithImageIndex = iItemWithImageIndex->Des(); + + switch( entryType ) { - // Directories need to arrange at ahead of files - TInt len = (*iLocalDirNameArray)[aIndex].Length(); - TLex lex( (*iLocalDirNameArray)[aIndex].Mid( - len - KIndexDataLen - KIndexDataLen, KIndexDataLen) ); - // Get icon index for the item - lex.Val( icon ); - listItem.Format( KImageHeader, icon ); - // Append localized name as list item name - listItem.Append((*iLocalDirNameArray)[aIndex].Left( - len - KIndexDataLen - KIndexDataLen ) ); + case EThisFolderIcon: + { + if ( iDirectoryLevel == 0 ) + { + // Root folder + fileName.Set( iRootFolderText->Des() ); + } + else + { + // Not the root folder + iLocalizer->SetFullPath( iCurrentPath.DriveAndPath() ); + if ( iLocalizer->IsLocalized() ) // Localized? + { + // Folder name is localized + fileName.Set( iLocalizer->LocalizedName() ); + } + } + break; + } + case EFolderIcon: // fall through + case ESubFolderIcon: + case EFolderEmptyIcon: + { + itemWithImageIndex = iCurrentPath.DriveAndPath(); + itemWithImageIndex.Append( entry.iName ); + // ignore error: + AknCFDUtility::AddTrailingBackslash( itemWithImageIndex ); + iLocalizer->SetFullPath( itemWithImageIndex ); + if( iLocalizer->IsLocalized() ) + { + fileName.Set( iLocalizer->LocalizedName() ); + } + break; + } + default: // EFileIcon + { + break; + } } - else - { - TInt len = (*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Length(); - TLex lex( (*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Mid( - len - KIndexDataLen - KIndexDataLen, KIndexDataLen) ); - lex.Val( icon ); - listItem.Format( KImageHeader, icon ); - listItem.Append((*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Left( - len - KIndexDataLen - KIndexDataLen ) ); - } - return listItem; + + _LIT( KImageHeader, "%d\t" ); + itemWithImageIndex.Format( KImageHeader, entryType ); + itemWithImageIndex.Append( fileName ); + + return itemWithImageIndex; } // ----------------------------------------------------------------------------- @@ -588,34 +622,26 @@ // TBool CAknFileSelectionModel::ContainsSubfolders( const TDesC& aFolder ) { - return ContainsContents( aFolder, KEntryAttDir | KEntryAttMatchExclusive ); - } - -// ----------------------------------------------------------------------------- -// CAknFileSelectionModel::ContainsFiles -// -// ----------------------------------------------------------------------------- -// -TBool CAknFileSelectionModel::ContainsFiles( const TDesC& aFolder ) - { - return ContainsContents( aFolder, KEntryAttNormal ); - } - -// ----------------------------------------------------------------------------- -// CAknFileSelectionModel::ContainsFiles -// -// ----------------------------------------------------------------------------- -// -TBool CAknFileSelectionModel::ContainsContents( - const TDesC& aFolder, TUint aAttMask ) - { TPath directory( iCurrentPath.DriveAndPath() ); directory.Append( aFolder ); AknCFDUtility::AddTrailingBackslash( directory ); // ignore error + // Keep old code for possible roll-back + /* + CDir* array = ReadDirectory( directory ); + if( ( !array ) || ( array->Count() == 0 ) || ( !(* array)[ 0 ].IsDir() ) ) + { + delete array; + return EFalse; + } + delete array; + return ETrue; + */ + RDir dir; TBool ret( EFalse ); - if ( dir.Open( iFs, directory, aAttMask ) != KErrNone ) + if ( dir.Open( + iFs, directory, KEntryAttDir | KEntryAttMatchExclusive ) != KErrNone ) { return EFalse; } @@ -627,23 +653,111 @@ dir.Close(); return ret; } -// ----------------------------------------------------------------------------- -// CAknFileSelectionModel::AppendIconForFileL -// -// ----------------------------------------------------------------------------- -// -TInt CAknFileSelectionModel::GetIconForFileL(const TDesC& aFileName ) const + +void CAknFileSelectionModel::AppendIconForFileL(const TDesC& aFileName) { - TParsePtrC ptr( aFileName ); - TPtrC ptrc = ptr.Ext(); - for ( TInt i = 0; i < iFileTypeArray->Count(); i++ ) + //TFileName absFileName( iCurrentPath.DriveAndPath() ); + HBufC *bufAbsFileName = HBufC::NewLC(KMaxPath); + *bufAbsFileName = iCurrentPath.DriveAndPath(); + TPtr absFileName = bufAbsFileName->Des(); + + absFileName.Append( aFileName ); + TUid uidIgnore; + TDataType dataType; + TInt err = iApaSession.AppForDocument( absFileName, uidIgnore, dataType ); + TInt iconIndex = EUnknowTypeIcon; + CleanupStack::PopAndDestroy(); //bufAbsFileName + + if( err != KErrNone ) + { + // Couldn't find out the data type, use generic file icon: + iconIndex = EUnknowTypeIcon; + } + else { - if ( ptrc.MatchF( (*iFileTypeArray)[i].iFileType ) == 0 ) + HBufC *bufDataTypeBuf = HBufC::NewLC(KMaxDataTypeLength); + *bufDataTypeBuf = dataType.Des(); + TPtr dataTypeBuf = bufDataTypeBuf->Des(); + + if( dataTypeBuf.MatchF( KCFDMimeTypeAudioVoiceRec ) == 0 || + dataTypeBuf.MatchF( KCFDMimeTypeAudioVoiceRec2 ) == 0 ) + { + iconIndex = EVoiceRecFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypePlaylist ) == 0 ) + { + iconIndex = EPlaylistFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeRam ) == 0 ) + { + iconIndex = ELinkFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeAudio ) == 0 ) + { + iconIndex = ESoundFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeImageGms ) == 0 ) + { + iconIndex = EGmsFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeImage ) == 0 ) + { + iconIndex = EImageFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeVideo ) == 0 || + dataTypeBuf.MatchF( KCFDMimeTypeVideoRealMedia ) == 0 || + dataTypeBuf.MatchF( KCFDMimeTypeVideoSdp ) == 0 ) + { + iconIndex = EVideoFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeGame ) == 0 ) + { + iconIndex = EGameFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeNote ) == 0 ) { - return (*iFileTypeArray)[i].iIconIndex; + iconIndex = ENoteFileIcon; + } + else if( dataTypeBuf.MatchF( KCFDMimeTypeJava ) == 0 ) + { + iconIndex = EJavaFileIcon; + } + else if ( dataTypeBuf.MatchF( KCFDMimeTypeFlash ) == 0 ) + { + iconIndex = EFlashFileIcon; } + else + { + // Check from the file name extension, if it's a SIS file: + //TParse fileName; + //fileName.Set( aFileName, NULL, NULL ); + + HBufC * bufFileName = aFileName.AllocLC(); + TPtr ptrFileName = bufFileName->Des(); + TParsePtr fileName(ptrFileName); + + TPtrC ext( fileName.Ext() ); + if( ext.CompareF( KCFDFileExtSis ) == 0 + || ext.CompareF( KCFDFileExtSisx ) == 0 ) + { + iconIndex = ESisFileIcon; + } + // RApaLsSession does not recognize .mid's: + else if( ext.CompareF( KCFDFileExtMid ) == 0 ) + { + iconIndex = ESoundFileIcon; + } + else + { + iconIndex = EUnknowTypeIcon; + } + CleanupStack::PopAndDestroy(); //bufFileName + + } + + CleanupStack::PopAndDestroy(); //bufDataTypeBuf } - return EUnknowTypeIcon; + iImageIndexArray.Append( iconIndex ); } TPtrC CAknFileSelectionModel::GetLocalizedName(const TDesC& aFileName) @@ -651,7 +765,7 @@ TParsePtrC parsedEntry( aFileName ); TPtrC fileName( parsedEntry.NameAndExt() ); - TPtr itemWithImageIndex = iStringBuf->Des(); + TPtr itemWithImageIndex = iItemWithImageIndex->Des(); itemWithImageIndex = iCurrentPath.DriveAndPath(); itemWithImageIndex.Append( aFileName); @@ -665,4 +779,30 @@ return fileName; } +// ----------------------------------------------------------------------------- +// CAknFileSelectionModel::ContainsFiles +// +// ----------------------------------------------------------------------------- +// +TBool CAknFileSelectionModel::ContainsFiles( const TDesC& aFolder ) + { + TPath directory( iCurrentPath.DriveAndPath() ); + directory.Append( aFolder ); + AknCFDUtility::AddTrailingBackslash( directory ); // ignore error + + RDir dir; + TBool ret( EFalse ); + if ( dir.Open( + iFs, directory, KEntryAttNormal ) != KErrNone ) + { + return EFalse; + } + TEntry entry; + if ( dir.Read( entry ) == KErrNone ) + { + ret = ETrue; + } + dir.Close(); + return ret; + } // End of File