author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:51:42 +0300 | |
branch | RCL_3 |
changeset 26 | e78c61e77b1a |
parent 25 | 7e0eff37aedb |
permissions | -rw-r--r-- |
25 | 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 |
// CMediaFileHandler::Remove |
|
1541 |
// Remove an item from list of search reuslt |
|
1542 |
// ----------------------------------------------------------------------------- |
|
1543 |
// |
|
1544 |
void CMediaFileHandler::Remove( TInt aIndex ) |
|
1545 |
{ |
|
1546 |
if( aIndex >= ResultCount() ) |
|
1547 |
{ |
|
1548 |
// Invalid index |
|
1549 |
return; |
|
1550 |
} |
|
1551 |
iSearchList->Remove( aIndex ); |
|
1552 |
} |
|
1553 |
||
1554 |
// ----------------------------------------------------------------------------- |
|
1555 |
// CMediaFileHandler::UnknownArtistCount |
|
1556 |
// |
|
1557 |
// Returns 1 if artist has at least one music file without album attribute, |
|
1558 |
// 0 otherwise. |
|
1559 |
// ----------------------------------------------------------------------------- |
|
1560 |
// |
|
1561 |
TInt CMediaFileHandler::UnknownArtistCount() |
|
1562 |
{ |
|
1563 |
TInt ret = 0; |
|
1564 |
||
1565 |
TInt err = KErrNone; |
|
1566 |
TRAP( err, ret = UnknownArtistCountL() ); |
|
1567 |
if ( err != KErrNone ) |
|
1568 |
{ |
|
1569 |
ret = 0; |
|
1570 |
} |
|
1571 |
return ret; |
|
1572 |
} |
|
1573 |
||
1574 |
||
1575 |
// ----------------------------------------------------------------------------- |
|
1576 |
// CMediaFileHandler::UnknownArtistCountL |
|
1577 |
// |
|
1578 |
// Returns 1 if artist has at least one music file without album attribute, |
|
1579 |
// 0 otherwise. |
|
1580 |
// ----------------------------------------------------------------------------- |
|
1581 |
// |
|
1582 |
TInt CMediaFileHandler::UnknownArtistCountL() |
|
1583 |
{ |
|
1584 |
CMdEObjectQuery* artistQuery = iArtistQuery->Query(); |
|
1585 |
if ( !artistQuery ) |
|
1586 |
{ |
|
1587 |
return 0; |
|
1588 |
} |
|
1589 |
||
1590 |
TInt count = artistQuery->Count(); |
|
1591 |
for ( TInt i=0; i<count; i++ ) |
|
1592 |
{ |
|
1593 |
CMdEObject& object = artistQuery->Result( i ); |
|
1594 |
||
1595 |
CMdEPropertyDef& propDef = |
|
1596 |
CMediaFileHandler::PropertyDefL( iSession, CMediaFileHandler::EAttrAlbum ); |
|
1597 |
||
1598 |
CMdEProperty* property = NULL; |
|
1599 |
TInt ret = object.Property( propDef, property, 0 ); |
|
1600 |
if ( ret == KErrNotFound ) |
|
1601 |
{ |
|
1602 |
return 1; |
|
1603 |
} |
|
1604 |
} |
|
1605 |
||
1606 |
return 0; |
|
1607 |
} |
|
1608 |
// ----------------------------------------------------------------------------- |
|
1609 |
// void CMediaFileHandler::StartRomScaning() |
|
1610 |
// |
|
1611 |
// Start rom scanning |
|
1612 |
// ----------------------------------------------------------------------------- |
|
1613 |
// |
|
1614 |
||
1615 |
void CMediaFileHandler::StartRomScaning( TInt aQueryType ) |
|
1616 |
{ |
|
1617 |
||
1618 |
if ( iRomScanState != MMediaFileHandlerObserver::ERomScanComplete ) |
|
1619 |
{ |
|
1620 |
iRomScanState = MMediaFileHandlerObserver::ERomScanInProgress; |
|
1621 |
iRomFileList->Reset(); |
|
1622 |
TRAPD( err , iRomFileList->ReadRomFilesL() ); |
|
1623 |
if ( err != KErrNone ) |
|
1624 |
{ |
|
1625 |
iRomScanState = MMediaFileHandlerObserver::ERomScanError; |
|
1626 |
} |
|
1627 |
else |
|
1628 |
{ |
|
1629 |
iRomScanState = MMediaFileHandlerObserver::ERomScanComplete; |
|
1630 |
} |
|
1631 |
} |
|
1632 |
||
1633 |
iSearchList->SetRomFileList( iRomFileList ); |
|
1634 |
||
1635 |
if ( iQueryinProgress ) |
|
1636 |
{ |
|
1637 |
QueryRomEmptyL( aQueryType ); |
|
1638 |
} |
|
1639 |
||
1640 |
CallObserver( MMediaFileHandlerObserver::EScanRomComplete, KErrNone ); |
|
1641 |
} |
|
1642 |
||
1643 |
// ----------------------------------------------------------------------------- |
|
1644 |
// CMediaFileHandler::CancelQuery |
|
1645 |
// |
|
1646 |
// Cancels ongoing query. |
|
1647 |
// ----------------------------------------------------------------------------- |
|
1648 |
// |
|
1649 |
void CMediaFileHandler::CancelQuery() |
|
1650 |
{ |
|
1651 |
if ( !iSessionOpen || !iQuery ) |
|
1652 |
{ |
|
1653 |
return; |
|
1654 |
} |
|
1655 |
||
1656 |
if ( !iQuery->IsComplete() ) |
|
1657 |
{ |
|
1658 |
iQuery->Cancel(); // this calls HandleQueryCompleted synchronously |
|
1659 |
} |
|
1660 |
} |
|
1661 |
||
1662 |
||
1663 |
// ----------------------------------------------------------------------------- |
|
1664 |
// CMediaFileHandler::LeaveIfSessionClosedL |
|
1665 |
// |
|
1666 |
// ----------------------------------------------------------------------------- |
|
1667 |
// |
|
1668 |
void CMediaFileHandler::LeaveIfSessionClosedL() |
|
1669 |
{ |
|
1670 |
if ( !iSession || !iSessionOpen ) |
|
1671 |
{ |
|
1672 |
User::Leave( KErrDisconnected ); |
|
1673 |
} |
|
1674 |
} |
|
1675 |
||
1676 |
||
1677 |
// ----------------------------------------------------------------------------- |
|
1678 |
// CMediaFileHandler::SetObserver |
|
1679 |
// |
|
1680 |
// ----------------------------------------------------------------------------- |
|
1681 |
// |
|
1682 |
void CMediaFileHandler::SetObserver( MMediaFileHandlerObserver* aObserver ) |
|
1683 |
{ |
|
1684 |
iObserver = aObserver; |
|
1685 |
} |
|
1686 |
||
1687 |
||
1688 |
// ----------------------------------------------------------------------------- |
|
1689 |
// CMediaFileHandler::CheckAttrL |
|
1690 |
// |
|
1691 |
// ----------------------------------------------------------------------------- |
|
1692 |
// |
|
1693 |
void CMediaFileHandler::CheckAttrL( TInt aAttr ) |
|
1694 |
{ |
|
1695 |
if ( aAttr != EAttrArtist && aAttr != EAttrAlbum && |
|
1696 |
aAttr != EAttrGenre && aAttr != EAttrComposer ) |
|
1697 |
{ |
|
1698 |
User::Leave( KErrNotSupported ); |
|
1699 |
} |
|
1700 |
} |
|
1701 |
||
1702 |
||
1703 |
// ----------------------------------------------------------------------------- |
|
1704 |
// CMediaFileHandler::GetAttributeL |
|
1705 |
// |
|
1706 |
// NOTE: GetAttributeL only gets full name or file name |
|
1707 |
// ----------------------------------------------------------------------------- |
|
1708 |
// |
|
1709 |
void CMediaFileHandler::GetAttributeL( TInt aIndex, TInt aAttr, |
|
1710 |
TDes& aValue, TInt aQueryId ) |
|
1711 |
{ |
|
1712 |
aValue = KNullDesC; |
|
1713 |
||
1714 |
if ( !iSessionOpen ) |
|
1715 |
{ |
|
1716 |
return; |
|
1717 |
} |
|
1718 |
||
1719 |
TInt id = iSearchList->SearchId(); |
|
1720 |
if ( id != aQueryId ) |
|
1721 |
{ |
|
1722 |
return; // search list and UI do not match |
|
1723 |
} |
|
1724 |
||
1725 |
iSearchList->SetSession( iSession ); |
|
1726 |
iSearchList->GetAttributeL( aIndex, aAttr, aValue ); |
|
1727 |
} |
|
1728 |
||
1729 |
||
1730 |
||
1731 |
// ----------------------------------------------------------------------------- |
|
1732 |
// CMediaFileHandler::GetAttribute |
|
1733 |
// |
|
1734 |
// ----------------------------------------------------------------------------- |
|
1735 |
// |
|
1736 |
void CMediaFileHandler::GetAttribute( TInt aIndex, TInt aAttr, |
|
1737 |
TDes& aValue, TInt aQueryId ) |
|
1738 |
{ |
|
1739 |
TRAP_IGNORE( GetAttributeL( aIndex, aAttr, aValue, aQueryId ) ); |
|
1740 |
} |
|
1741 |
||
1742 |
||
1743 |
// ----------------------------------------------------------------------------- |
|
1744 |
// CMediaFileHandler::Attribute |
|
1745 |
// |
|
1746 |
// ----------------------------------------------------------------------------- |
|
1747 |
// |
|
1748 |
TInt CMediaFileHandler::Attribute( TInt aIndex, TInt aAttr, TInt aQueryId ) |
|
1749 |
{ |
|
1750 |
if ( !iSessionOpen ) |
|
1751 |
{ |
|
1752 |
return KErrNotFound; |
|
1753 |
} |
|
1754 |
||
1755 |
TInt id = iSearchList->SearchId(); |
|
1756 |
if ( id != aQueryId ) |
|
1757 |
{ |
|
1758 |
return KErrNotFound; |
|
1759 |
} |
|
1760 |
||
1761 |
return iSearchList->Attribute( aIndex, aAttr ); |
|
1762 |
} |
|
1763 |
||
1764 |
||
1765 |
// ----------------------------------------------------------------------------- |
|
1766 |
// CMediaFileHandler::ItemIndex |
|
1767 |
// |
|
1768 |
// ----------------------------------------------------------------------------- |
|
1769 |
// |
|
1770 |
TInt CMediaFileHandler::ItemIndex( TInt aItemId, TInt aIndex ) |
|
1771 |
{ |
|
1772 |
return iSearchList->ItemIndex( aItemId, aIndex ); |
|
1773 |
} |
|
1774 |
||
1775 |
||
1776 |
// ----------------------------------------------------------------------------- |
|
1777 |
// CMediaFileHandler::ItemIndex |
|
1778 |
// |
|
1779 |
// ----------------------------------------------------------------------------- |
|
1780 |
// |
|
1781 |
TInt CMediaFileHandler::ItemIndex( const TDesC& aItemText, TInt aIndex ) |
|
1782 |
{ |
|
1783 |
return iSearchList->ItemIndex( aItemText, aIndex ); |
|
1784 |
} |
|
1785 |
||
1786 |
||
1787 |
// ----------------------------------------------------------------------------- |
|
1788 |
// CMediaFileHandler::ReadMediaFileDataL |
|
1789 |
// |
|
1790 |
// ----------------------------------------------------------------------------- |
|
1791 |
// |
|
1792 |
CMediaFileData* CMediaFileHandler::ReadMediaFileDataL( TInt aId ) |
|
1793 |
{ |
|
1794 |
if ( !iSessionOpen ) |
|
1795 |
{ |
|
1796 |
User::Leave( KErrNotFound ); |
|
1797 |
} |
|
1798 |
||
1799 |
CMdEObject* object = iSession->GetFullObjectL( aId ); |
|
1800 |
CleanupStack::PushL( object ); |
|
1801 |
||
1802 |
CMediaFileData* data = CMediaFileData::NewL(); |
|
1803 |
CleanupStack::PushL( data ); |
|
1804 |
||
1805 |
data->SetAttrL( EAttrFullName, object->Uri() ); |
|
1806 |
||
1807 |
CMdEProperty* property = NULL; |
|
1808 |
TInt ret = object->Property( PropertyDefL( EAttrSongName ), property, 0 ); |
|
1809 |
if ( ret != KErrNotFound ) |
|
1810 |
{ |
|
1811 |
data->SetAttrL( EAttrSongName, property->TextValueL() ); |
|
1812 |
} |
|
1813 |
||
1814 |
ret = object->Property( PropertyDefL( EAttrArtist ), property, 0 ); |
|
1815 |
if ( ret != KErrNotFound ) |
|
1816 |
{ |
|
1817 |
data->SetAttrL( EAttrArtist, property->TextValueL() ); |
|
1818 |
} |
|
1819 |
||
1820 |
ret = object->Property( PropertyDefL( EAttrAlbum ), property, 0 ); |
|
1821 |
if ( ret != KErrNotFound ) |
|
1822 |
{ |
|
1823 |
data->SetAttrL( EAttrAlbum, property->TextValueL() ); |
|
1824 |
} |
|
1825 |
||
1826 |
ret = object->Property( PropertyDefL( EAttrGenre ), property, 0 ); |
|
1827 |
if ( ret != KErrNotFound ) |
|
1828 |
{ |
|
1829 |
data->SetAttrL( EAttrGenre, property->TextValueL() ); |
|
1830 |
} |
|
1831 |
||
1832 |
ret = object->Property( PropertyDefL( EAttrComposer ), property, 0 ); |
|
1833 |
if ( ret != KErrNotFound ) |
|
1834 |
{ |
|
1835 |
data->SetAttrL( EAttrComposer, property->TextValueL() ); |
|
1836 |
} |
|
1837 |
||
1838 |
CleanupStack::Pop( data ); |
|
1839 |
CleanupStack::PopAndDestroy( object ); |
|
1840 |
||
1841 |
return data; |
|
1842 |
} |
|
1843 |
||
1844 |
// ----------------------------------------------------------------------------- |
|
1845 |
// CMediaFileHandler::ReadMediaFileDataL |
|
1846 |
// |
|
1847 |
// ----------------------------------------------------------------------------- |
|
1848 |
// |
|
1849 |
CMediaFileData* CMediaFileHandler::RomMediaFileDataL( TInt aId ,TInt aMediaType ) |
|
1850 |
{ |
|
1851 |
if (!iRomFileList) |
|
1852 |
{ |
|
1853 |
User::Leave(KErrNotFound); |
|
1854 |
} |
|
1855 |
||
1856 |
TBuf<KBufSize128> buf; |
|
1857 |
CMediaFileData* data = CMediaFileData::NewL(); |
|
1858 |
CleanupStack::PushL(data); |
|
1859 |
||
1860 |
if (aMediaType == EMediaTypeTone) |
|
1861 |
{ |
|
1862 |
data->SetAttrL(EAttrFullName, iRomFileList->Item(aId, 0)); |
|
1863 |
iRomFileList->GetRomFileName(aId, 0, buf); |
|
1864 |
data->SetAttrL(EAttrSongName, buf); |
|
1865 |
} |
|
1866 |
||
1867 |
if (aMediaType == EMediaTypeVideo) |
|
1868 |
{ |
|
1869 |
data->SetAttrL(EAttrFullName, iRomFileList->Item(aId, 1)); |
|
1870 |
iRomFileList->GetRomFileName(aId, 1, buf); |
|
1871 |
data->SetAttrL(EAttrSongName, buf); |
|
1872 |
} |
|
1873 |
||
1874 |
CleanupStack::Pop(data); |
|
1875 |
||
1876 |
return data; |
|
1877 |
} |
|
1878 |
||
1879 |
||
1880 |
// ----------------------------------------------------------------------------- |
|
1881 |
// CMediaFileHandler::PropertyDefL |
|
1882 |
// |
|
1883 |
// ----------------------------------------------------------------------------- |
|
1884 |
// |
|
1885 |
CMdEPropertyDef& CMediaFileHandler::PropertyDefL( TInt aAttr ) |
|
1886 |
{ |
|
1887 |
return PropertyDefL( iSession, aAttr ); |
|
1888 |
} |
|
1889 |
||
1890 |
||
1891 |
// ----------------------------------------------------------------------------- |
|
1892 |
// CMediaFileHandler::PropertyDefL |
|
1893 |
// |
|
1894 |
// ----------------------------------------------------------------------------- |
|
1895 |
// |
|
1896 |
CMdEPropertyDef& CMediaFileHandler::PropertyDefL( CMdESession* aSession, TInt aAttr ) |
|
1897 |
{ |
|
1898 |
CMdENamespaceDef& defNS = aSession->GetDefaultNamespaceDefL(); |
|
1899 |
||
1900 |
CMdEObjectDef& objectDef = |
|
1901 |
defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1902 |
||
1903 |
if ( aAttr == EAttrFileSize ) |
|
1904 |
{ |
|
1905 |
return objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
|
1906 |
} |
|
1907 |
else if ( aAttr == EAttrMediaType ) |
|
1908 |
{ |
|
1909 |
return objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); |
|
1910 |
} |
|
1911 |
else if ( aAttr == EAttrSongName || aAttr == EAttrFileName ) |
|
1912 |
{ |
|
1913 |
return objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
|
1914 |
} |
|
1915 |
else if ( aAttr == EAttrArtist ) |
|
1916 |
{ |
|
1917 |
return objectDef.GetPropertyDefL( MdeConstants::MediaObject::KArtistProperty ); |
|
1918 |
} |
|
1919 |
else if ( aAttr == EAttrAlbum ) |
|
1920 |
{ |
|
1921 |
return objectDef.GetPropertyDefL( MdeConstants::Audio::KAlbumProperty ); |
|
1922 |
} |
|
1923 |
else if ( aAttr == EAttrGenre ) |
|
1924 |
{ |
|
1925 |
return objectDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty ); |
|
1926 |
} |
|
1927 |
else if ( aAttr == EAttrComposer ) |
|
1928 |
{ |
|
1929 |
return objectDef.GetPropertyDefL( MdeConstants::Audio::KComposerProperty ); |
|
1930 |
} |
|
1931 |
else |
|
1932 |
{ |
|
1933 |
User::Leave( KErrNotSupported ); |
|
1934 |
} |
|
1935 |
||
1936 |
return objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
|
1937 |
} |
|
1938 |
||
1939 |
||
1940 |
// ----------------------------------------------------------------------------- |
|
1941 |
// CMediaFileHandler::QueryReady |
|
1942 |
// |
|
1943 |
// ----------------------------------------------------------------------------- |
|
1944 |
// |
|
1945 |
TBool CMediaFileHandler::QueryReady() |
|
1946 |
{ |
|
1947 |
if ( iIdle ) |
|
1948 |
{ |
|
1949 |
TBool isSearching = iIdle->IsActive(); |
|
1950 |
if ( isSearching ) |
|
1951 |
{ |
|
1952 |
return EFalse; // we are between audio, tone and and video search |
|
1953 |
} |
|
1954 |
} |
|
1955 |
||
1956 |
TBool isWaitingObserverCall = iQueryCaller->IsActive(); |
|
1957 |
if ( isWaitingObserverCall ) |
|
1958 |
{ |
|
1959 |
return EFalse; // query is ready but observer not called yet |
|
1960 |
} |
|
1961 |
||
1962 |
if ( iQuery ) |
|
1963 |
{ |
|
1964 |
return iQuery->IsComplete(); |
|
1965 |
} |
|
1966 |
||
1967 |
return ETrue; |
|
1968 |
} |
|
1969 |
||
1970 |
||
1971 |
// ----------------------------------------------------------------------------- |
|
1972 |
// CMediaFileHandler::ExcludeMimeTypesL |
|
1973 |
// |
|
1974 |
// Exclude mime types from query. |
|
1975 |
// ----------------------------------------------------------------------------- |
|
1976 |
// |
|
1977 |
void CMediaFileHandler::ExcludeMimeTypesL( CMdELogicCondition& aCondition, |
|
1978 |
TInt /*aAttr*/ ) |
|
1979 |
{ |
|
1980 |
TInt count = iExcludedMimeTypes->Count(); |
|
1981 |
||
1982 |
if ( count == 0 ) |
|
1983 |
{ |
|
1984 |
return; |
|
1985 |
} |
|
1986 |
||
1987 |
CMdEPropertyDef& fileTypeDef = PropertyDefL( EAttrMediaType ); |
|
1988 |
CMdELogicCondition& condition = |
|
1989 |
aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
1990 |
||
1991 |
for ( TInt i=0; i<count; i++ ) |
|
1992 |
{ |
|
1993 |
TPtrC ptr = iExcludedMimeTypes->MimeType( i ); |
|
1994 |
condition.AddPropertyConditionL( fileTypeDef, |
|
1995 |
ETextPropertyConditionCompareEquals, ptr ); |
|
1996 |
} |
|
1997 |
condition.SetNegate( ETrue ); |
|
1998 |
} |
|
1999 |
||
2000 |
||
2001 |
// ----------------------------------------------------------------------------- |
|
2002 |
// CMediaFileHandler::IncludeMusicPropertiesL |
|
2003 |
// |
|
2004 |
// Adds properties that are used to find out whether media file is music. |
|
2005 |
// File is considered music if: |
|
2006 |
// 1. it has metadata artist or album or genre or composer |
|
2007 |
// 2. its mime type is 'music' mime type (eg mp3) |
|
2008 |
// ----------------------------------------------------------------------------- |
|
2009 |
// |
|
2010 |
void CMediaFileHandler::IncludeMusicPropertiesL( CMdELogicCondition& aCondition ) |
|
2011 |
{ |
|
2012 |
ExcludeRomFilesL( aCondition ); |
|
2013 |
// CMdEObjectCondition& cond = aCondition.AddObjectConditionL( |
|
2014 |
// EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
2015 |
// cond.SetNegate( ETrue ); |
|
2016 |
||
2017 |
// CMdELogicCondition& condition = |
|
2018 |
// aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
2019 |
ExcludeRecordingsL( aCondition ); |
|
2020 |
// CMdEPropertyDef& fileTypeDef = PropertyDefL( EAttrMediaType ); |
|
2021 |
// condition.AddPropertyConditionL( fileTypeDef, |
|
2022 |
// ETextPropertyConditionCompareContains, KMimeTypeAMR ); |
|
2023 |
// condition.AddPropertyConditionL( fileTypeDef, |
|
2024 |
// ETextPropertyConditionCompareContains, KMimeTypeWAV ); |
|
2025 |
// condition.SetNegate( ETrue ); |
|
2026 |
} |
|
2027 |
||
2028 |
||
2029 |
||
2030 |
// ----------------------------------------------------------------------------- |
|
2031 |
// CMediaFileHandler::IncludeMusicPropertiesL |
|
2032 |
// |
|
2033 |
// Adds properties that are used to find out whether media file is music. |
|
2034 |
// File is considered music if: |
|
2035 |
// 1. it has metadata artist or album or genre or composer |
|
2036 |
// 2. its mime type is 'music' mime type (eg mp3) |
|
2037 |
// ----------------------------------------------------------------------------- |
|
2038 |
// |
|
2039 |
/* |
|
2040 |
void CMediaFileHandler::IncludeMusicPropertiesL( CMdELogicCondition& aCondition ) |
|
2041 |
{ |
|
2042 |
//aLogicCondition.SetOperator( ELogicConditionOperatorAnd ); |
|
2043 |
||
2044 |
CMdEPropertyDef& mimeTypeDef = PropertyDefL( EAttrMediaType ); |
|
2045 |
CMdEPropertyDef& artistTypeDef = PropertyDefL( EAttrArtist ); |
|
2046 |
CMdEPropertyDef& albumTypeDef = PropertyDefL( EAttrAlbum ); |
|
2047 |
CMdEPropertyDef& genreTypeDef = PropertyDefL( EAttrGenre ); |
|
2048 |
CMdEPropertyDef& composerTypeDef = PropertyDefL( EAttrComposer ); |
|
2049 |
||
2050 |
CMdELogicCondition& condition = |
|
2051 |
aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2052 |
||
2053 |
condition.AddPropertyConditionL( mimeTypeDef, |
|
2054 |
ETextPropertyConditionCompareContains, KMimeMp3 ); |
|
2055 |
condition.AddPropertyConditionL( artistTypeDef ); |
|
2056 |
condition.AddPropertyConditionL( albumTypeDef ); |
|
2057 |
condition.AddPropertyConditionL( genreTypeDef ); |
|
2058 |
condition.AddPropertyConditionL( composerTypeDef ); |
|
2059 |
} |
|
2060 |
*/ |
|
2061 |
||
2062 |
||
2063 |
||
2064 |
// ----------------------------------------------------------------------------- |
|
2065 |
// CMediaFileHandler::ExcludeMusicPropertiesL |
|
2066 |
// |
|
2067 |
// ----------------------------------------------------------------------------- |
|
2068 |
// |
|
2069 |
void CMediaFileHandler::ExcludeMusicPropertiesL( CMdELogicCondition& aCondition ) |
|
2070 |
{ |
|
2071 |
CMdEPropertyDef& mimeTypeDef = PropertyDefL( EAttrMediaType ); |
|
2072 |
CMdEPropertyDef& artistTypeDef = PropertyDefL( EAttrArtist ); |
|
2073 |
CMdEPropertyDef& albumTypeDef = PropertyDefL( EAttrAlbum ); |
|
2074 |
CMdEPropertyDef& genreTypeDef = PropertyDefL( EAttrGenre ); |
|
2075 |
CMdEPropertyDef& composerTypeDef = PropertyDefL( EAttrComposer ); |
|
2076 |
||
2077 |
CMdELogicCondition& condition = |
|
2078 |
aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
2079 |
||
2080 |
condition.AddPropertyConditionL( mimeTypeDef, |
|
2081 |
ETextPropertyConditionCompareContains, KMimeMp3 ); |
|
2082 |
condition.AddPropertyConditionL( artistTypeDef ); |
|
2083 |
condition.AddPropertyConditionL( albumTypeDef ); |
|
2084 |
condition.AddPropertyConditionL( genreTypeDef ); |
|
2085 |
condition.AddPropertyConditionL( composerTypeDef ); |
|
2086 |
||
2087 |
condition.SetNegate( ETrue ); |
|
2088 |
} |
|
2089 |
||
2090 |
||
2091 |
// ----------------------------------------------------------------------------- |
|
2092 |
// CMediaFileHandler::IncludeMusicSearchConditionL |
|
2093 |
// |
|
2094 |
// ----------------------------------------------------------------------------- |
|
2095 |
// |
|
2096 |
void CMediaFileHandler::IncludeMusicSearchConditionL( CMdELogicCondition& aCondition, |
|
2097 |
const TDesC& aSearchText ) |
|
2098 |
||
2099 |
{ |
|
2100 |
_LIT( KFormat, "%S%S" ); |
|
2101 |
||
2102 |
CMdELogicCondition& condition = |
|
2103 |
aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2104 |
||
2105 |
CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
2106 |
CMdEPropertyDef& artist = PropertyDefL( EAttrArtist ); |
|
2107 |
CMdEPropertyDef& album = PropertyDefL( EAttrAlbum ); |
|
2108 |
CMdEPropertyDef& genre = PropertyDefL( EAttrGenre ); |
|
2109 |
CMdEPropertyDef& composer = PropertyDefL( EAttrComposer ); |
|
2110 |
||
2111 |
// first find from the start of the property |
|
2112 |
condition.AddPropertyConditionL( songName, |
|
2113 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2114 |
||
2115 |
condition.AddPropertyConditionL( artist, |
|
2116 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2117 |
||
2118 |
||
2119 |
condition.AddPropertyConditionL( album, |
|
2120 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2121 |
||
2122 |
||
2123 |
condition.AddPropertyConditionL( genre, |
|
2124 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2125 |
||
2126 |
||
2127 |
condition.AddPropertyConditionL( composer, |
|
2128 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2129 |
||
2130 |
||
2131 |
// then find from the start of property words |
|
2132 |
TBuf<KBufSize128> buf; |
|
2133 |
if ( aSearchText.Length() < KBufSize128-1 ) |
|
2134 |
{ |
|
2135 |
buf.Format( KFormat, &KSpace, &aSearchText ); |
|
2136 |
||
2137 |
condition.AddPropertyConditionL( songName, |
|
2138 |
ETextPropertyConditionCompareContains, buf ); |
|
2139 |
condition.AddPropertyConditionL( artist, |
|
2140 |
ETextPropertyConditionCompareContains, buf ); |
|
2141 |
condition.AddPropertyConditionL( album, |
|
2142 |
ETextPropertyConditionCompareContains, buf ); |
|
2143 |
condition.AddPropertyConditionL( genre, |
|
2144 |
ETextPropertyConditionCompareContains, buf ); |
|
2145 |
condition.AddPropertyConditionL( composer, |
|
2146 |
ETextPropertyConditionCompareContains, buf ); |
|
2147 |
} |
|
2148 |
} |
|
2149 |
||
2150 |
||
2151 |
// ----------------------------------------------------------------------------- |
|
2152 |
// CMediaFileHandler::IncludeVideoConditionL |
|
2153 |
// |
|
2154 |
// ----------------------------------------------------------------------------- |
|
2155 |
// |
|
2156 |
void CMediaFileHandler::IncludeVideoSearchConditionL( |
|
2157 |
CMdELogicCondition& aCondition, const TDesC& aSearchText ) |
|
2158 |
||
2159 |
{ |
|
2160 |
_LIT( KFormat, "%S%S" ); |
|
2161 |
||
2162 |
CMdELogicCondition& condition = |
|
2163 |
aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2164 |
||
2165 |
CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
2166 |
CMdEPropertyDef& artist = PropertyDefL( EAttrArtist ); |
|
2167 |
CMdEPropertyDef& genre = PropertyDefL( EAttrGenre ); |
|
2168 |
||
2169 |
// first find from the start of the property |
|
2170 |
condition.AddPropertyConditionL( songName, |
|
2171 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2172 |
condition.AddPropertyConditionL( artist, |
|
2173 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2174 |
condition.AddPropertyConditionL( genre, |
|
2175 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2176 |
||
2177 |
// then find from the start of property words |
|
2178 |
TBuf<KBufSize128> buf; |
|
2179 |
if ( aSearchText.Length() < KBufSize128-1 ) |
|
2180 |
{ |
|
2181 |
buf.Format( KFormat, &KSpace, &aSearchText ); |
|
2182 |
||
2183 |
condition.AddPropertyConditionL( songName, |
|
2184 |
ETextPropertyConditionCompareContains, buf ); |
|
2185 |
condition.AddPropertyConditionL( artist, |
|
2186 |
ETextPropertyConditionCompareContains, buf ); |
|
2187 |
condition.AddPropertyConditionL( genre, |
|
2188 |
ETextPropertyConditionCompareContains, buf ); |
|
2189 |
} |
|
2190 |
} |
|
2191 |
||
2192 |
||
2193 |
// ----------------------------------------------------------------------------- |
|
2194 |
// CMediaFileHandler::IncludeToneSearchConditionL |
|
2195 |
// |
|
2196 |
// ----------------------------------------------------------------------------- |
|
2197 |
// |
|
2198 |
void CMediaFileHandler::IncludeToneSearchConditionL( CMdELogicCondition& aCondition, |
|
2199 |
const TDesC& aSearchText ) |
|
2200 |
||
2201 |
{ |
|
2202 |
_LIT( KFormat, "%S%S" ); |
|
2203 |
||
2204 |
CMdELogicCondition& condition = |
|
2205 |
aCondition.AddLogicConditionL( ELogicConditionOperatorOr ); |
|
2206 |
||
2207 |
CMdEPropertyDef& songName = PropertyDefL( EAttrSongName ); |
|
2208 |
||
2209 |
// first find from the start of the property |
|
2210 |
condition.AddPropertyConditionL( songName, |
|
2211 |
ETextPropertyConditionCompareBeginsWith, aSearchText ); |
|
2212 |
||
2213 |
// then find from the start of property words |
|
2214 |
TBuf<KBufSize128> buf; |
|
2215 |
if ( aSearchText.Length() < KBufSize128-1 ) |
|
2216 |
{ |
|
2217 |
buf.Format( KFormat, &KSpace, &aSearchText ); |
|
2218 |
||
2219 |
condition.AddPropertyConditionL( songName, |
|
2220 |
ETextPropertyConditionCompareContains, buf ); |
|
2221 |
} |
|
2222 |
} |
|
2223 |
||
2224 |
||
2225 |
// ----------------------------------------------------------------------------- |
|
2226 |
// CMediaFileHandler::ExcludeRecordingsL |
|
2227 |
// |
|
2228 |
// Exclude recording mime types from query (.amr and .wav). |
|
2229 |
// ----------------------------------------------------------------------------- |
|
2230 |
// |
|
2231 |
void CMediaFileHandler::ExcludeRecordingsL( CMdELogicCondition& aCondition ) |
|
2232 |
{ |
|
2233 |
CMdEPropertyDef& mimeTypeDef = PropertyDefL( EAttrMediaType ); |
|
2234 |
CMdELogicCondition& condition = |
|
2235 |
aCondition.AddLogicConditionL( ELogicConditionOperatorAnd ); |
|
2236 |
condition.AddPropertyConditionL( mimeTypeDef, |
|
2237 |
ETextPropertyConditionCompareEquals, KMimeTypeAMR ); |
|
2238 |
condition.AddPropertyConditionL( mimeTypeDef, |
|
2239 |
ETextPropertyConditionCompareEquals, KMimeTypeWAV ); |
|
2240 |
condition.SetNegate( ETrue ); |
|
2241 |
} |
|
2242 |
||
2243 |
||
2244 |
// ----------------------------------------------------------------------------- |
|
2245 |
// CMediaFileHandler::ExcludeRomFilesL |
|
2246 |
// |
|
2247 |
// Exclude music files that are in rom (default tones). |
|
2248 |
// ----------------------------------------------------------------------------- |
|
2249 |
// |
|
2250 |
void CMediaFileHandler::ExcludeRomFilesL( CMdELogicCondition& aCondition ) |
|
2251 |
{ |
|
2252 |
_LIT( KDriveZ, "z:\\" ); |
|
2253 |
||
2254 |
CMdEObjectCondition& cond = aCondition.AddObjectConditionL( |
|
2255 |
EObjectConditionCompareUriBeginsWith, KDriveZ ); |
|
2256 |
cond.SetNegate( ETrue ); |
|
2257 |
} |
|
2258 |
||
2259 |
||
2260 |
// ------------------------------------------------------------------------------- |
|
2261 |
// CMediaFileHandler::StrCopy |
|
2262 |
// |
|
2263 |
// String copy with lenght check. |
|
2264 |
// ------------------------------------------------------------------------------- |
|
2265 |
// |
|
2266 |
void CMediaFileHandler::StrCopy( TDes& aTarget, const TDesC& aSource ) |
|
2267 |
{ |
|
2268 |
TInt len = aTarget.MaxLength(); |
|
2269 |
if( len < aSource.Length() ) |
|
2270 |
{ |
|
2271 |
aTarget.Copy( aSource.Left( len ) ); |
|
2272 |
return; |
|
2273 |
} |
|
2274 |
aTarget.Copy( aSource ); |
|
2275 |
} |
|
2276 |
||
2277 |
||
2278 |
// ----------------------------------------------------------------------------- |
|
2279 |
// CMediaFileHandler::EnableObserverCall |
|
2280 |
// |
|
2281 |
// ----------------------------------------------------------------------------- |
|
2282 |
// |
|
2283 |
void CMediaFileHandler::EnableObserverCall( TBool aEnable ) |
|
2284 |
{ |
|
2285 |
iObserverCallEnabled = aEnable; |
|
2286 |
} |
|
2287 |
||
2288 |
||
2289 |
// ----------------------------------------------------------------------------- |
|
2290 |
// CMediaFileHandler::CallObserver |
|
2291 |
// |
|
2292 |
// ----------------------------------------------------------------------------- |
|
2293 |
// |
|
2294 |
void CMediaFileHandler::CallObserver( TInt aEvent, TInt aError ) |
|
2295 |
{ |
|
2296 |
const TInt KDelay = 100; // milliseconds |
|
2297 |
||
2298 |
if ( !iObserverCallEnabled ) |
|
2299 |
{ |
|
2300 |
return; |
|
2301 |
} |
|
2302 |
||
2303 |
iQueryError = aError; |
|
2304 |
iQueryEvent = aEvent; |
|
2305 |
||
2306 |
iQueryCaller->Start( 0, KDelay ); |
|
2307 |
} |
|
2308 |
||
2309 |
||
2310 |
// ----------------------------------------------------------------------------- |
|
2311 |
// CMediaFileHandler::CallObserverWithDelay |
|
2312 |
// |
|
2313 |
// ----------------------------------------------------------------------------- |
|
2314 |
// |
|
2315 |
void CMediaFileHandler::CallObserverWithDelay() |
|
2316 |
{ |
|
2317 |
const TInt KOneSecond = 1000; |
|
2318 |
||
2319 |
if ( !iObserverCallEnabled ) |
|
2320 |
{ |
|
2321 |
return; |
|
2322 |
} |
|
2323 |
||
2324 |
iObjectNotificationCaller->Start( 1, 2*KOneSecond ); |
|
2325 |
} |
|
2326 |
||
2327 |
||
2328 |
// ----------------------------------------------------------------------------- |
|
2329 |
// CMediaFileHandler::HandleActiveCallL (from MMFActiveCallerObserver) |
|
2330 |
// |
|
2331 |
// ----------------------------------------------------------------------------- |
|
2332 |
// |
|
2333 |
void CMediaFileHandler::HandleActiveCallL( TInt aCallId ) |
|
2334 |
{ |
|
2335 |
if ( !iObserver ) |
|
2336 |
{ |
|
2337 |
return; |
|
2338 |
} |
|
2339 |
||
2340 |
// inform observer that query is ready |
|
2341 |
if ( aCallId == 0 ) |
|
2342 |
{ |
|
2343 |
TRAP_IGNORE( iObserver->HandleMFEventL( iQueryEvent, iQueryError ) ); |
|
2344 |
} |
|
2345 |
||
2346 |
// inform observer that database has changed |
|
2347 |
if ( aCallId == 1 ) |
|
2348 |
{ |
|
2349 |
if ( QueryReady() ) |
|
2350 |
{ |
|
2351 |
TRAP_IGNORE( iObserver->HandleMFEventL( MMediaFileHandlerObserver::EMediaFileChanged, KErrNone ) ); |
|
2352 |
} |
|
2353 |
} |
|
2354 |
} |
|
2355 |
||
2356 |
||
2357 |
// ----------------------------------------------------------------------------- |
|
2358 |
// CMediaFileHandler::SetQueryId |
|
2359 |
// |
|
2360 |
// ----------------------------------------------------------------------------- |
|
2361 |
// |
|
2362 |
void CMediaFileHandler::SetQueryId( TInt aId ) |
|
2363 |
{ |
|
2364 |
// this id is passed to CSearchList after successful database search |
|
2365 |
iQueryId = aId; |
|
2366 |
} |
|
2367 |
||
2368 |
||
2369 |
// ----------------------------------------------------------------------------- |
|
2370 |
// CMediaFileHandler::Panic |
|
2371 |
// |
|
2372 |
// ----------------------------------------------------------------------------- |
|
2373 |
// |
|
2374 |
void CMediaFileHandler::Panic( TInt aReason ) |
|
2375 |
{ |
|
2376 |
_LIT( KPanicCategory, "CMediaFileHandler" ); |
|
2377 |
||
2378 |
User::Panic( KPanicCategory, aReason ); |
|
2379 |
} |
|
2380 |
||
2381 |
||
2382 |
// ----------------------------------------------------------------------------- |
|
2383 |
// CMediaFileHandler::MediaType |
|
2384 |
// |
|
2385 |
// ----------------------------------------------------------------------------- |
|
2386 |
// |
|
2387 |
TInt CMediaFileHandler::MediaType( TInt aQueryType ) |
|
2388 |
{ |
|
2389 |
TInt mediaType = EMediaTypeMusic; |
|
2390 |
if ( aQueryType == EQueryVideo ) |
|
2391 |
{ |
|
2392 |
mediaType = EMediaTypeVideo; |
|
2393 |
} |
|
2394 |
if ( aQueryType == EQueryRecording ) |
|
2395 |
{ |
|
2396 |
mediaType = EMediaTypeRecording; |
|
2397 |
} |
|
2398 |
if ( aQueryType == EQueryTone ) |
|
2399 |
{ |
|
2400 |
mediaType = EMediaTypeTone; |
|
2401 |
} |
|
2402 |
||
2403 |
return mediaType; |
|
2404 |
} |
|
2405 |
||
2406 |
||
2407 |
||
2408 |
/****************************************************************************** |
|
2409 |
* class CSearchListItem |
|
2410 |
******************************************************************************/ |
|
2411 |
||
2412 |
||
2413 |
// ----------------------------------------------------------------------------- |
|
2414 |
// CSearchListItem::NewL |
|
2415 |
// |
|
2416 |
// ----------------------------------------------------------------------------- |
|
2417 |
// |
|
2418 |
CSearchListItem* CSearchListItem::NewLC() |
|
2419 |
{ |
|
2420 |
CSearchListItem* self = new (ELeave) CSearchListItem(); |
|
2421 |
CleanupStack::PushL( self ); |
|
2422 |
self->ConstructL(); |
|
2423 |
||
2424 |
return self; |
|
2425 |
} |
|
2426 |
||
2427 |
||
2428 |
// ----------------------------------------------------------------------------- |
|
2429 |
// CSearchListItem::NewL |
|
2430 |
// |
|
2431 |
// ----------------------------------------------------------------------------- |
|
2432 |
// |
|
2433 |
CSearchListItem* CSearchListItem::NewL() |
|
2434 |
{ |
|
2435 |
CSearchListItem* self = new (ELeave) CSearchListItem(); |
|
2436 |
CleanupStack::PushL( self ); |
|
2437 |
self->ConstructL(); |
|
2438 |
CleanupStack::Pop( self ); |
|
2439 |
return self; |
|
2440 |
} |
|
2441 |
||
2442 |
||
2443 |
// ----------------------------------------------------------------------------- |
|
2444 |
// Destructor |
|
2445 |
// |
|
2446 |
// ----------------------------------------------------------------------------- |
|
2447 |
// |
|
2448 |
CSearchListItem::~CSearchListItem() |
|
2449 |
{ |
|
2450 |
delete iTitle; |
|
2451 |
} |
|
2452 |
||
2453 |
||
2454 |
// ----------------------------------------------------------------------------- |
|
2455 |
// CSearchListItem::CSearchListItem |
|
2456 |
// |
|
2457 |
// ----------------------------------------------------------------------------- |
|
2458 |
// |
|
2459 |
CSearchListItem::CSearchListItem() |
|
2460 |
{ |
|
2461 |
iId = KErrNotFound; |
|
2462 |
iMediaType = KErrNotFound; |
|
2463 |
iStorageType = KErrNotFound; |
|
2464 |
iTitle = NULL; |
|
2465 |
} |
|
2466 |
||
2467 |
||
2468 |
// ----------------------------------------------------------------------------- |
|
2469 |
// CSearchListItem::ConstructL |
|
2470 |
// |
|
2471 |
// ----------------------------------------------------------------------------- |
|
2472 |
// |
|
2473 |
void CSearchListItem::ConstructL() |
|
2474 |
{ |
|
2475 |
} |
|
2476 |
||
2477 |
// ----------------------------------------------------------------------------- |
|
2478 |
// CSearchListItem::SetTitleL |
|
2479 |
// |
|
2480 |
// ----------------------------------------------------------------------------- |
|
2481 |
// |
|
2482 |
||
2483 |
void CSearchListItem::SetTitleL( const TDesC& aText, TBool aFullName ) |
|
2484 |
{ |
|
2485 |
delete iTitle; |
|
2486 |
iTitle = NULL; |
|
2487 |
||
2488 |
if ( aFullName ) |
|
2489 |
{ |
|
2490 |
TParsePtrC parse( aText ); |
|
2491 |
iTitle = parse.Name().AllocL(); |
|
2492 |
} |
|
2493 |
else |
|
2494 |
{ |
|
2495 |
iTitle = aText.AllocL(); |
|
2496 |
} |
|
2497 |
} |
|
2498 |
||
2499 |
||
2500 |
// ----------------------------------------------------------------------------- |
|
2501 |
// CSearchListItem::Title |
|
2502 |
// |
|
2503 |
// ----------------------------------------------------------------------------- |
|
2504 |
// |
|
2505 |
||
2506 |
const TDesC& CSearchListItem::Title() const |
|
2507 |
{ |
|
2508 |
return *iTitle; |
|
2509 |
} |
|
2510 |
||
2511 |
||
2512 |
||
2513 |
||
2514 |
/****************************************************************************** |
|
2515 |
* class CRomFileList |
|
2516 |
******************************************************************************/ |
|
2517 |
||
2518 |
||
2519 |
||
2520 |
// ----------------------------------------------------------------------------- |
|
2521 |
// Static constructor function CRomFileList::NewL |
|
2522 |
// |
|
2523 |
// ----------------------------------------------------------------------------- |
|
2524 |
// |
|
2525 |
CRomFileList* CRomFileList::NewL() |
|
2526 |
{ |
|
2527 |
CRomFileList* self = new (ELeave) CRomFileList(); |
|
2528 |
CleanupStack::PushL( self ); |
|
2529 |
self->ConstructL(); |
|
2530 |
CleanupStack::Pop( self ); |
|
2531 |
||
2532 |
return self; |
|
2533 |
} |
|
2534 |
||
2535 |
||
2536 |
// ----------------------------------------------------------------------------- |
|
2537 |
// Destructor |
|
2538 |
// |
|
2539 |
// ----------------------------------------------------------------------------- |
|
2540 |
// |
|
2541 |
CRomFileList::~CRomFileList() |
|
2542 |
{ |
|
2543 |
iRomToneList.ResetAndDestroy(); |
|
2544 |
iRomVideoList.ResetAndDestroy(); |
|
2545 |
iList.Reset(); |
|
2546 |
iList.Close(); |
|
2547 |
iVedioList.Reset(); |
|
2548 |
iVedioList.Close(); |
|
2549 |
} |
|
2550 |
||
2551 |
||
2552 |
// ----------------------------------------------------------------------------- |
|
2553 |
// CRomFileList::CRomFileList |
|
2554 |
// |
|
2555 |
// ----------------------------------------------------------------------------- |
|
2556 |
// |
|
2557 |
CRomFileList::CRomFileList() |
|
2558 |
{ |
|
2559 |
} |
|
2560 |
||
2561 |
||
2562 |
// ----------------------------------------------------------------------------- |
|
2563 |
// CRomFileList::ConstructL |
|
2564 |
// |
|
2565 |
// ----------------------------------------------------------------------------- |
|
2566 |
// |
|
2567 |
void CRomFileList::ConstructL() |
|
2568 |
{ |
|
2569 |
} |
|
2570 |
||
2571 |
// ----------------------------------------------------------------------------- |
|
2572 |
// CRomFileList::RomFileItem( TInt aIndex ) |
|
2573 |
// |
|
2574 |
// ----------------------------------------------------------------------------- |
|
2575 |
// |
|
2576 |
TInt CRomFileList::RomFileItem( CSearchListItem* aItem, TInt aIndex) |
|
2577 |
{ |
|
2578 |
if( aIndex >= 0 && aIndex < iRomToneList.Count() ) |
|
2579 |
{ |
|
2580 |
aItem->iId = iRomToneList[aIndex]->iId; |
|
2581 |
aItem->iMediaType = iRomToneList[aIndex]->iMediaType; |
|
2582 |
aItem->iStorageType = iRomToneList[aIndex]->iStorageType; |
|
2583 |
TPtrC title = iRomToneList[aIndex]->Title(); |
|
2584 |
aItem->SetTitleL( title, EFalse ); |
|
2585 |
return KErrNone; |
|
2586 |
} |
|
2587 |
return KErrGeneral; |
|
2588 |
} |
|
2589 |
||
2590 |
// ----------------------------------------------------------------------------- |
|
2591 |
// CRomFileList::RomVedioItem( TInt aIndex ) |
|
2592 |
// |
|
2593 |
// ----------------------------------------------------------------------------- |
|
2594 |
// |
|
2595 |
TInt CRomFileList::RomVedioItem( CSearchListItem* aItem, TInt aIndex) |
|
2596 |
{ |
|
2597 |
if( aIndex >= 0 && aIndex < iRomVideoList.Count() ) |
|
2598 |
{ |
|
2599 |
aItem->iId = iRomVideoList[aIndex]->iId; |
|
2600 |
aItem->iMediaType = iRomVideoList[aIndex]->iMediaType; |
|
2601 |
aItem->iStorageType = iRomVideoList[aIndex]->iStorageType; |
|
2602 |
TPtrC title = iRomVideoList[aIndex]->Title(); |
|
2603 |
aItem->SetTitleL( title, EFalse ); |
|
2604 |
return KErrNone; |
|
2605 |
} |
|
2606 |
return KErrGeneral; |
|
2607 |
} |
|
2608 |
// ----------------------------------------------------------------------------- |
|
2609 |
// CRomFileList::Count() |
|
2610 |
// |
|
2611 |
// ----------------------------------------------------------------------------- |
|
2612 |
// |
|
2613 |
||
2614 |
TInt CRomFileList::Count(TInt aType ) |
|
2615 |
{ |
|
2616 |
if ( aType == 0 ) |
|
2617 |
{ |
|
2618 |
//Tone item count |
|
2619 |
return iRomToneList.Count(); |
|
2620 |
} |
|
2621 |
else if ( aType == 1 ) |
|
2622 |
{ |
|
2623 |
// Video item count() |
|
2624 |
return iRomVideoList.Count(); |
|
2625 |
} |
|
2626 |
return KErrNotSupported; |
|
2627 |
} |
|
2628 |
||
2629 |
// ----------------------------------------------------------------------------- |
|
2630 |
// CRomFileList::Reset() |
|
2631 |
// |
|
2632 |
// ----------------------------------------------------------------------------- |
|
2633 |
// |
|
2634 |
||
2635 |
void CRomFileList::Reset() |
|
2636 |
{ |
|
2637 |
iRomToneList.Reset(); |
|
2638 |
iRomVideoList.Reset(); |
|
2639 |
iList.Reset(); |
|
2640 |
iVedioList.Reset(); |
|
2641 |
} |
|
2642 |
// ----------------------------------------------------------------------------- |
|
2643 |
// CRomFileList::ReadRomFilesL() |
|
2644 |
// |
|
2645 |
// ----------------------------------------------------------------------------- |
|
2646 |
// |
|
2647 |
||
2648 |
void CRomFileList::ReadRomFilesL() |
|
2649 |
{ |
|
2650 |
_LIT( KFormat, "%S%S" ); |
|
2651 |
||
2652 |
iRomToneList.ResetAndDestroy(); |
|
2653 |
iList.Reset(); |
|
2654 |
||
2655 |
iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::SoundsPath() ); |
|
2656 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iRomToneList ) ); |
|
2657 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iList ) ); |
|
2658 |
||
2659 |
iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::DigitalSoundsPath() ); |
|
2660 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iRomToneList ) ); |
|
2661 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iList ) ); |
|
2662 |
||
2663 |
iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::SimpleSoundsPath() ); |
|
2664 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iRomToneList ) ); |
|
2665 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iList ) ); |
|
2666 |
||
2667 |
TRAP_IGNORE( ReadRomVediosL() ); |
|
2668 |
} |
|
2669 |
||
2670 |
||
2671 |
// ----------------------------------------------------------------------------- |
|
2672 |
// CRomFileList::ReadRomFilesL() |
|
2673 |
// |
|
2674 |
// ----------------------------------------------------------------------------- |
|
2675 |
// |
|
2676 |
||
2677 |
void CRomFileList::ReadRomVediosL() |
|
2678 |
{ |
|
2679 |
_LIT( KFormat, "%S%S" ); |
|
2680 |
||
2681 |
iRomVideoList.Reset(); |
|
2682 |
iVedioList.Reset(); |
|
2683 |
||
2684 |
iFileName.Format( KFormat, &PathInfo::RomRootPath(), &PathInfo::VideosPath() ); |
|
2685 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iRomVideoList ) ); |
|
2686 |
TRAP_IGNORE( ReadDirectoryL( iFileName, iVedioList ) ); |
|
2687 |
||
2688 |
if ( iRomVideoList.Count() > 0 ) |
|
2689 |
{ |
|
2690 |
for( TInt i(0); i < iRomVideoList.Count(); i++) |
|
2691 |
{ |
|
2692 |
iRomVideoList[i]->iMediaType = CMediaFileHandler::EMediaTypeVideo; |
|
2693 |
} |
|
2694 |
} |
|
2695 |
||
2696 |
} |
|
2697 |
||
2698 |
||
2699 |
// ----------------------------------------------------------------------------- |
|
2700 |
// TDesC& CRomFileList::Item( TInt aIndex ) |
|
2701 |
// |
|
2702 |
// ----------------------------------------------------------------------------- |
|
2703 |
// |
|
2704 |
const TDesC& CRomFileList::Item(TInt aIndex, TInt aType) |
|
2705 |
{ |
|
2706 |
TInt count = 0; |
|
2707 |
if ( aType == 0 ) |
|
2708 |
{ |
|
2709 |
count = iList.Count(); |
|
2710 |
if (aIndex >= 0 && aIndex < count) |
|
2711 |
{ |
|
2712 |
return iList[aIndex]; |
|
2713 |
} |
|
2714 |
} |
|
2715 |
else if ( aType == 1 ) |
|
2716 |
{ |
|
2717 |
count = iVedioList.Count(); |
|
2718 |
if (aIndex >= 0 && aIndex < count) |
|
2719 |
{ |
|
2720 |
return iVedioList[aIndex]; |
|
2721 |
} |
|
2722 |
} |
|
2723 |
return KNullDesC; |
|
2724 |
} |
|
2725 |
||
2726 |
||
2727 |
// ----------------------------------------------------------------------------- |
|
2728 |
// CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2729 |
// RPointerArray<CSearchListItem>& aList ) |
|
2730 |
// |
|
2731 |
// ----------------------------------------------------------------------------- |
|
2732 |
// |
|
2733 |
||
2734 |
void CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2735 |
RPointerArray<CSearchListItem>& aList ) |
|
2736 |
{ |
|
2737 |
_LIT( KFormat, "%S%S" ); |
|
2738 |
||
2739 |
CDir* dir = NULL; |
|
2740 |
RFs fsSession; |
|
2741 |
User::LeaveIfError( fsSession.Connect() ); |
|
2742 |
CleanupClosePushL( fsSession ); |
|
2743 |
||
2744 |
if ( !BaflUtils::FolderExists( fsSession, aDirectory ) ) |
|
2745 |
{ |
|
2746 |
User::Leave( KErrNotFound ); |
|
2747 |
} |
|
2748 |
||
2749 |
TInt err = fsSession.GetDir( aDirectory, KEntryAttNormal, ESortByName, dir ); |
|
2750 |
User::LeaveIfError( err ); |
|
2751 |
CleanupStack::PushL( dir ); |
|
2752 |
TInt index; |
|
2753 |
TInt count = dir->Count(); |
|
2754 |
TFileName filename; |
|
2755 |
for ( TInt i=0; i<count; i++ ) |
|
2756 |
{ |
|
2757 |
const TEntry item = (*dir)[i]; |
|
2758 |
filename.Format( KFormat, &aDirectory, &item.iName ); |
|
2759 |
index = aList.Count(); |
|
2760 |
CSearchListItem* item2 = SearchListItemFromRomL( filename, index ); |
|
2761 |
aList.AppendL( item2 ); |
|
2762 |
} |
|
2763 |
||
2764 |
CleanupStack::PopAndDestroy( dir ); |
|
2765 |
||
2766 |
CleanupStack::PopAndDestroy(); // fsSession |
|
2767 |
} |
|
2768 |
||
2769 |
// ----------------------------------------------------------------------------- |
|
2770 |
// CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2771 |
// RPointerArray<CSearchListItem>& aList ) |
|
2772 |
// |
|
2773 |
// ----------------------------------------------------------------------------- |
|
2774 |
// |
|
2775 |
||
2776 |
void CRomFileList::ReadDirectoryL( const TDesC& aDirectory, |
|
2777 |
RArray<TFileName>& aList ) |
|
2778 |
{ |
|
2779 |
_LIT( KFormat, "%S%S" ); |
|
2780 |
||
2781 |
CDir* dir = NULL; |
|
2782 |
RFs fsSession; |
|
2783 |
User::LeaveIfError( fsSession.Connect() ); |
|
2784 |
CleanupClosePushL( fsSession ); |
|
2785 |
||
2786 |
if ( !BaflUtils::FolderExists( fsSession, aDirectory ) ) |
|
2787 |
{ |
|
2788 |
User::Leave( KErrNotFound ); |
|
2789 |
} |
|
2790 |
||
2791 |
TInt err = fsSession.GetDir( aDirectory, KEntryAttNormal, ESortByName, dir ); |
|
2792 |
User::LeaveIfError( err ); |
|
2793 |
CleanupStack::PushL( dir ); |
|
2794 |
||
2795 |
TInt count = dir->Count(); |
|
2796 |
TFileName filename; |
|
2797 |
for ( TInt i=0; i<count; i++ ) |
|
2798 |
{ |
|
2799 |
const TEntry item = (*dir)[i]; |
|
2800 |
filename.Format( KFormat, &aDirectory, &item.iName ); |
|
2801 |
aList.AppendL( filename ); |
|
2802 |
} |
|
2803 |
||
2804 |
CleanupStack::PopAndDestroy( dir ); |
|
2805 |
||
2806 |
CleanupStack::PopAndDestroy(); // fsSession |
|
2807 |
} |
|
2808 |
// ----------------------------------------------------------------------------- |
|
2809 |
// CRomFileList::SearchListItemFromRomL( const TDesC& aFileName ) |
|
2810 |
// |
|
2811 |
// ----------------------------------------------------------------------------- |
|
2812 |
// |
|
2813 |
||
2814 |
CSearchListItem* CRomFileList::SearchListItemFromRomL( const TDesC& aFileName ,TInt aIndex ) |
|
2815 |
{ |
|
2816 |
TParsePtrC parsedName( aFileName ); |
|
2817 |
||
2818 |
CSearchListItem* item = CSearchListItem::NewLC(); |
|
2819 |
||
2820 |
item->iId = aIndex; |
|
2821 |
item->SetTitleL( aFileName , ETrue); |
|
2822 |
item->iStorageType = CMediaFileHandler::ERomStorage; |
|
2823 |
item->iMediaType = CMediaFileHandler::EMediaTypeTone; |
|
2824 |
||
2825 |
CleanupStack::Pop(); // item |
|
2826 |
||
2827 |
return item; |
|
2828 |
} |
|
2829 |
||
2830 |
// ----------------------------------------------------------------------------- |
|
2831 |
// CRomFileList::GetRomFileName |
|
2832 |
// |
|
2833 |
// ----------------------------------------------------------------------------- |
|
2834 |
// |
|
2835 |
TInt CRomFileList::GetRomFileName(TInt aIndex, TInt aType, TDes& aValue) |
|
2836 |
{ |
|
2837 |
//return title of rom item; |
|
2838 |
if (aType == 0) |
|
2839 |
{ |
|
2840 |
if (aIndex >= 0 && aIndex < Count(0)) |
|
2841 |
{ |
|
2842 |
aValue.Copy( iRomToneList[aIndex]->Title() ); |
|
2843 |
return KErrNone; |
|
2844 |
} |
|
2845 |
return KErrGeneral; |
|
2846 |
} |
|
2847 |
else if (aType == 1) |
|
2848 |
{ |
|
2849 |
if (aIndex >= 0 && aIndex < Count(1)) |
|
2850 |
{ |
|
2851 |
aValue.Copy(iRomVideoList[aIndex]->Title()); |
|
2852 |
return KErrNone; |
|
2853 |
} |
|
2854 |
return KErrGeneral; |
|
2855 |
} |
|
2856 |
return KErrNotFound; |
|
2857 |
} |
|
2858 |
||
2859 |
||
2860 |
/****************************************************************************** |
|
2861 |
* class CSearchList |
|
2862 |
******************************************************************************/ |
|
2863 |
||
2864 |
||
2865 |
// ----------------------------------------------------------------------------- |
|
2866 |
// CSearchList::NewL |
|
2867 |
// |
|
2868 |
// ----------------------------------------------------------------------------- |
|
2869 |
// |
|
2870 |
CSearchList* CSearchList::NewL() |
|
2871 |
{ |
|
2872 |
CSearchList* self = new (ELeave) CSearchList(); |
|
2873 |
CleanupStack::PushL( self ); |
|
2874 |
self->ConstructL(); |
|
2875 |
CleanupStack::Pop( self ); |
|
2876 |
||
2877 |
return self; |
|
2878 |
} |
|
2879 |
||
2880 |
||
2881 |
// ----------------------------------------------------------------------------- |
|
2882 |
// Destructor |
|
2883 |
// |
|
2884 |
// ----------------------------------------------------------------------------- |
|
2885 |
// |
|
2886 |
CSearchList::~CSearchList() |
|
2887 |
{ |
|
2888 |
iList.ResetAndDestroy(); |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2889 |
iList.Close(); |
25 | 2890 |
delete iDriveUtil; |
2891 |
} |
|
2892 |
||
2893 |
||
2894 |
// ----------------------------------------------------------------------------- |
|
2895 |
// CSearchList::CSearchList |
|
2896 |
// |
|
2897 |
// ----------------------------------------------------------------------------- |
|
2898 |
// |
|
2899 |
CSearchList::CSearchList() |
|
2900 |
{ |
|
2901 |
iSearchId = KErrNotFound; |
|
2902 |
} |
|
2903 |
||
2904 |
||
2905 |
// ----------------------------------------------------------------------------- |
|
2906 |
// CSearchList::ConstructL |
|
2907 |
// |
|
2908 |
// ----------------------------------------------------------------------------- |
|
2909 |
// |
|
2910 |
void CSearchList::ConstructL() |
|
2911 |
{ |
|
2912 |
iDriveUtil = CDriveUtil::NewL(); |
|
2913 |
} |
|
2914 |
||
2915 |
||
2916 |
// ----------------------------------------------------------------------------- |
|
2917 |
// CSearchList::SetSession |
|
2918 |
// |
|
2919 |
// ----------------------------------------------------------------------------- |
|
2920 |
// |
|
2921 |
void CSearchList::SetSession( CMdESession* aSession ) |
|
2922 |
{ |
|
2923 |
iSession = aSession; |
|
2924 |
} |
|
2925 |
||
2926 |
// ----------------------------------------------------------------------------- |
|
2927 |
// CSearchList::SetRomFileList |
|
2928 |
// |
|
2929 |
// ----------------------------------------------------------------------------- |
|
2930 |
// |
|
2931 |
void CSearchList::SetRomFileList( CRomFileList* aRomFileList ) |
|
2932 |
{ |
|
2933 |
iRomFileList = aRomFileList; |
|
2934 |
} |
|
2935 |
||
2936 |
// ----------------------------------------------------------------------------- |
|
2937 |
// CSearchList::SetSearchId |
|
2938 |
// |
|
2939 |
// ----------------------------------------------------------------------------- |
|
2940 |
// |
|
2941 |
void CSearchList::SetSearchId( TInt aSearchId ) |
|
2942 |
{ |
|
2943 |
iSearchId = aSearchId; |
|
2944 |
} |
|
2945 |
||
2946 |
||
2947 |
// ----------------------------------------------------------------------------- |
|
2948 |
// CSearchList::SearchId |
|
2949 |
// |
|
2950 |
// ----------------------------------------------------------------------------- |
|
2951 |
// |
|
2952 |
TInt CSearchList::SearchId() |
|
2953 |
{ |
|
2954 |
return iSearchId; |
|
2955 |
} |
|
2956 |
||
2957 |
// ----------------------------------------------------------------------------- |
|
2958 |
// CSearchList::Remove |
|
2959 |
// Remove an item from the list of search results |
|
2960 |
// ----------------------------------------------------------------------------- |
|
2961 |
// |
|
2962 |
void CSearchList::Remove( TInt aIndex ) |
|
2963 |
{ |
|
2964 |
iList.Remove( aIndex ); |
|
2965 |
} |
|
2966 |
||
2967 |
// ----------------------------------------------------------------------------- |
|
2968 |
// CSearchList::TakeResultL |
|
2969 |
// |
|
2970 |
// ----------------------------------------------------------------------------- |
|
2971 |
// |
|
2972 |
void CSearchList::TakeResultL( CMdEObjectQuery* aQuery, TInt aMediaType ) |
|
2973 |
{ |
|
2974 |
if ( !aQuery ) |
|
2975 |
{ |
|
2976 |
return; |
|
2977 |
} |
|
2978 |
CMdEObjectQuery* query = static_cast<CMdEObjectQuery*> (aQuery); |
|
2979 |
TInt count = query->Count(); |
|
2980 |
||
2981 |
for (TInt i = 0; i < count; i++) |
|
2982 |
{ |
|
2983 |
CMdEObject* object = (CMdEObject*) query->TakeOwnershipOfResult(i); |
|
2984 |
CleanupStack::PushL(object); |
|
2985 |
AddItemL(*object, aMediaType); |
|
2986 |
CleanupStack::PopAndDestroy(object); |
|
2987 |
} |
|
2988 |
} |
|
2989 |
||
2990 |
// ----------------------------------------------------------------------------- |
|
2991 |
// CSearchList::SearchInToneL |
|
2992 |
// |
|
2993 |
// ----------------------------------------------------------------------------- |
|
2994 |
// |
|
2995 |
void CSearchList::SearchInToneL( CRomFileList* aQuery, const TDesC& aSearchText ) |
|
2996 |
{ |
|
2997 |
if ( !aQuery ) |
|
2998 |
{ |
|
2999 |
return; |
|
3000 |
} |
|
3001 |
TInt error = KErrNone; |
|
3002 |
TInt count = aQuery->Count( 0 ); |
|
3003 |
for( int i = 0; i< count; i++ ) |
|
3004 |
{ |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3005 |
CSearchListItem* item = CSearchListItem::NewLC(); |
25 | 3006 |
error = aQuery->RomFileItem( item, i ); |
3007 |
if ( error == KErrNone ) |
|
3008 |
{ |
|
3009 |
TPtrC title = item->Title(); |
|
3010 |
TInt rt = title.FindF( aSearchText ); |
|
3011 |
if ( rt != KErrNotFound ) |
|
3012 |
{ |
|
3013 |
iList.AppendL( item ); |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3014 |
CleanupStack::Pop( item ); |
25 | 3015 |
} |
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3016 |
else |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3017 |
{ |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3018 |
CleanupStack::PopAndDestroy( item ); |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3019 |
} |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3020 |
} |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3021 |
else |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3022 |
{ |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3023 |
CleanupStack::PopAndDestroy( item ); |
25 | 3024 |
} |
3025 |
} |
|
3026 |
} |
|
3027 |
||
3028 |
// ----------------------------------------------------------------------------- |
|
3029 |
// CSearchList::VideoSearchInRomL |
|
3030 |
// |
|
3031 |
// ----------------------------------------------------------------------------- |
|
3032 |
// |
|
3033 |
void CSearchList::VideoSearchInRomL( CRomFileList* aQuery, const TDesC& aSearchText ) |
|
3034 |
{ |
|
3035 |
if ( !aQuery ) |
|
3036 |
{ |
|
3037 |
return; |
|
3038 |
} |
|
3039 |
TInt error = KErrNone; |
|
3040 |
TInt count = aQuery->Count( 1 ); |
|
3041 |
for( int i = 0; i< count; i++ ) |
|
3042 |
{ |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3043 |
CSearchListItem* item = CSearchListItem::NewLC(); |
25 | 3044 |
error = aQuery->RomVedioItem( item, i ); |
3045 |
if ( error == KErrNone ) |
|
3046 |
{ |
|
3047 |
TPtrC title = item->Title(); |
|
3048 |
TInt rt = title.FindF( aSearchText ); |
|
3049 |
if ( rt != KErrNotFound ) |
|
3050 |
{ |
|
3051 |
iList.AppendL( item ); |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3052 |
CleanupStack::Pop( item ); |
25 | 3053 |
} |
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3054 |
else |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3055 |
{ |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3056 |
CleanupStack::PopAndDestroy( item ); |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3057 |
} |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3058 |
} |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3059 |
else |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3060 |
{ |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3061 |
CleanupStack::PopAndDestroy( item ); |
25 | 3062 |
} |
3063 |
} |
|
3064 |
} |
|
3065 |
// ----------------------------------------------------------------------------- |
|
3066 |
// CSearchList::TakeArtistResultL |
|
3067 |
// |
|
3068 |
// ----------------------------------------------------------------------------- |
|
3069 |
// |
|
3070 |
void CSearchList::TakeArtistResultL( CArtistQuery* aArtistQuery ) |
|
3071 |
{ |
|
3072 |
if ( !aArtistQuery ) |
|
3073 |
{ |
|
3074 |
return; |
|
3075 |
} |
|
3076 |
||
3077 |
CMdEObjectQuery* query = aArtistQuery->Query(); |
|
3078 |
if ( !query ) |
|
3079 |
{ |
|
3080 |
return; |
|
3081 |
} |
|
3082 |
TInt queryType = aArtistQuery->QueryType(); |
|
3083 |
||
3084 |
||
3085 |
TInt count = query->Count(); |
|
3086 |
for ( TInt i=0; i<count; i++ ) |
|
3087 |
{ |
|
3088 |
CMdEObject& object = query->Result( i ); |
|
3089 |
AddArtistItemL( object, queryType, aArtistQuery->Album() ); |
|
3090 |
} |
|
3091 |
} |
|
3092 |
||
3093 |
||
3094 |
// ----------------------------------------------------------------------------- |
|
3095 |
// CSearchList::TakeDistinctResultL |
|
3096 |
// |
|
3097 |
// ----------------------------------------------------------------------------- |
|
3098 |
// |
|
3099 |
void CSearchList::TakeDistinctResultL( CMdEObjectQuery* aQuery, |
|
3100 |
TInt /*aMediaType*/ ) |
|
3101 |
{ |
|
3102 |
if ( !aQuery ) |
|
3103 |
{ |
|
3104 |
return; |
|
3105 |
} |
|
3106 |
||
3107 |
TInt count = aQuery->Count(); |
|
3108 |
||
3109 |
for ( TInt i=0; i<count; i++ ) |
|
3110 |
{ |
|
3111 |
TPtrC ptr = aQuery->ResultDistinctValue( i ); |
|
3112 |
||
3113 |
CSearchListItem* item = CSearchListItem::NewLC(); |
|
3114 |
||
3115 |
item->SetTitleL( ptr, EFalse ); |
|
3116 |
item->iMediaType = KErrNotFound; |
|
3117 |
item->iStorageType = KErrNotFound; |
|
3118 |
||
3119 |
iList.AppendL( item ); |
|
3120 |
||
3121 |
CleanupStack::Pop( item ); |
|
3122 |
} |
|
3123 |
} |
|
3124 |
||
3125 |
||
3126 |
// ----------------------------------------------------------------------------- |
|
3127 |
// CSearchList::AddItemL |
|
3128 |
// |
|
3129 |
// ----------------------------------------------------------------------------- |
|
3130 |
// |
|
3131 |
void CSearchList::AddItemL( CMdEObject& aObject, TInt aMediaType ) |
|
3132 |
{ |
|
3133 |
CSearchListItem* item = CSearchListItem::NewLC(); |
|
3134 |
||
3135 |
TPtrC songName = TextL( aObject, CMediaFileHandler::EAttrSongName ); |
|
3136 |
||
3137 |
if ( songName.Length() > 0 ) |
|
3138 |
{ |
|
3139 |
item->SetTitleL( songName, EFalse ); |
|
3140 |
} |
|
3141 |
else |
|
3142 |
{ |
|
3143 |
item->SetTitleL( aObject.Uri(), ETrue ); |
|
3144 |
} |
|
3145 |
||
3146 |
||
3147 |
item->iId = aObject.Id(); |
|
3148 |
item->iMediaType = aMediaType; |
|
3149 |
||
3150 |
TInt storageType = CMediaFileHandler::EPhoneMemory; |
|
3151 |
if ( iDriveUtil->IsMemoryCard( aObject.Uri() ) ) |
|
3152 |
{ |
|
3153 |
storageType = CMediaFileHandler::EMemoryCard; |
|
3154 |
} |
|
3155 |
else if ( iDriveUtil->IsMassStorage( aObject.Uri() ) ) |
|
3156 |
{ |
|
3157 |
storageType = CMediaFileHandler::EMassStorage; |
|
3158 |
} |
|
3159 |
item->iStorageType = storageType; |
|
3160 |
||
3161 |
iList.AppendL( item ); |
|
3162 |
||
3163 |
CleanupStack::Pop( item ); |
|
3164 |
} |
|
3165 |
||
3166 |
// ----------------------------------------------------------------------------- |
|
3167 |
// CSearchList::AddRomItemL |
|
3168 |
// |
|
3169 |
// ----------------------------------------------------------------------------- |
|
3170 |
// |
|
3171 |
void CSearchList::AddRomItemL( CRomFileList* aRomList, TInt aMediaType ) |
|
3172 |
{ |
|
3173 |
if ( !aRomList ) |
|
3174 |
{ |
|
3175 |
return; |
|
3176 |
} |
|
3177 |
||
3178 |
TInt count =0; |
|
3179 |
TInt error = KErrNone; |
|
3180 |
if ( aMediaType == CMediaFileHandler::EMediaTypeTone ) |
|
3181 |
{ |
|
3182 |
count = aRomList->Count( 0 ); |
|
3183 |
for ( TInt i=0; i< count; i++ ) |
|
3184 |
{ |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3185 |
CSearchListItem* item = CSearchListItem::NewLC(); |
25 | 3186 |
error = aRomList->RomFileItem( item, i ); |
3187 |
if ( error == KErrNone ) |
|
3188 |
{ |
|
3189 |
iList.AppendL( item ); |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3190 |
CleanupStack::Pop( item ); |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3191 |
} |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3192 |
else |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3193 |
{ |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3194 |
CleanupStack::PopAndDestroy( item ); |
25 | 3195 |
} |
3196 |
} |
|
3197 |
} |
|
3198 |
else if ( aMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
3199 |
{ |
|
3200 |
count = aRomList->Count( 1 ); |
|
3201 |
for (TInt i = 0; i < count; i++) |
|
3202 |
{ |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3203 |
CSearchListItem* item = CSearchListItem::NewLC(); |
25 | 3204 |
error = aRomList->RomVedioItem(item, i); |
3205 |
if (error == KErrNone) |
|
3206 |
{ |
|
3207 |
iList.AppendL(item); |
|
26
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3208 |
CleanupStack::Pop( item ); |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3209 |
} |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3210 |
else |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3211 |
{ |
e78c61e77b1a
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3212 |
CleanupStack::PopAndDestroy( item ); |
25 | 3213 |
} |
3214 |
} |
|
3215 |
} |
|
3216 |
||
3217 |
} |
|
3218 |
||
3219 |
// ----------------------------------------------------------------------------- |
|
3220 |
// CSearchList::AddAlbumItemL |
|
3221 |
// |
|
3222 |
// ----------------------------------------------------------------------------- |
|
3223 |
// |
|
3224 |
void CSearchList::AddAlbumItemL( const TDesC& aAlbum ) |
|
3225 |
{ |
|
3226 |
TLinearOrder<CSearchListItem> sortFunction( CSearchList::Compare ); |
|
3227 |
||
3228 |
CSearchListItem* item = CSearchListItem::NewLC(); |
|
3229 |
||
3230 |
item->SetTitleL( aAlbum, EFalse ); |
|
3231 |
||
3232 |
CleanupStack::Pop( item ); |
|
3233 |
||
3234 |
item->iMediaType = KErrNotFound; |
|
3235 |
item->iStorageType = KErrNotFound; |
|
3236 |
item->iId = KErrNotFound; |
|
3237 |
||
3238 |
TInt err = iList.InsertInOrder( item, sortFunction ); |
|
3239 |
if ( err != KErrNone ) |
|
3240 |
{ |
|
3241 |
delete item; |
|
3242 |
} |
|
3243 |
if ( err != KErrNone && err != KErrAlreadyExists ) |
|
3244 |
{ |
|
3245 |
User::Leave( err ); |
|
3246 |
} |
|
3247 |
} |
|
3248 |
||
3249 |
||
3250 |
// ----------------------------------------------------------------------------- |
|
3251 |
// CSearchList::AddArtistItemL |
|
3252 |
// |
|
3253 |
// ----------------------------------------------------------------------------- |
|
3254 |
// |
|
3255 |
void CSearchList::AddArtistItemL( CMdEObject& aObject, |
|
3256 |
TInt aQueryType, const TDesC& aAlbum ) |
|
3257 |
{ |
|
3258 |
// all songs for one artist |
|
3259 |
if ( aQueryType == CMediaFileHandler::EQueryArtistAll ) |
|
3260 |
{ |
|
3261 |
AddItemL( aObject, CMediaFileHandler::EMediaTypeMusic ); |
|
3262 |
return; |
|
3263 |
} |
|
3264 |
||
3265 |
TPtrC album = TextL( aObject, CMediaFileHandler::EAttrAlbum ); |
|
3266 |
||
3267 |
// unknown songs (no album metadata) for one artist |
|
3268 |
if ( aQueryType == CMediaFileHandler::EQueryArtistUnknown ) |
|
3269 |
{ |
|
3270 |
if ( album.Length() == 0 ) |
|
3271 |
{ |
|
3272 |
AddItemL( aObject, CMediaFileHandler::EMediaTypeMusic ); |
|
3273 |
} |
|
3274 |
} |
|
3275 |
||
3276 |
// all albums for one artist |
|
3277 |
if ( aQueryType == CMediaFileHandler::EQueryArtist ) |
|
3278 |
{ |
|
3279 |
if ( album.Length() > 0 ) |
|
3280 |
{ |
|
3281 |
AddAlbumItemL( album ); |
|
3282 |
} |
|
3283 |
} |
|
3284 |
||
3285 |
// songs in one album |
|
3286 |
if ( aQueryType == CMediaFileHandler::EQueryArtistAlbum ) |
|
3287 |
{ |
|
3288 |
if ( album.Length() > 0 ) |
|
3289 |
{ |
|
3290 |
if ( album.Compare( aAlbum ) == 0 ) |
|
3291 |
{ |
|
3292 |
AddItemL( aObject, CMediaFileHandler::EMediaTypeMusic ); |
|
3293 |
} |
|
3294 |
} |
|
3295 |
} |
|
3296 |
} |
|
3297 |
||
3298 |
||
3299 |
// ----------------------------------------------------------------------------- |
|
3300 |
// CSearchList::Sort |
|
3301 |
// |
|
3302 |
// ----------------------------------------------------------------------------- |
|
3303 |
// |
|
3304 |
void CSearchList::Sort() |
|
3305 |
{ |
|
3306 |
iList.Sort( TLinearOrder<CSearchListItem>(CSearchList::Compare) ); |
|
3307 |
} |
|
3308 |
||
3309 |
||
3310 |
// ----------------------------------------------------------------------------- |
|
3311 |
// CSearchList::Reset |
|
3312 |
// |
|
3313 |
// ----------------------------------------------------------------------------- |
|
3314 |
// |
|
3315 |
void CSearchList::Reset() |
|
3316 |
{ |
|
3317 |
iSearchId = KErrNotFound; |
|
3318 |
iList.ResetAndDestroy(); |
|
3319 |
} |
|
3320 |
||
3321 |
||
3322 |
// ----------------------------------------------------------------------------- |
|
3323 |
// CSearchList::Count |
|
3324 |
// |
|
3325 |
// ----------------------------------------------------------------------------- |
|
3326 |
// |
|
3327 |
TInt CSearchList::Count() |
|
3328 |
{ |
|
3329 |
return iList.Count(); |
|
3330 |
} |
|
3331 |
||
3332 |
||
3333 |
// ----------------------------------------------------------------------------- |
|
3334 |
// CSearchList::GetAttributeL |
|
3335 |
// |
|
3336 |
// ----------------------------------------------------------------------------- |
|
3337 |
// |
|
3338 |
void CSearchList::GetAttributeL( TInt aIndex, TInt aAttr, TDes& aValue ) |
|
3339 |
{ |
|
3340 |
aValue = KNullDesC; |
|
3341 |
||
3342 |
if ( !iSession ) |
|
3343 |
{ |
|
3344 |
return; |
|
3345 |
} |
|
3346 |
||
3347 |
if ( aIndex == KErrNotFound ) |
|
3348 |
{ |
|
3349 |
return; |
|
3350 |
} |
|
3351 |
||
3352 |
TInt count = iList.Count(); |
|
3353 |
if ( aIndex < 0 || aIndex >= count ) |
|
3354 |
{ |
|
3355 |
return; |
|
3356 |
} |
|
3357 |
||
3358 |
if ( aAttr == CMediaFileHandler::EAttrFullName ) |
|
3359 |
{ |
|
3360 |
CSearchListItem* item = iList[aIndex]; |
|
3361 |
if ( item->iStorageType == CMediaFileHandler::ERomStorage ) |
|
3362 |
{ |
|
3363 |
if ( item->iMediaType == CMediaFileHandler::EMediaTypeTone ) |
|
3364 |
{ |
|
3365 |
TPtrC name = iRomFileList->Item( item->iId , 0 ); |
|
3366 |
TMFDialogUtil::StrCopy( aValue, name ); |
|
3367 |
} |
|
3368 |
||
3369 |
if ( item->iMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
3370 |
{ |
|
3371 |
TPtrC name = iRomFileList->Item( item->iId , 1 ); |
|
3372 |
TMFDialogUtil::StrCopy( aValue, name ); |
|
3373 |
} |
|
3374 |
} |
|
3375 |
else |
|
3376 |
{ |
|
3377 |
CMdEObject* object = iSession->GetFullObjectL( item->iId ); |
|
3378 |
CleanupStack::PushL( object ); |
|
3379 |
TMFDialogUtil::StrCopy( aValue, object->Uri() ); |
|
3380 |
CleanupStack::PopAndDestroy( object ); |
|
3381 |
} |
|
3382 |
} |
|
3383 |
||
3384 |
else if ( aAttr == CMediaFileHandler::EAttrSongName || |
|
3385 |
aAttr == CMediaFileHandler::EAttrFileName ) |
|
3386 |
{ |
|
3387 |
CSearchListItem* item = iList[aIndex]; |
|
3388 |
TMFDialogUtil::StrCopy( aValue, item->Title() ); |
|
3389 |
if ( aValue.Length() == 0 ) |
|
3390 |
{ |
|
3391 |
if ( item->iStorageType == CMediaFileHandler::ERomStorage ) |
|
3392 |
{ |
|
3393 |
if ( item->iMediaType == CMediaFileHandler::EMediaTypeTone ) |
|
3394 |
{ |
|
3395 |
TPtrC name = iRomFileList->Item( aIndex,0 ); |
|
3396 |
TMFDialogUtil::StrCopy( aValue, name ); |
|
3397 |
} |
|
3398 |
||
3399 |
if ( item->iMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
3400 |
{ |
|
3401 |
TPtrC name = iRomFileList->Item( aIndex,1 ); |
|
3402 |
TMFDialogUtil::StrCopy( aValue, name ); |
|
3403 |
} |
|
3404 |
} |
|
3405 |
else |
|
3406 |
{ |
|
3407 |
CMdEObject* object = iSession->GetFullObjectL( item->iId ); |
|
3408 |
CleanupStack::PushL( object ); |
|
3409 |
TParsePtrC parse( object->Uri() ); |
|
3410 |
TMFDialogUtil::StrCopy( aValue, parse.Name() ); |
|
3411 |
CleanupStack::PopAndDestroy( object ); |
|
3412 |
} |
|
3413 |
} |
|
3414 |
} |
|
3415 |
} |
|
3416 |
||
3417 |
||
3418 |
// ----------------------------------------------------------------------------- |
|
3419 |
// CSearchList::Attribute |
|
3420 |
// |
|
3421 |
// ----------------------------------------------------------------------------- |
|
3422 |
// |
|
3423 |
TInt CSearchList::Attribute( TInt aIndex, TInt aAttr ) |
|
3424 |
{ |
|
3425 |
if ( aIndex == KErrNotFound ) |
|
3426 |
{ |
|
3427 |
return KErrNotFound; |
|
3428 |
} |
|
3429 |
||
3430 |
TInt count = iList.Count(); |
|
3431 |
if ( aIndex < 0 || aIndex >= count ) |
|
3432 |
{ |
|
3433 |
return KErrNotFound; |
|
3434 |
} |
|
3435 |
||
3436 |
||
3437 |
TInt ret = KErrNotFound; |
|
3438 |
if ( aAttr == CMediaFileHandler::EAttrMediaType ) |
|
3439 |
{ |
|
3440 |
CSearchListItem* item = iList[aIndex]; |
|
3441 |
ret = item->iMediaType; |
|
3442 |
} |
|
3443 |
||
3444 |
else if ( aAttr == CMediaFileHandler::EAttrStorageType ) |
|
3445 |
{ |
|
3446 |
CSearchListItem* item = iList[aIndex]; |
|
3447 |
ret = item->iStorageType; |
|
3448 |
} |
|
3449 |
else if ( aAttr == CMediaFileHandler::EAttrMediaFileId ) |
|
3450 |
{ |
|
3451 |
CSearchListItem* item = iList[aIndex]; |
|
3452 |
ret = item->iId; |
|
3453 |
} |
|
3454 |
||
3455 |
return ret; |
|
3456 |
} |
|
3457 |
||
3458 |
||
3459 |
// ----------------------------------------------------------------------------- |
|
3460 |
// CSearchList::Compare |
|
3461 |
// |
|
3462 |
// ----------------------------------------------------------------------------- |
|
3463 |
// |
|
3464 |
TInt CSearchList::Compare( const CSearchListItem& aFirst, |
|
3465 |
const CSearchListItem& aSecond ) |
|
3466 |
{ |
|
3467 |
TPtrC first = aFirst.Title(); |
|
3468 |
TPtrC second = aSecond.Title(); |
|
3469 |
||
3470 |
return first.Compare( second ); |
|
3471 |
} |
|
3472 |
||
3473 |
||
3474 |
// ----------------------------------------------------------------------------- |
|
3475 |
// CSearchList::Panic |
|
3476 |
// |
|
3477 |
// ----------------------------------------------------------------------------- |
|
3478 |
// |
|
3479 |
void CSearchList::Panic( TInt aReason ) |
|
3480 |
{ |
|
3481 |
TMFDialogUtil::Panic( aReason ); |
|
3482 |
} |
|
3483 |
||
3484 |
||
3485 |
// ----------------------------------------------------------------------------- |
|
3486 |
// CSearchList::TextL |
|
3487 |
// |
|
3488 |
// ----------------------------------------------------------------------------- |
|
3489 |
// |
|
3490 |
const TDesC& CSearchList::TextL( CMdEObject& aObject, TInt aId ) |
|
3491 |
{ |
|
3492 |
CMdEPropertyDef& propDef = |
|
3493 |
CMediaFileHandler::PropertyDefL( iSession, aId ); |
|
3494 |
||
3495 |
CMdEProperty* property = NULL; |
|
3496 |
TInt err = aObject.Property( propDef, property, 0 ); |
|
3497 |
||
3498 |
if ( err != KErrNotFound && property ) |
|
3499 |
{ |
|
3500 |
return property->TextValueL(); |
|
3501 |
} |
|
3502 |
||
3503 |
return KNullDesC; |
|
3504 |
} |
|
3505 |
||
3506 |
||
3507 |
||
3508 |
// ----------------------------------------------------------------------------- |
|
3509 |
// CSearchList::ItemIndex |
|
3510 |
// |
|
3511 |
// ----------------------------------------------------------------------------- |
|
3512 |
// |
|
3513 |
TInt CSearchList::ItemIndex( TInt aId ) |
|
3514 |
{ |
|
3515 |
TInt count = iList.Count(); |
|
3516 |
||
3517 |
for ( TInt i=0; i<count; i++ ) |
|
3518 |
{ |
|
3519 |
CSearchListItem* item = iList[i]; |
|
3520 |
if ( item->iId == aId ) |
|
3521 |
{ |
|
3522 |
return i; |
|
3523 |
} |
|
3524 |
} |
|
3525 |
||
3526 |
return KErrNotFound; |
|
3527 |
} |
|
3528 |
||
3529 |
||
3530 |
// ----------------------------------------------------------------------------- |
|
3531 |
// CSearchList::ItemIndex |
|
3532 |
// |
|
3533 |
// ----------------------------------------------------------------------------- |
|
3534 |
// |
|
3535 |
TInt CSearchList::ItemIndex( const TDesC& aText ) |
|
3536 |
{ |
|
3537 |
TInt count = iList.Count(); |
|
3538 |
||
3539 |
for ( TInt i=0; i<count; i++ ) |
|
3540 |
{ |
|
3541 |
CSearchListItem* item = iList[i]; |
|
3542 |
if ( aText.CompareF( item->Title() ) == 0 ) |
|
3543 |
{ |
|
3544 |
return i; |
|
3545 |
} |
|
3546 |
} |
|
3547 |
||
3548 |
||
3549 |
||
3550 |
return KErrNotFound; |
|
3551 |
} |
|
3552 |
||
3553 |
||
3554 |
// ----------------------------------------------------------------------------- |
|
3555 |
// CSearchList::ItemIndex |
|
3556 |
// |
|
3557 |
// ----------------------------------------------------------------------------- |
|
3558 |
// |
|
3559 |
TInt CSearchList::ItemIndex( TInt aId, TInt aIndex ) |
|
3560 |
{ |
|
3561 |
TInt count = iList.Count(); |
|
3562 |
if ( aIndex >= 0 && aIndex < count ) |
|
3563 |
{ |
|
3564 |
CSearchListItem* item = iList[aIndex]; |
|
3565 |
if ( item->iId == aId ) |
|
3566 |
{ |
|
3567 |
return aIndex; |
|
3568 |
} |
|
3569 |
} |
|
3570 |
||
3571 |
return ItemIndex( aId ); |
|
3572 |
} |
|
3573 |
||
3574 |
||
3575 |
// ----------------------------------------------------------------------------- |
|
3576 |
// CSearchList::ItemIndex |
|
3577 |
// |
|
3578 |
// ----------------------------------------------------------------------------- |
|
3579 |
// |
|
3580 |
TInt CSearchList::ItemIndex( const TDesC& aText, TInt aIndex ) |
|
3581 |
{ |
|
3582 |
TInt count = iList.Count(); |
|
3583 |
if ( aIndex >= 0 && aIndex < count ) |
|
3584 |
{ |
|
3585 |
CSearchListItem* item = iList[aIndex]; |
|
3586 |
if ( aText.CompareF( item->Title() ) == 0 ) |
|
3587 |
{ |
|
3588 |
return aIndex; |
|
3589 |
} |
|
3590 |
} |
|
3591 |
||
3592 |
return ItemIndex( aText ); |
|
3593 |
} |
|
3594 |
||
3595 |
||
3596 |
/****************************************************************************** |
|
3597 |
* class CArtistQuery |
|
3598 |
******************************************************************************/ |
|
3599 |
||
3600 |
||
3601 |
||
3602 |
// ----------------------------------------------------------------------------- |
|
3603 |
// CArtistQuery::NewL |
|
3604 |
// |
|
3605 |
// ----------------------------------------------------------------------------- |
|
3606 |
// |
|
3607 |
CArtistQuery* CArtistQuery::NewL() |
|
3608 |
{ |
|
3609 |
CArtistQuery* self = new (ELeave) CArtistQuery(); |
|
3610 |
CleanupStack::PushL( self ); |
|
3611 |
self->ConstructL(); |
|
3612 |
CleanupStack::Pop( self ); |
|
3613 |
||
3614 |
return self; |
|
3615 |
} |
|
3616 |
||
3617 |
||
3618 |
// ----------------------------------------------------------------------------- |
|
3619 |
// Destructor |
|
3620 |
// |
|
3621 |
// ----------------------------------------------------------------------------- |
|
3622 |
// |
|
3623 |
CArtistQuery::~CArtistQuery() |
|
3624 |
{ |
|
3625 |
delete iArtist; |
|
3626 |
delete iAlbum; |
|
3627 |
delete iQuery; |
|
3628 |
} |
|
3629 |
||
3630 |
||
3631 |
// ----------------------------------------------------------------------------- |
|
3632 |
// CArtistQuery::CArtistQuery |
|
3633 |
// |
|
3634 |
// ----------------------------------------------------------------------------- |
|
3635 |
// |
|
3636 |
CArtistQuery::CArtistQuery() |
|
3637 |
{ |
|
3638 |
iQueryType = KErrNotFound; |
|
3639 |
} |
|
3640 |
||
3641 |
||
3642 |
// ----------------------------------------------------------------------------- |
|
3643 |
// CArtistQuery::ConstructL |
|
3644 |
// |
|
3645 |
// ----------------------------------------------------------------------------- |
|
3646 |
// |
|
3647 |
void CArtistQuery::ConstructL() |
|
3648 |
{ |
|
3649 |
iArtist = HBufC::NewL( 0 ); |
|
3650 |
iAlbum = HBufC::NewL( 0 ); |
|
3651 |
} |
|
3652 |
||
3653 |
// ----------------------------------------------------------------------------- |
|
3654 |
// CArtistQuery::SetQueryType |
|
3655 |
// |
|
3656 |
// ----------------------------------------------------------------------------- |
|
3657 |
// |
|
3658 |
void CArtistQuery::SetQueryType( TInt aType ) |
|
3659 |
{ |
|
3660 |
iQueryType = aType; |
|
3661 |
} |
|
3662 |
||
3663 |
||
3664 |
// ----------------------------------------------------------------------------- |
|
3665 |
// CArtistQuery::QueryType |
|
3666 |
// |
|
3667 |
// ----------------------------------------------------------------------------- |
|
3668 |
// |
|
3669 |
TInt CArtistQuery::QueryType() |
|
3670 |
{ |
|
3671 |
return iQueryType; |
|
3672 |
} |
|
3673 |
||
3674 |
||
3675 |
// ----------------------------------------------------------------------------- |
|
3676 |
// CArtistQuery::SetQuery |
|
3677 |
// |
|
3678 |
// ----------------------------------------------------------------------------- |
|
3679 |
// |
|
3680 |
void CArtistQuery::SetQuery( CMdEObjectQuery* aQuery ) |
|
3681 |
{ |
|
3682 |
delete iQuery; |
|
3683 |
iQuery = NULL; |
|
3684 |
iQuery = aQuery; |
|
3685 |
} |
|
3686 |
||
3687 |
||
3688 |
// ----------------------------------------------------------------------------- |
|
3689 |
// CArtistQuery::Query |
|
3690 |
// |
|
3691 |
// ----------------------------------------------------------------------------- |
|
3692 |
// |
|
3693 |
CMdEObjectQuery* CArtistQuery::Query() |
|
3694 |
{ |
|
3695 |
return iQuery; |
|
3696 |
} |
|
3697 |
||
3698 |
||
3699 |
// ----------------------------------------------------------------------------- |
|
3700 |
// CArtistQuery::Artist |
|
3701 |
// |
|
3702 |
// ----------------------------------------------------------------------------- |
|
3703 |
// |
|
3704 |
const TDesC& CArtistQuery::Artist() |
|
3705 |
{ |
|
3706 |
return *iArtist; |
|
3707 |
} |
|
3708 |
||
3709 |
||
3710 |
// ----------------------------------------------------------------------------- |
|
3711 |
// CArtistQuery::Album |
|
3712 |
// |
|
3713 |
// ----------------------------------------------------------------------------- |
|
3714 |
// |
|
3715 |
const TDesC& CArtistQuery::Album() |
|
3716 |
{ |
|
3717 |
return *iAlbum; |
|
3718 |
} |
|
3719 |
||
3720 |
||
3721 |
// ----------------------------------------------------------------------------- |
|
3722 |
// CArtistQuery::SetAlbumL |
|
3723 |
// |
|
3724 |
// ----------------------------------------------------------------------------- |
|
3725 |
// |
|
3726 |
void CArtistQuery::SetAlbumL( const TDesC& aText ) |
|
3727 |
{ |
|
3728 |
delete iAlbum; |
|
3729 |
iAlbum = NULL; |
|
3730 |
iAlbum = aText.AllocL(); |
|
3731 |
} |
|
3732 |
||
3733 |
// ----------------------------------------------------------------------------- |
|
3734 |
// CArtistQuery::SetArtistL |
|
3735 |
// |
|
3736 |
// ----------------------------------------------------------------------------- |
|
3737 |
// |
|
3738 |
void CArtistQuery::SetArtistL( const TDesC& aText ) |
|
3739 |
{ |
|
3740 |
delete iArtist; |
|
3741 |
iArtist = NULL; |
|
3742 |
iArtist = aText.AllocL(); |
|
3743 |
} |
|
3744 |
||
3745 |
||
3746 |
// ----------------------------------------------------------------------------- |
|
3747 |
// CArtistQuery::ResetL |
|
3748 |
// |
|
3749 |
// ----------------------------------------------------------------------------- |
|
3750 |
// |
|
3751 |
void CArtistQuery::ResetL() |
|
3752 |
{ |
|
3753 |
iQueryType = KErrNotFound; |
|
3754 |
||
3755 |
delete iArtist; |
|
3756 |
iArtist = NULL; |
|
3757 |
||
3758 |
delete iAlbum; |
|
3759 |
iAlbum = NULL; |
|
3760 |
||
3761 |
delete iQuery; |
|
3762 |
iQuery = NULL; |
|
3763 |
||
3764 |
iArtist = HBufC::NewL( 0 ); |
|
3765 |
iAlbum = HBufC::NewL( 0 ); |
|
3766 |
} |
|
3767 |
||
3768 |
||
3769 |
// End of File |