diff -r 8bda91a87a00 -r 8ee96d21d9bf profilesservices/MediaFileList/Src/mediafiledialogstate.cpp --- a/profilesservices/MediaFileList/Src/mediafiledialogstate.cpp Thu Aug 19 10:12:30 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1501 +0,0 @@ -/* -* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Class used to deal with the items of the Main view -* -*/ - - - - -// INCLUDE FILES - -#include "mediafiledialogstate.h" -#include "mediafiledialogutils.h" - -#include // for .rss resource enums -#include - - - -/****************************************************************************** - * class TMFListItem - ******************************************************************************/ - - -// ------------------------------------------------------------------------------- -// TMFListItem::TMFListItem -// -// ------------------------------------------------------------------------------- -// -TMFListItem::TMFListItem() - : iListIndex(KErrNotFound), iFolderId(KErrNotFound), iParentFolderId(KErrNotFound), - iChildFolderId(KErrNotFound), iPersistent(ETrue), - iHidden(EFalse), iIconId(EEIconEmpty), iChildIconId(EEIconEmpty), - iUnknownCount(KErrNotFound) - { - } - - - -/****************************************************************************** - * class TMFCurrentItemInfo - ******************************************************************************/ - - -// ------------------------------------------------------------------------------- -// TMFCurrentItemInfo::TMFCurrentItemInfo -// -// ------------------------------------------------------------------------------- -// -void TMFCurrentItemInfo::Reset() - { - iIndexCheckNeeded = EFalse; - iItemIndex = KErrNotFound; - iMediaFileId = KErrNotFound; - iFolderId = KErrNotFound; - iFolderText = KNullDesC; - } - - -/****************************************************************************** - * class CMediaFileDialogState - ******************************************************************************/ - - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::NewL -// -// ----------------------------------------------------------------------------- -CMediaFileDialogState* CMediaFileDialogState::NewL() - { - CMediaFileDialogState* self = new ( ELeave ) CMediaFileDialogState(); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - - return self; - } - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::CMediaFileDialogState -// -// ----------------------------------------------------------------------------- -// -CMediaFileDialogState::CMediaFileDialogState() - { - iCurrentFolderId = EEFolderRoot; - iCurrentFolderIndex = 0; - iListPosition = KErrNotFound; - - iQueryFolderId = EEFolderRoot; - iQueryDirection = EEQueryDown; - iQueryText = KNullDesC; - iPreviousFolderId = KErrNotFound; - iCurrentItemInfo.Reset(); - } - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::ConstructL -// -// ----------------------------------------------------------------------------- -// -void CMediaFileDialogState::ConstructL() - { - AddPermanentItemsL(); - } - -// ---------------------------------------------------------------------------- -// Destructor -// -// ---------------------------------------------------------------------------- -// -CMediaFileDialogState::~CMediaFileDialogState() - { - iList.Close(); - } - - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::Init -// -// ----------------------------------------------------------------------------- -// -void CMediaFileDialogState::Init() - { - // initialize non-persistent folders - TInt count = iList.Count(); - for ( TInt i=0; i buf; - GetFolderInfo( aListIndex, id, buf, persistent, icon ); - - return id; - } - - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::FolderIndex -// -// ----------------------------------------------------------------------------- -// -TInt CMediaFileDialogState::FolderIndex( TInt aListIndex ) - { - if ( aListIndex < 0 ) - { - return KErrNotFound; - } - - TInt folderIndex = KErrNotFound; - - TInt count = iList.Count(); - for ( TInt i=0; i -// Music -// All -// Artist -// -// -// All -// -// -// Unknown -// Unknown -// Album -// -// -// -// Unknown -// -// -// Genre -// Unknown -// Composer -// Unknown -// Videos -// -// -// Recordings -// -// -// -// ----------------------------------------------------------------------------- -// -void CMediaFileDialogState::AddPermanentItemsL() - { - TMFListItem item; - - // Root - item.iListIndex = 0; - item.iFolderId = EEFolderRoot; - item.iParentFolderId = KErrNotFound; - item.iChildFolderId = KErrNotFound; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = KErrNotFound; - item.iChildIconId = KErrNotFound; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_MEDIA_FILE_DIALOG_TITLE ); - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Downloads - item.iListIndex = 0; - item.iFolderId = EEFolderDownload; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolderDownload; - item.iChildIconId = EEIconEmpty; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_DOWNLOAD ); - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Tones - item.iListIndex = 1; - item.iFolderId = EEFolderTones; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconTone; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_TONES ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_TONES ); - User::LeaveIfError( iList.Append( item ) ); - - // Music - item.iListIndex = 2; - item.iFolderId = EEFolderMusic; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = KErrNotFound; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = KErrNotFound; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_MUSIC ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_MUSIC ); - User::LeaveIfError( iList.Append( item ) ); - - // Videos - item.iListIndex = 3; - item.iFolderId = EEFolderVideos; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconVideo; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_VIDEOS ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_VIDEOS ); - User::LeaveIfError( iList.Append( item ) ); - - // Recordings - item.iListIndex = 4; - item.iFolderId = EEFolderRecordings; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconFolder; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_RECORDINGS ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_RECORDINGS ); - User::LeaveIfError( iList.Append( item ) ); - - // Null item one - item.iListIndex = 5; - item.iFolderId = EEFolderNullItemOne; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = ETrue; // by default not visible - item.iIconId = EEIconEmpty; - item.iChildIconId = KErrNotFound; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Null item two - item.iListIndex = 6; - item.iFolderId = EEFolderNullItemTwo; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = KErrNotFound; - item.iPersistent = ETrue; - item.iHidden = ETrue; // by default not visible - item.iIconId = EEIconEmpty; - item.iChildIconId = KErrNotFound; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Search - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderSearch; - item.iParentFolderId = EEFolderRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = ETrue; // visible only when search is used in root level - item.iIconId = EEIconEmpty; - item.iChildIconId = KErrNotFound; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - - //StringLoader::Load( item.iText, R_QTN_VIEW_SEARCH ); - //StringLoader::Load( item.iTitle, R_QTN_VIEW_SEARCH ); - User::LeaveIfError( iList.Append( item ) ); - - - // Music Search - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderSearchMusic; - item.iParentFolderId = EEFolderMusic; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = ETrue; // visible only when search is used in root level - item.iIconId = EEIconEmpty; - item.iChildIconId = KErrNotFound; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // All music - item.iListIndex = 0; - item.iFolderId = EEFolderAllMusic; - item.iParentFolderId = EEFolderMusic; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_ALL_MUSIC ); - StringLoader::Load( item.iTitle, R_QTN_FOLDER_ALL_MUSIC ); - User::LeaveIfError( iList.Append( item ) ); - - - // Artist Root - item.iListIndex = 1; - item.iFolderId = EEFolderArtistRoot; - item.iParentFolderId = EEFolderMusic; - item.iChildFolderId = EEFolderArtist; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconArtist; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_ARTIST ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_ARTIST ); - User::LeaveIfError( iList.Append( item ) ); - - // Album Root - item.iListIndex = 2; - item.iFolderId = EEFolderAlbumRoot; - item.iParentFolderId = EEFolderMusic; - item.iChildFolderId = EEFolderAlbum; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconAlbum; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_ALBUM ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_ALBUM ); - User::LeaveIfError( iList.Append( item ) ); - - // Genre Root - item.iListIndex = 3; - item.iFolderId = EEFolderGenreRoot; - item.iParentFolderId = EEFolderMusic; - item.iChildFolderId = EEFolderGenre; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconGenre; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_GENRE ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_GENRE ); - User::LeaveIfError( iList.Append( item ) ); - - // Composer Root - item.iListIndex = 4; - item.iFolderId = EEFolderComposerRoot; - item.iParentFolderId = EEFolderMusic; - item.iChildFolderId = EEFolderComposer; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconComposer; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_COMPOSER ); - StringLoader::Load( item.iTitle, R_QTN_VIEW_COMPOSER ); - User::LeaveIfError( iList.Append( item ) ); - - // Album ( represents some album under EEFolderAlbumRoot ) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderAlbum; - item.iParentFolderId = EEFolderAlbumRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = EFalse; - item.iHidden = EFalse; - item.iIconId = EEIconAlbum; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Album Unknown ( all music files without album attribute ) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderAlbumUnknown; - item.iParentFolderId = EEFolderAlbumRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconUnknown; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_UNKNOWN_ALBUM ); - StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_ALBUM ); - User::LeaveIfError( iList.Append( item ) ); - - // Genre ( represents some genre under EEFolderGenreRoot ) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderGenre; - item.iParentFolderId = EEFolderGenreRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = EFalse; - item.iHidden = EFalse; - item.iIconId = EEIconGenre; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Genre Unknown ( all music files without genre attribute ) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderGenreUnknown; - item.iParentFolderId = EEFolderGenreRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconUnknown; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_UNKNOWN_GENRE ); - StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_GENRE ); - User::LeaveIfError( iList.Append( item ) ); - - // Composer ( represents some composer under EEFolderComposerRoot ) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderComposer; - item.iParentFolderId = EEFolderComposerRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = EFalse; - item.iHidden = EFalse; - item.iIconId = EEIconComposer; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Composer Unknown ( all music files without composer attribute ) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderComposerUnknown; - item.iParentFolderId = EEFolderComposerRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconUnknown; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_UNKNOWN_COMPOSER ); - StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_COMPOSER ); - User::LeaveIfError( iList.Append( item ) ); - - - - // - // folders under Artist root - // - - // Artist (artist folder, folder name is artist name) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderArtist; - item.iParentFolderId = EEFolderArtistRoot; - item.iChildFolderId = EEFolderArtistAlbum; - item.iPersistent = EFalse; - item.iHidden = EFalse; - item.iIconId = EEIconArtist; - item.iChildIconId = EEIconAlbum; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Artist all (all music files for one artist) - item.iListIndex = 0; - item.iFolderId = EEFolderArtistAll; - item.iParentFolderId = EEFolderArtist; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconFolder; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_FOLDER_ARTIST_ALL ); - StringLoader::Load( item.iTitle, R_QTN_FOLDER_ARTIST_ALL ); - User::LeaveIfError( iList.Append( item ) ); - - // Artist album (one album, folder name is album name) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderArtistAlbum; - item.iParentFolderId = EEFolderArtist; - item.iChildFolderId = EEFolderNone; - item.iPersistent = EFalse; - item.iHidden = EFalse; - item.iIconId = EEIconAlbum; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - item.iText = KNullDesC; - item.iTitle = KNullDesC; - User::LeaveIfError( iList.Append( item ) ); - - // Artist album unknown (music files for one artist without album attribute) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderArtistAlbumUnknown; - item.iParentFolderId = EEFolderArtist; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconUnknown; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_UNKNOWN_ALBUM ); - StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_ALBUM ); - User::LeaveIfError( iList.Append( item ) ); - - // Artist unknown (all music files without artist attribute) - item.iListIndex = KErrNotFound; - item.iFolderId = EEFolderArtistUnknown; - item.iParentFolderId = EEFolderArtistRoot; - item.iChildFolderId = EEFolderNone; - item.iPersistent = ETrue; - item.iHidden = EFalse; - item.iIconId = EEIconUnknown; - item.iChildIconId = EEIconMusic; - item.iUnknownCount = KErrNotFound; - StringLoader::Load( item.iText, R_QTN_UNKNOWN_ARTIST ); - StringLoader::Load( item.iTitle, R_QTN_UNKNOWN_ARTIST ); - User::LeaveIfError( iList.Append( item ) ); - } - - - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::Panic -// -// ----------------------------------------------------------------------------- -// -void CMediaFileDialogState::Panic( TInt aReason ) - { - _LIT( KPanicCategory, "CMediaFileDialogState" ); - - User::Panic( KPanicCategory, aReason ); - } - - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::PrintCurrentFolder (test code) -// -// ----------------------------------------------------------------------------- -// -void CMediaFileDialogState::PrintCurrentFolder() - { - TBuf buf; - - GetFolderTypeText( buf, iCurrentFolderId ); - User::InfoPrint( buf ); - } - - -// ----------------------------------------------------------------------------- -// CMediaFileDialogState::GetFolderTypeText (test code) -// -// ----------------------------------------------------------------------------- -// -void CMediaFileDialogState::GetFolderTypeText(TDes& aText, TInt aType) - { - switch (aType) - { - case EEFolderRoot: - aText = _L("EFolderRoot"); - break; - case EEFolderTones: - aText = _L("EFolderTones"); - break; - case EEFolderMusic: - aText = _L("EFolderMusic"); - break; - case EEFolderVideos: - aText = _L("EFolderVideos"); - break; - case EEFolderRecordings: - aText = _L("EFolderRecordings"); - break; - case EEFolderSearch: - aText = _L("EEFolderSearch"); - break; - - case EEFolderRecent: - aText = _L("EFolderRecent"); - break; - - - case EEFolderArtistRoot: - aText = _L("EFolderArtistRoot"); - break; - case EEFolderArtist: - aText = _L("EFolderArtist"); - break; - case EEFolderArtistUnknown: - aText = _L("EFolderArtistUnknown"); - break; - case EEFolderArtistAll: - aText = _L("EEFolderArtistAll"); - break; - case EEFolderArtistAlbum: - aText = _L("EEFolderArtistAlbum"); - break; - case EEFolderArtistAlbumUnknown: - aText = _L("EEFolderArtistAlbumUnknown"); - break; - - - case EEFolderAllMusic: - aText = _L("EFolderAllMusic"); - break; - - case EEFolderAlbumRoot: - aText = _L("EFolderAlbumRoot"); - break; - case EEFolderAlbum: - aText = _L("EFolderAlbum"); - break; - case EEFolderAlbumUnknown: - aText = _L("EFolderAlbumUnknown"); - break; - - case EEFolderGenreRoot: - aText = _L("EFolderGenreRoot"); - break; - case EEFolderGenre: - aText = _L("EFolderGenre"); - break; - case EEFolderGenreUnknown: - aText = _L("EFolderGenreUnknown"); - break; - - case EEFolderComposerRoot: - aText = _L("EFolderComposerRoot"); - break; - case EEFolderComposer: - aText = _L("EFolderComposer"); - break; - case EEFolderComposerUnknown: - aText = _L("EFolderComposerUnknown"); - break; - - case EEFolderUnknown: - aText = _L("EFolderUnknown"); - break; - - case EEFolderNone: - aText = _L("EFolderNone"); - break; - - default: - aText = _L("### unknown ###"); - break; - } - } - - - - - - - -// End of File