1 /* |
|
2 * Copyright (c) 2007 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: Used to interact with the MDE. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mediafilehandler.h" |
|
22 #include "mediafilelistdebug.h" |
|
23 #include "mediafiledialogstate.h" |
|
24 #include "mediafilelist.h" |
|
25 |
|
26 #include <pathinfo.h> |
|
27 #include <bautils.h> |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 /****************************************************************************** |
|
33 * class CMediaFileData |
|
34 ******************************************************************************/ |
|
35 |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CMediaFileData::NewL |
|
40 // |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMediaFileData* CMediaFileData::NewL() |
|
44 { |
|
45 CMediaFileData* self = new (ELeave) CMediaFileData(); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop( self ); |
|
49 |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Destructor |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CMediaFileData::~CMediaFileData() |
|
60 { |
|
61 delete iFullName; |
|
62 delete iName; |
|
63 delete iArtist; |
|
64 delete iAlbum; |
|
65 delete iGenre; |
|
66 delete iComposer; |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMediaFileData::CMediaFileData |
|
72 // |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CMediaFileData::CMediaFileData() |
|
76 { |
|
77 iMediaFileType = KErrNotFound; |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMediaFileData::ConstructL |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CMediaFileData::ConstructL() |
|
87 { |
|
88 iFullName = HBufC::NewL( 0 ); |
|
89 iName = HBufC::NewL( 0 ); |
|
90 iArtist = HBufC::NewL( 0 ); |
|
91 iAlbum = HBufC::NewL( 0 ); |
|
92 iGenre = HBufC::NewL( 0 ); |
|
93 iComposer = HBufC::NewL( 0 ); |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CMediaFileData::Attr |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 const TDesC& CMediaFileData::Attr( TInt aAttr ) |
|
103 { |
|
104 if ( aAttr == CMediaFileHandler::EAttrFullName ) |
|
105 { |
|
106 return *iFullName; |
|
107 } |
|
108 if ( aAttr == CMediaFileHandler::EAttrSongName ) |
|
109 { |
|
110 return *iName; |
|
111 } |
|
112 if ( aAttr == CMediaFileHandler::EAttrArtist ) |
|
113 { |
|
114 return *iArtist; |
|
115 } |
|
116 if ( aAttr == CMediaFileHandler::EAttrAlbum ) |
|
117 { |
|
118 return *iAlbum; |
|
119 } |
|
120 if ( aAttr == CMediaFileHandler::EAttrGenre ) |
|
121 { |
|
122 return *iGenre; |
|
123 } |
|
124 if ( aAttr == CMediaFileHandler::EAttrComposer ) |
|
125 { |
|
126 return *iComposer; |
|
127 } |
|
128 |
|
129 return KNullDesC; |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CMediaFileData::SetAttrL |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CMediaFileData::SetAttrL( TInt aAttr, const TDesC& aValue ) |
|
139 { |
|
140 if ( aAttr == CMediaFileHandler::EAttrFullName ) |
|
141 { |
|
142 delete iFullName; |
|
143 iFullName = NULL; |
|
144 iFullName = aValue.AllocL(); |
|
145 } |
|
146 if ( aAttr == CMediaFileHandler::EAttrSongName ) |
|
147 { |
|
148 delete iName; |
|
149 iName = NULL; |
|
150 iName = aValue.AllocL(); |
|
151 |
|
152 } |
|
153 if ( aAttr == CMediaFileHandler::EAttrArtist ) |
|
154 { |
|
155 delete iArtist; |
|
156 iArtist = NULL; |
|
157 iArtist = aValue.AllocL(); |
|
158 } |
|
159 if ( aAttr == CMediaFileHandler::EAttrAlbum ) |
|
160 { |
|
161 delete iAlbum; |
|
162 iAlbum = NULL; |
|
163 iAlbum = aValue.AllocL(); |
|
164 } |
|
165 if ( aAttr == CMediaFileHandler::EAttrGenre ) |
|
166 { |
|
167 delete iGenre; |
|
168 iGenre = NULL; |
|
169 iGenre = aValue.AllocL(); |
|
170 } |
|
171 if ( aAttr == CMediaFileHandler::EAttrComposer ) |
|
172 { |
|
173 delete iComposer; |
|
174 iComposer = NULL; |
|
175 iComposer = aValue.AllocL(); |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CMediaFileData::GetAttr |
|
182 // |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CMediaFileData::GetAttr( TInt aAttr, TDes& aValue ) |
|
186 { |
|
187 if ( aAttr == CMediaFileHandler::EAttrFullName ) |
|
188 { |
|
189 TMFDialogUtil::StrCopy( aValue, iFullName->Des() ); |
|
190 } |
|
191 else if ( aAttr == CMediaFileHandler::EAttrSongName ) |
|
192 { |
|
193 TMFDialogUtil::StrCopy( aValue, iName->Des() ); |
|
194 } |
|
195 else if ( aAttr == CMediaFileHandler::EAttrArtist ) |
|
196 { |
|
197 TMFDialogUtil::StrCopy( aValue, iArtist->Des() ); |
|
198 } |
|
199 else if ( aAttr == CMediaFileHandler::EAttrAlbum ) |
|
200 { |
|
201 TMFDialogUtil::StrCopy( aValue, iAlbum->Des() ); |
|
202 } |
|
203 else if ( aAttr == CMediaFileHandler::EAttrGenre ) |
|
204 { |
|
205 TMFDialogUtil::StrCopy( aValue, iGenre->Des() ); |
|
206 } |
|
207 else if ( aAttr == CMediaFileHandler::EAttrComposer ) |
|
208 { |
|
209 TMFDialogUtil::StrCopy( aValue, iComposer->Des() ); |
|
210 } |
|
211 else |
|
212 { |
|
213 aValue = KNullDesC; |
|
214 } |
|
215 } |
|
216 |
|
217 |
|
218 /****************************************************************************** |
|
219 * class CMediaFileHandler |
|
220 ******************************************************************************/ |
|
221 |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CMediaFileHandler::NewL |
|
226 // |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 CMediaFileHandler* CMediaFileHandler::NewL() |
|
230 { |
|
231 CMediaFileHandler* self = new (ELeave) CMediaFileHandler(); |
|
232 CleanupStack::PushL( self ); |
|
233 self->ConstructL(); |
|
234 CleanupStack::Pop( self ); |
|
235 |
|
236 return self; |
|
237 } |
|
238 |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // Destructor |
|
242 // |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 CMediaFileHandler::~CMediaFileHandler() |
|
246 { |
|
247 delete iSearchList; |
|
248 |
|
249 delete iQueryCaller; |
|
250 delete iObjectNotificationCaller; |
|
251 |
|
252 delete iDriveUtil; |
|
253 delete iExcludedMimeTypes; |
|
254 delete iIdle; |
|
255 |
|
256 delete iQuery; |
|
257 delete iArtistQuery; |
|
258 delete iSession; |
|
259 |
|
260 delete iRomFileList; |
|
261 } |
|
262 |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CMediaFileHandler::CMediaFileHandler |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 CMediaFileHandler::CMediaFileHandler() |
|
270 { |
|
271 iSessionOpen = EFalse; |
|
272 iObserverCallEnabled = ETrue; |
|
273 |
|
274 iMaxFileSize = KErrNotFound; |
|
275 iQueryId = KErrNotFound; |
|
276 iQueryType = KErrNotFound; |
|
277 iQueryError = KErrNone; |
|
278 iQueryEvent = KErrNotFound; |
|
279 iVideoSearchDisabled = EFalse; |
|
280 |
|
281 iMediaFileCounter = 0; |
|
282 } |
|
283 |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CMediaFileHandler::ConstructL |
|
287 // |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 void CMediaFileHandler::ConstructL() |
|
291 { |
|
292 iSession = CMdESession::NewL( *this ); |
|
293 iSearchList = CSearchList::NewL(); |
|
294 |
|
295 iQueryCaller = CMFActiveCaller::NewL( this ); |
|
296 iObjectNotificationCaller = CMFActiveCaller::NewL( this ); |
|
297 |
|
298 iDriveUtil = CDriveUtil::NewL(); |
|
299 iArtistQuery = CArtistQuery::NewL(); |
|
300 iExcludedMimeTypes = CMimeTypeList::NewL(); |
|
301 |
|
302 iRomFileList = CRomFileList::NewL(); |
|
303 iQueryinProgress = EFalse; |
|
304 iRomScanState = MMediaFileHandlerObserver::ENoneRomScan; |
|
305 } |
|
306 |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CMediaFileHandler::SetAttr |
|
310 // |
|
311 // ----------------------------------------------------------------------------- |
|
312 void CMediaFileHandler::SetAttrL( TInt aAttr, TInt aValue ) |
|
313 { |
|
314 switch ( aAttr ) |
|
315 { |
|
316 case CMediaFileList::EAttrFileSize: |
|
317 { |
|
318 iMaxFileSize = aValue; |
|
319 break; |
|
320 } |
|
321 case CMediaFileList::EAttrExcludeFolder: |
|
322 { |
|
323 if ( aValue == CMediaFileList::EFolderVideos ) |
|
324 { |
|
325 iVideoSearchDisabled = ETrue; |
|
326 } |
|
327 break; |
|
328 } |
|
329 default: |
|
330 { |
|
331 break; |
|
332 } |
|
333 } |
|
334 } |
|
335 |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CMediaFileHandler::SetAttrL |
|
339 // |
|
340 // ----------------------------------------------------------------------------- |
|
341 void CMediaFileHandler::SetAttrL( TInt aAttr, const TDesC& aValue ) |
|
342 { |
|
343 if ( aAttr == CMediaFileList::EAttrExcludeMimeType ) |
|
344 { |
|
345 iExcludedMimeTypes->AddMimeTypeL( aValue ); |
|
346 } |
|
347 } |
|
348 |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CMediaFileHandler::SetAttr |
|
352 // |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void CMediaFileHandler::SetAttrL( TInt /*aAttr*/, TAny* /*aValue*/ ) |
|
356 { |
|
357 } |
|
358 |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CMediaFileHandler::HandleSessionOpened (from MMdESessionObserver) |
|
362 // |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 void CMediaFileHandler::HandleSessionOpened( CMdESession& /*aSession*/, TInt aError ) |
|
366 { |
|
367 if ( aError != KErrNone ) |
|
368 { |
|
369 delete iSession; |
|
370 iSession = NULL; |
|
371 iSessionOpen = EFalse; |
|
372 } |
|
373 else |
|
374 { |
|
375 iSessionOpen = ETrue; |
|
376 |
|
377 TRAP_IGNORE( AddObjectObserverL() ); |
|
378 } |
|
379 |
|
380 CallObserver( MMediaFileHandlerObserver::EInitComplete, aError ); |
|
381 } |
|
382 |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CMediaFileHandler::AddObjectObserverL |
|
386 // |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 void CMediaFileHandler::AddObjectObserverL() |
|
390 { |
|
391 if ( iSessionOpen ) |
|
392 { |
|
393 TUint32 notificationType = ENotifyAdd | ENotifyModify | ENotifyRemove; |
|
394 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
395 iSession->AddObjectObserverL( *this, NULL, notificationType, &defNS ); |
|
396 |
|
397 iSession->AddObjectPresentObserverL( *this ); |
|
398 } |
|
399 } |
|
400 |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CMediaFileHandler::HandleSessionError (from MMdESessionObserver) |
|
404 // |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CMediaFileHandler::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
|
408 { |
|
409 if ( aError == KErrNone ) |
|
410 { |
|
411 return; |
|
412 } |
|
413 |
|
414 delete iSession; |
|
415 iSession = NULL; |
|
416 iSessionOpen = EFalse; |
|
417 |
|
418 CallObserver( MMediaFileHandlerObserver::EError, aError ); |
|
419 } |
|
420 |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CMediaFileHandler::HandleQueryNewResults (from MMdEQueryObserver) |
|
424 // |
|
425 // This observer function is called during query. Calling frequency is defined |
|
426 // in second parameter of CMdEQuery::FindL. |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CMediaFileHandler::HandleQueryNewResults( CMdEQuery& /*aQuery*/, |
|
430 TInt /*aFirstNewItemIndex*/, |
|
431 TInt /*aNewItemCount*/ ) |
|
432 { |
|
433 } |
|
434 |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CMediaFileHandler::HandleObjectNotification (MMdEObjectObserver) |
|
438 // |
|
439 // Called when metadata database changes. |
|
440 // ----------------------------------------------------------------------------- |
|
441 // |
|
442 void CMediaFileHandler::HandleObjectNotification( CMdESession& /*aSession*/, |
|
443 TObserverNotificationType aType, |
|
444 const RArray<TItemId>& aObjectIdArray ) |
|
445 { |
|
446 const TInt KObserverCallStep = 100; |
|
447 |
|
448 if ( aType == ENotifyAdd || aType == ENotifyModify || aType == ENotifyRemove ) |
|
449 { |
|
450 if ( iObserver ) |
|
451 { |
|
452 TInt count = aObjectIdArray.Count(); |
|
453 FLOG( _L("CMediaFileHandler::HandleObjectNotification: count is %d"), count ); |
|
454 |
|
455 iMediaFileCounter = iMediaFileCounter + count; |
|
456 if ( iMediaFileCounter >= KObserverCallStep ) |
|
457 { |
|
458 iMediaFileCounter = 0; |
|
459 TRAP_IGNORE( iObserver->HandleMFEventL( |
|
460 MMediaFileHandlerObserver::EMediaFileChanged, KErrNone ) ); |
|
461 } |
|
462 else |
|
463 { |
|
464 // delayed call to avoid many consecutive observer calls |
|
465 CallObserverWithDelay(); |
|
466 } |
|
467 } |
|
468 } |
|
469 } |
|
470 |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CMediaFileHandler::HandleObjectPresentNotification (MMdEObjectPresentObserver) |
|
474 // |
|
475 // Called when previously used memory card is inserted and hidden |
|
476 // metadata files are made present again. |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 void CMediaFileHandler::HandleObjectPresentNotification( CMdESession& /*aSession*/, |
|
480 TBool /*aPresent*/, const RArray<TItemId>& aObjectIdArray ) |
|
481 { |
|
482 if ( iObserver ) |
|
483 { |
|
484 TInt count = aObjectIdArray.Count(); |
|
485 FLOG( _L("CMediaFileHandler::HandleObjectPresentNotification: count is %d"), count ); |
|
486 |
|
487 // delayed call to avoid many consecutive observer calls |
|
488 CallObserverWithDelay(); |
|
489 } |
|
490 } |
|
491 |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CMediaFileHandler::HandleQueryCompleted (MMdEQueryObserver) |
|
495 // |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 void CMediaFileHandler::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError ) |
|
499 { |
|
500 |
|
501 TInt err = KErrNone; |
|
502 TRAP( err, HandleQueryCompletedL( aQuery, aError ) ); |
|
503 |
|
504 if ( err == KErrCancel ) |
|
505 { |
|
506 CallObserver( MMediaFileHandlerObserver::EQueryCanceled, KErrNone ); |
|
507 } |
|
508 else if ( err != KErrNone ) |
|
509 { |
|
510 iSearchList->Reset(); |
|
511 TRAP_IGNORE( iArtistQuery->ResetL() ); |
|
512 |
|
513 CallObserver( MMediaFileHandlerObserver::EError, err ); |
|
514 } |
|
515 } |
|
516 |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CMediaFileHandler::HandleQueryCompletedL |
|
520 // |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 void CMediaFileHandler::HandleQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError ) |
|
524 { |
|
525 TInt err = aError; |
|
526 |
|
527 if ( !iQuery && ( iRomScanState != MMediaFileHandlerObserver::ERomScanComplete |
|
528 && (iQueryType == EQueryTone || iQueryType == ESearchTones )) ) |
|
529 { |
|
530 err = KErrGeneral; |
|
531 } |
|
532 if ( err == KErrCancel ) |
|
533 { |
|
534 if ( iQueryType == ESearchAudio || iQueryType == ESearchMusic || |
|
535 iQueryType == ESearchTones || iQueryType == ESearchVideo ) |
|
536 { |
|
537 iSearchList->Reset(); |
|
538 } |
|
539 User::Leave( err ); |
|
540 } |
|
541 if ( err != KErrNone ) |
|
542 { |
|
543 User::Leave( err ); |
|
544 } |
|
545 |
|
546 |
|
547 iSearchList->SetSession( iSession ); |
|
548 |
|
549 TQueryResultMode resultMode = EQueryResultModeItem; |
|
550 if ( iQuery ) |
|
551 { |
|
552 resultMode = iQuery->ResultMode(); |
|
553 } |
|
554 |
|
555 |
|
556 if ( resultMode == EQueryResultModeDistinctValues ) |
|
557 { |
|
558 iSearchList->Reset(); |
|
559 iSearchList->TakeDistinctResultL( iQuery, KErrNotFound ); |
|
560 iSearchList->SetSearchId( iQueryId ); |
|
561 iSearchList->Sort(); |
|
562 |
|
563 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
564 } |
|
565 else if ( resultMode == EQueryResultModeCount ) |
|
566 { |
|
567 // EQueryResultModeCount currently not used |
|
568 CallObserver( MMediaFileHandlerObserver::EUnknownQueryComplete, KErrNone ); |
|
569 } |
|
570 else if ( resultMode == EQueryResultModeItem ) |
|
571 { |
|
572 if ( iQueryType == ESearchAudio ) |
|
573 { |
|
574 // ESearchAudio currently not used |
|
575 iSearchList->Reset(); |
|
576 iSearchList->TakeResultL( iQuery, EMediaTypeMusic ); |
|
577 iSearchList->Sort(); |
|
578 iSearchList->SetSearchId( iQueryId ); |
|
579 |
|
580 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
581 |
|
582 /* |
|
583 // ESearchAudio currently not used |
|
584 iSearchList->Reset(); |
|
585 iSearchList->TakeResultL( iQuery, EMediaTypeMusic ); |
|
586 |
|
587 delete iIdle; |
|
588 iIdle = NULL; |
|
589 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
590 if ( iIdle ) |
|
591 { |
|
592 iIdle->Start( TCallBack( SearchVideo, this ) ); |
|
593 } |
|
594 */ |
|
595 } |
|
596 else if ( iQueryType == ESearchMusic ) |
|
597 { |
|
598 // search is done in 3 steps (music, tones and videos) |
|
599 iSearchList->Reset(); |
|
600 iSearchList->TakeResultL( iQuery, EMediaTypeMusic ); |
|
601 |
|
602 // call SearchTonesL after short delay (iQuery cannot |
|
603 // be deleted in this function) |
|
604 delete iIdle; |
|
605 iIdle = NULL; |
|
606 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
607 if ( iIdle ) |
|
608 { |
|
609 iIdle->Start( TCallBack( SearchTones, this ) ); |
|
610 } |
|
611 else |
|
612 { |
|
613 User::Leave( KErrNoMemory ); |
|
614 } |
|
615 } |
|
616 else if ( iQueryType == ESearchTones ) |
|
617 { |
|
618 iSearchList->SearchInToneL( iRomFileList, iSearchText ); |
|
619 iQueryinProgress = EFalse; |
|
620 // call SearchVideosL after short delay (iQuery cannot |
|
621 // be deleted in this function) |
|
622 delete iIdle; |
|
623 iIdle = NULL; |
|
624 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
625 if ( iIdle ) |
|
626 { |
|
627 iIdle->Start( TCallBack( SearchVideo, this ) ); |
|
628 } |
|
629 else |
|
630 { |
|
631 User::Leave( KErrNoMemory ); |
|
632 } |
|
633 } |
|
634 else if ( iQueryType == ESearchVideo ) |
|
635 { |
|
636 iSearchList->TakeResultL( iQuery, EMediaTypeVideo ); |
|
637 iSearchList->VideoSearchInRomL( iRomFileList, iSearchText ); |
|
638 iSearchList->Sort(); |
|
639 iSearchList->SetSearchId( iQueryId ); |
|
640 |
|
641 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
642 } |
|
643 |
|
644 else if ( iQueryType == EQueryArtist ) |
|
645 { |
|
646 // store CMdEObjectQuery to avoid multiple queries for one artist |
|
647 iArtistQuery->SetQuery( iQuery ); |
|
648 iQuery = NULL; |
|
649 |
|
650 iSearchList->Reset(); |
|
651 iSearchList->TakeArtistResultL( iArtistQuery ); |
|
652 iSearchList->Sort(); |
|
653 iSearchList->SetSearchId( iQueryId ); |
|
654 |
|
655 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
656 } |
|
657 else if ( iQueryType == EQueryArtistEmpty ) |
|
658 { |
|
659 // use previously stored CMdEObjectQuery for artist query |
|
660 iSearchList->Reset(); |
|
661 iSearchList->TakeArtistResultL( iArtistQuery ); |
|
662 iSearchList->Sort(); |
|
663 iSearchList->SetSearchId( iQueryId ); |
|
664 |
|
665 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
666 } |
|
667 else if ( iQueryType == EQueryEmpty ) |
|
668 { |
|
669 iSearchList->Reset(); |
|
670 iSearchList->SetSearchId( iQueryId ); |
|
671 |
|
672 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
673 } |
|
674 else if ( iQueryType == EQueryUnknown ) |
|
675 { |
|
676 iSearchList->Reset(); |
|
677 iSearchList->TakeResultL( iQuery, EMediaTypeMusic ); |
|
678 iSearchList->SetSearchId( iQueryId ); |
|
679 |
|
680 CallObserver( MMediaFileHandlerObserver::EUnknownQueryComplete, KErrNone ); |
|
681 } |
|
682 else |
|
683 { |
|
684 TInt mediaType = MediaType( iQueryType ); |
|
685 iSearchList->Reset(); |
|
686 if ( mediaType == EMediaTypeTone ) |
|
687 { |
|
688 iSearchList->AddRomItemL( iRomFileList, mediaType ); |
|
689 } |
|
690 else |
|
691 { |
|
692 iSearchList->TakeResultL( iQuery, mediaType ); |
|
693 if ( mediaType == EMediaTypeVideo ) |
|
694 { |
|
695 iSearchList->AddRomItemL( iRomFileList, mediaType ); |
|
696 } |
|
697 } |
|
698 iQueryinProgress = EFalse; |
|
699 iSearchList->SetSearchId( iQueryId ); |
|
700 iSearchList->Sort(); |
|
701 |
|
702 CallObserver( MMediaFileHandlerObserver::EQueryComplete, KErrNone ); |
|
703 } |
|
704 } |
|
705 else |
|
706 { |
|
707 CallObserver( MMediaFileHandlerObserver::EError, KErrNotSupported ); |
|
708 } |
|
709 } |
|
710 |
|
711 |
|
712 // ----------------------------------------------------------------------------- |
|
713 // CMediaFileHandler::QueryArtistL |
|
714 // |
|
715 // Finds all music files for one artist. Query results are placed in |
|
716 // CArtistQuery. |
|
717 // CArtistQuery can then be used for artist subqueries (all albums, one album, |
|
718 // all songs, unknown songs). |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CMediaFileHandler::QueryArtistL( TInt aAttr, const TDesC& aArtist, |
|
722 const TDesC& aAlbum, TBool aRefresh ) |
|
723 { |
|
724 LeaveIfSessionClosedL(); |
|
725 |
|
726 if ( aAttr != EQueryArtist && aAttr != EQueryArtistAlbum && |
|
727 aAttr != EQueryArtistAll && aAttr != EQueryArtistUnknown ) |
|
728 { |
|
729 User::Leave( KErrNotSupported ); |
|
730 } |
|
731 |
|
732 TBool updateFromDatabase = aRefresh; |
|
733 if ( iArtistQuery->Artist().Compare( aArtist ) != 0 ) |
|
734 { |
|
735 updateFromDatabase = ETrue; |
|
736 } |
|
737 |
|
738 if ( updateFromDatabase ) |
|
739 { |
|
740 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
741 CMdEObjectDef& objectDef = defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
742 |
|
743 delete iQuery; |
|
744 iQuery = NULL; |
|
745 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
746 |
|
747 // set attributes that are included in query result |
|
748 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
749 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
750 CMdEPropertyDef& albumPropertyDef = PropertyDefL( EAttrAlbum ); |
|
751 iQuery->AddPropertyFilterL( &albumPropertyDef ); |
|
752 |
|
753 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
754 CMdEPropertyDef& propertyDef = PropertyDefL( EAttrArtist ); |
|
755 conditions.AddPropertyConditionL( propertyDef, |
|
756 ETextPropertyConditionCompareEquals, aArtist ); |
|
757 |
|
758 iQuery->SetResultMode( EQueryResultModeItem ); |
|
759 |
|
760 iArtistQuery->SetArtistL( aArtist ); |
|
761 iArtistQuery->SetAlbumL( aAlbum ); |
|
762 iQuery->FindL(); |
|
763 iQueryType = EQueryArtist; |
|
764 } |
|
765 else |
|
766 { |
|
767 iArtistQuery->SetAlbumL( aAlbum ); |
|
768 QueryArtistEmptyL(); |
|
769 iQueryType = EQueryArtistEmpty; |
|
770 } |
|
771 |
|
772 iArtistQuery->SetQueryType( aAttr ); |
|
773 } |
|
774 |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CMediaFileHandler::QueryArtistEmptyL |
|
778 // |
|
779 // Makes empty query. Query results were previously placed into CArtistQuery. |
|
780 // ----------------------------------------------------------------------------- |
|
781 // |
|
782 void CMediaFileHandler::QueryArtistEmptyL() |
|
783 { |
|
784 LeaveIfSessionClosedL(); |
|
785 |
|
786 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
787 CMdEObjectDef& objectDef = |
|
788 defNS.GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
789 |
|
790 delete iQuery; |
|
791 iQuery = NULL; |
|
792 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
793 |
|
794 iQuery->SetResultMode( EQueryResultModeItem ); |
|
795 |
|
796 iQuery->FindL( 1 ); |
|
797 |
|
798 iQueryType = EQueryArtistEmpty; |
|
799 } |
|
800 |
|
801 |
|
802 // ----------------------------------------------------------------------------- |
|
803 // CMediaFileHandler::QueryMusicL |
|
804 // |
|
805 // Finds music files. |
|
806 // ----------------------------------------------------------------------------- |
|
807 // |
|
808 void CMediaFileHandler::QueryMusicL( TInt /*aAttr*/ ) |
|
809 { |
|
810 LeaveIfSessionClosedL(); |
|
811 |
|
812 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
813 CMdEObjectDef& musicObjectDef = |
|
814 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
815 |
|
816 delete iQuery; |
|
817 iQuery = NULL; |
|
818 iQuery = iSession->NewObjectQueryL( defNS, musicObjectDef, this ); |
|
819 |
|
820 // set attributes that are included in query result |
|
821 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
822 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
823 CMdEPropertyDef& fileTypePropertyDef = PropertyDefL( EAttrMediaType ); |
|
824 iQuery->AddPropertyFilterL( &fileTypePropertyDef ); |
|
825 |
|
826 |
|
827 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
828 |
|
829 // include properties that identify music |
|
830 IncludeMusicPropertiesL( conditions ); |
|
831 |
|
832 // |
|
833 // example of defining sort order |
|
834 // |
|
835 // iQuery->AppendOrderRuleL( TMdEOrderRule( namePropertyDef, ESortAscending ) ); |
|
836 |
|
837 iQuery->SetResultMode( EQueryResultModeItem ); |
|
838 |
|
839 iQuery->FindL(); |
|
840 |
|
841 iQueryType = EQueryMusic; |
|
842 } |
|
843 |
|
844 |
|
845 // ----------------------------------------------------------------------------- |
|
846 // CMediaFileHandler::QueryMusicL |
|
847 // |
|
848 // Finds music files with attibute that matches aFindText. Supported attributes |
|
849 // are EAttrArtist, EAttrAlbum, EAttrGenre and EAttrComposer. |
|
850 // ----------------------------------------------------------------------------- |
|
851 // |
|
852 void CMediaFileHandler::QueryMusicL( TInt aAttr, const TDesC& aFindText ) |
|
853 { |
|
854 LeaveIfSessionClosedL(); |
|
855 CheckAttrL( aAttr ); |
|
856 |
|
857 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
858 CMdEObjectDef& objectDef = |
|
859 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
860 |
|
861 delete iQuery; |
|
862 iQuery = NULL; |
|
863 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
864 |
|
865 // set attributes that are included in query result |
|
866 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
867 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
868 |
|
869 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
870 CMdEPropertyDef& propertyDef = PropertyDefL( aAttr ); |
|
871 conditions.AddPropertyConditionL( propertyDef, |
|
872 ETextPropertyConditionCompareEquals, aFindText ); |
|
873 IncludeMusicPropertiesL( conditions ); |
|
874 iQuery->SetResultMode( EQueryResultModeItem ); |
|
875 |
|
876 iQuery->FindL(); |
|
877 |
|
878 iQueryType = EQueryMusic; |
|
879 } |
|
880 |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CMediaFileHandler::QueryVideosL |
|
884 // |
|
885 // Finds all video files. |
|
886 // ----------------------------------------------------------------------------- |
|
887 // |
|
888 void CMediaFileHandler::QueryVideosL( TInt /*aAttr*/ ) |
|
889 { |
|
890 LeaveIfSessionClosedL(); |
|
891 |
|
892 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
893 CMdEObjectDef& videoObjectDef = |
|
894 defNS.GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
895 |
|
896 delete iQuery; |
|
897 iQuery = NULL; |
|
898 iQuery = iSession->NewObjectQueryL( defNS, videoObjectDef, this ); |
|
899 |
|
900 // set attributes that are included in query result |
|
901 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
902 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
903 |
|
904 iQuery->SetResultMode( EQueryResultModeItem ); |
|
905 |
|
906 iQuery->FindL(); |
|
907 |
|
908 iQueryType = EQueryVideo; |
|
909 } |
|
910 |
|
911 |
|
912 // ----------------------------------------------------------------------------- |
|
913 // CMediaFileHandler::QueryAttributeValuesL |
|
914 // |
|
915 // Finds all different values for aAttr (all artists, albums, genres, |
|
916 // or composers). |
|
917 // ----------------------------------------------------------------------------- |
|
918 // |
|
919 void CMediaFileHandler::QueryAttributeValuesL( TInt aAttr ) |
|
920 { |
|
921 LeaveIfSessionClosedL(); |
|
922 CheckAttrL( aAttr ); |
|
923 |
|
924 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
925 CMdEObjectDef& objectDef = |
|
926 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
927 |
|
928 delete iQuery; |
|
929 iQuery = NULL; |
|
930 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
931 |
|
932 iQuery->SetResultMode( EQueryResultModeDistinctValues ); |
|
933 |
|
934 CMdEPropertyDef& propertyDef = PropertyDefL( aAttr ); |
|
935 |
|
936 // distinct query requires exactly one property filter |
|
937 // (eg. attribute that is included in query result) |
|
938 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
939 conditions.AddPropertyConditionL( propertyDef ); |
|
940 iQuery->AddPropertyFilterL( &propertyDef ); |
|
941 IncludeMusicPropertiesL( conditions ); |
|
942 iQuery->FindL(); |
|
943 |
|
944 iQueryType = EQueryMusic; |
|
945 } |
|
946 |
|
947 |
|
948 // ----------------------------------------------------------------------------- |
|
949 // CMediaFileHandler::QueryMusicUnknownL |
|
950 // |
|
951 // Find music files that do not have attribute aAttr (eg find all files without |
|
952 // album attribute). |
|
953 // ----------------------------------------------------------------------------- |
|
954 // |
|
955 void CMediaFileHandler::QueryMusicUnknownL( TInt aAttr ) |
|
956 { |
|
957 LeaveIfSessionClosedL(); |
|
958 CheckAttrL( aAttr ); |
|
959 |
|
960 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
961 CMdEObjectDef& objectDef = |
|
962 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
963 |
|
964 delete iQuery; |
|
965 iQuery = NULL; |
|
966 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
967 |
|
968 iQuery->SetResultMode( EQueryResultModeItem ); |
|
969 |
|
970 CMdEPropertyDef& propertyDef = PropertyDefL( aAttr ); |
|
971 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
972 |
|
973 |
|
974 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
975 |
|
976 // include properties that identify music |
|
977 IncludeMusicPropertiesL( conditions ); |
|
978 |
|
979 // add condition: get music that do not have aAttr attribute |
|
980 CMdELogicCondition& condition = |
|
981 conditions.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
982 condition.AddPropertyConditionL( propertyDef ); |
|
983 condition.SetNegate( ETrue ); |
|
984 |
|
985 // set attributes that are included in query result |
|
986 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
987 |
|
988 iQuery->FindL(); |
|
989 |
|
990 iQueryType = EQueryMusic; |
|
991 } |
|
992 |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CMediaFileHandler::QueryMusicUnknownCountL |
|
996 // |
|
997 // Find whether there are music files that do not have attribute aAttr |
|
998 // (eg files without album attribute) |
|
999 // |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // |
|
1002 void CMediaFileHandler::QueryMusicUnknownCountL( TInt aAttr ) |
|
1003 { |
|
1004 LeaveIfSessionClosedL(); |
|
1005 CheckAttrL( aAttr ); |
|
1006 |
|
1007 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1008 CMdEObjectDef& objectDef = |
|
1009 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1010 |
|
1011 delete iQuery; |
|
1012 iQuery = NULL; |
|
1013 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1014 |
|
1015 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1016 |
|
1017 CMdEPropertyDef& propertyDef = PropertyDefL( aAttr ); |
|
1018 |
|
1019 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1020 |
|
1021 // include properties that identify music |
|
1022 IncludeMusicPropertiesL( conditions ); |
|
1023 |
|
1024 // add condition: get music that do not have aAttr attribute |
|
1025 CMdELogicCondition& condition = |
|
1026 conditions.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
1027 condition.AddPropertyConditionL( propertyDef ); |
|
1028 condition.SetNegate( ETrue ); |
|
1029 |
|
1030 |
|
1031 // count 0 or 1 is enough for UI |
|
1032 iQuery->FindL( 1 ); |
|
1033 iQueryType = EQueryUnknown; |
|
1034 } |
|
1035 |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // CMediaFileHandler::QueryEmptyL |
|
1039 // |
|
1040 // Makes empty query. |
|
1041 // ----------------------------------------------------------------------------- |
|
1042 // |
|
1043 void CMediaFileHandler::QueryEmptyL() |
|
1044 { |
|
1045 LeaveIfSessionClosedL(); |
|
1046 iQueryType = EQueryEmpty; |
|
1047 if ( iQuery ) |
|
1048 { |
|
1049 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1050 HandleQueryCompleted( *iQuery , KErrNone); |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1055 CMdEObjectDef& objectDef = |
|
1056 defNS.GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
1057 |
|
1058 delete iQuery; |
|
1059 iQuery = NULL; |
|
1060 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1061 |
|
1062 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1063 iQuery->FindL( 0 ); |
|
1064 |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // CMediaFileHandler::QueryRomEmptyL( TInt aQueryType ) |
|
1070 // |
|
1071 // Makes empty query. |
|
1072 // ----------------------------------------------------------------------------- |
|
1073 // |
|
1074 void CMediaFileHandler::QueryRomEmptyL( TInt aQueryType ) |
|
1075 { |
|
1076 LeaveIfSessionClosedL(); |
|
1077 if ( iQuery ) |
|
1078 { |
|
1079 iQueryType = aQueryType; |
|
1080 HandleQueryCompleted( *iQuery , KErrNone); |
|
1081 } |
|
1082 else |
|
1083 { |
|
1084 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1085 CMdEObjectDef& objectDef = |
|
1086 defNS.GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
1087 |
|
1088 delete iQuery; |
|
1089 iQuery = NULL; |
|
1090 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1091 |
|
1092 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1093 iQuery->FindL( 0 ); |
|
1094 |
|
1095 iQueryType = aQueryType; |
|
1096 } |
|
1097 } |
|
1098 |
|
1099 |
|
1100 // ----------------------------------------------------------------------------- |
|
1101 // CMediaFileHandler::QueryRecordingsL |
|
1102 // |
|
1103 // Finds all recordings. |
|
1104 // |
|
1105 // Note: File is considered a recording if file extension is "amr" or "wav" and |
|
1106 // file is not in rom. |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CMediaFileHandler::QueryRecordingsL( TInt /*aAttr*/ ) |
|
1110 { |
|
1111 LeaveIfSessionClosedL(); |
|
1112 |
|
1113 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1114 CMdEObjectDef& musicObjectDef = |
|
1115 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1116 |
|
1117 delete iQuery; |
|
1118 iQuery = NULL; |
|
1119 iQuery = iSession->NewObjectQueryL( defNS, musicObjectDef, this ); |
|
1120 |
|
1121 |
|
1122 // set attributes that are included in query result |
|
1123 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
1124 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
1125 |
|
1126 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1127 |
|
1128 CMdEPropertyDef& fileTypeDef = PropertyDefL( EAttrMediaType ); |
|
1129 |
|
1130 |
|
1131 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1132 CMdEObjectCondition& cond = conditions.AddObjectConditionL( |
|
1133 EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
1134 cond.SetNegate( ETrue ); |
|
1135 |
|
1136 |
|
1137 CMdELogicCondition& condition = |
|
1138 conditions.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
1139 condition.AddPropertyConditionL( fileTypeDef, |
|
1140 ETextPropertyConditionCompareContains, KMimeTypeAMR ); |
|
1141 condition.AddPropertyConditionL( fileTypeDef, |
|
1142 ETextPropertyConditionCompareContains, KMimeTypeWAV ); |
|
1143 |
|
1144 iQuery->FindL(); |
|
1145 |
|
1146 iQueryType = EQueryRecording; |
|
1147 } |
|
1148 |
|
1149 |
|
1150 // ----------------------------------------------------------------------------- |
|
1151 // CMediaFileHandler::QueryTonesL |
|
1152 // |
|
1153 // Finds all tones. |
|
1154 // Note: Audio file is considered a tone if it is not music or video. |
|
1155 // ----------------------------------------------------------------------------- |
|
1156 // |
|
1157 void CMediaFileHandler::QueryTonesL( TInt /*aAttr*/ ) |
|
1158 { |
|
1159 LeaveIfSessionClosedL(); |
|
1160 |
|
1161 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1162 CMdEObjectDef& musicObjectDef = |
|
1163 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1164 |
|
1165 delete iQuery; |
|
1166 iQuery = NULL; |
|
1167 iQuery = iSession->NewObjectQueryL( defNS, musicObjectDef, this ); |
|
1168 |
|
1169 |
|
1170 // set attributes that are included in query result |
|
1171 CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
1172 iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
1173 |
|
1174 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1175 |
|
1176 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1177 ExcludeMusicPropertiesL( conditions ); |
|
1178 |
|
1179 iQuery->FindL(); |
|
1180 |
|
1181 iQueryType = EQueryTone; |
|
1182 } |
|
1183 |
|
1184 |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 // CMediaFileHandler::QueryDefaultTonesL |
|
1187 // |
|
1188 // Finds all sound files from rom (nokia default tones). |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // |
|
1191 void CMediaFileHandler::QueryDefaultTonesL( TInt /*aAttr*/ ) |
|
1192 { |
|
1193 |
|
1194 if ( iRomScanState == MMediaFileHandlerObserver::ERomScanComplete ) |
|
1195 { |
|
1196 QueryRomEmptyL( EQueryTone ); |
|
1197 } |
|
1198 else if ( iRomScanState == MMediaFileHandlerObserver::ERomScanInProgress ) |
|
1199 { |
|
1200 iQueryinProgress = ETrue; |
|
1201 } |
|
1202 else |
|
1203 { |
|
1204 //Rom scan not start or failed for some reason |
|
1205 iQueryinProgress = ETrue; |
|
1206 StartRomScaning( EQueryTone ); |
|
1207 } |
|
1208 } |
|
1209 |
|
1210 // ----------------------------------------------------------------------------- |
|
1211 // CMediaFileHandler::QueryDefaultTTonessL |
|
1212 // |
|
1213 // Finds all sound files from rom (nokia default tones). |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // |
|
1216 //void CMediaFileHandler::QueryDefaultTonesL( TInt /*aAttr*/ ) |
|
1217 // { |
|
1218 // LeaveIfSessionClosedL(); |
|
1219 // |
|
1220 // CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1221 // CMdEObjectDef& musicObjectDef = |
|
1222 // defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1223 // |
|
1224 // delete iQuery; |
|
1225 // iQuery = NULL; |
|
1226 // iQuery = iSession->NewObjectQueryL( defNS, musicObjectDef, this ); |
|
1227 // |
|
1228 // |
|
1229 // // set attributes that are included in query result |
|
1230 // CMdEPropertyDef& namePropertyDef = PropertyDefL( EAttrSongName ); |
|
1231 // iQuery->AddPropertyFilterL( &namePropertyDef ); |
|
1232 // |
|
1233 // iQuery->SetResultMode( EQueryResultModeItem ); |
|
1234 // |
|
1235 // CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1236 // CMdEObjectCondition& cond = conditions.AddObjectConditionL( |
|
1237 // EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
1238 // |
|
1239 // iQuery->FindL(); |
|
1240 // |
|
1241 // iQueryType = EQueryTone; |
|
1242 // } |
|
1243 |
|
1244 // ----------------------------------------------------------------------------- |
|
1245 // CMediaFileHandler::SearchL |
|
1246 // |
|
1247 // Finds all music, tone and video files with any attibute that |
|
1248 // matches aFindText. |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 // |
|
1251 void CMediaFileHandler::SearchL( const TDesC& aSearchText ) |
|
1252 { |
|
1253 // |
|
1254 // search is done in 3 steps, SearchTonesL and SearchVideoL are |
|
1255 // called after SearchMusicL is done. Search results are collected |
|
1256 // in iSearchList. |
|
1257 // |
|
1258 |
|
1259 if ( aSearchText.Length() == 0 ) |
|
1260 { |
|
1261 iSearchText = KNullDesC; |
|
1262 QueryEmptyL(); |
|
1263 } |
|
1264 else |
|
1265 { |
|
1266 StrCopy( iSearchText, aSearchText ); |
|
1267 SearchMusicL( iSearchText ); |
|
1268 } |
|
1269 } |
|
1270 |
|
1271 |
|
1272 // ----------------------------------------------------------------------------- |
|
1273 // CMediaFileHandler::SearchAudioL |
|
1274 // |
|
1275 // Finds all audio files with attibute that matches aFindText. |
|
1276 // Searched attributes are name, artist, album, genre, composer. |
|
1277 // ----------------------------------------------------------------------------- |
|
1278 // |
|
1279 void CMediaFileHandler::SearchAudioL( const TDesC& aSearchText ) |
|
1280 { |
|
1281 SearchMusicL( aSearchText ); |
|
1282 iQueryType = ESearchAudio; |
|
1283 |
|
1284 /* |
|
1285 LeaveIfSessionClosedL(); |
|
1286 |
|
1287 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1288 CMdEObjectDef& objectDef = |
|
1289 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1290 |
|
1291 delete iQuery; |
|
1292 iQuery = NULL; |
|
1293 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1294 |
|
1295 // set attributes that are included in query result |
|
1296 CMdEPropertyDef& song = PropertyDefL( EAttrSongName ); |
|
1297 iQuery->AddPropertyFilterL( &song ); |
|
1298 |
|
1299 CMdEPropertyDef& artist = PropertyDefL( EAttrArtist ); |
|
1300 iQuery->AddPropertyFilterL( &artist ); |
|
1301 CMdEPropertyDef& album = PropertyDefL( EAttrAlbum ); |
|
1302 iQuery->AddPropertyFilterL( &album ); |
|
1303 CMdEPropertyDef& genre = PropertyDefL( EAttrGenre ); |
|
1304 iQuery->AddPropertyFilterL( &genre ); |
|
1305 CMdEPropertyDef& composer = PropertyDefL( EAttrComposer ); |
|
1306 iQuery->AddPropertyFilterL( &composer ); |
|
1307 |
|
1308 CMdEPropertyDef& fileTypePropertyDef = PropertyDefL( EAttrMediaType ); |
|
1309 iQuery->AddPropertyFilterL( &fileTypePropertyDef ); |
|
1310 |
|
1311 |
|
1312 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1313 conditions.SetOperator( ELogicConditionOperatorAnd ); |
|
1314 |
|
1315 IncludeMusicSearchConditionL( conditions, aSearchText ); |
|
1316 |
|
1317 |
|
1318 |
|
1319 // iQuery->AppendOrderRuleL( TMdEOrderRule( song, ESortAscending ) ); |
|
1320 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1321 iQuery->FindL(); |
|
1322 |
|
1323 iQueryType = ESearchAudio; |
|
1324 */ |
|
1325 } |
|
1326 |
|
1327 |
|
1328 // ----------------------------------------------------------------------------- |
|
1329 // CMediaFileHandler::SearchMusicL |
|
1330 // |
|
1331 // Finds all music with attibute that matches aFindText. |
|
1332 // Searched attributes are name, artist, album, genre, composer. |
|
1333 // ----------------------------------------------------------------------------- |
|
1334 // |
|
1335 void CMediaFileHandler::SearchMusicL( const TDesC& aSearchText ) |
|
1336 { |
|
1337 LeaveIfSessionClosedL(); |
|
1338 |
|
1339 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1340 CMdEObjectDef& objectDef = |
|
1341 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1342 |
|
1343 delete iQuery; |
|
1344 iQuery = NULL; |
|
1345 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1346 |
|
1347 // set attributes that are included in query result |
|
1348 CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
1349 iQuery->AddPropertyFilterL( &songName ); |
|
1350 CMdEPropertyDef& fileTypePropertyDef = PropertyDefL( EAttrMediaType ); |
|
1351 iQuery->AddPropertyFilterL( &fileTypePropertyDef ); |
|
1352 |
|
1353 |
|
1354 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1355 conditions.SetOperator( ELogicConditionOperatorAnd ); |
|
1356 |
|
1357 //IncludeMusicPropertiesL( conditions ); |
|
1358 IncludeMusicSearchConditionL( conditions, aSearchText ); |
|
1359 |
|
1360 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1361 iQuery->FindL(); |
|
1362 |
|
1363 iQueryType = ESearchMusic; |
|
1364 } |
|
1365 |
|
1366 |
|
1367 // ----------------------------------------------------------------------------- |
|
1368 // CMediaFileHandler::SearchTonesL |
|
1369 // |
|
1370 // Finds all tones with attibute that matches aFindText. |
|
1371 // Searched attribute is file name. |
|
1372 // ----------------------------------------------------------------------------- |
|
1373 // |
|
1374 void CMediaFileHandler::SearchTonesL( const TDesC& /*aSearchText */) |
|
1375 { |
|
1376 if ( iRomScanState == MMediaFileHandlerObserver::ERomScanComplete ) |
|
1377 { |
|
1378 QueryRomEmptyL( ESearchTones ); |
|
1379 } |
|
1380 else if ( iRomScanState == MMediaFileHandlerObserver::ERomScanInProgress ) |
|
1381 { |
|
1382 iQueryinProgress = ETrue; |
|
1383 } |
|
1384 else |
|
1385 { |
|
1386 //Rom scan not start or failed for some reason |
|
1387 iQueryinProgress = ETrue; |
|
1388 StartRomScaning( ESearchTones ); |
|
1389 } |
|
1390 } |
|
1391 |
|
1392 // |
|
1393 //// ----------------------------------------------------------------------------- |
|
1394 //// CMediaFileHandler::SearchTonesL |
|
1395 //// |
|
1396 //// Finds all tones with attibute that matches aFindText. |
|
1397 //// Searched attribute is file name. |
|
1398 //// ----------------------------------------------------------------------------- |
|
1399 //// |
|
1400 //void CMediaFileHandler::SearchTonesL( const TDesC& aSearchText ) |
|
1401 // { |
|
1402 // LeaveIfSessionClosedL(); |
|
1403 // |
|
1404 // CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1405 // CMdEObjectDef& objectDef = |
|
1406 // defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1407 // |
|
1408 // delete iQuery; |
|
1409 // iQuery = NULL; |
|
1410 // iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1411 // |
|
1412 // // set attributes that are included in query result |
|
1413 // CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
1414 // iQuery->AddPropertyFilterL( &songName ); |
|
1415 // CMdEPropertyDef& fileTypePropertyDef = PropertyDefL( EAttrMediaType ); |
|
1416 // iQuery->AddPropertyFilterL( &fileTypePropertyDef ); |
|
1417 // |
|
1418 // |
|
1419 // CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1420 // conditions.SetOperator( ELogicConditionOperatorAnd ); |
|
1421 // |
|
1422 // //ExcludeMusicPropertiesL( conditions ); |
|
1423 // CMdEObjectCondition& cond = conditions.AddObjectConditionL( |
|
1424 // EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
1425 // |
|
1426 // IncludeToneSearchConditionL( conditions, aSearchText ); |
|
1427 // |
|
1428 // iQuery->SetResultMode( EQueryResultModeItem ); |
|
1429 // iQuery->FindL(); |
|
1430 // |
|
1431 // iQueryType = ESearchTones; |
|
1432 // } |
|
1433 |
|
1434 |
|
1435 |
|
1436 // ----------------------------------------------------------------------------- |
|
1437 // CMediaFileHandler::SearchVideoL |
|
1438 // |
|
1439 // Finds all videos with attibute that matches aFindText. |
|
1440 // Searched attributes are name, artist, genre. |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 // |
|
1443 void CMediaFileHandler::SearchVideoL( const TDesC& aSearchText ) |
|
1444 { |
|
1445 LeaveIfSessionClosedL(); |
|
1446 if ( iRomScanState != MMediaFileHandlerObserver::ERomScanComplete ) |
|
1447 { |
|
1448 |
|
1449 StartRomScaning( ESearchVideo ); |
|
1450 } |
|
1451 |
|
1452 CMdENamespaceDef& defNS = iSession->GetDefaultNamespaceDefL(); |
|
1453 CMdEObjectDef& objectDef = |
|
1454 defNS.GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
1455 |
|
1456 delete iQuery; |
|
1457 iQuery = NULL; |
|
1458 iQuery = iSession->NewObjectQueryL( defNS, objectDef, this ); |
|
1459 |
|
1460 // set attributes that are included in query result |
|
1461 CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
1462 iQuery->AddPropertyFilterL( &songName ); |
|
1463 |
|
1464 CMdELogicCondition& conditions = iQuery->Conditions(); |
|
1465 IncludeVideoSearchConditionL( conditions, aSearchText ); |
|
1466 |
|
1467 iQuery->SetResultMode( EQueryResultModeItem ); |
|
1468 |
|
1469 if ( iVideoSearchDisabled ) |
|
1470 { |
|
1471 iQuery->FindL( 0 ); |
|
1472 } |
|
1473 else |
|
1474 { |
|
1475 iQuery->FindL(); |
|
1476 } |
|
1477 |
|
1478 iQueryType = ESearchVideo; |
|
1479 } |
|
1480 |
|
1481 |
|
1482 // ----------------------------------------------------------------------------- |
|
1483 // CMediaFileDialog::SearchVideo |
|
1484 // |
|
1485 // ----------------------------------------------------------------------------- |
|
1486 // |
|
1487 TInt CMediaFileHandler::SearchVideo( TAny *aObj ) |
|
1488 { |
|
1489 CMediaFileHandler* handler = (CMediaFileHandler*) aObj; |
|
1490 |
|
1491 TInt err = KErrNone; |
|
1492 TRAP( err, handler->SearchVideoL( handler->iSearchText ) ); |
|
1493 |
|
1494 if ( err != KErrNone ) |
|
1495 { |
|
1496 handler->CallObserver( MMediaFileHandlerObserver::EError, err ); |
|
1497 } |
|
1498 |
|
1499 return 0; |
|
1500 } |
|
1501 |
|
1502 |
|
1503 // ----------------------------------------------------------------------------- |
|
1504 // CMediaFileDialog::SearchTones |
|
1505 // |
|
1506 // ----------------------------------------------------------------------------- |
|
1507 // |
|
1508 TInt CMediaFileHandler::SearchTones( TAny *aObj ) |
|
1509 { |
|
1510 CMediaFileHandler* handler = (CMediaFileHandler*) aObj; |
|
1511 |
|
1512 TInt err = KErrNone; |
|
1513 TRAP( err, handler->SearchTonesL( handler->iSearchText ) ); |
|
1514 |
|
1515 if ( err != KErrNone ) |
|
1516 { |
|
1517 handler->CallObserver( MMediaFileHandlerObserver::EError, err ); |
|
1518 } |
|
1519 |
|
1520 return 0; |
|
1521 } |
|
1522 |
|
1523 |
|
1524 // ----------------------------------------------------------------------------- |
|
1525 // CMediaFileHandler::ResultCount |
|
1526 // |
|
1527 // ----------------------------------------------------------------------------- |
|
1528 // |
|
1529 TInt CMediaFileHandler::ResultCount() |
|
1530 { |
|
1531 if ( !iSessionOpen ) |
|
1532 { |
|
1533 return 0; |
|
1534 } |
|
1535 |
|
1536 return iSearchList->Count(); |
|
1537 } |
|
1538 |
|
1539 |
|
1540 // ----------------------------------------------------------------------------- |
|
1541 // CMediaFileHandler::UnknownArtistCount |
|
1542 // |
|
1543 // Returns 1 if artist has at least one music file without album attribute, |
|
1544 // 0 otherwise. |
|
1545 // ----------------------------------------------------------------------------- |
|
1546 // |
|
1547 TInt CMediaFileHandler::UnknownArtistCount() |
|
1548 { |
|
1549 TInt ret = 0; |
|
1550 |
|
1551 TInt err = KErrNone; |
|
1552 TRAP( err, ret = UnknownArtistCountL() ); |
|
1553 if ( err != KErrNone ) |
|
1554 { |
|
1555 ret = 0; |
|
1556 } |
|
1557 return ret; |
|
1558 } |
|
1559 |
|
1560 |
|
1561 // ----------------------------------------------------------------------------- |
|
1562 // CMediaFileHandler::UnknownArtistCountL |
|
1563 // |
|
1564 // Returns 1 if artist has at least one music file without album attribute, |
|
1565 // 0 otherwise. |
|
1566 // ----------------------------------------------------------------------------- |
|
1567 // |
|
1568 TInt CMediaFileHandler::UnknownArtistCountL() |
|
1569 { |
|
1570 CMdEObjectQuery* artistQuery = iArtistQuery->Query(); |
|
1571 if ( !artistQuery ) |
|
1572 { |
|
1573 return 0; |
|
1574 } |
|
1575 |
|
1576 TInt count = artistQuery->Count(); |
|
1577 for ( TInt i=0; i<count; i++ ) |
|
1578 { |
|
1579 CMdEObject& object = artistQuery->Result( i ); |
|
1580 |
|
1581 CMdEPropertyDef& propDef = |
|
1582 CMediaFileHandler::PropertyDefL( iSession, CMediaFileHandler::EAttrAlbum ); |
|
1583 |
|
1584 CMdEProperty* property = NULL; |
|
1585 TInt ret = object.Property( propDef, property, 0 ); |
|
1586 if ( ret == KErrNotFound ) |
|
1587 { |
|
1588 return 1; |
|
1589 } |
|
1590 } |
|
1591 |
|
1592 return 0; |
|
1593 } |
|
1594 // ----------------------------------------------------------------------------- |
|
1595 // void CMediaFileHandler::StartRomScaning() |
|
1596 // |
|
1597 // Start rom scanning |
|
1598 // ----------------------------------------------------------------------------- |
|
1599 // |
|
1600 |
|
1601 void CMediaFileHandler::StartRomScaning( TInt aQueryType ) |
|
1602 { |
|
1603 |
|
1604 if ( iRomScanState != MMediaFileHandlerObserver::ERomScanComplete ) |
|
1605 { |
|
1606 iRomScanState = MMediaFileHandlerObserver::ERomScanInProgress; |
|
1607 iRomFileList->Reset(); |
|
1608 TRAPD( err , iRomFileList->ReadRomFilesL() ); |
|
1609 if ( err != KErrNone ) |
|
1610 { |
|
1611 iRomScanState = MMediaFileHandlerObserver::ERomScanError; |
|
1612 } |
|
1613 else |
|
1614 { |
|
1615 iRomScanState = MMediaFileHandlerObserver::ERomScanComplete; |
|
1616 } |
|
1617 } |
|
1618 |
|
1619 iSearchList->SetRomFileList( iRomFileList ); |
|
1620 |
|
1621 if ( iQueryinProgress ) |
|
1622 { |
|
1623 QueryRomEmptyL( aQueryType ); |
|
1624 } |
|
1625 |
|
1626 CallObserver( MMediaFileHandlerObserver::EScanRomComplete, KErrNone ); |
|
1627 } |
|
1628 |
|
1629 // ----------------------------------------------------------------------------- |
|
1630 // CMediaFileHandler::CancelQuery |
|
1631 // |
|
1632 // Cancels ongoing query. |
|
1633 // ----------------------------------------------------------------------------- |
|
1634 // |
|
1635 void CMediaFileHandler::CancelQuery() |
|
1636 { |
|
1637 if ( !iSessionOpen || !iQuery ) |
|
1638 { |
|
1639 return; |
|
1640 } |
|
1641 |
|
1642 if ( !iQuery->IsComplete() ) |
|
1643 { |
|
1644 iQuery->Cancel(); // this calls HandleQueryCompleted synchronously |
|
1645 } |
|
1646 } |
|
1647 |
|
1648 |
|
1649 // ----------------------------------------------------------------------------- |
|
1650 // CMediaFileHandler::LeaveIfSessionClosedL |
|
1651 // |
|
1652 // ----------------------------------------------------------------------------- |
|
1653 // |
|
1654 void CMediaFileHandler::LeaveIfSessionClosedL() |
|
1655 { |
|
1656 if ( !iSession || !iSessionOpen ) |
|
1657 { |
|
1658 User::Leave( KErrDisconnected ); |
|
1659 } |
|
1660 } |
|
1661 |
|
1662 |
|
1663 // ----------------------------------------------------------------------------- |
|
1664 // CMediaFileHandler::SetObserver |
|
1665 // |
|
1666 // ----------------------------------------------------------------------------- |
|
1667 // |
|
1668 void CMediaFileHandler::SetObserver( MMediaFileHandlerObserver* aObserver ) |
|
1669 { |
|
1670 iObserver = aObserver; |
|
1671 } |
|
1672 |
|
1673 |
|
1674 // ----------------------------------------------------------------------------- |
|
1675 // CMediaFileHandler::CheckAttrL |
|
1676 // |
|
1677 // ----------------------------------------------------------------------------- |
|
1678 // |
|
1679 void CMediaFileHandler::CheckAttrL( TInt aAttr ) |
|
1680 { |
|
1681 if ( aAttr != EAttrArtist && aAttr != EAttrAlbum && |
|
1682 aAttr != EAttrGenre && aAttr != EAttrComposer ) |
|
1683 { |
|
1684 User::Leave( KErrNotSupported ); |
|
1685 } |
|
1686 } |
|
1687 |
|
1688 |
|
1689 // ----------------------------------------------------------------------------- |
|
1690 // CMediaFileHandler::GetAttributeL |
|
1691 // |
|
1692 // NOTE: GetAttributeL only gets full name or file name |
|
1693 // ----------------------------------------------------------------------------- |
|
1694 // |
|
1695 void CMediaFileHandler::GetAttributeL( TInt aIndex, TInt aAttr, |
|
1696 TDes& aValue, TInt aQueryId ) |
|
1697 { |
|
1698 aValue = KNullDesC; |
|
1699 |
|
1700 if ( !iSessionOpen ) |
|
1701 { |
|
1702 return; |
|
1703 } |
|
1704 |
|
1705 TInt id = iSearchList->SearchId(); |
|
1706 if ( id != aQueryId ) |
|
1707 { |
|
1708 return; // search list and UI do not match |
|
1709 } |
|
1710 |
|
1711 iSearchList->SetSession( iSession ); |
|
1712 iSearchList->GetAttributeL( aIndex, aAttr, aValue ); |
|
1713 } |
|
1714 |
|
1715 |
|
1716 |
|
1717 // ----------------------------------------------------------------------------- |
|
1718 // CMediaFileHandler::GetAttribute |
|
1719 // |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 // |
|
1722 void CMediaFileHandler::GetAttribute( TInt aIndex, TInt aAttr, |
|
1723 TDes& aValue, TInt aQueryId ) |
|
1724 { |
|
1725 TRAP_IGNORE( GetAttributeL( aIndex, aAttr, aValue, aQueryId ) ); |
|
1726 } |
|
1727 |
|
1728 |
|
1729 // ----------------------------------------------------------------------------- |
|
1730 // CMediaFileHandler::Attribute |
|
1731 // |
|
1732 // ----------------------------------------------------------------------------- |
|
1733 // |
|
1734 TInt CMediaFileHandler::Attribute( TInt aIndex, TInt aAttr, TInt aQueryId ) |
|
1735 { |
|
1736 if ( !iSessionOpen ) |
|
1737 { |
|
1738 return KErrNotFound; |
|
1739 } |
|
1740 |
|
1741 TInt id = iSearchList->SearchId(); |
|
1742 if ( id != aQueryId ) |
|
1743 { |
|
1744 return KErrNotFound; |
|
1745 } |
|
1746 |
|
1747 return iSearchList->Attribute( aIndex, aAttr ); |
|
1748 } |
|
1749 |
|
1750 |
|
1751 // ----------------------------------------------------------------------------- |
|
1752 // CMediaFileHandler::ItemIndex |
|
1753 // |
|
1754 // ----------------------------------------------------------------------------- |
|
1755 // |
|
1756 TInt CMediaFileHandler::ItemIndex( TInt aItemId, TInt aIndex ) |
|
1757 { |
|
1758 return iSearchList->ItemIndex( aItemId, aIndex ); |
|
1759 } |
|
1760 |
|
1761 |
|
1762 // ----------------------------------------------------------------------------- |
|
1763 // CMediaFileHandler::ItemIndex |
|
1764 // |
|
1765 // ----------------------------------------------------------------------------- |
|
1766 // |
|
1767 TInt CMediaFileHandler::ItemIndex( const TDesC& aItemText, TInt aIndex ) |
|
1768 { |
|
1769 return iSearchList->ItemIndex( aItemText, aIndex ); |
|
1770 } |
|
1771 |
|
1772 |
|
1773 // ----------------------------------------------------------------------------- |
|
1774 // CMediaFileHandler::ReadMediaFileDataL |
|
1775 // |
|
1776 // ----------------------------------------------------------------------------- |
|
1777 // |
|
1778 CMediaFileData* CMediaFileHandler::ReadMediaFileDataL( TInt aId ) |
|
1779 { |
|
1780 if ( !iSessionOpen ) |
|
1781 { |
|
1782 User::Leave( KErrNotFound ); |
|
1783 } |
|
1784 |
|
1785 CMdEObject* object = iSession->GetFullObjectL( aId ); |
|
1786 CleanupStack::PushL( object ); |
|
1787 |
|
1788 CMediaFileData* data = CMediaFileData::NewL(); |
|
1789 CleanupStack::PushL( data ); |
|
1790 |
|
1791 data->SetAttrL( EAttrFullName, object->Uri() ); |
|
1792 |
|
1793 CMdEProperty* property = NULL; |
|
1794 TInt ret = object->Property( PropertyDefL( EAttrSongName ), property, 0 ); |
|
1795 if ( ret != KErrNotFound ) |
|
1796 { |
|
1797 data->SetAttrL( EAttrSongName, property->TextValueL() ); |
|
1798 } |
|
1799 |
|
1800 ret = object->Property( PropertyDefL( EAttrArtist ), property, 0 ); |
|
1801 if ( ret != KErrNotFound ) |
|
1802 { |
|
1803 data->SetAttrL( EAttrArtist, property->TextValueL() ); |
|
1804 } |
|
1805 |
|
1806 ret = object->Property( PropertyDefL( EAttrAlbum ), property, 0 ); |
|
1807 if ( ret != KErrNotFound ) |
|
1808 { |
|
1809 data->SetAttrL( EAttrAlbum, property->TextValueL() ); |
|
1810 } |
|
1811 |
|
1812 ret = object->Property( PropertyDefL( EAttrGenre ), property, 0 ); |
|
1813 if ( ret != KErrNotFound ) |
|
1814 { |
|
1815 data->SetAttrL( EAttrGenre, property->TextValueL() ); |
|
1816 } |
|
1817 |
|
1818 ret = object->Property( PropertyDefL( EAttrComposer ), property, 0 ); |
|
1819 if ( ret != KErrNotFound ) |
|
1820 { |
|
1821 data->SetAttrL( EAttrComposer, property->TextValueL() ); |
|
1822 } |
|
1823 |
|
1824 CleanupStack::Pop( data ); |
|
1825 CleanupStack::PopAndDestroy( object ); |
|
1826 |
|
1827 return data; |
|
1828 } |
|
1829 |
|
1830 // ----------------------------------------------------------------------------- |
|
1831 // CMediaFileHandler::ReadMediaFileDataL |
|
1832 // |
|
1833 // ----------------------------------------------------------------------------- |
|
1834 // |
|
1835 CMediaFileData* CMediaFileHandler::RomMediaFileDataL( TInt aId ,TInt aMediaType ) |
|
1836 { |
|
1837 if (!iRomFileList) |
|
1838 { |
|
1839 User::Leave(KErrNotFound); |
|
1840 } |
|
1841 |
|
1842 TBuf<KBufSize128> buf; |
|
1843 CMediaFileData* data = CMediaFileData::NewL(); |
|
1844 CleanupStack::PushL(data); |
|
1845 |
|
1846 if (aMediaType == EMediaTypeTone) |
|
1847 { |
|
1848 data->SetAttrL(EAttrFullName, iRomFileList->Item(aId, 0)); |
|
1849 iRomFileList->GetRomFileName(aId, 0, buf); |
|
1850 data->SetAttrL(EAttrSongName, buf); |
|
1851 } |
|
1852 |
|
1853 if (aMediaType == EMediaTypeVideo) |
|
1854 { |
|
1855 data->SetAttrL(EAttrFullName, iRomFileList->Item(aId, 1)); |
|
1856 iRomFileList->GetRomFileName(aId, 1, buf); |
|
1857 data->SetAttrL(EAttrSongName, buf); |
|
1858 } |
|
1859 |
|
1860 CleanupStack::Pop(data); |
|
1861 |
|
1862 return data; |
|
1863 } |
|
1864 |
|
1865 |
|
1866 // ----------------------------------------------------------------------------- |
|
1867 // CMediaFileHandler::PropertyDefL |
|
1868 // |
|
1869 // ----------------------------------------------------------------------------- |
|
1870 // |
|
1871 CMdEPropertyDef& CMediaFileHandler::PropertyDefL( TInt aAttr ) |
|
1872 { |
|
1873 return PropertyDefL( iSession, aAttr ); |
|
1874 } |
|
1875 |
|
1876 |
|
1877 // ----------------------------------------------------------------------------- |
|
1878 // CMediaFileHandler::PropertyDefL |
|
1879 // |
|
1880 // ----------------------------------------------------------------------------- |
|
1881 // |
|
1882 CMdEPropertyDef& CMediaFileHandler::PropertyDefL( CMdESession* aSession, TInt aAttr ) |
|
1883 { |
|
1884 CMdENamespaceDef& defNS = aSession->GetDefaultNamespaceDefL(); |
|
1885 |
|
1886 CMdEObjectDef& objectDef = |
|
1887 defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1888 |
|
1889 if ( aAttr == EAttrFileSize ) |
|
1890 { |
|
1891 return objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
|
1892 } |
|
1893 else if ( aAttr == EAttrMediaType ) |
|
1894 { |
|
1895 return objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); |
|
1896 } |
|
1897 else if ( aAttr == EAttrSongName || aAttr == EAttrFileName ) |
|
1898 { |
|
1899 return objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
|
1900 } |
|
1901 else if ( aAttr == EAttrArtist ) |
|
1902 { |
|
1903 return objectDef.GetPropertyDefL( MdeConstants::MediaObject::KArtistProperty ); |
|
1904 } |
|
1905 else if ( aAttr == EAttrAlbum ) |
|
1906 { |
|
1907 return objectDef.GetPropertyDefL( MdeConstants::Audio::KAlbumProperty ); |
|
1908 } |
|
1909 else if ( aAttr == EAttrGenre ) |
|
1910 { |
|
1911 return objectDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty ); |
|
1912 } |
|
1913 else if ( aAttr == EAttrComposer ) |
|
1914 { |
|
1915 return objectDef.GetPropertyDefL( MdeConstants::Audio::KComposerProperty ); |
|
1916 } |
|
1917 else |
|
1918 { |
|
1919 User::Leave( KErrNotSupported ); |
|
1920 } |
|
1921 |
|
1922 return objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
|
1923 } |
|
1924 |
|
1925 |
|
1926 // ----------------------------------------------------------------------------- |
|
1927 // CMediaFileHandler::QueryReady |
|
1928 // |
|
1929 // ----------------------------------------------------------------------------- |
|
1930 // |
|
1931 TBool CMediaFileHandler::QueryReady() |
|
1932 { |
|
1933 if ( iIdle ) |
|
1934 { |
|
1935 TBool isSearching = iIdle->IsActive(); |
|
1936 if ( isSearching ) |
|
1937 { |
|
1938 return EFalse; // we are between audio, tone and and video search |
|
1939 } |
|
1940 } |
|
1941 |
|
1942 TBool isWaitingObserverCall = iQueryCaller->IsActive(); |
|
1943 if ( isWaitingObserverCall ) |
|
1944 { |
|
1945 return EFalse; // query is ready but observer not called yet |
|
1946 } |
|
1947 |
|
1948 if ( iQuery ) |
|
1949 { |
|
1950 return iQuery->IsComplete(); |
|
1951 } |
|
1952 |
|
1953 return ETrue; |
|
1954 } |
|
1955 |
|
1956 |
|
1957 // ----------------------------------------------------------------------------- |
|
1958 // CMediaFileHandler::ExcludeMimeTypesL |
|
1959 // |
|
1960 // Exclude mime types from query. |
|
1961 // ----------------------------------------------------------------------------- |
|
1962 // |
|
1963 void CMediaFileHandler::ExcludeMimeTypesL( CMdELogicCondition& aCondition, |
|
1964 TInt /*aAttr*/ ) |
|
1965 { |
|
1966 TInt count = iExcludedMimeTypes->Count(); |
|
1967 |
|
1968 if ( count == 0 ) |
|
1969 { |
|
1970 return; |
|
1971 } |
|
1972 |
|
1973 CMdEPropertyDef& fileTypeDef = PropertyDefL( EAttrMediaType ); |
|
1974 CMdELogicCondition& condition = |
|
1975 aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
1976 |
|
1977 for ( TInt i=0; i<count; i++ ) |
|
1978 { |
|
1979 TPtrC ptr = iExcludedMimeTypes->MimeType( i ); |
|
1980 condition.AddPropertyConditionL( fileTypeDef, |
|
1981 ETextPropertyConditionCompareEquals, ptr ); |
|
1982 } |
|
1983 condition.SetNegate( ETrue ); |
|
1984 } |
|
1985 |
|
1986 |
|
1987 // ----------------------------------------------------------------------------- |
|
1988 // CMediaFileHandler::IncludeMusicPropertiesL |
|
1989 // |
|
1990 // Adds properties that are used to find out whether media file is music. |
|
1991 // File is considered music if: |
|
1992 // 1. it has metadata artist or album or genre or composer |
|
1993 // 2. its mime type is 'music' mime type (eg mp3) |
|
1994 // ----------------------------------------------------------------------------- |
|
1995 // |
|
1996 void CMediaFileHandler::IncludeMusicPropertiesL( CMdELogicCondition& aCondition ) |
|
1997 { |
|
1998 ExcludeRomFilesL( aCondition ); |
|
1999 // CMdEObjectCondition& cond = aCondition.AddObjectConditionL( |
|
2000 // EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
2001 // cond.SetNegate( ETrue ); |
|
2002 |
|
2003 // CMdELogicCondition& condition = |
|
2004 // aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
2005 ExcludeRecordingsL( aCondition ); |
|
2006 // CMdEPropertyDef& fileTypeDef = PropertyDefL( EAttrMediaType ); |
|
2007 // condition.AddPropertyConditionL( fileTypeDef, |
|
2008 // ETextPropertyConditionCompareContains, KMimeTypeAMR ); |
|
2009 // condition.AddPropertyConditionL( fileTypeDef, |
|
2010 // ETextPropertyConditionCompareContains, KMimeTypeWAV ); |
|
2011 // condition.SetNegate( ETrue ); |
|
2012 } |
|
2013 |
|
2014 |
|
2015 |
|
2016 // ----------------------------------------------------------------------------- |
|
2017 // CMediaFileHandler::IncludeMusicPropertiesL |
|
2018 // |
|
2019 // Adds properties that are used to find out whether media file is music. |
|
2020 // File is considered music if: |
|
2021 // 1. it has metadata artist or album or genre or composer |
|
2022 // 2. its mime type is 'music' mime type (eg mp3) |
|
2023 // ----------------------------------------------------------------------------- |
|
2024 // |
|
2025 /* |
|
2026 void CMediaFileHandler::IncludeMusicPropertiesL( CMdELogicCondition& aCondition ) |
|
2027 { |
|
2028 //aLogicCondition.SetOperator( ELogicConditionOperatorAnd ); |
|
2029 |
|
2030 CMdEPropertyDef& mimeTypeDef = PropertyDefL( EAttrMediaType ); |
|
2031 CMdEPropertyDef& artistTypeDef = PropertyDefL( EAttrArtist ); |
|
2032 CMdEPropertyDef& albumTypeDef = PropertyDefL( EAttrAlbum ); |
|
2033 CMdEPropertyDef& genreTypeDef = PropertyDefL( EAttrGenre ); |
|
2034 CMdEPropertyDef& composerTypeDef = PropertyDefL( EAttrComposer ); |
|
2035 |
|
2036 CMdELogicCondition& condition = |
|
2037 aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2038 |
|
2039 condition.AddPropertyConditionL( mimeTypeDef, |
|
2040 ETextPropertyConditionCompareContains, KMimeMp3 ); |
|
2041 condition.AddPropertyConditionL( artistTypeDef ); |
|
2042 condition.AddPropertyConditionL( albumTypeDef ); |
|
2043 condition.AddPropertyConditionL( genreTypeDef ); |
|
2044 condition.AddPropertyConditionL( composerTypeDef ); |
|
2045 } |
|
2046 */ |
|
2047 |
|
2048 |
|
2049 |
|
2050 // ----------------------------------------------------------------------------- |
|
2051 // CMediaFileHandler::ExcludeMusicPropertiesL |
|
2052 // |
|
2053 // ----------------------------------------------------------------------------- |
|
2054 // |
|
2055 void CMediaFileHandler::ExcludeMusicPropertiesL( CMdELogicCondition& aCondition ) |
|
2056 { |
|
2057 CMdEPropertyDef& mimeTypeDef = PropertyDefL( EAttrMediaType ); |
|
2058 CMdEPropertyDef& artistTypeDef = PropertyDefL( EAttrArtist ); |
|
2059 CMdEPropertyDef& albumTypeDef = PropertyDefL( EAttrAlbum ); |
|
2060 CMdEPropertyDef& genreTypeDef = PropertyDefL( EAttrGenre ); |
|
2061 CMdEPropertyDef& composerTypeDef = PropertyDefL( EAttrComposer ); |
|
2062 |
|
2063 CMdELogicCondition& condition = |
|
2064 aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
2065 |
|
2066 condition.AddPropertyConditionL( mimeTypeDef, |
|
2067 ETextPropertyConditionCompareContains, KMimeMp3 ); |
|
2068 condition.AddPropertyConditionL( artistTypeDef ); |
|
2069 condition.AddPropertyConditionL( albumTypeDef ); |
|
2070 condition.AddPropertyConditionL( genreTypeDef ); |
|
2071 condition.AddPropertyConditionL( composerTypeDef ); |
|
2072 |
|
2073 condition.SetNegate( ETrue ); |
|
2074 } |
|
2075 |
|
2076 |
|
2077 // ----------------------------------------------------------------------------- |
|
2078 // CMediaFileHandler::IncludeMusicSearchConditionL |
|
2079 // |
|
2080 // ----------------------------------------------------------------------------- |
|
2081 // |
|
2082 void CMediaFileHandler::IncludeMusicSearchConditionL( CMdELogicCondition& aCondition, |
|
2083 const TDesC& aSearchText ) |
|
2084 |
|
2085 { |
|
2086 _LIT( KFormat, "%S%S" ); |
|
2087 |
|
2088 CMdELogicCondition& condition = |
|
2089 aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2090 |
|
2091 CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
2092 CMdEPropertyDef& artist = PropertyDefL( EAttrArtist ); |
|
2093 CMdEPropertyDef& album = PropertyDefL( EAttrAlbum ); |
|
2094 CMdEPropertyDef& genre = PropertyDefL( EAttrGenre ); |
|
2095 CMdEPropertyDef& composer = PropertyDefL( EAttrComposer ); |
|
2096 |
|
2097 // first find from the start of the property |
|
2098 condition.AddPropertyConditionL( songName, |
|
2099 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2100 |
|
2101 condition.AddPropertyConditionL( artist, |
|
2102 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2103 |
|
2104 |
|
2105 condition.AddPropertyConditionL( album, |
|
2106 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2107 |
|
2108 |
|
2109 condition.AddPropertyConditionL( genre, |
|
2110 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2111 |
|
2112 |
|
2113 condition.AddPropertyConditionL( composer, |
|
2114 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2115 |
|
2116 |
|
2117 // then find from the start of property words |
|
2118 TBuf<KBufSize128> buf; |
|
2119 if ( aSearchText.Length() < KBufSize128-1 ) |
|
2120 { |
|
2121 buf.Format( KFormat, &KSpace, &aSearchText ); |
|
2122 |
|
2123 condition.AddPropertyConditionL( songName, |
|
2124 ETextPropertyConditionCompareContains, buf ); |
|
2125 condition.AddPropertyConditionL( artist, |
|
2126 ETextPropertyConditionCompareContains, buf ); |
|
2127 condition.AddPropertyConditionL( album, |
|
2128 ETextPropertyConditionCompareContains, buf ); |
|
2129 condition.AddPropertyConditionL( genre, |
|
2130 ETextPropertyConditionCompareContains, buf ); |
|
2131 condition.AddPropertyConditionL( composer, |
|
2132 ETextPropertyConditionCompareContains, buf ); |
|
2133 } |
|
2134 } |
|
2135 |
|
2136 |
|
2137 // ----------------------------------------------------------------------------- |
|
2138 // CMediaFileHandler::IncludeVideoConditionL |
|
2139 // |
|
2140 // ----------------------------------------------------------------------------- |
|
2141 // |
|
2142 void CMediaFileHandler::IncludeVideoSearchConditionL( |
|
2143 CMdELogicCondition& aCondition, const TDesC& aSearchText ) |
|
2144 |
|
2145 { |
|
2146 _LIT( KFormat, "%S%S" ); |
|
2147 |
|
2148 CMdELogicCondition& condition = |
|
2149 aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2150 |
|
2151 CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
2152 CMdEPropertyDef& artist = PropertyDefL( EAttrArtist ); |
|
2153 CMdEPropertyDef& genre = PropertyDefL( EAttrGenre ); |
|
2154 |
|
2155 // first find from the start of the property |
|
2156 condition.AddPropertyConditionL( songName, |
|
2157 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2158 condition.AddPropertyConditionL( artist, |
|
2159 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2160 condition.AddPropertyConditionL( genre, |
|
2161 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2162 |
|
2163 // then find from the start of property words |
|
2164 TBuf<KBufSize128> buf; |
|
2165 if ( aSearchText.Length() < KBufSize128-1 ) |
|
2166 { |
|
2167 buf.Format( KFormat, &KSpace, &aSearchText ); |
|
2168 |
|
2169 condition.AddPropertyConditionL( songName, |
|
2170 ETextPropertyConditionCompareContains, buf ); |
|
2171 condition.AddPropertyConditionL( artist, |
|
2172 ETextPropertyConditionCompareContains, buf ); |
|
2173 condition.AddPropertyConditionL( genre, |
|
2174 ETextPropertyConditionCompareContains, buf ); |
|
2175 } |
|
2176 } |
|
2177 |
|
2178 |
|
2179 // ----------------------------------------------------------------------------- |
|
2180 // CMediaFileHandler::IncludeToneSearchConditionL |
|
2181 // |
|
2182 // ----------------------------------------------------------------------------- |
|
2183 // |
|
2184 void CMediaFileHandler::IncludeToneSearchConditionL( CMdELogicCondition& aCondition, |
|
2185 const TDesC& aSearchText ) |
|
2186 |
|
2187 { |
|
2188 _LIT( KFormat, "%S%S" ); |
|
2189 |
|
2190 CMdELogicCondition& condition = |
|
2191 aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2192 |
|
2193 CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
2194 |
|
2195 // first find from the start of the property |
|
2196 condition.AddPropertyConditionL( songName, |
|
2197 ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2198 |
|
2199 // then find from the start of property words |
|
2200 TBuf<KBufSize128> buf; |
|
2201 if ( aSearchText.Length() < KBufSize128-1 ) |
|
2202 { |
|
2203 buf.Format( KFormat, &KSpace, &aSearchText ); |
|
2204 |
|
2205 condition.AddPropertyConditionL( songName, |
|
2206 ETextPropertyConditionCompareContains, buf ); |
|
2207 } |
|
2208 } |
|
2209 |
|
2210 |
|
2211 // ----------------------------------------------------------------------------- |
|
2212 // CMediaFileHandler::ExcludeRecordingsL |
|
2213 // |
|
2214 // Exclude recording mime types from query (.amr and .wav). |
|
2215 // ----------------------------------------------------------------------------- |
|
2216 // |
|
2217 void CMediaFileHandler::ExcludeRecordingsL( CMdELogicCondition& aCondition ) |
|
2218 { |
|
2219 CMdEPropertyDef& mimeTypeDef = PropertyDefL( EAttrMediaType ); |
|
2220 CMdELogicCondition& condition = |
|
2221 aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
2222 condition.AddPropertyConditionL( mimeTypeDef, |
|
2223 ETextPropertyConditionCompareEquals, KMimeTypeAMR ); |
|
2224 condition.AddPropertyConditionL( mimeTypeDef, |
|
2225 ETextPropertyConditionCompareEquals, KMimeTypeWAV ); |
|
2226 condition.SetNegate( ETrue ); |
|
2227 } |
|
2228 |
|
2229 |
|
2230 // ----------------------------------------------------------------------------- |
|
2231 // CMediaFileHandler::ExcludeRomFilesL |
|
2232 // |
|
2233 // Exclude music files that are in rom (default tones). |
|
2234 // ----------------------------------------------------------------------------- |
|
2235 // |
|
2236 void CMediaFileHandler::ExcludeRomFilesL( CMdELogicCondition& aCondition ) |
|
2237 { |
|
2238 _LIT( KDriveZ, "z:\\" ); |
|
2239 |
|
2240 CMdEObjectCondition& cond = aCondition.AddObjectConditionL( |
|
2241 EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
2242 cond.SetNegate( ETrue ); |
|
2243 } |
|
2244 |
|
2245 |
|
2246 // ------------------------------------------------------------------------------- |
|
2247 // CMediaFileHandler::StrCopy |
|
2248 // |
|
2249 // String copy with lenght check. |
|
2250 // ------------------------------------------------------------------------------- |
|
2251 // |
|
2252 void CMediaFileHandler::StrCopy( TDes& aTarget, const TDesC& aSource ) |
|
2253 { |
|
2254 TInt len = aTarget.MaxLength(); |
|
2255 if( len < aSource.Length() ) |
|
2256 { |
|
2257 aTarget.Copy( aSource.Left( len ) ); |
|
2258 return; |
|
2259 } |
|
2260 aTarget.Copy( aSource ); |
|
2261 } |
|
2262 |
|
2263 |
|
2264 // ----------------------------------------------------------------------------- |
|
2265 // CMediaFileHandler::EnableObserverCall |
|
2266 // |
|
2267 // ----------------------------------------------------------------------------- |
|
2268 // |
|
2269 void CMediaFileHandler::EnableObserverCall( TBool aEnable ) |
|
2270 { |
|
2271 iObserverCallEnabled = aEnable; |
|
2272 } |
|
2273 |
|
2274 |
|
2275 // ----------------------------------------------------------------------------- |
|
2276 // CMediaFileHandler::CallObserver |
|
2277 // |
|
2278 // ----------------------------------------------------------------------------- |
|
2279 // |
|
2280 void CMediaFileHandler::CallObserver( TInt aEvent, TInt aError ) |
|
2281 { |
|
2282 const TInt KDelay = 100; // milliseconds |
|
2283 |
|
2284 if ( !iObserverCallEnabled ) |
|
2285 { |
|
2286 return; |
|
2287 } |
|
2288 |
|
2289 iQueryError = aError; |
|
2290 iQueryEvent = aEvent; |
|
2291 |
|
2292 iQueryCaller->Start( 0, KDelay ); |
|
2293 } |
|
2294 |
|
2295 |
|
2296 // ----------------------------------------------------------------------------- |
|
2297 // CMediaFileHandler::CallObserverWithDelay |
|
2298 // |
|
2299 // ----------------------------------------------------------------------------- |
|
2300 // |
|
2301 void CMediaFileHandler::CallObserverWithDelay() |
|
2302 { |
|
2303 const TInt KOneSecond = 1000; |
|
2304 |
|
2305 if ( !iObserverCallEnabled ) |
|
2306 { |
|
2307 return; |
|
2308 } |
|
2309 |
|
2310 iObjectNotificationCaller->Start( 1, 2*KOneSecond ); |
|
2311 } |
|
2312 |
|
2313 |
|
2314 // ----------------------------------------------------------------------------- |
|
2315 // CMediaFileHandler::HandleActiveCallL (from MMFActiveCallerObserver) |
|
2316 // |
|
2317 // ----------------------------------------------------------------------------- |
|
2318 // |
|
2319 void CMediaFileHandler::HandleActiveCallL( TInt aCallId ) |
|
2320 { |
|
2321 if ( !iObserver ) |
|
2322 { |
|
2323 return; |
|
2324 } |
|
2325 |
|
2326 // inform observer that query is ready |
|
2327 if ( aCallId == 0 ) |
|
2328 { |
|
2329 TRAP_IGNORE( iObserver->HandleMFEventL( iQueryEvent, iQueryError ) ); |
|
2330 } |
|
2331 |
|
2332 // inform observer that database has changed |
|
2333 if ( aCallId == 1 ) |
|
2334 { |
|
2335 if ( QueryReady() ) |
|
2336 { |
|
2337 TRAP_IGNORE( iObserver->HandleMFEventL( MMediaFileHandlerObserver::EMediaFileChanged, KErrNone ) ); |
|
2338 } |
|
2339 } |
|
2340 } |
|
2341 |
|
2342 |
|
2343 // ----------------------------------------------------------------------------- |
|
2344 // CMediaFileHandler::SetQueryId |
|
2345 // |
|
2346 // ----------------------------------------------------------------------------- |
|
2347 // |
|
2348 void CMediaFileHandler::SetQueryId( TInt aId ) |
|
2349 { |
|
2350 // this id is passed to CSearchList after successful database search |
|
2351 iQueryId = aId; |
|
2352 } |
|
2353 |
|
2354 |
|
2355 // ----------------------------------------------------------------------------- |
|
2356 // CMediaFileHandler::Panic |
|
2357 // |
|
2358 // ----------------------------------------------------------------------------- |
|
2359 // |
|
2360 void CMediaFileHandler::Panic( TInt aReason ) |
|
2361 { |
|
2362 _LIT( KPanicCategory, "CMediaFileHandler" ); |
|
2363 |
|
2364 User::Panic( KPanicCategory, aReason ); |
|
2365 } |
|
2366 |
|
2367 |
|
2368 // ----------------------------------------------------------------------------- |
|
2369 // CMediaFileHandler::MediaType |
|
2370 // |
|
2371 // ----------------------------------------------------------------------------- |
|
2372 // |
|
2373 TInt CMediaFileHandler::MediaType( TInt aQueryType ) |
|
2374 { |
|
2375 TInt mediaType = EMediaTypeMusic; |
|
2376 if ( aQueryType == EQueryVideo ) |
|
2377 { |
|
2378 mediaType = EMediaTypeVideo; |
|
2379 } |
|
2380 if ( aQueryType == EQueryRecording ) |
|
2381 { |
|
2382 mediaType = EMediaTypeRecording; |
|
2383 } |
|
2384 if ( aQueryType == EQueryTone ) |
|
2385 { |
|
2386 mediaType = EMediaTypeTone; |
|
2387 } |
|
2388 |
|
2389 return mediaType; |
|
2390 } |
|
2391 |
|
2392 |
|
2393 |
|
2394 /****************************************************************************** |
|
2395 * class CSearchListItem |
|
2396 ******************************************************************************/ |
|
2397 |
|
2398 |
|
2399 // ----------------------------------------------------------------------------- |
|
2400 // CSearchListItem::NewL |
|
2401 // |
|
2402 // ----------------------------------------------------------------------------- |
|
2403 // |
|
2404 CSearchListItem* CSearchListItem::NewLC() |
|
2405 { |
|
2406 CSearchListItem* self = new (ELeave) CSearchListItem(); |
|
2407 CleanupStack::PushL( self ); |
|
2408 self->ConstructL(); |
|
2409 |
|
2410 return self; |
|
2411 } |
|
2412 |
|
2413 |
|
2414 // ----------------------------------------------------------------------------- |
|
2415 // CSearchListItem::NewL |
|
2416 // |
|
2417 // ----------------------------------------------------------------------------- |
|
2418 // |
|
2419 CSearchListItem* CSearchListItem::NewL() |
|
2420 { |
|
2421 CSearchListItem* self = new (ELeave) CSearchListItem(); |
|
2422 CleanupStack::PushL( self ); |
|
2423 self->ConstructL(); |
|
2424 CleanupStack::Pop( self ); |
|
2425 return self; |
|
2426 } |
|
2427 |
|
2428 |
|
2429 // ----------------------------------------------------------------------------- |
|
2430 // Destructor |
|
2431 // |
|
2432 // ----------------------------------------------------------------------------- |
|
2433 // |
|
2434 CSearchListItem::~CSearchListItem() |
|
2435 { |
|
2436 delete iTitle; |
|
2437 } |
|
2438 |
|
2439 |
|
2440 // ----------------------------------------------------------------------------- |
|
2441 // CSearchListItem::CSearchListItem |
|
2442 // |
|
2443 // ----------------------------------------------------------------------------- |
|
2444 // |
|
2445 CSearchListItem::CSearchListItem() |
|
2446 { |
|
2447 iId = KErrNotFound; |
|
2448 iMediaType = KErrNotFound; |
|
2449 iStorageType = KErrNotFound; |
|
2450 iTitle = NULL; |
|
2451 } |
|
2452 |
|
2453 |
|
2454 // ----------------------------------------------------------------------------- |
|
2455 // CSearchListItem::ConstructL |
|
2456 // |
|
2457 // ----------------------------------------------------------------------------- |
|
2458 // |
|
2459 void CSearchListItem::ConstructL() |
|
2460 { |
|
2461 } |
|
2462 |
|
2463 // ----------------------------------------------------------------------------- |
|
2464 // CSearchListItem::SetTitleL |
|
2465 // |
|
2466 // ----------------------------------------------------------------------------- |
|
2467 // |
|
2468 |
|
2469 void CSearchListItem::SetTitleL( const TDesC& aText, TBool aFullName ) |
|
2470 { |
|
2471 delete iTitle; |
|
2472 iTitle = NULL; |
|
2473 |
|
2474 if ( aFullName ) |
|
2475 { |
|
2476 TParsePtrC parse( aText ); |
|
2477 iTitle = parse.Name().AllocL(); |
|
2478 } |
|
2479 else |
|
2480 { |
|
2481 iTitle = aText.AllocL(); |
|
2482 } |
|
2483 } |
|
2484 |
|
2485 |
|
2486 // ----------------------------------------------------------------------------- |
|
2487 // CSearchListItem::Title |
|
2488 // |
|
2489 // ----------------------------------------------------------------------------- |
|
2490 // |
|
2491 |
|
2492 const TDesC& CSearchListItem::Title() const |
|
2493 { |
|
2494 return *iTitle; |
|
2495 } |
|
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 /****************************************************************************** |
|
2501 * class CRomFileList |
|
2502 ******************************************************************************/ |
|
2503 |
|
2504 |
|
2505 |
|
2506 // ----------------------------------------------------------------------------- |
|
2507 // Static constructor function CRomFileList::NewL |
|
2508 // |
|
2509 // ----------------------------------------------------------------------------- |
|
2510 // |
|
2511 CRomFileList* CRomFileList::NewL() |
|
2512 { |
|
2513 CRomFileList* self = new (ELeave) CRomFileList(); |
|
2514 CleanupStack::PushL( self ); |
|
2515 self->ConstructL(); |
|
2516 CleanupStack::Pop( self ); |
|
2517 |
|
2518 return self; |
|
2519 } |
|
2520 |
|
2521 |
|
2522 // ----------------------------------------------------------------------------- |
|
2523 // Destructor |
|
2524 // |
|
2525 // ----------------------------------------------------------------------------- |
|
2526 // |
|
2527 CRomFileList::~CRomFileList() |
|
2528 { |
|
2529 iRomToneList.ResetAndDestroy(); |
|
2530 iRomVideoList.ResetAndDestroy(); |
|
2531 iList.Reset(); |
|
2532 iList.Close(); |
|
2533 iVedioList.Reset(); |
|
2534 iVedioList.Close(); |
|
2535 } |
|
2536 |
|
2537 |
|
2538 // ----------------------------------------------------------------------------- |
|
2539 // CRomFileList::CRomFileList |
|
2540 // |
|
2541 // ----------------------------------------------------------------------------- |
|
2542 // |
|
2543 CRomFileList::CRomFileList() |
|
2544 { |
|
2545 } |
|
2546 |
|
2547 |
|
2548 // ----------------------------------------------------------------------------- |
|
2549 // CRomFileList::ConstructL |
|
2550 // |
|
2551 // ----------------------------------------------------------------------------- |
|
2552 // |
|
2553 void CRomFileList::ConstructL() |
|
2554 { |
|
2555 } |
|
2556 |
|
2557 // ----------------------------------------------------------------------------- |
|
2558 // CRomFileList::RomFileItem( TInt aIndex ) |
|
2559 // |
|
2560 // ----------------------------------------------------------------------------- |
|
2561 // |
|
2562 TInt CRomFileList::RomFileItem( CSearchListItem* aItem, TInt aIndex) |
|
2563 { |
|
2564 if( aIndex >= 0 && aIndex < iRomToneList.Count() ) |
|
2565 { |
|
2566 aItem->iId = iRomToneList[aIndex]->iId; |
|
2567 aItem->iMediaType = iRomToneList[aIndex]->iMediaType; |
|
2568 aItem->iStorageType = iRomToneList[aIndex]->iStorageType; |
|
2569 TPtrC title = iRomToneList[aIndex]->Title(); |
|
2570 aItem->SetTitleL( title, EFalse ); |
|
2571 return KErrNone; |
|
2572 } |
|
2573 return KErrGeneral; |
|
2574 } |
|
2575 |
|
2576 // ----------------------------------------------------------------------------- |
|
2577 // CRomFileList::RomVedioItem( TInt aIndex ) |
|
2578 // |
|
2579 // ----------------------------------------------------------------------------- |
|
2580 // |
|
2581 TInt CRomFileList::RomVedioItem( CSearchListItem* aItem, TInt aIndex) |
|
2582 { |
|
2583 if( aIndex >= 0 && aIndex < iRomVideoList.Count() ) |
|
2584 { |
|
2585 aItem->iId = iRomVideoList[aIndex]->iId; |
|
2586 aItem->iMediaType = iRomVideoList[aIndex]->iMediaType; |
|
2587 aItem->iStorageType = iRomVideoList[aIndex]->iStorageType; |
|
2588 TPtrC title = iRomVideoList[aIndex]->Title(); |
|
2589 aItem->SetTitleL( title, EFalse ); |
|
2590 return KErrNone; |
|
2591 } |
|
2592 return KErrGeneral; |
|
2593 } |
|
2594 // ----------------------------------------------------------------------------- |
|
2595 // CRomFileList::Count() |
|
2596 // |
|
2597 // ----------------------------------------------------------------------------- |
|
2598 // |
|
2599 |
|
2600 TInt CRomFileList::Count(TInt aType ) |
|
2601 { |
|
2602 if ( aType == 0 ) |
|
2603 { |
|
2604 //Tone item count |
|
2605 return iRomToneList.Count(); |
|
2606 } |
|
2607 else if ( aType == 1 ) |
|
2608 { |
|
2609 // Video item count() |
|
2610 return iRomVideoList.Count(); |
|
2611 } |
|
2612 return KErrNotSupported; |
|
2613 } |
|
2614 |
|
2615 // ----------------------------------------------------------------------------- |
|
2616 // CRomFileList::Reset() |
|
2617 // |
|
2618 // ----------------------------------------------------------------------------- |
|
2619 // |
|
2620 |
|
2621 void CRomFileList::Reset() |
|
2622 { |
|
2623 iRomToneList.Reset(); |
|
2624 iRomVideoList.Reset(); |
|
2625 iList.Reset(); |
|
2626 iVedioList.Reset(); |
|
2627 } |
|
2628 // ----------------------------------------------------------------------------- |
|
2629 // CRomFileList::ReadRomFilesL() |
|
2630 // |
|
2631 // ----------------------------------------------------------------------------- |
|
2632 // |
|
2633 |
|
2634 void CRomFileList::ReadRomFilesL() |
|
2635 { |
|
2636 _LIT( KFormat, "%S%S" ); |
|
2637 |
|
2638 iRomToneList.ResetAndDestroy(); |
|
2639 iList.Reset(); |
|
2640 |
|
2641 iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::SoundsPath() ); |
|
2642 TRAP_IGNORE( ReadDirectoryL( iFileName, iRomToneList ) ); |
|
2643 TRAP_IGNORE( ReadDirectoryL( iFileName, iList ) ); |
|
2644 |
|
2645 iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::DigitalSoundsPath() ); |
|
2646 TRAP_IGNORE( ReadDirectoryL( iFileName, iRomToneList ) ); |
|
2647 TRAP_IGNORE( ReadDirectoryL( iFileName, iList ) ); |
|
2648 |
|
2649 iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::SimpleSoundsPath() ); |
|
2650 TRAP_IGNORE( ReadDirectoryL( iFileName, iRomToneList ) ); |
|
2651 TRAP_IGNORE( ReadDirectoryL( iFileName, iList ) ); |
|
2652 |
|
2653 TRAP_IGNORE( ReadRomVediosL() ); |
|
2654 } |
|
2655 |
|
2656 |
|
2657 // ----------------------------------------------------------------------------- |
|
2658 // CRomFileList::ReadRomFilesL() |
|
2659 // |
|
2660 // ----------------------------------------------------------------------------- |
|
2661 // |
|
2662 |
|
2663 void CRomFileList::ReadRomVediosL() |
|
2664 { |
|
2665 _LIT( KFormat, "%S%S" ); |
|
2666 |
|
2667 iRomVideoList.Reset(); |
|
2668 iVedioList.Reset(); |
|
2669 |
|
2670 iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::VideosPath() ); |
|
2671 TRAP_IGNORE( ReadDirectoryL( iFileName, iRomVideoList ) ); |
|
2672 TRAP_IGNORE( ReadDirectoryL( iFileName, iVedioList ) ); |
|
2673 |
|
2674 if ( iRomVideoList.Count() > 0 ) |
|
2675 { |
|
2676 for( TInt i(0); i < iRomVideoList.Count(); i++) |
|
2677 { |
|
2678 iRomVideoList[i]->iMediaType = CMediaFileHandler::EMediaTypeVideo; |
|
2679 } |
|
2680 } |
|
2681 |
|
2682 } |
|
2683 |
|
2684 |
|
2685 // ----------------------------------------------------------------------------- |
|
2686 // TDesC& CRomFileList::Item( TInt aIndex ) |
|
2687 // |
|
2688 // ----------------------------------------------------------------------------- |
|
2689 // |
|
2690 const TDesC& CRomFileList::Item(TInt aIndex, TInt aType) |
|
2691 { |
|
2692 TInt count = 0; |
|
2693 if ( aType == 0 ) |
|
2694 { |
|
2695 count = iList.Count(); |
|
2696 if (aIndex >= 0 && aIndex < count) |
|
2697 { |
|
2698 return iList[aIndex]; |
|
2699 } |
|
2700 } |
|
2701 else if ( aType == 1 ) |
|
2702 { |
|
2703 count = iVedioList.Count(); |
|
2704 if (aIndex >= 0 && aIndex < count) |
|
2705 { |
|
2706 return iVedioList[aIndex]; |
|
2707 } |
|
2708 } |
|
2709 return KNullDesC; |
|
2710 } |
|
2711 |
|
2712 |
|
2713 // ----------------------------------------------------------------------------- |
|
2714 // CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2715 // RPointerArray<CSearchListItem>& aList ) |
|
2716 // |
|
2717 // ----------------------------------------------------------------------------- |
|
2718 // |
|
2719 |
|
2720 void CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2721 RPointerArray<CSearchListItem>& aList ) |
|
2722 { |
|
2723 _LIT( KFormat, "%S%S" ); |
|
2724 |
|
2725 CDir* dir = NULL; |
|
2726 RFs fsSession; |
|
2727 User::LeaveIfError( fsSession.Connect() ); |
|
2728 CleanupClosePushL( fsSession ); |
|
2729 |
|
2730 if ( !BaflUtils::FolderExists( fsSession, aDirectory ) ) |
|
2731 { |
|
2732 User::Leave( KErrNotFound ); |
|
2733 } |
|
2734 |
|
2735 TInt err = fsSession.GetDir( aDirectory, KEntryAttNormal, ESortByName, dir ); |
|
2736 User::LeaveIfError( err ); |
|
2737 CleanupStack::PushL( dir ); |
|
2738 TInt index; |
|
2739 TInt count = dir->Count(); |
|
2740 TFileName filename; |
|
2741 for ( TInt i=0; i<count; i++ ) |
|
2742 { |
|
2743 const TEntry item = (*dir)[i]; |
|
2744 filename.Format( KFormat, &aDirectory, &item.iName ); |
|
2745 index = aList.Count(); |
|
2746 CSearchListItem* item2 = SearchListItemFromRomL( filename, index ); |
|
2747 aList.Append( item2 ); |
|
2748 } |
|
2749 |
|
2750 CleanupStack::PopAndDestroy( dir ); |
|
2751 |
|
2752 CleanupStack::PopAndDestroy(); // fsSession |
|
2753 } |
|
2754 |
|
2755 // ----------------------------------------------------------------------------- |
|
2756 // CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2757 // RPointerArray<CSearchListItem>& aList ) |
|
2758 // |
|
2759 // ----------------------------------------------------------------------------- |
|
2760 // |
|
2761 |
|
2762 void CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2763 RArray<TFileName>& aList ) |
|
2764 { |
|
2765 _LIT( KFormat, "%S%S" ); |
|
2766 |
|
2767 CDir* dir = NULL; |
|
2768 RFs fsSession; |
|
2769 User::LeaveIfError( fsSession.Connect() ); |
|
2770 CleanupClosePushL( fsSession ); |
|
2771 |
|
2772 if ( !BaflUtils::FolderExists( fsSession, aDirectory ) ) |
|
2773 { |
|
2774 User::Leave( KErrNotFound ); |
|
2775 } |
|
2776 |
|
2777 TInt err = fsSession.GetDir( aDirectory, KEntryAttNormal, ESortByName, dir ); |
|
2778 User::LeaveIfError( err ); |
|
2779 CleanupStack::PushL( dir ); |
|
2780 |
|
2781 TInt count = dir->Count(); |
|
2782 TFileName filename; |
|
2783 for ( TInt i=0; i<count; i++ ) |
|
2784 { |
|
2785 const TEntry item = (*dir)[i]; |
|
2786 filename.Format( KFormat, &aDirectory, &item.iName ); |
|
2787 aList.Append( filename ); |
|
2788 } |
|
2789 |
|
2790 CleanupStack::PopAndDestroy( dir ); |
|
2791 |
|
2792 CleanupStack::PopAndDestroy(); // fsSession |
|
2793 } |
|
2794 // ----------------------------------------------------------------------------- |
|
2795 // CRomFileList::SearchListItemFromRomL( const TDesC& aFileName ) |
|
2796 // |
|
2797 // ----------------------------------------------------------------------------- |
|
2798 // |
|
2799 |
|
2800 CSearchListItem* CRomFileList::SearchListItemFromRomL( const TDesC& aFileName ,TInt aIndex ) |
|
2801 { |
|
2802 TParsePtrC parsedName( aFileName ); |
|
2803 |
|
2804 CSearchListItem* item = CSearchListItem::NewLC(); |
|
2805 |
|
2806 item->iId = aIndex; |
|
2807 item->SetTitleL( aFileName , ETrue); |
|
2808 item->iStorageType = CMediaFileHandler::ERomStorage; |
|
2809 item->iMediaType = CMediaFileHandler::EMediaTypeTone; |
|
2810 |
|
2811 CleanupStack::Pop(); // item |
|
2812 |
|
2813 return item; |
|
2814 } |
|
2815 |
|
2816 // ----------------------------------------------------------------------------- |
|
2817 // CRomFileList::GetRomFileName |
|
2818 // |
|
2819 // ----------------------------------------------------------------------------- |
|
2820 // |
|
2821 TInt CRomFileList::GetRomFileName(TInt aIndex, TInt aType, TDes& aValue) |
|
2822 { |
|
2823 //return title of rom item; |
|
2824 if (aType == 0) |
|
2825 { |
|
2826 if (aIndex >= 0 && aIndex < Count(0)) |
|
2827 { |
|
2828 aValue.Copy( iRomToneList[aIndex]->Title() ); |
|
2829 return KErrNone; |
|
2830 } |
|
2831 return KErrGeneral; |
|
2832 } |
|
2833 else if (aType == 1) |
|
2834 { |
|
2835 if (aIndex >= 0 && aIndex < Count(1)) |
|
2836 { |
|
2837 aValue.Copy(iRomVideoList[aIndex]->Title()); |
|
2838 return KErrNone; |
|
2839 } |
|
2840 return KErrGeneral; |
|
2841 } |
|
2842 return KErrNotFound; |
|
2843 } |
|
2844 |
|
2845 |
|
2846 /****************************************************************************** |
|
2847 * class CSearchList |
|
2848 ******************************************************************************/ |
|
2849 |
|
2850 |
|
2851 // ----------------------------------------------------------------------------- |
|
2852 // CSearchList::NewL |
|
2853 // |
|
2854 // ----------------------------------------------------------------------------- |
|
2855 // |
|
2856 CSearchList* CSearchList::NewL() |
|
2857 { |
|
2858 CSearchList* self = new (ELeave) CSearchList(); |
|
2859 CleanupStack::PushL( self ); |
|
2860 self->ConstructL(); |
|
2861 CleanupStack::Pop( self ); |
|
2862 |
|
2863 return self; |
|
2864 } |
|
2865 |
|
2866 |
|
2867 // ----------------------------------------------------------------------------- |
|
2868 // Destructor |
|
2869 // |
|
2870 // ----------------------------------------------------------------------------- |
|
2871 // |
|
2872 CSearchList::~CSearchList() |
|
2873 { |
|
2874 iList.ResetAndDestroy(); |
|
2875 delete iDriveUtil; |
|
2876 } |
|
2877 |
|
2878 |
|
2879 // ----------------------------------------------------------------------------- |
|
2880 // CSearchList::CSearchList |
|
2881 // |
|
2882 // ----------------------------------------------------------------------------- |
|
2883 // |
|
2884 CSearchList::CSearchList() |
|
2885 { |
|
2886 iSearchId = KErrNotFound; |
|
2887 } |
|
2888 |
|
2889 |
|
2890 // ----------------------------------------------------------------------------- |
|
2891 // CSearchList::ConstructL |
|
2892 // |
|
2893 // ----------------------------------------------------------------------------- |
|
2894 // |
|
2895 void CSearchList::ConstructL() |
|
2896 { |
|
2897 iDriveUtil = CDriveUtil::NewL(); |
|
2898 } |
|
2899 |
|
2900 |
|
2901 // ----------------------------------------------------------------------------- |
|
2902 // CSearchList::SetSession |
|
2903 // |
|
2904 // ----------------------------------------------------------------------------- |
|
2905 // |
|
2906 void CSearchList::SetSession( CMdESession* aSession ) |
|
2907 { |
|
2908 iSession = aSession; |
|
2909 } |
|
2910 |
|
2911 // ----------------------------------------------------------------------------- |
|
2912 // CSearchList::SetRomFileList |
|
2913 // |
|
2914 // ----------------------------------------------------------------------------- |
|
2915 // |
|
2916 void CSearchList::SetRomFileList( CRomFileList* aRomFileList ) |
|
2917 { |
|
2918 iRomFileList = aRomFileList; |
|
2919 } |
|
2920 |
|
2921 // ----------------------------------------------------------------------------- |
|
2922 // CSearchList::SetSearchId |
|
2923 // |
|
2924 // ----------------------------------------------------------------------------- |
|
2925 // |
|
2926 void CSearchList::SetSearchId( TInt aSearchId ) |
|
2927 { |
|
2928 iSearchId = aSearchId; |
|
2929 } |
|
2930 |
|
2931 |
|
2932 // ----------------------------------------------------------------------------- |
|
2933 // CSearchList::SearchId |
|
2934 // |
|
2935 // ----------------------------------------------------------------------------- |
|
2936 // |
|
2937 TInt CSearchList::SearchId() |
|
2938 { |
|
2939 return iSearchId; |
|
2940 } |
|
2941 |
|
2942 |
|
2943 // ----------------------------------------------------------------------------- |
|
2944 // CSearchList::TakeResultL |
|
2945 // |
|
2946 // ----------------------------------------------------------------------------- |
|
2947 // |
|
2948 void CSearchList::TakeResultL( CMdEObjectQuery* aQuery, TInt aMediaType ) |
|
2949 { |
|
2950 if ( !aQuery ) |
|
2951 { |
|
2952 return; |
|
2953 } |
|
2954 CMdEObjectQuery* query = static_cast<CMdEObjectQuery*> (aQuery); |
|
2955 TInt count = query->Count(); |
|
2956 |
|
2957 for (TInt i = 0; i < count; i++) |
|
2958 { |
|
2959 CMdEObject* object = (CMdEObject*) query->TakeOwnershipOfResult(i); |
|
2960 CleanupStack::PushL(object); |
|
2961 AddItemL(*object, aMediaType); |
|
2962 CleanupStack::PopAndDestroy(object); |
|
2963 } |
|
2964 } |
|
2965 |
|
2966 // ----------------------------------------------------------------------------- |
|
2967 // CSearchList::SearchInToneL |
|
2968 // |
|
2969 // ----------------------------------------------------------------------------- |
|
2970 // |
|
2971 void CSearchList::SearchInToneL( CRomFileList* aQuery, const TDesC& aSearchText ) |
|
2972 { |
|
2973 if ( !aQuery ) |
|
2974 { |
|
2975 return; |
|
2976 } |
|
2977 TInt error = KErrNone; |
|
2978 TInt count = aQuery->Count( 0 ); |
|
2979 for( int i = 0; i< count; i++ ) |
|
2980 { |
|
2981 CSearchListItem* item = CSearchListItem::NewL(); |
|
2982 error = aQuery->RomFileItem( item, i ); |
|
2983 if ( error == KErrNone ) |
|
2984 { |
|
2985 TPtrC title = item->Title(); |
|
2986 TInt rt = title.FindF( aSearchText ); |
|
2987 if ( rt != KErrNotFound ) |
|
2988 { |
|
2989 iList.Append( item ); |
|
2990 } |
|
2991 } |
|
2992 } |
|
2993 } |
|
2994 |
|
2995 // ----------------------------------------------------------------------------- |
|
2996 // CSearchList::VideoSearchInRomL |
|
2997 // |
|
2998 // ----------------------------------------------------------------------------- |
|
2999 // |
|
3000 void CSearchList::VideoSearchInRomL( CRomFileList* aQuery, const TDesC& aSearchText ) |
|
3001 { |
|
3002 if ( !aQuery ) |
|
3003 { |
|
3004 return; |
|
3005 } |
|
3006 TInt error = KErrNone; |
|
3007 TInt count = aQuery->Count( 1 ); |
|
3008 for( int i = 0; i< count; i++ ) |
|
3009 { |
|
3010 CSearchListItem* item = CSearchListItem::NewL(); |
|
3011 error = aQuery->RomVedioItem( item, i ); |
|
3012 if ( error == KErrNone ) |
|
3013 { |
|
3014 TPtrC title = item->Title(); |
|
3015 TInt rt = title.FindF( aSearchText ); |
|
3016 if ( rt != KErrNotFound ) |
|
3017 { |
|
3018 iList.Append( item ); |
|
3019 } |
|
3020 } |
|
3021 } |
|
3022 } |
|
3023 // ----------------------------------------------------------------------------- |
|
3024 // CSearchList::TakeArtistResultL |
|
3025 // |
|
3026 // ----------------------------------------------------------------------------- |
|
3027 // |
|
3028 void CSearchList::TakeArtistResultL( CArtistQuery* aArtistQuery ) |
|
3029 { |
|
3030 if ( !aArtistQuery ) |
|
3031 { |
|
3032 return; |
|
3033 } |
|
3034 |
|
3035 CMdEObjectQuery* query = aArtistQuery->Query(); |
|
3036 if ( !query ) |
|
3037 { |
|
3038 return; |
|
3039 } |
|
3040 TInt queryType = aArtistQuery->QueryType(); |
|
3041 |
|
3042 |
|
3043 TInt count = query->Count(); |
|
3044 for ( TInt i=0; i<count; i++ ) |
|
3045 { |
|
3046 CMdEObject& object = query->Result( i ); |
|
3047 AddArtistItemL( object, queryType, aArtistQuery->Album() ); |
|
3048 } |
|
3049 } |
|
3050 |
|
3051 |
|
3052 // ----------------------------------------------------------------------------- |
|
3053 // CSearchList::TakeDistinctResultL |
|
3054 // |
|
3055 // ----------------------------------------------------------------------------- |
|
3056 // |
|
3057 void CSearchList::TakeDistinctResultL( CMdEObjectQuery* aQuery, |
|
3058 TInt /*aMediaType*/ ) |
|
3059 { |
|
3060 if ( !aQuery ) |
|
3061 { |
|
3062 return; |
|
3063 } |
|
3064 |
|
3065 TInt count = aQuery->Count(); |
|
3066 |
|
3067 for ( TInt i=0; i<count; i++ ) |
|
3068 { |
|
3069 TPtrC ptr = aQuery->ResultDistinctValue( i ); |
|
3070 |
|
3071 CSearchListItem* item = CSearchListItem::NewLC(); |
|
3072 |
|
3073 item->SetTitleL( ptr, EFalse ); |
|
3074 item->iMediaType = KErrNotFound; |
|
3075 item->iStorageType = KErrNotFound; |
|
3076 |
|
3077 iList.AppendL( item ); |
|
3078 |
|
3079 CleanupStack::Pop( item ); |
|
3080 } |
|
3081 } |
|
3082 |
|
3083 |
|
3084 // ----------------------------------------------------------------------------- |
|
3085 // CSearchList::AddItemL |
|
3086 // |
|
3087 // ----------------------------------------------------------------------------- |
|
3088 // |
|
3089 void CSearchList::AddItemL( CMdEObject& aObject, TInt aMediaType ) |
|
3090 { |
|
3091 CSearchListItem* item = CSearchListItem::NewLC(); |
|
3092 |
|
3093 TPtrC songName = TextL( aObject, CMediaFileHandler::EAttrSongName ); |
|
3094 |
|
3095 if ( songName.Length() > 0 ) |
|
3096 { |
|
3097 item->SetTitleL( songName, EFalse ); |
|
3098 } |
|
3099 else |
|
3100 { |
|
3101 item->SetTitleL( aObject.Uri(), ETrue ); |
|
3102 } |
|
3103 |
|
3104 |
|
3105 item->iId = aObject.Id(); |
|
3106 item->iMediaType = aMediaType; |
|
3107 |
|
3108 TInt storageType = CMediaFileHandler::EPhoneMemory; |
|
3109 if ( iDriveUtil->IsMemoryCard( aObject.Uri() ) ) |
|
3110 { |
|
3111 storageType = CMediaFileHandler::EMemoryCard; |
|
3112 } |
|
3113 else if ( iDriveUtil->IsMassStorage( aObject.Uri() ) ) |
|
3114 { |
|
3115 storageType = CMediaFileHandler::EMassStorage; |
|
3116 } |
|
3117 item->iStorageType = storageType; |
|
3118 |
|
3119 iList.AppendL( item ); |
|
3120 |
|
3121 CleanupStack::Pop( item ); |
|
3122 } |
|
3123 |
|
3124 // ----------------------------------------------------------------------------- |
|
3125 // CSearchList::AddRomItemL |
|
3126 // |
|
3127 // ----------------------------------------------------------------------------- |
|
3128 // |
|
3129 void CSearchList::AddRomItemL( CRomFileList* aRomList, TInt aMediaType ) |
|
3130 { |
|
3131 if ( !aRomList ) |
|
3132 { |
|
3133 return; |
|
3134 } |
|
3135 |
|
3136 TInt count =0; |
|
3137 TInt error = KErrNone; |
|
3138 if ( aMediaType == CMediaFileHandler::EMediaTypeTone ) |
|
3139 { |
|
3140 count = aRomList->Count( 0 ); |
|
3141 for ( TInt i=0; i< count; i++ ) |
|
3142 { |
|
3143 CSearchListItem* item = CSearchListItem::NewL(); |
|
3144 error = aRomList->RomFileItem( item, i ); |
|
3145 if ( error == KErrNone ) |
|
3146 { |
|
3147 iList.AppendL( item ); |
|
3148 } |
|
3149 } |
|
3150 } |
|
3151 else if ( aMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
3152 { |
|
3153 count = aRomList->Count( 1 ); |
|
3154 for (TInt i = 0; i < count; i++) |
|
3155 { |
|
3156 CSearchListItem* item = CSearchListItem::NewL(); |
|
3157 error = aRomList->RomVedioItem(item, i); |
|
3158 if (error == KErrNone) |
|
3159 { |
|
3160 iList.AppendL(item); |
|
3161 } |
|
3162 } |
|
3163 } |
|
3164 |
|
3165 } |
|
3166 |
|
3167 // ----------------------------------------------------------------------------- |
|
3168 // CSearchList::AddAlbumItemL |
|
3169 // |
|
3170 // ----------------------------------------------------------------------------- |
|
3171 // |
|
3172 void CSearchList::AddAlbumItemL( const TDesC& aAlbum ) |
|
3173 { |
|
3174 TLinearOrder<CSearchListItem> sortFunction( CSearchList::Compare ); |
|
3175 |
|
3176 CSearchListItem* item = CSearchListItem::NewLC(); |
|
3177 |
|
3178 item->SetTitleL( aAlbum, EFalse ); |
|
3179 |
|
3180 CleanupStack::Pop( item ); |
|
3181 |
|
3182 item->iMediaType = KErrNotFound; |
|
3183 item->iStorageType = KErrNotFound; |
|
3184 item->iId = KErrNotFound; |
|
3185 |
|
3186 TInt err = iList.InsertInOrder( item, sortFunction ); |
|
3187 if ( err != KErrNone ) |
|
3188 { |
|
3189 delete item; |
|
3190 } |
|
3191 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
3192 { |
|
3193 User::Leave( err ); |
|
3194 } |
|
3195 } |
|
3196 |
|
3197 |
|
3198 // ----------------------------------------------------------------------------- |
|
3199 // CSearchList::AddArtistItemL |
|
3200 // |
|
3201 // ----------------------------------------------------------------------------- |
|
3202 // |
|
3203 void CSearchList::AddArtistItemL( CMdEObject& aObject, |
|
3204 TInt aQueryType, const TDesC& aAlbum ) |
|
3205 { |
|
3206 // all songs for one artist |
|
3207 if ( aQueryType == CMediaFileHandler::EQueryArtistAll ) |
|
3208 { |
|
3209 AddItemL( aObject, CMediaFileHandler::EMediaTypeMusic ); |
|
3210 return; |
|
3211 } |
|
3212 |
|
3213 TPtrC album = TextL( aObject, CMediaFileHandler::EAttrAlbum ); |
|
3214 |
|
3215 // unknown songs (no album metadata) for one artist |
|
3216 if ( aQueryType == CMediaFileHandler::EQueryArtistUnknown ) |
|
3217 { |
|
3218 if ( album.Length() == 0 ) |
|
3219 { |
|
3220 AddItemL( aObject, CMediaFileHandler::EMediaTypeMusic ); |
|
3221 } |
|
3222 } |
|
3223 |
|
3224 // all albums for one artist |
|
3225 if ( aQueryType == CMediaFileHandler::EQueryArtist ) |
|
3226 { |
|
3227 if ( album.Length() > 0 ) |
|
3228 { |
|
3229 AddAlbumItemL( album ); |
|
3230 } |
|
3231 } |
|
3232 |
|
3233 // songs in one album |
|
3234 if ( aQueryType == CMediaFileHandler::EQueryArtistAlbum ) |
|
3235 { |
|
3236 if ( album.Length() > 0 ) |
|
3237 { |
|
3238 if ( album.Compare( aAlbum ) == 0 ) |
|
3239 { |
|
3240 AddItemL( aObject, CMediaFileHandler::EMediaTypeMusic ); |
|
3241 } |
|
3242 } |
|
3243 } |
|
3244 } |
|
3245 |
|
3246 |
|
3247 // ----------------------------------------------------------------------------- |
|
3248 // CSearchList::Sort |
|
3249 // |
|
3250 // ----------------------------------------------------------------------------- |
|
3251 // |
|
3252 void CSearchList::Sort() |
|
3253 { |
|
3254 iList.Sort( TLinearOrder<CSearchListItem>(CSearchList::Compare) ); |
|
3255 } |
|
3256 |
|
3257 |
|
3258 // ----------------------------------------------------------------------------- |
|
3259 // CSearchList::Reset |
|
3260 // |
|
3261 // ----------------------------------------------------------------------------- |
|
3262 // |
|
3263 void CSearchList::Reset() |
|
3264 { |
|
3265 iSearchId = KErrNotFound; |
|
3266 iList.ResetAndDestroy(); |
|
3267 } |
|
3268 |
|
3269 |
|
3270 // ----------------------------------------------------------------------------- |
|
3271 // CSearchList::Count |
|
3272 // |
|
3273 // ----------------------------------------------------------------------------- |
|
3274 // |
|
3275 TInt CSearchList::Count() |
|
3276 { |
|
3277 return iList.Count(); |
|
3278 } |
|
3279 |
|
3280 |
|
3281 // ----------------------------------------------------------------------------- |
|
3282 // CSearchList::GetAttributeL |
|
3283 // |
|
3284 // ----------------------------------------------------------------------------- |
|
3285 // |
|
3286 void CSearchList::GetAttributeL( TInt aIndex, TInt aAttr, TDes& aValue ) |
|
3287 { |
|
3288 aValue = KNullDesC; |
|
3289 |
|
3290 if ( !iSession ) |
|
3291 { |
|
3292 return; |
|
3293 } |
|
3294 |
|
3295 if ( aIndex == KErrNotFound ) |
|
3296 { |
|
3297 return; |
|
3298 } |
|
3299 |
|
3300 TInt count = iList.Count(); |
|
3301 if ( aIndex < 0 || aIndex >= count ) |
|
3302 { |
|
3303 return; |
|
3304 } |
|
3305 |
|
3306 if ( aAttr == CMediaFileHandler::EAttrFullName ) |
|
3307 { |
|
3308 CSearchListItem* item = iList[aIndex]; |
|
3309 if ( item->iStorageType == CMediaFileHandler::ERomStorage ) |
|
3310 { |
|
3311 if ( item->iMediaType == CMediaFileHandler::EMediaTypeTone ) |
|
3312 { |
|
3313 TPtrC name = iRomFileList->Item( item->iId , 0 ); |
|
3314 TMFDialogUtil::StrCopy( aValue, name ); |
|
3315 } |
|
3316 |
|
3317 if ( item->iMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
3318 { |
|
3319 TPtrC name = iRomFileList->Item( item->iId , 1 ); |
|
3320 TMFDialogUtil::StrCopy( aValue, name ); |
|
3321 } |
|
3322 } |
|
3323 else |
|
3324 { |
|
3325 CMdEObject* object = iSession->GetFullObjectL( item->iId ); |
|
3326 CleanupStack::PushL( object ); |
|
3327 TMFDialogUtil::StrCopy( aValue, object->Uri() ); |
|
3328 CleanupStack::PopAndDestroy( object ); |
|
3329 } |
|
3330 } |
|
3331 |
|
3332 else if ( aAttr == CMediaFileHandler::EAttrSongName || |
|
3333 aAttr == CMediaFileHandler::EAttrFileName ) |
|
3334 { |
|
3335 CSearchListItem* item = iList[aIndex]; |
|
3336 TMFDialogUtil::StrCopy( aValue, item->Title() ); |
|
3337 if ( aValue.Length() == 0 ) |
|
3338 { |
|
3339 if ( item->iStorageType == CMediaFileHandler::ERomStorage ) |
|
3340 { |
|
3341 if ( item->iMediaType == CMediaFileHandler::EMediaTypeTone ) |
|
3342 { |
|
3343 TPtrC name = iRomFileList->Item( aIndex,0 ); |
|
3344 TMFDialogUtil::StrCopy( aValue, name ); |
|
3345 } |
|
3346 |
|
3347 if ( item->iMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
3348 { |
|
3349 TPtrC name = iRomFileList->Item( aIndex,1 ); |
|
3350 TMFDialogUtil::StrCopy( aValue, name ); |
|
3351 } |
|
3352 } |
|
3353 else |
|
3354 { |
|
3355 CMdEObject* object = iSession->GetFullObjectL( item->iId ); |
|
3356 CleanupStack::PushL( object ); |
|
3357 TParsePtrC parse( object->Uri() ); |
|
3358 TMFDialogUtil::StrCopy( aValue, parse.Name() ); |
|
3359 CleanupStack::PopAndDestroy( object ); |
|
3360 } |
|
3361 } |
|
3362 } |
|
3363 } |
|
3364 |
|
3365 |
|
3366 // ----------------------------------------------------------------------------- |
|
3367 // CSearchList::Attribute |
|
3368 // |
|
3369 // ----------------------------------------------------------------------------- |
|
3370 // |
|
3371 TInt CSearchList::Attribute( TInt aIndex, TInt aAttr ) |
|
3372 { |
|
3373 if ( aIndex == KErrNotFound ) |
|
3374 { |
|
3375 return KErrNotFound; |
|
3376 } |
|
3377 |
|
3378 TInt count = iList.Count(); |
|
3379 if ( aIndex < 0 || aIndex >= count ) |
|
3380 { |
|
3381 return KErrNotFound; |
|
3382 } |
|
3383 |
|
3384 |
|
3385 TInt ret = KErrNotFound; |
|
3386 if ( aAttr == CMediaFileHandler::EAttrMediaType ) |
|
3387 { |
|
3388 CSearchListItem* item = iList[aIndex]; |
|
3389 ret = item->iMediaType; |
|
3390 } |
|
3391 |
|
3392 else if ( aAttr == CMediaFileHandler::EAttrStorageType ) |
|
3393 { |
|
3394 CSearchListItem* item = iList[aIndex]; |
|
3395 ret = item->iStorageType; |
|
3396 } |
|
3397 else if ( aAttr == CMediaFileHandler::EAttrMediaFileId ) |
|
3398 { |
|
3399 CSearchListItem* item = iList[aIndex]; |
|
3400 ret = item->iId; |
|
3401 } |
|
3402 |
|
3403 return ret; |
|
3404 } |
|
3405 |
|
3406 |
|
3407 // ----------------------------------------------------------------------------- |
|
3408 // CSearchList::Compare |
|
3409 // |
|
3410 // ----------------------------------------------------------------------------- |
|
3411 // |
|
3412 TInt CSearchList::Compare( const CSearchListItem& aFirst, |
|
3413 const CSearchListItem& aSecond ) |
|
3414 { |
|
3415 TPtrC first = aFirst.Title(); |
|
3416 TPtrC second = aSecond.Title(); |
|
3417 |
|
3418 return first.Compare( second ); |
|
3419 } |
|
3420 |
|
3421 |
|
3422 // ----------------------------------------------------------------------------- |
|
3423 // CSearchList::Panic |
|
3424 // |
|
3425 // ----------------------------------------------------------------------------- |
|
3426 // |
|
3427 void CSearchList::Panic( TInt aReason ) |
|
3428 { |
|
3429 TMFDialogUtil::Panic( aReason ); |
|
3430 } |
|
3431 |
|
3432 |
|
3433 // ----------------------------------------------------------------------------- |
|
3434 // CSearchList::TextL |
|
3435 // |
|
3436 // ----------------------------------------------------------------------------- |
|
3437 // |
|
3438 const TDesC& CSearchList::TextL( CMdEObject& aObject, TInt aId ) |
|
3439 { |
|
3440 CMdEPropertyDef& propDef = |
|
3441 CMediaFileHandler::PropertyDefL( iSession, aId ); |
|
3442 |
|
3443 CMdEProperty* property = NULL; |
|
3444 TInt err = aObject.Property( propDef, property, 0 ); |
|
3445 |
|
3446 if ( err != KErrNotFound && property ) |
|
3447 { |
|
3448 return property->TextValueL(); |
|
3449 } |
|
3450 |
|
3451 return KNullDesC; |
|
3452 } |
|
3453 |
|
3454 |
|
3455 |
|
3456 // ----------------------------------------------------------------------------- |
|
3457 // CSearchList::ItemIndex |
|
3458 // |
|
3459 // ----------------------------------------------------------------------------- |
|
3460 // |
|
3461 TInt CSearchList::ItemIndex( TInt aId ) |
|
3462 { |
|
3463 TInt count = iList.Count(); |
|
3464 |
|
3465 for ( TInt i=0; i<count; i++ ) |
|
3466 { |
|
3467 CSearchListItem* item = iList[i]; |
|
3468 if ( item->iId == aId ) |
|
3469 { |
|
3470 return i; |
|
3471 } |
|
3472 } |
|
3473 |
|
3474 return KErrNotFound; |
|
3475 } |
|
3476 |
|
3477 |
|
3478 // ----------------------------------------------------------------------------- |
|
3479 // CSearchList::ItemIndex |
|
3480 // |
|
3481 // ----------------------------------------------------------------------------- |
|
3482 // |
|
3483 TInt CSearchList::ItemIndex( const TDesC& aText ) |
|
3484 { |
|
3485 TInt count = iList.Count(); |
|
3486 |
|
3487 for ( TInt i=0; i<count; i++ ) |
|
3488 { |
|
3489 CSearchListItem* item = iList[i]; |
|
3490 if ( aText.CompareF( item->Title() ) == 0 ) |
|
3491 { |
|
3492 return i; |
|
3493 } |
|
3494 } |
|
3495 |
|
3496 |
|
3497 |
|
3498 return KErrNotFound; |
|
3499 } |
|
3500 |
|
3501 |
|
3502 // ----------------------------------------------------------------------------- |
|
3503 // CSearchList::ItemIndex |
|
3504 // |
|
3505 // ----------------------------------------------------------------------------- |
|
3506 // |
|
3507 TInt CSearchList::ItemIndex( TInt aId, TInt aIndex ) |
|
3508 { |
|
3509 TInt count = iList.Count(); |
|
3510 if ( aIndex >= 0 && aIndex < count ) |
|
3511 { |
|
3512 CSearchListItem* item = iList[aIndex]; |
|
3513 if ( item->iId == aId ) |
|
3514 { |
|
3515 return aIndex; |
|
3516 } |
|
3517 } |
|
3518 |
|
3519 return ItemIndex( aId ); |
|
3520 } |
|
3521 |
|
3522 |
|
3523 // ----------------------------------------------------------------------------- |
|
3524 // CSearchList::ItemIndex |
|
3525 // |
|
3526 // ----------------------------------------------------------------------------- |
|
3527 // |
|
3528 TInt CSearchList::ItemIndex( const TDesC& aText, TInt aIndex ) |
|
3529 { |
|
3530 TInt count = iList.Count(); |
|
3531 if ( aIndex >= 0 && aIndex < count ) |
|
3532 { |
|
3533 CSearchListItem* item = iList[aIndex]; |
|
3534 if ( aText.CompareF( item->Title() ) == 0 ) |
|
3535 { |
|
3536 return aIndex; |
|
3537 } |
|
3538 } |
|
3539 |
|
3540 return ItemIndex( aText ); |
|
3541 } |
|
3542 |
|
3543 |
|
3544 /****************************************************************************** |
|
3545 * class CArtistQuery |
|
3546 ******************************************************************************/ |
|
3547 |
|
3548 |
|
3549 |
|
3550 // ----------------------------------------------------------------------------- |
|
3551 // CArtistQuery::NewL |
|
3552 // |
|
3553 // ----------------------------------------------------------------------------- |
|
3554 // |
|
3555 CArtistQuery* CArtistQuery::NewL() |
|
3556 { |
|
3557 CArtistQuery* self = new (ELeave) CArtistQuery(); |
|
3558 CleanupStack::PushL( self ); |
|
3559 self->ConstructL(); |
|
3560 CleanupStack::Pop( self ); |
|
3561 |
|
3562 return self; |
|
3563 } |
|
3564 |
|
3565 |
|
3566 // ----------------------------------------------------------------------------- |
|
3567 // Destructor |
|
3568 // |
|
3569 // ----------------------------------------------------------------------------- |
|
3570 // |
|
3571 CArtistQuery::~CArtistQuery() |
|
3572 { |
|
3573 delete iArtist; |
|
3574 delete iAlbum; |
|
3575 delete iQuery; |
|
3576 } |
|
3577 |
|
3578 |
|
3579 // ----------------------------------------------------------------------------- |
|
3580 // CArtistQuery::CArtistQuery |
|
3581 // |
|
3582 // ----------------------------------------------------------------------------- |
|
3583 // |
|
3584 CArtistQuery::CArtistQuery() |
|
3585 { |
|
3586 iQueryType = KErrNotFound; |
|
3587 } |
|
3588 |
|
3589 |
|
3590 // ----------------------------------------------------------------------------- |
|
3591 // CArtistQuery::ConstructL |
|
3592 // |
|
3593 // ----------------------------------------------------------------------------- |
|
3594 // |
|
3595 void CArtistQuery::ConstructL() |
|
3596 { |
|
3597 iArtist = HBufC::NewL( 0 ); |
|
3598 iAlbum = HBufC::NewL( 0 ); |
|
3599 } |
|
3600 |
|
3601 // ----------------------------------------------------------------------------- |
|
3602 // CArtistQuery::SetQueryType |
|
3603 // |
|
3604 // ----------------------------------------------------------------------------- |
|
3605 // |
|
3606 void CArtistQuery::SetQueryType( TInt aType ) |
|
3607 { |
|
3608 iQueryType = aType; |
|
3609 } |
|
3610 |
|
3611 |
|
3612 // ----------------------------------------------------------------------------- |
|
3613 // CArtistQuery::QueryType |
|
3614 // |
|
3615 // ----------------------------------------------------------------------------- |
|
3616 // |
|
3617 TInt CArtistQuery::QueryType() |
|
3618 { |
|
3619 return iQueryType; |
|
3620 } |
|
3621 |
|
3622 |
|
3623 // ----------------------------------------------------------------------------- |
|
3624 // CArtistQuery::SetQuery |
|
3625 // |
|
3626 // ----------------------------------------------------------------------------- |
|
3627 // |
|
3628 void CArtistQuery::SetQuery( CMdEObjectQuery* aQuery ) |
|
3629 { |
|
3630 delete iQuery; |
|
3631 iQuery = NULL; |
|
3632 iQuery = aQuery; |
|
3633 } |
|
3634 |
|
3635 |
|
3636 // ----------------------------------------------------------------------------- |
|
3637 // CArtistQuery::Query |
|
3638 // |
|
3639 // ----------------------------------------------------------------------------- |
|
3640 // |
|
3641 CMdEObjectQuery* CArtistQuery::Query() |
|
3642 { |
|
3643 return iQuery; |
|
3644 } |
|
3645 |
|
3646 |
|
3647 // ----------------------------------------------------------------------------- |
|
3648 // CArtistQuery::Artist |
|
3649 // |
|
3650 // ----------------------------------------------------------------------------- |
|
3651 // |
|
3652 const TDesC& CArtistQuery::Artist() |
|
3653 { |
|
3654 return *iArtist; |
|
3655 } |
|
3656 |
|
3657 |
|
3658 // ----------------------------------------------------------------------------- |
|
3659 // CArtistQuery::Album |
|
3660 // |
|
3661 // ----------------------------------------------------------------------------- |
|
3662 // |
|
3663 const TDesC& CArtistQuery::Album() |
|
3664 { |
|
3665 return *iAlbum; |
|
3666 } |
|
3667 |
|
3668 |
|
3669 // ----------------------------------------------------------------------------- |
|
3670 // CArtistQuery::SetAlbumL |
|
3671 // |
|
3672 // ----------------------------------------------------------------------------- |
|
3673 // |
|
3674 void CArtistQuery::SetAlbumL( const TDesC& aText ) |
|
3675 { |
|
3676 delete iAlbum; |
|
3677 iAlbum = NULL; |
|
3678 iAlbum = aText.AllocL(); |
|
3679 } |
|
3680 |
|
3681 // ----------------------------------------------------------------------------- |
|
3682 // CArtistQuery::SetArtistL |
|
3683 // |
|
3684 // ----------------------------------------------------------------------------- |
|
3685 // |
|
3686 void CArtistQuery::SetArtistL( const TDesC& aText ) |
|
3687 { |
|
3688 delete iArtist; |
|
3689 iArtist = NULL; |
|
3690 iArtist = aText.AllocL(); |
|
3691 } |
|
3692 |
|
3693 |
|
3694 // ----------------------------------------------------------------------------- |
|
3695 // CArtistQuery::ResetL |
|
3696 // |
|
3697 // ----------------------------------------------------------------------------- |
|
3698 // |
|
3699 void CArtistQuery::ResetL() |
|
3700 { |
|
3701 iQueryType = KErrNotFound; |
|
3702 |
|
3703 delete iArtist; |
|
3704 iArtist = NULL; |
|
3705 |
|
3706 delete iAlbum; |
|
3707 iAlbum = NULL; |
|
3708 |
|
3709 delete iQuery; |
|
3710 iQuery = NULL; |
|
3711 |
|
3712 iArtist = HBufC::NewL( 0 ); |
|
3713 iAlbum = HBufC::NewL( 0 ); |
|
3714 } |
|
3715 |
|
3716 |
|
3717 // End of File |
|