25
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* This class implements a model of a file list. Features:
|
|
16 |
* - Contents of multiple folders in the same list
|
|
17 |
* - Filtering with wildcards (*?)
|
|
18 |
* - Filtering by maximum file size
|
|
19 |
* - Sorting (name / date, ascending / descending)
|
|
20 |
* - Entry presentation formatting using an abstract interface
|
|
21 |
* The class is inherited from MDesCArray, so it can be used directly
|
|
22 |
* as a model for a listbox.
|
|
23 |
*
|
|
24 |
*
|
|
25 |
*/
|
|
26 |
|
|
27 |
|
|
28 |
// CLASS HEADER
|
|
29 |
#include "CFLDFileListModel.h"
|
|
30 |
|
|
31 |
// INTERNAL INCLUDES
|
|
32 |
#include "CFLDOperationObserver.h"
|
|
33 |
#include "CFLDChangedItemObserver.h"
|
|
34 |
#include "CFLDEntryReference.h"
|
|
35 |
#include "CFLDWaitNote.h"
|
|
36 |
#include "CFLDPopupList.h"
|
|
37 |
#include "MFLDEntryFormatter.h"
|
|
38 |
|
|
39 |
// EXTERNAL INCLUDES
|
|
40 |
#include <MCLFContentListingEngine.h>
|
|
41 |
#include <MCLFItem.h>
|
|
42 |
#include <MCLFItemListModel.h>
|
|
43 |
#include <MCLFModifiableItem.h>
|
|
44 |
#include <ContentListingFactory.h>
|
|
45 |
#include <CLFContentListing.hrh>
|
|
46 |
#include <barsread.h> // For TResourceReader
|
|
47 |
#include <ConeResLoader.h> // For RConeResourceLoader
|
|
48 |
#include <coemain.h> // CCoeEnv
|
|
49 |
#include <pathinfo.h>
|
|
50 |
#include <data_caging_path_literals.hrh> // For KDC_RESOURCE_FILES_DIR
|
|
51 |
#include <filelist.rsg> // For R_FLD_WAIT_NOTE
|
|
52 |
#include <bautils.h> // For BaflUtils
|
|
53 |
#include <apgcli.h> // For RApaLsSession
|
|
54 |
#include <aknnotewrappers.h>
|
|
55 |
#include <StringLoader.h>
|
|
56 |
|
|
57 |
// CONSTANTS
|
|
58 |
namespace
|
|
59 |
{
|
|
60 |
_LIT( KFLDROMDriveLetter, "Z:" );
|
|
61 |
const TInt KGranularityFilters( 2 );
|
|
62 |
}
|
|
63 |
|
|
64 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// CFLDFileListModel::NewL
|
|
68 |
// Two-phased constructor.
|
|
69 |
// -----------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
CFLDFileListModel* CFLDFileListModel::NewL(
|
|
72 |
const TInt aModelResourceId, const TInt aDirectoriesResourceId )
|
|
73 |
{
|
|
74 |
// The default stuff.
|
|
75 |
CFLDFileListModel* self =
|
|
76 |
CFLDFileListModel::NewLC( aModelResourceId, aDirectoriesResourceId );
|
|
77 |
CleanupStack::Pop( self ); // self
|
|
78 |
return self;
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CFLDFileListModel::NewLC
|
|
83 |
// Two-phased constructor.
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CFLDFileListModel* CFLDFileListModel::NewLC(
|
|
87 |
const TInt aModelResourceId, const TInt aDirectoriesResourceId )
|
|
88 |
{
|
|
89 |
CFLDFileListModel* self =
|
|
90 |
new( ELeave ) CFLDFileListModel();
|
|
91 |
CleanupStack::PushL( self );
|
|
92 |
self->ConstructL( aModelResourceId, aDirectoriesResourceId );
|
|
93 |
return self;
|
|
94 |
}
|
|
95 |
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
// CFLDFileListModel::CFLDFileListModel
|
|
98 |
// C++ constructor can NOT contain any code, that might leave.
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
CFLDFileListModel::CFLDFileListModel()
|
|
102 |
: iExclusiveMimeTypes( KGranularityFilters ),
|
|
103 |
iExclusiveMediaTypes( KGranularityFilters ),
|
|
104 |
iDirectoryPaths( KGranularityFilters ),
|
|
105 |
iRomDirectoryPaths( KGranularityFilters ),
|
|
106 |
iMaxFileSize( 0 )
|
|
107 |
{
|
|
108 |
}
|
|
109 |
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
// CFLDFileListModel::ConstructL
|
|
112 |
// Symbian 2nd phase constructor can leave.
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CFLDFileListModel::ConstructL(
|
|
116 |
const TInt aModelResourceId, const TInt aDirectoriesResourceId )
|
|
117 |
{
|
|
118 |
// Create CLF Operation Observer to monitor, when
|
|
119 |
// refresh operation has completed
|
|
120 |
iObserver = CFLDOperationObserver::NewL();
|
|
121 |
|
|
122 |
// Create Content Listing Engine and a list model
|
|
123 |
iEngine = ContentListingFactory::NewContentListingEngineLC();
|
|
124 |
CleanupStack::Pop(); // iEngine
|
|
125 |
|
|
126 |
// Load CLF definitions from user given resource
|
|
127 |
TResourceReader reader;
|
|
128 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, aModelResourceId );
|
|
129 |
iModel = iEngine->CreateListModelLC( *iObserver, reader );
|
|
130 |
CleanupStack::Pop(); // iModel
|
|
131 |
CleanupStack::PopAndDestroy(); // reader
|
|
132 |
|
|
133 |
// Load wait note from default-resource
|
|
134 |
iWaitNote = CFLDWaitNote::NewL( R_FLD_WAIT_NOTE );
|
|
135 |
|
|
136 |
// Load directories
|
|
137 |
CFLDFileListModel::LoadDirectoriesL( aDirectoriesResourceId );
|
|
138 |
|
|
139 |
// Create changed item observer to monitor, when
|
|
140 |
// tone selection files are modified or deleted
|
|
141 |
iChangedItemObserver = CFLDChangedItemObserver::NewL(iWaitNote);
|
|
142 |
iEngine->AddChangedItemObserverL( *iChangedItemObserver );
|
|
143 |
|
|
144 |
// Set post filter
|
|
145 |
iModel->SetPostFilter( this );
|
|
146 |
}
|
|
147 |
|
|
148 |
// Destructor
|
|
149 |
CFLDFileListModel::~CFLDFileListModel()
|
|
150 |
{
|
|
151 |
if( iModel )
|
|
152 |
{
|
|
153 |
iModel->CancelRefresh();
|
|
154 |
delete iModel;
|
|
155 |
}
|
|
156 |
|
|
157 |
delete iEngine;
|
|
158 |
delete iObserver;
|
|
159 |
delete iChangedItemObserver;
|
|
160 |
delete iEntryFormatter;
|
|
161 |
delete iWaitNote;
|
|
162 |
|
|
163 |
iEndNullTextRingingToneArray.ResetAndDestroy();
|
|
164 |
iEndNullTextArray.ResetAndDestroy();
|
|
165 |
iNullTextRingingToneArray.ResetAndDestroy();
|
|
166 |
iNullTextArray.ResetAndDestroy();
|
|
167 |
iEntryReferences.ResetAndDestroy();
|
|
168 |
iExclusiveMimeTypes.Reset();
|
|
169 |
iExclusiveMediaTypes.Reset();
|
|
170 |
iDirectoryPaths.Reset();
|
|
171 |
iRomDirectoryPaths.Reset();
|
|
172 |
iRomRingingToneArray.ResetAndDestroy();
|
|
173 |
}
|
|
174 |
|
|
175 |
|
|
176 |
// -----------------------------------------------------------------------------
|
|
177 |
// CFLDFileListModel::LoadRomDirectoriesL
|
|
178 |
// (other items were commented in a header).
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CFLDFileListModel::LoadDirectoriesL( const TInt aDirectoriesResourceId )
|
|
182 |
{
|
|
183 |
TResourceReader reader;
|
|
184 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, aDirectoriesResourceId );
|
|
185 |
|
|
186 |
// Read ROM directories from resource
|
|
187 |
TInt count( reader.ReadInt16() );
|
|
188 |
while( --count >= 0 )
|
|
189 |
{
|
|
190 |
TPtrC ptr( reader.ReadTPtrC() );
|
|
191 |
// Ignore return value
|
|
192 |
AddRomDirectoryL( ptr );
|
|
193 |
}
|
|
194 |
|
|
195 |
// Read directories from resource
|
|
196 |
count = reader.ReadInt16();
|
|
197 |
while( --count >= 0 )
|
|
198 |
{
|
|
199 |
TPtrC ptr( reader.ReadTPtrC() );
|
|
200 |
// Ignore return value
|
|
201 |
AddDirectoryL( ptr );
|
|
202 |
}
|
|
203 |
|
|
204 |
CleanupStack::PopAndDestroy(); // reader
|
|
205 |
}
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
// CFLDFileListModel::AddRomDirectoryL
|
|
208 |
// (other items were commented in a header).
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
TInt CFLDFileListModel::AddRomDirectoryL( const TDesC& aDirectory )
|
|
212 |
{
|
|
213 |
TInt index( 0 );
|
|
214 |
if( iRomDirectoryPaths.Find( aDirectory, index ) == 0 )
|
|
215 |
{
|
|
216 |
// A duplicate was found, do not add to the array, return.
|
|
217 |
return KErrAlreadyExists;
|
|
218 |
}
|
|
219 |
|
|
220 |
RFs& fsSession( CCoeEnv::Static()->FsSession() );
|
|
221 |
// Check that the directory really exists
|
|
222 |
if ( !BaflUtils::FolderExists( fsSession, aDirectory ) )
|
|
223 |
{
|
|
224 |
return KErrPathNotFound;
|
|
225 |
}
|
|
226 |
iRomDirectoryPaths.AppendL( aDirectory );
|
|
227 |
|
|
228 |
return KErrNone;
|
|
229 |
}
|
|
230 |
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
// CFLDFileListModel::AddDirectoryL
|
|
233 |
// (other items were commented in a header).
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
TInt CFLDFileListModel::AddDirectoryL( const TDesC& aDirectory )
|
|
237 |
{
|
|
238 |
TInt index( 0 );
|
|
239 |
if( iDirectoryPaths.Find( aDirectory, index ) == 0 )
|
|
240 |
{
|
|
241 |
// A duplicate was found, do not add to the array, return.
|
|
242 |
return KErrAlreadyExists;
|
|
243 |
}
|
|
244 |
|
|
245 |
iDirectoryPaths.AppendL( aDirectory );
|
|
246 |
|
|
247 |
return KErrNone;
|
|
248 |
}
|
|
249 |
|
|
250 |
// -----------------------------------------------------------------------------
|
|
251 |
// CFLDFileListModel::SetWantedMimeTypesL()
|
|
252 |
// (other items were commented in a header).
|
|
253 |
// -----------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
void CFLDFileListModel::SetWantedMimeTypesL( const MDesCArray& aMimeTypes )
|
|
256 |
{
|
|
257 |
CFLDFileListModel::ResetExclusiveMimeTypes();
|
|
258 |
CFLDFileListModel::ResetExclusiveMediaTypes();
|
|
259 |
|
|
260 |
iModel->SetWantedMimeTypesL( aMimeTypes );
|
|
261 |
}
|
|
262 |
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
// CFLDFileListModel::SetWantedMediaTypesL()
|
|
265 |
// (other items were commented in a header).
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
//
|
|
268 |
void CFLDFileListModel::SetWantedMediaTypesL(
|
|
269 |
const TArray<TCLFMediaType>& aMediaTypes )
|
|
270 |
{
|
|
271 |
CFLDFileListModel::ResetExclusiveMimeTypes();
|
|
272 |
CFLDFileListModel::ResetExclusiveMediaTypes();
|
|
273 |
|
|
274 |
// Temporary solution
|
|
275 |
RArray<TInt> array;
|
|
276 |
TInt count( aMediaTypes.Count() );
|
|
277 |
CleanupClosePushL( array );
|
|
278 |
for( TInt i = 0; i < count; i++ )
|
|
279 |
{
|
|
280 |
array.AppendL( aMediaTypes[i]);
|
|
281 |
}
|
|
282 |
|
|
283 |
iModel->SetWantedMediaTypesL( array.Array() );
|
|
284 |
CleanupStack::PopAndDestroy( &array );
|
|
285 |
}
|
|
286 |
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
// CFLDFileListModel::PopulateReferenceListL
|
|
289 |
// (other items were commented in a header).
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
void CFLDFileListModel::PopulateReferenceListL()
|
|
293 |
{
|
|
294 |
// Do not allow to update model from changed item observer
|
|
295 |
iChangedItemObserver->SetFileListModel( NULL );
|
|
296 |
|
|
297 |
// Send reference of CActiveSchedulerWait to the CLF Operation Observer
|
|
298 |
iObserver->PrepareForRefresh( iWait );
|
|
299 |
|
|
300 |
// CLF hogs the processor when doing its refresh. Make sure we'll
|
|
301 |
// have enough of a slice to be able to handle the End key presses.
|
|
302 |
RWsSession& wsSession = CCoeEnv::Static()->WsSession();
|
|
303 |
wsSession.ComputeMode( RWsSession::EPriorityControlDisabled );
|
|
304 |
|
|
305 |
// Call refresh to get all music files from the file system to the model
|
|
306 |
iModel->RefreshL();
|
|
307 |
|
|
308 |
// Display a wait note if user tries to do something while refresh
|
|
309 |
// operation of the list model has not finished yet.
|
|
310 |
if( iObserver->IsRefreshOngoing() && !iWait.IsStarted() )
|
|
311 |
{
|
|
312 |
// View the wait note
|
|
313 |
if( iWaitNote && !iWaitNote->IsRunning() )
|
|
314 |
{
|
|
315 |
iWaitNote->OpenWaitNoteL();
|
|
316 |
}
|
|
317 |
|
|
318 |
// Wait for the refresh operation to complete. Operation Observer will
|
|
319 |
// stop this wait when the refresh operation has compeleted.
|
|
320 |
iWait.Start(); // CSI: 10 # the state of iWait is checked above
|
|
321 |
|
|
322 |
// Close the wait note
|
|
323 |
if ( iWaitNote )
|
|
324 |
{
|
|
325 |
iWaitNote->CloseWaitNoteL();
|
|
326 |
}
|
|
327 |
}
|
|
328 |
|
|
329 |
// Back to default behavior
|
|
330 |
wsSession.ComputeMode( RWsSession::EPriorityControlComputeOff );
|
|
331 |
|
|
332 |
PopulateListBoxL();
|
|
333 |
|
|
334 |
if( iPopupList )
|
|
335 |
{ // Model has updated; list should try to handle it
|
|
336 |
iPopupList->CancelPreview();
|
|
337 |
TRAP_IGNORE( iPopupList->ListBox()->HandleItemAdditionL() );
|
|
338 |
// List has updated; set focus to the first item
|
|
339 |
iPopupList->ListBox()->SetCurrentItemIndexAndDraw( 0 );
|
|
340 |
}
|
|
341 |
|
|
342 |
// Allow to update model from changed item observer
|
|
343 |
// (unless we're displaying ROM tones only)
|
|
344 |
if( !iRomTonesOnly )
|
|
345 |
{
|
|
346 |
iChangedItemObserver->SetFileListModel( this );
|
|
347 |
}
|
|
348 |
}
|
|
349 |
|
|
350 |
// -----------------------------------------------------------------------------
|
|
351 |
// CFLDFileListModel::ScanRomDirectoriesL
|
|
352 |
// (other items were commented in a header).
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
void CFLDFileListModel::ScanRomDirectoriesL()
|
|
356 |
{
|
|
357 |
CDir* fileList( NULL );
|
|
358 |
RFs& fsSession( CCoeEnv::Static()->FsSession() );
|
|
359 |
|
|
360 |
TInt directoryCount( iRomDirectoryPaths.Count() );
|
|
361 |
for( TInt i= 0; i<directoryCount; i++ )
|
|
362 |
{
|
|
363 |
User::LeaveIfError(fsSession.GetDir(
|
|
364 |
iRomDirectoryPaths.MdcaPoint(i),
|
|
365 |
KEntryAttNormal,ESortByName, fileList));
|
|
366 |
CleanupStack::PushL( fileList );
|
|
367 |
|
|
368 |
TInt fileCount( fileList->Count() );
|
|
369 |
for ( TInt j=0; j<fileCount; j++ )
|
|
370 |
{
|
|
371 |
const TEntry item = (*fileList)[j];
|
|
372 |
TBufC<KMaxFileName> tempBuf = item.iName;
|
|
373 |
HBufC* concateName = HBufC::NewLC(
|
|
374 |
iRomDirectoryPaths.MdcaPoint(i).Length() + tempBuf.Length() );
|
|
375 |
TPtr des = concateName->Des();
|
|
376 |
des.Insert(0, iRomDirectoryPaths.MdcaPoint(i) );
|
|
377 |
des.Append( tempBuf );
|
|
378 |
|
|
379 |
// Only files located on ROM must be scanned
|
|
380 |
// CLF has already scanned other ( supported ) locations
|
|
381 |
if( ( des.Left( KFLDROMDriveLetter().Length() ).CompareF(
|
|
382 |
KFLDROMDriveLetter ) == 0 ) )
|
|
383 |
{
|
|
384 |
TParsePtrC parsedName( des );
|
|
385 |
|
|
386 |
MCLFModifiableItem* clfModifiableItem
|
|
387 |
= ContentListingFactory::NewModifiableItemLC();
|
|
388 |
clfModifiableItem->AddFieldL( ECLFFieldIdFileName, parsedName.NameAndExt() );
|
|
389 |
clfModifiableItem->AddFieldL( ECLFFieldIdPath, parsedName.Path() );
|
|
390 |
clfModifiableItem->AddFieldL( ECLFFieldIdDrive, parsedName.Drive() );
|
|
391 |
#ifdef RD_VIDEO_AS_RINGING_TONE
|
|
392 |
if( PathInfo::PathType( parsedName.DriveAndPath() ) == PathInfo::EVideosPath )
|
|
393 |
{
|
|
394 |
clfModifiableItem->AddFieldL( ECLFFieldIdMediaType, ECLFMediaTypeVideo);
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
clfModifiableItem->AddFieldL( ECLFFieldIdMediaType, ECLFMediaTypeSound);
|
|
399 |
}
|
|
400 |
#else
|
|
401 |
clfModifiableItem->AddFieldL( ECLFFieldIdMediaType, ECLFMediaTypeSound);
|
|
402 |
#endif
|
|
403 |
clfModifiableItem->AddFieldL( ECLFFieldIdFileNameAndPath, des );
|
|
404 |
|
|
405 |
// Find out MIME type
|
|
406 |
RApaLsSession apaLsSession;
|
|
407 |
User::LeaveIfError( apaLsSession.Connect() );
|
|
408 |
CleanupClosePushL( apaLsSession );
|
|
409 |
TUid dummyUid = { 0 }; // instantiate as zero
|
|
410 |
TDataType dataType( dummyUid );
|
|
411 |
TInt err = apaLsSession.AppForDocument( parsedName.FullName(), dummyUid, dataType );
|
|
412 |
CleanupStack::PopAndDestroy(); // apaLsSession.Close()
|
|
413 |
if( err == KErrNone )
|
|
414 |
{
|
|
415 |
clfModifiableItem->AddFieldL( ECLFFieldIdMimeType, dataType.Des() );
|
|
416 |
User::LeaveIfError( iRomRingingToneArray.Append( clfModifiableItem ) );
|
|
417 |
CleanupStack::Pop(); // clfModifiableItem
|
|
418 |
}
|
|
419 |
else
|
|
420 |
{
|
|
421 |
CleanupStack::PopAndDestroy(); // clfModifiableItem
|
|
422 |
}
|
|
423 |
}
|
|
424 |
CleanupStack::PopAndDestroy( concateName );
|
|
425 |
}
|
|
426 |
CleanupStack::PopAndDestroy( fileList);
|
|
427 |
}
|
|
428 |
}
|
|
429 |
|
|
430 |
|
|
431 |
// -----------------------------------------------------------------------------
|
|
432 |
// CompareEntries
|
|
433 |
// For sorting entry references alphabetically by tone name.
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
TInt CompareEntries(const CFLDEntryReference& entry1, const CFLDEntryReference& entry2 )
|
|
437 |
{
|
|
438 |
TParsePtrC parsed1( entry1.PathAndMediaFileName() );
|
|
439 |
TParsePtrC parsed2( entry2.PathAndMediaFileName() );
|
|
440 |
|
|
441 |
return parsed1.Name().CompareF( parsed2.Name() );
|
|
442 |
}
|
|
443 |
|
|
444 |
// -----------------------------------------------------------------------------
|
|
445 |
// CFLDFileListModel::ScanRomDirectoriesAndInsertL
|
|
446 |
// (other items were commented in a header).
|
|
447 |
// -----------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
void CFLDFileListModel::ScanRomDirectoriesAndInsertL()
|
|
450 |
{
|
|
451 |
CDir* fileList( NULL );
|
|
452 |
RFs fsSession;
|
|
453 |
User::LeaveIfError( fsSession.Connect() );
|
|
454 |
CleanupClosePushL( fsSession );
|
|
455 |
|
|
456 |
TInt directoryCount( iRomDirectoryPaths.Count() );
|
|
457 |
for( TInt i= 0; i<directoryCount; i++ )
|
|
458 |
{
|
|
459 |
User::LeaveIfError(fsSession.GetDir(
|
|
460 |
iRomDirectoryPaths.MdcaPoint(i),
|
|
461 |
KEntryAttNormal,ESortByName, fileList));
|
|
462 |
CleanupStack::PushL( fileList );
|
|
463 |
|
|
464 |
TInt fileCount( fileList->Count() );
|
|
465 |
for ( TInt j=0; j<fileCount; j++ )
|
|
466 |
{
|
|
467 |
const TEntry item = (*fileList)[j];
|
|
468 |
TBufC<KMaxFileName> tempBuf = item.iName;
|
|
469 |
HBufC* concateName = HBufC::NewLC(
|
|
470 |
iRomDirectoryPaths.MdcaPoint(i).Length() + tempBuf.Length() );
|
|
471 |
TPtr des = concateName->Des();
|
|
472 |
des.Insert(0, iRomDirectoryPaths.MdcaPoint(i) );
|
|
473 |
des.Append( tempBuf );
|
|
474 |
|
|
475 |
// Only files located on ROM must be scanned
|
|
476 |
if( ( des.Left( KFLDROMDriveLetter().Length() ).CompareF(
|
|
477 |
KFLDROMDriveLetter ) == 0 ) )
|
|
478 |
{
|
|
479 |
// Add file to entry-list
|
|
480 |
CFLDEntryReference* entryRef = new( ELeave ) CFLDEntryReference();
|
|
481 |
CleanupStack::PushL( entryRef );
|
|
482 |
HBufC* pathAndMediaFileName = des.AllocL();
|
|
483 |
entryRef->SetPathAndMediaFileName( pathAndMediaFileName );
|
|
484 |
|
|
485 |
TParsePtrC parsedName( des );
|
|
486 |
if( PathInfo::PathType( parsedName.DriveAndPath() ) == PathInfo::EVideosPath )
|
|
487 |
{
|
|
488 |
entryRef->SetMediaType( ECLFMediaTypeVideo);
|
|
489 |
}
|
|
490 |
else
|
|
491 |
{
|
|
492 |
entryRef->SetMediaType( ECLFMediaTypeSound);
|
|
493 |
}
|
|
494 |
|
|
495 |
iEntryFormatter->FormatL( *entryRef );
|
|
496 |
User::LeaveIfError( iEntryReferences.Append( entryRef ) );
|
|
497 |
CleanupStack::Pop( entryRef );
|
|
498 |
}
|
|
499 |
CleanupStack::PopAndDestroy( concateName );
|
|
500 |
}
|
|
501 |
CleanupStack::PopAndDestroy( fileList);
|
|
502 |
}
|
|
503 |
|
|
504 |
TLinearOrder<CFLDEntryReference>* sorter =
|
|
505 |
new( ELeave ) TLinearOrder<CFLDEntryReference> ( CompareEntries );
|
|
506 |
iEntryReferences.Sort( *sorter );
|
|
507 |
delete sorter;
|
|
508 |
|
|
509 |
CleanupStack::PopAndDestroy(); // fsSession
|
|
510 |
}
|
|
511 |
|
|
512 |
|
|
513 |
// -----------------------------------------------------------------------------
|
|
514 |
// CFLDFileListModel::FilterItemsL
|
|
515 |
// (other items were commented in a header).
|
|
516 |
// -----------------------------------------------------------------------------
|
|
517 |
//
|
|
518 |
void CFLDFileListModel::FilterItemsL( const TArray<MCLFItem*>& aItemList,
|
|
519 |
RPointerArray<MCLFItem>& aFilteredItemList )
|
|
520 |
{
|
|
521 |
|
|
522 |
// Add all found entries into model
|
|
523 |
TInt count( aItemList.Count() );
|
|
524 |
for( TInt i = 0 ; i < count ; ++i )
|
|
525 |
{
|
|
526 |
MCLFItem* item = aItemList[i];
|
|
527 |
aFilteredItemList.AppendL( item );
|
|
528 |
}
|
|
529 |
|
|
530 |
// Fetch tones from ROM directories
|
|
531 |
CFLDFileListModel::ScanRomDirectoriesL();
|
|
532 |
|
|
533 |
// Add all found entries into model
|
|
534 |
count = iRomRingingToneArray.Count();
|
|
535 |
for( TInt i = 0 ; i < count ; ++i )
|
|
536 |
{
|
|
537 |
MCLFItem* item = iRomRingingToneArray[i];
|
|
538 |
aFilteredItemList.AppendL( item );
|
|
539 |
}
|
|
540 |
|
|
541 |
}
|
|
542 |
|
|
543 |
// -----------------------------------------------------------------------------
|
|
544 |
// CFLDFileListModel::GetPopupList
|
|
545 |
// (other items were commented in a header).
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
CFLDPopupList* CFLDFileListModel::GetPopupList()
|
|
549 |
{
|
|
550 |
return iPopupList;
|
|
551 |
}
|
|
552 |
|
|
553 |
// -----------------------------------------------------------------------------
|
|
554 |
// CFLDFileListModel::AddExclusiveMimeTypeL
|
|
555 |
// (other items were commented in a header).
|
|
556 |
// -----------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
void CFLDFileListModel::AddExclusiveMimeTypeL( const TDesC& aMimeType )
|
|
559 |
{
|
|
560 |
TInt index( 0 );
|
|
561 |
if( iExclusiveMimeTypes.Find( aMimeType, index ) == 0 )
|
|
562 |
|
|
563 |
{
|
|
564 |
// A duplicate was found, do not add to the array, just return.
|
|
565 |
return;
|
|
566 |
}
|
|
567 |
iExclusiveMimeTypes.AppendL( aMimeType );
|
|
568 |
}
|
|
569 |
|
|
570 |
// -----------------------------------------------------------------------------
|
|
571 |
// CFLDFileListModel::AddExclusiveMediaTypeL
|
|
572 |
// (other items were commented in a header).
|
|
573 |
// -----------------------------------------------------------------------------
|
|
574 |
//
|
|
575 |
void CFLDFileListModel::AddExclusiveMediaTypeL( const TInt32 aMediaType )
|
|
576 |
{
|
|
577 |
if( iExclusiveMediaTypes.Find( aMediaType ) != KErrNotFound )
|
|
578 |
{
|
|
579 |
// A duplicate was found, do not add to the array, just return.
|
|
580 |
return;
|
|
581 |
}
|
|
582 |
iExclusiveMediaTypes.AppendL( aMediaType );
|
|
583 |
}
|
|
584 |
|
|
585 |
// -----------------------------------------------------------------------------
|
|
586 |
// CFLDFileListModel::ResetExclusiveMimeTypes
|
|
587 |
// (other items were commented in a header).
|
|
588 |
// -----------------------------------------------------------------------------
|
|
589 |
//
|
|
590 |
void CFLDFileListModel::ResetExclusiveMimeTypes()
|
|
591 |
{
|
|
592 |
iExclusiveMimeTypes.Reset();
|
|
593 |
}
|
|
594 |
|
|
595 |
// -----------------------------------------------------------------------------
|
|
596 |
// CFLDFileListModel::ResetExclusiveMediaTypes
|
|
597 |
// (other items were commented in a header).
|
|
598 |
// -----------------------------------------------------------------------------
|
|
599 |
//
|
|
600 |
void CFLDFileListModel::ResetExclusiveMediaTypes()
|
|
601 |
{
|
|
602 |
iExclusiveMediaTypes.Reset();
|
|
603 |
}
|
|
604 |
|
|
605 |
// -----------------------------------------------------------------------------
|
|
606 |
// CFLDFileListModel::CheckRules
|
|
607 |
// (other items were commented in a header).
|
|
608 |
// -----------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
TBool CFLDFileListModel::CheckRules(
|
|
611 |
TPtrC& aMimeType, TInt32 aMediaType, TPtrC& aPathAndFileName )
|
|
612 |
{
|
|
613 |
|
|
614 |
// Check exclusive MIME types
|
|
615 |
if( iExclusiveMimeTypes.Count() > 0 )
|
|
616 |
{
|
|
617 |
TInt index( 0 );
|
|
618 |
if( iExclusiveMimeTypes.Find( aMimeType, index ) == 0 )
|
|
619 |
{
|
|
620 |
return EFalse;
|
|
621 |
}
|
|
622 |
}
|
|
623 |
|
|
624 |
// Check exclusive media types
|
|
625 |
if( iExclusiveMediaTypes.Count() > 0 )
|
|
626 |
{
|
|
627 |
if( iExclusiveMediaTypes.Find( aMediaType ) != KErrNotFound )
|
|
628 |
{
|
|
629 |
return EFalse;
|
|
630 |
}
|
|
631 |
}
|
|
632 |
|
|
633 |
if( ( aPathAndFileName.Left( KFLDROMDriveLetter().Length() ).CompareF(
|
|
634 |
KFLDROMDriveLetter ) == 0 ) )
|
|
635 |
{
|
|
636 |
// ROM tones are accepted always
|
|
637 |
return ETrue;
|
|
638 |
}
|
|
639 |
|
|
640 |
// Check defined pathes
|
|
641 |
if( iDirectoryPaths.Count() > 0 )
|
|
642 |
{
|
|
643 |
TParsePtrC parsedName( aPathAndFileName );
|
|
644 |
TInt index( 0 );
|
|
645 |
if( iDirectoryPaths.Find( parsedName.DriveAndPath(), index ) != 0 )
|
|
646 |
{
|
|
647 |
// File is not part of defined path set
|
|
648 |
return EFalse;
|
|
649 |
}
|
|
650 |
}
|
|
651 |
|
|
652 |
// File is part of defined path set or then no directory paths are defined
|
|
653 |
return ETrue;
|
|
654 |
}
|
|
655 |
|
|
656 |
// -----------------------------------------------------------------------------
|
|
657 |
// CFLDFileListModel::PopulateListBoxL
|
|
658 |
// (other items were commented in a header).
|
|
659 |
// -----------------------------------------------------------------------------
|
|
660 |
//
|
|
661 |
void CFLDFileListModel::PopulateListBoxL()
|
|
662 |
{
|
|
663 |
// Add all items to the list box
|
|
664 |
TInt countItems( iModel->ItemCount() );
|
|
665 |
TInt error;
|
|
666 |
|
|
667 |
for( TInt i = 0; i < countItems; i++ )
|
|
668 |
{
|
|
669 |
// Check name and path
|
|
670 |
TPtrC fieldValueNameAndPath;
|
|
671 |
error = iModel->Item( i ).GetField(
|
|
672 |
ECLFFieldIdFileNameAndPath, fieldValueNameAndPath );
|
|
673 |
|
|
674 |
if( error == KErrNone )
|
|
675 |
{
|
|
676 |
// Check media type
|
|
677 |
TInt32 mediaTypeValue;
|
|
678 |
error = iModel->Item( i ).GetField(
|
|
679 |
ECLFFieldIdMediaType, mediaTypeValue );
|
|
680 |
|
|
681 |
if( error == KErrNone )
|
|
682 |
{
|
|
683 |
// Check MIME type
|
|
684 |
TPtrC fieldValueMime;
|
|
685 |
error = iModel->Item( i ).GetField(
|
|
686 |
ECLFFieldIdMimeType, fieldValueMime );
|
|
687 |
|
|
688 |
if( error == KErrNone )
|
|
689 |
{
|
|
690 |
// Check include/exclude rules
|
|
691 |
if( CFLDFileListModel::CheckRules(
|
|
692 |
fieldValueMime, mediaTypeValue,
|
|
693 |
fieldValueNameAndPath ) )
|
|
694 |
{
|
|
695 |
// Everything seems to be ok,
|
|
696 |
// now check file-size limit
|
|
697 |
if ( iMaxFileSize )
|
|
698 |
{
|
|
699 |
if ( CheckToneFileSizeL(
|
|
700 |
fieldValueNameAndPath, iMaxFileSize)
|
|
701 |
!= KErrNone )
|
|
702 |
{
|
|
703 |
continue;
|
|
704 |
}
|
|
705 |
}
|
|
706 |
// Finally, add file to entry-list
|
|
707 |
CFLDEntryReference* entryRef
|
|
708 |
= new( ELeave ) CFLDEntryReference();
|
|
709 |
CleanupStack::PushL( entryRef );
|
|
710 |
HBufC* pathAndMediaFileName
|
|
711 |
= fieldValueNameAndPath.AllocL();
|
|
712 |
entryRef->SetPathAndMediaFileName(
|
|
713 |
pathAndMediaFileName );
|
|
714 |
entryRef->SetMediaType( mediaTypeValue );
|
|
715 |
iEntryFormatter->FormatL( *entryRef );
|
|
716 |
User::LeaveIfError(
|
|
717 |
iEntryReferences.Append( entryRef ) );
|
|
718 |
CleanupStack::Pop( entryRef );
|
|
719 |
}
|
|
720 |
}
|
|
721 |
}
|
|
722 |
}
|
|
723 |
}
|
|
724 |
|
|
725 |
if( countItems == 0 )
|
|
726 |
{
|
|
727 |
// No tones from CLF -- likely out of memory. Scan for ROM tones only.
|
|
728 |
HBufC* errorText = StringLoader::LoadLC(
|
|
729 |
R_FLD_QTN_PROFILES_ERROR_NOT_ENOUGH_MEMORY );
|
|
730 |
CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue );
|
|
731 |
note->ExecuteLD( *errorText );
|
|
732 |
CleanupStack::PopAndDestroy( errorText );
|
|
733 |
|
|
734 |
iRomTonesOnly = ETrue;
|
|
735 |
ScanRomDirectoriesAndInsertL();
|
|
736 |
}
|
|
737 |
|
|
738 |
}
|
|
739 |
|
|
740 |
|
|
741 |
// -----------------------------------------------------------------------------
|
|
742 |
// CFLDFileListModel::RefreshEntryListL
|
|
743 |
// (other items were commented in a header).
|
|
744 |
// -----------------------------------------------------------------------------
|
|
745 |
//
|
|
746 |
void CFLDFileListModel::RefreshEntryListL()
|
|
747 |
{
|
|
748 |
iRomTonesOnly = EFalse;
|
|
749 |
|
|
750 |
iRomRingingToneArray.ResetAndDestroy();
|
|
751 |
iEntryReferences.ResetAndDestroy();
|
|
752 |
PopulateReferenceListL();
|
|
753 |
}
|
|
754 |
|
|
755 |
// -----------------------------------------------------------------------------
|
|
756 |
// CFLDFileListModel::SetPopupList
|
|
757 |
// (other items were commented in a header).
|
|
758 |
// -----------------------------------------------------------------------------
|
|
759 |
//
|
|
760 |
void CFLDFileListModel::SetPopupList( CFLDPopupList* aPopupList )
|
|
761 |
{
|
|
762 |
iPopupList = aPopupList;
|
|
763 |
}
|
|
764 |
|
|
765 |
// -----------------------------------------------------------------------------
|
|
766 |
// CFLDFileListModel::MdcaPoint
|
|
767 |
// (other items were commented in a header).
|
|
768 |
// -----------------------------------------------------------------------------
|
|
769 |
//
|
|
770 |
TPtrC16 CFLDFileListModel::MdcaPoint( TInt aIndex ) const
|
|
771 |
{
|
|
772 |
TInt nullItemCount( iNullTextArray.Count() );
|
|
773 |
if( aIndex < nullItemCount )
|
|
774 |
{
|
|
775 |
// Points to a null item in the beginning of the list.
|
|
776 |
return iNullTextArray[aIndex]->Des();
|
|
777 |
}
|
|
778 |
TInt referenceListCount( iEntryReferences.Count() );
|
|
779 |
if( aIndex >= referenceListCount + nullItemCount )
|
|
780 |
{
|
|
781 |
// Points to a null item in the end of the list.
|
|
782 |
return iEndNullTextArray[aIndex - referenceListCount - nullItemCount]
|
|
783 |
->Des();
|
|
784 |
}
|
|
785 |
|
|
786 |
// The index points to one of the directory entries
|
|
787 |
return iEntryReferences[aIndex - nullItemCount]
|
|
788 |
->FormattedPresentation().Des();
|
|
789 |
|
|
790 |
}
|
|
791 |
|
|
792 |
// -----------------------------------------------------------------------------
|
|
793 |
// CFLDFileListModel::MdcaCount
|
|
794 |
// (other items were commented in a header).
|
|
795 |
// -----------------------------------------------------------------------------
|
|
796 |
//
|
|
797 |
TInt CFLDFileListModel::MdcaCount() const
|
|
798 |
{
|
|
799 |
return iNullTextArray.Count()
|
|
800 |
+ iEntryReferences.Count() + iEndNullTextArray.Count();
|
|
801 |
}
|
|
802 |
|
|
803 |
// -----------------------------------------------------------------------------
|
|
804 |
// CFLDFileListModel::SetEntryFormatter
|
|
805 |
// (other items were commented in a header).
|
|
806 |
// -----------------------------------------------------------------------------
|
|
807 |
//
|
|
808 |
void CFLDFileListModel::SetEntryFormatter( MFLDEntryFormatter* aFormatter )
|
|
809 |
{
|
|
810 |
delete iEntryFormatter;
|
|
811 |
iEntryFormatter = aFormatter;
|
|
812 |
}
|
|
813 |
|
|
814 |
// -----------------------------------------------------------------------------
|
|
815 |
// CFLDFileListModel::InsertNullItemL
|
|
816 |
// (other items were commented in a header).
|
|
817 |
// -----------------------------------------------------------------------------
|
|
818 |
//
|
|
819 |
void CFLDFileListModel::InsertNullItemL( const TDesC& aItemText )
|
|
820 |
{
|
|
821 |
InsertNullItemL( aItemText, KNullDesC );
|
|
822 |
}
|
|
823 |
|
|
824 |
// -----------------------------------------------------------------------------
|
|
825 |
// CFLDFileListModel::InsertNullItemL
|
|
826 |
// (other items were commented in a header).
|
|
827 |
// -----------------------------------------------------------------------------
|
|
828 |
//
|
|
829 |
void CFLDFileListModel::InsertNullItemL(
|
|
830 |
const TDesC& aItemText, const TDesC& aFileName )
|
|
831 |
{
|
|
832 |
HBufC* text = iEntryFormatter->FormatTextLC( aItemText );
|
|
833 |
// Takes ownership
|
|
834 |
User::LeaveIfError( iNullTextArray.Append( text ) );
|
|
835 |
CleanupStack::Pop( text );
|
|
836 |
|
|
837 |
text = aFileName.AllocLC();
|
|
838 |
// Takes ownership
|
|
839 |
User::LeaveIfError( iNullTextRingingToneArray.Append( text ) );
|
|
840 |
CleanupStack::Pop( text );
|
|
841 |
}
|
|
842 |
|
|
843 |
// -----------------------------------------------------------------------------
|
|
844 |
// CFLDFileListModel::InsertEndNullItemL
|
|
845 |
// (other items were commented in a header).
|
|
846 |
// -----------------------------------------------------------------------------
|
|
847 |
//
|
|
848 |
void CFLDFileListModel::InsertEndNullItemL( const TDesC& aItemText )
|
|
849 |
{
|
|
850 |
InsertEndNullItemL( aItemText, KNullDesC );
|
|
851 |
}
|
|
852 |
|
|
853 |
// -----------------------------------------------------------------------------
|
|
854 |
// CFLDFileListModel::InsertEndNullItemL
|
|
855 |
// (other items were commented in a header).
|
|
856 |
// -----------------------------------------------------------------------------
|
|
857 |
//
|
|
858 |
void CFLDFileListModel::InsertEndNullItemL(
|
|
859 |
const TDesC& aItemText, const TDesC& aFileName )
|
|
860 |
{
|
|
861 |
HBufC* text = iEntryFormatter->FormatTextLC( aItemText );
|
|
862 |
// Takes ownership
|
|
863 |
User::LeaveIfError( iEndNullTextArray.Append( text ) );
|
|
864 |
CleanupStack::Pop( text );
|
|
865 |
|
|
866 |
text = aFileName.AllocLC();
|
|
867 |
// Takes ownership
|
|
868 |
User::LeaveIfError( iEndNullTextRingingToneArray.Append( text ) );
|
|
869 |
CleanupStack::Pop( text );
|
|
870 |
}
|
|
871 |
|
|
872 |
// -----------------------------------------------------------------------------
|
|
873 |
// CFLDFileListModel::GetFileName
|
|
874 |
// (other items were commented in a header).
|
|
875 |
// -----------------------------------------------------------------------------
|
|
876 |
//
|
|
877 |
void CFLDFileListModel::GetFileName( TDes& aFileName, const TInt aIndex )
|
|
878 |
{
|
|
879 |
TInt nullItemCount( iNullTextRingingToneArray.Count() );
|
|
880 |
if( aIndex < nullItemCount )
|
|
881 |
{
|
|
882 |
// Points to a null item in the beginning of the list.
|
|
883 |
aFileName.Copy( iNullTextRingingToneArray[aIndex]->Des() );
|
|
884 |
return;
|
|
885 |
}
|
|
886 |
TInt referenceListCount( iEntryReferences.Count() );
|
|
887 |
if( aIndex >= referenceListCount + nullItemCount )
|
|
888 |
{
|
|
889 |
// Points to a null item in the end of the list.
|
|
890 |
aFileName.Copy( iEndNullTextRingingToneArray[
|
|
891 |
aIndex - referenceListCount - nullItemCount]->Des() );
|
|
892 |
return;
|
|
893 |
}
|
|
894 |
|
|
895 |
// The index points to one of the directory entries
|
|
896 |
CFLDEntryReference& entry = *iEntryReferences[aIndex - nullItemCount];
|
|
897 |
aFileName.Copy( entry.PathAndMediaFileName().Des() );
|
|
898 |
|
|
899 |
}
|
|
900 |
|
|
901 |
// -----------------------------------------------------------------------------
|
|
902 |
// CFLDFileListModel::FindFileL
|
|
903 |
// (other items were commented in a header).
|
|
904 |
// -----------------------------------------------------------------------------
|
|
905 |
//
|
|
906 |
TInt CFLDFileListModel::FindFileL( const TDesC& aFileName )
|
|
907 |
{
|
|
908 |
TInt ret( KErrNotFound );
|
|
909 |
TInt count( MdcaCount() );
|
|
910 |
TFileName fileName( KNullDesC );
|
|
911 |
for( TInt index( 0 ); index < count; index++ )
|
|
912 |
{
|
|
913 |
GetFileNameAtIndex( index, fileName );
|
|
914 |
if( fileName.CompareF( aFileName ) == 0 )
|
|
915 |
{
|
|
916 |
ret = index;
|
|
917 |
break;
|
|
918 |
}
|
|
919 |
}
|
|
920 |
return ret;
|
|
921 |
}
|
|
922 |
|
|
923 |
// -----------------------------------------------------------------------------
|
|
924 |
// CFLDFileListModel::GetFileNameAtIndex
|
|
925 |
// (other items were commented in a header).
|
|
926 |
// -----------------------------------------------------------------------------
|
|
927 |
//
|
|
928 |
void CFLDFileListModel::GetFileNameAtIndex(
|
|
929 |
TInt aIndex, TDes& aFileName ) const
|
|
930 |
{
|
|
931 |
TInt nullItemCount( iNullTextRingingToneArray.Count() );
|
|
932 |
if( aIndex < nullItemCount )
|
|
933 |
{
|
|
934 |
// Points to a null item in the beginning of the list.
|
|
935 |
aFileName.Copy( iNullTextRingingToneArray[aIndex]->Des() );
|
|
936 |
return;
|
|
937 |
}
|
|
938 |
TInt referenceListCount( iEntryReferences.Count() );
|
|
939 |
if( aIndex >= referenceListCount + nullItemCount )
|
|
940 |
{
|
|
941 |
// Points to a null item in the end of the list.
|
|
942 |
aFileName.Copy( iEndNullTextRingingToneArray[
|
|
943 |
aIndex - referenceListCount - nullItemCount]->Des() );
|
|
944 |
return;
|
|
945 |
}
|
|
946 |
|
|
947 |
// The index points to one of the directory entries
|
|
948 |
CFLDEntryReference& entry = *iEntryReferences[aIndex - nullItemCount];
|
|
949 |
aFileName.Copy( entry.PathAndMediaFileName().Des() );
|
|
950 |
}
|
|
951 |
|
|
952 |
// -----------------------------------------------------------------------------
|
|
953 |
// CFLDFileListModel::MediaFileType
|
|
954 |
// (other items were commented in a header).
|
|
955 |
// -----------------------------------------------------------------------------
|
|
956 |
//
|
|
957 |
TInt32 CFLDFileListModel::MediaFileType( const TDesC& aFileName ) const
|
|
958 |
{
|
|
959 |
if( iRomTonesOnly )
|
|
960 |
{
|
|
961 |
// Model is empty, get media type from entry reference
|
|
962 |
for(TInt i = 0; i < iEntryReferences.Count(); i++)
|
|
963 |
{
|
|
964 |
if( aFileName.CompareF( iEntryReferences[i]->PathAndMediaFileName() ) == 0 )
|
|
965 |
{
|
|
966 |
return iEntryReferences[i]->MediaType();
|
|
967 |
}
|
|
968 |
}
|
|
969 |
}
|
|
970 |
else
|
|
971 |
{
|
|
972 |
TInt countItems( iModel->ItemCount() );
|
|
973 |
for( TInt i = 0; i < countItems; i++ )
|
|
974 |
{
|
|
975 |
// Get value of requested field and add item to the list box
|
|
976 |
TPtrC fieldValue;
|
|
977 |
TInt error( iModel->Item( i ).GetField(
|
|
978 |
ECLFFieldIdFileNameAndPath, fieldValue ) );
|
|
979 |
|
|
980 |
if( error == KErrNone )
|
|
981 |
{
|
|
982 |
if( aFileName.CompareF( fieldValue ) == 0 )
|
|
983 |
{
|
|
984 |
TInt32 mediaTypeValue;
|
|
985 |
TInt error( iModel->Item( i ).GetField(
|
|
986 |
ECLFFieldIdMediaType, mediaTypeValue ) );
|
|
987 |
|
|
988 |
if( error == KErrNone )
|
|
989 |
{
|
|
990 |
return mediaTypeValue;
|
|
991 |
}
|
|
992 |
}
|
|
993 |
}
|
|
994 |
}
|
|
995 |
}
|
|
996 |
return KErrNotFound;
|
|
997 |
}
|
|
998 |
|
|
999 |
// -----------------------------------------------------------------------------
|
|
1000 |
// CFLDFileListModel::SetMaxFileSize
|
|
1001 |
// (other items were commented in a header).
|
|
1002 |
// -----------------------------------------------------------------------------
|
|
1003 |
//
|
|
1004 |
void CFLDFileListModel::SetMaxFileSize( const TInt aMaxFileSize )
|
|
1005 |
{
|
|
1006 |
iMaxFileSize = aMaxFileSize;
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
// -----------------------------------------------------------------------------
|
|
1010 |
// CFLDFileListModel::CheckToneFileSizeL
|
|
1011 |
// (other items were commented in a header).
|
|
1012 |
// -----------------------------------------------------------------------------
|
|
1013 |
//
|
|
1014 |
TInt CFLDFileListModel::CheckToneFileSizeL(
|
|
1015 |
const TDesC& aFile, TInt aSizeLimit )
|
|
1016 |
{
|
|
1017 |
RFs& fsSession( CCoeEnv::Static()->FsSession() );
|
|
1018 |
|
|
1019 |
// Get file size
|
|
1020 |
TInt size = 0;
|
|
1021 |
TInt error = KErrNone;
|
|
1022 |
|
|
1023 |
TEntry entry;
|
|
1024 |
if ( fsSession.Entry( aFile, entry ) == KErrNone )
|
|
1025 |
{
|
|
1026 |
size = entry.iSize;
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
// Check. NOTE: now if file size couldn't be determined, check fails.
|
|
1030 |
if ( aSizeLimit && size > aSizeLimit )
|
|
1031 |
{
|
|
1032 |
error = KErrTooBig;
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
return error;
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
|
|
1039 |
// End of File
|