|
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: Class of Mediafiledialog. UI control of mediafilelist |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "mediafiledialog.h" |
|
24 #include "mediafiledialogutils.h" |
|
25 #include "mediafilelist.h" |
|
26 #include "mediafilehandler.h" |
|
27 #include "mediafilelistdebug.h" |
|
28 #include "mediafileprotection.h" |
|
29 #include "mediafilevideopreviewdialog.h" |
|
30 #include "mediafiletest.h" // test code |
|
31 |
|
32 #include <eikclbd.h> // for CColumnListBoxData |
|
33 #include <coecobs.h> // MCoeControlObserver |
|
34 #include <AknUtils.h> // AknTextUtils AknFind |
|
35 #include <AknIconArray.h> // for GulArray |
|
36 #include <AknWaitDialog.h> |
|
37 #include <textresolver.h> |
|
38 #include <StringLoader.h> |
|
39 #include <akninputblock.h> // CAknInputBlock |
|
40 #include <mmferrors.h> |
|
41 // search field |
|
42 #include <aknselectionlist.h> // AknSelectionList.cpp |
|
43 #include <aknsfld.h> // CAknSearchField |
|
44 #include <eikcapc.h> // CEikCaptionedControl |
|
45 |
|
46 #include <aknconsts.h> // KAvkonBitmapFile, KAvkonVariatedBitmapsFile |
|
47 #include <AknsConstants.h> // icon constants |
|
48 #include <aknmemorycardui.mbg> // memory card icon |
|
49 #include <avkon.mbg> |
|
50 |
|
51 #include <avkon.loc> |
|
52 #include <mediafilelist.rsg> |
|
53 #include <mediafilelist.mbg> |
|
54 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
55 #include <touchfeedback.h> // For MTouchFeedback |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 /****************************************************************************** |
|
62 * class CMediaFileDialog |
|
63 ******************************************************************************/ |
|
64 |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CMediaFileDialog::NewL |
|
69 // |
|
70 // ----------------------------------------------------------------------------- |
|
71 CMediaFileDialog* CMediaFileDialog::NewL() |
|
72 { |
|
73 FLOG( _L("CMediaFileDialog::NewL START") ); |
|
74 |
|
75 CMediaFileDialog* self = new (ELeave) CMediaFileDialog(); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop( self ); |
|
79 |
|
80 FLOG( _L("CMediaFileDialog::NewL END") ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CMediaFileDialog::CMediaFileDialog |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CMediaFileDialog::CMediaFileDialog() |
|
91 { |
|
92 FLOG( _L("CMediaFileDialog::CMediaFileDialog START") ); |
|
93 |
|
94 iResourceFileId = KErrNotFound; |
|
95 iForeGround = ETrue; |
|
96 iDatabaseOpen = EFalse; |
|
97 iPeninputActive = EFalse; |
|
98 |
|
99 iNullItemFileTypeOne = KErrNotFound; |
|
100 iNullItemFileTypeTwo = KErrNotFound; |
|
101 iDialogTitle = KNullDesC; |
|
102 iIsDoubleClicked = EFalse; |
|
103 |
|
104 FLOG( _L("CMediaFileDialog::CMediaFileDialog END") ); |
|
105 } |
|
106 |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // Destructor |
|
110 // |
|
111 // ---------------------------------------------------------------------------- |
|
112 // |
|
113 CMediaFileDialog::~CMediaFileDialog() |
|
114 { |
|
115 FLOG( _L("CMediaFileDialog::~CMediaFileDialog START") ); |
|
116 |
|
117 if ( iResourceFileId != KErrNotFound ) |
|
118 { |
|
119 CEikonEnv::Static()->DeleteResourceFile( iResourceFileId ); |
|
120 } |
|
121 |
|
122 delete iStatusPaneHandler; |
|
123 delete iMFListHandler; |
|
124 delete iMediaFileHandler; |
|
125 delete iState; |
|
126 |
|
127 delete iFindCtrl; |
|
128 delete iCaller; |
|
129 delete iSearchCaller; |
|
130 |
|
131 delete iAudioPreviewHandler; |
|
132 delete iVideoPreviewHandler; |
|
133 |
|
134 delete iNullItemFileNameOne; |
|
135 delete iNullItemFileNameTwo; |
|
136 |
|
137 if ( iAvkonAppUi ) |
|
138 { |
|
139 iAvkonAppUi->RemoveFromStack(this); |
|
140 } |
|
141 |
|
142 CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
143 |
|
144 if ( iPopupNote ) |
|
145 { |
|
146 iPopupNote->HideInfoPopupNote(); |
|
147 delete iPopupNote; |
|
148 } |
|
149 |
|
150 delete iWaitNote; |
|
151 if ( AknLayoutUtils::PenEnabled() ) |
|
152 { |
|
153 iPeninputServer.RemovePenUiActivationHandler(); |
|
154 iPeninputServer.Close(); |
|
155 } |
|
156 |
|
157 delete iIdle; |
|
158 |
|
159 delete iProtectionHandler; |
|
160 |
|
161 delete iInputBlock; |
|
162 |
|
163 #ifdef _DEBUG |
|
164 delete iTest; // test code |
|
165 #endif |
|
166 |
|
167 FLOG( _L("CMediaFileDialog::~CMediaFileDialog END") ); |
|
168 } |
|
169 |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CMediaFileDialog::ConstructL |
|
173 // |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CMediaFileDialog::ConstructL() |
|
177 { |
|
178 FLOG( _L("CMediaFileDialog::ConstructL START") ); |
|
179 |
|
180 iResourceFileId = TMFDialogUtil::AddResFileL(); |
|
181 |
|
182 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
183 coeEnv->AddForegroundObserverL( *this ); |
|
184 |
|
185 CAknDialog::ConstructL( R_MEDIA_FILE_DIALOG_MENU ); |
|
186 |
|
187 if ( iMenuBar ) |
|
188 { |
|
189 iMenuBar->SetContextMenuTitleResourceId( |
|
190 R_MEDIA_FILE_DIALOG_CONTEXT_MENU ); |
|
191 } |
|
192 |
|
193 // get previous title so it can be restored |
|
194 iStatusPaneHandler = CStatusPaneHandler::NewL( iAvkonAppUi ); |
|
195 iStatusPaneHandler->StoreOriginalTitleL(); |
|
196 |
|
197 iMediaFileHandler = CMediaFileHandler::NewL(); |
|
198 iMediaFileHandler->SetObserver( this ); |
|
199 |
|
200 iState = CMediaFileDialogState::NewL(); |
|
201 |
|
202 #ifndef RD_VIDEO_AS_RINGING_TONE |
|
203 iState->HideRootFolder( EEFolderVideos, ETrue, |
|
204 KNullDesC, KErrNotFound ); |
|
205 |
|
206 iMediaFileHandler->SetAttrL( CMediaFileList::EAttrExcludeFolder, CMediaFileList::EFolderVideos ); |
|
207 #endif |
|
208 |
|
209 iMFListHandler = CMFListHandler::NewL(); |
|
210 iMFListHandler->SetObserver( this ); |
|
211 |
|
212 iCaller = CMFActiveCaller::NewL( this ); |
|
213 iSearchCaller = CMFActiveCaller::NewL( this ); |
|
214 |
|
215 iAudioPreviewHandler = CMFAudioPreviewHandler::NewL(); |
|
216 iVideoPreviewHandler = CMFVideoPreviewHandler::NewL(); |
|
217 |
|
218 iAudioPreviewHandler->SetObserver( this ); |
|
219 |
|
220 iPopupNote = CAknInfoPopupNoteController::NewL(); |
|
221 |
|
222 iWaitNote = CMediaFileWaitNote::NewL( this ); |
|
223 |
|
224 if ( AknLayoutUtils::PenEnabled() ) |
|
225 { |
|
226 User::LeaveIfError( iPeninputServer.Connect() ); |
|
227 iPeninputServer.AddPenUiActivationHandler( this, EPluginInputModeAll ); |
|
228 } |
|
229 |
|
230 iProtectionHandler = CMFProtectionHandler::NewL(); |
|
231 |
|
232 #ifdef _DEBUG |
|
233 iTest = CMFDialogTest::NewL( this ); // test code |
|
234 #endif |
|
235 |
|
236 FLOG( _L("CMediaFileDialog::ConstructL END") ); |
|
237 } |
|
238 |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CMediaFileDialog::ShowDialogL |
|
242 // |
|
243 // ----------------------------------------------------------------------------- |
|
244 TBool CMediaFileDialog::ShowDialogL( TDes* aFileName, TInt* aNullItem, |
|
245 TInt* aInfo, TDes* aDesInfo ) |
|
246 { |
|
247 __ASSERT_ALWAYS( aFileName, Panic( KErrGeneral ) ); |
|
248 __ASSERT_ALWAYS( aNullItem, Panic( KErrGeneral ) ); |
|
249 |
|
250 iFileName = aFileName; |
|
251 |
|
252 iNullItem = aNullItem; |
|
253 *iNullItem = KErrNotFound; |
|
254 |
|
255 iInfo = aInfo; |
|
256 iDesInfo = aDesInfo; |
|
257 |
|
258 TBool ret = ExecuteLD( R_MEDIA_FILE_DIALOG ); |
|
259 |
|
260 return ret; |
|
261 } |
|
262 |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CMediaFileDialog::SetAttrL |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 void CMediaFileDialog::SetAttrL( TInt aAttr, TInt aValue ) |
|
269 { |
|
270 iAudioPreviewHandler->SetAttrL( aAttr, aValue ); |
|
271 iVideoPreviewHandler->SetAttrL( aAttr, aValue ); |
|
272 iMediaFileHandler->SetAttrL( aAttr, aValue ); |
|
273 iProtectionHandler->SetAttrL( aAttr, aValue ); |
|
274 |
|
275 if ( aAttr == CMediaFileList::EAttrExcludeFolder ) |
|
276 { |
|
277 if ( aValue == CMediaFileList::EFolderDownload ) |
|
278 { |
|
279 iState->HideRootFolder( EEFolderDownload, ETrue, |
|
280 KNullDesC, KErrNotFound ); |
|
281 } |
|
282 if ( aValue == CMediaFileList::EFolderVideos ) |
|
283 { |
|
284 iState->HideRootFolder( EEFolderVideos, ETrue, |
|
285 KNullDesC, KErrNotFound ); |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CMediaFileDialog::SetAttrL |
|
293 // |
|
294 // ----------------------------------------------------------------------------- |
|
295 void CMediaFileDialog::SetAttrL( TInt aAttr, const TDesC& aValue ) |
|
296 { |
|
297 iAudioPreviewHandler->SetAttrL( aAttr, aValue ); |
|
298 iVideoPreviewHandler->SetAttrL( aAttr, aValue ); |
|
299 iMediaFileHandler->SetAttrL( aAttr, aValue ); |
|
300 iProtectionHandler->SetAttrL( aAttr, aValue ); |
|
301 |
|
302 if ( aAttr == CMediaFileList::EAttrTitle ) |
|
303 { |
|
304 TMFDialogUtil::StrCopy( iDialogTitle, aValue ); |
|
305 } |
|
306 } |
|
307 |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CMediaFileDialog::SetAttrL |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 void CMediaFileDialog::SetAttrL( TInt aAttr, TAny* aValue ) |
|
314 { |
|
315 iAudioPreviewHandler->SetAttrL( aAttr, aValue ); |
|
316 iVideoPreviewHandler->SetAttrL( aAttr, aValue ); |
|
317 iMediaFileHandler->SetAttrL( aAttr, aValue ); |
|
318 } |
|
319 |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CMediaFileDialog::SetNullItemL |
|
323 // |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CMediaFileDialog::SetNullItemL( const TDesC& aText, |
|
327 const TDesC& aMediaFile, |
|
328 TInt aMediaFileType, TInt aIconId ) |
|
329 { |
|
330 TInt iconId = EEIconEmpty; |
|
331 if ( aIconId == CMediaFileList::ENullItemIconDefaultTone ) |
|
332 { |
|
333 iconId = EEIconTone; |
|
334 } |
|
335 else if ( aIconId == CMediaFileList::ENullItemIconOff ) |
|
336 { |
|
337 iconId = EEIconNullItemOff; |
|
338 } |
|
339 |
|
340 TInt mediaType = CMediaFileList::EMediaFileTypeAudio; |
|
341 if ( aMediaFileType == CMediaFileList::EMediaFileTypeVideo ) |
|
342 { |
|
343 mediaType = CMediaFileList::EMediaFileTypeVideo; |
|
344 } |
|
345 |
|
346 |
|
347 if ( !iNullItemFileNameOne ) |
|
348 { |
|
349 iNullItemFileNameOne = aMediaFile.AllocL(); |
|
350 iNullItemFileTypeOne = mediaType; |
|
351 |
|
352 iState->EnableNullItemL( EEFolderNullItemOne, aText, iconId ); |
|
353 } |
|
354 else if ( !iNullItemFileNameTwo ) |
|
355 { |
|
356 iNullItemFileNameTwo = aMediaFile.AllocL(); |
|
357 iNullItemFileTypeTwo = mediaType; |
|
358 |
|
359 iState->EnableNullItemL( EEFolderNullItemTwo, aText, iconId ); |
|
360 } |
|
361 else |
|
362 { |
|
363 User::Leave( KErrNotSupported ); // two null items supported |
|
364 } |
|
365 } |
|
366 |
|
367 |
|
368 |
|
369 //------------------------------------------------------------------------------ |
|
370 // CMediaFileDialog::ActivateL |
|
371 // |
|
372 // Called by system when dialog is activated. |
|
373 //------------------------------------------------------------------------------ |
|
374 // |
|
375 void CMediaFileDialog::ActivateL() |
|
376 { |
|
377 CAknDialog::ActivateL(); |
|
378 |
|
379 // this cannot be in ConstructL which is executed before dialog is launched |
|
380 iAvkonAppUi->AddToStackL( this ); |
|
381 AknFind::HandleFixedFindSizeChanged( this, iListBox, FindBox() ); |
|
382 DrawNow(); |
|
383 } |
|
384 |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CMediaFileDialog::PreLayoutDynInitL |
|
388 // |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CMediaFileDialog::PreLayoutDynInitL() |
|
392 { |
|
393 const TInt KFindBoxLength = 20; |
|
394 |
|
395 iListBox = (CAknSingleGraphicStyleListBox*) (ControlOrNull(1)); |
|
396 iListBox->DisableSingleClick(ETrue); |
|
397 __ASSERT_ALWAYS( iListBox, TMFDialogUtil::Panic( KErrGeneral ) ); |
|
398 |
|
399 iListBox->Model()->SetItemTextArray( iMFListHandler ); |
|
400 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
401 |
|
402 iListBox->SetListBoxObserver( this ); |
|
403 iListBox->CreateScrollBarFrameL( ETrue ); |
|
404 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
405 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); |
|
406 |
|
407 iListBox->SetContainerWindowL( *this ); |
|
408 |
|
409 SetIconsL(); |
|
410 |
|
411 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
412 |
|
413 |
|
414 iState->Init(); |
|
415 |
|
416 if ( iDialogTitle.Length() > 0 ) |
|
417 { |
|
418 iStatusPaneHandler->SetTitleL( iDialogTitle ); |
|
419 } |
|
420 else |
|
421 { |
|
422 iStatusPaneHandler->SetTitleL( R_QTN_MEDIA_FILE_DIALOG_TITLE ); |
|
423 } |
|
424 iStatusPaneHandler->SetNaviPaneTitleL( KNullDesC ); |
|
425 |
|
426 |
|
427 // |
|
428 // create find box. NOTE: findbox functionality is quite complex and |
|
429 // is implemented by copy pasting code from other apps. |
|
430 // |
|
431 |
|
432 CFindControl* control = ( CFindControl* )ControlOrNull( EFindControl ); |
|
433 if ( control ) |
|
434 { |
|
435 CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EFixed; |
|
436 control->iFind = CAknSearchField::NewL( |
|
437 *control, flags, 0, KFindBoxLength ); |
|
438 //control->iFind = searchField; |
|
439 control->SetContainerWindowL( *this ); |
|
440 CEikEdwin& edwin = control->iFind->Editor(); |
|
441 control->iFind->AddAdaptiveSearchTextObserverL( this ); |
|
442 } |
|
443 |
|
444 if ( FindBox() ) |
|
445 { |
|
446 CAknFilteredTextListBoxModel* model = |
|
447 STATIC_CAST( CAknFilteredTextListBoxModel*, iListBox->Model() ); |
|
448 |
|
449 FindBox()->MakeVisible( EFalse ); |
|
450 } |
|
451 |
|
452 |
|
453 UpdateListBoxL(); |
|
454 |
|
455 DrawDeferred(); |
|
456 } |
|
457 |
|
458 |
|
459 //------------------------------------------------------------------------------ |
|
460 // CMediaFileDialog::ProcessCommandL |
|
461 // |
|
462 // Handle commands from menu. NOTE: Current implemntation does not use menu. |
|
463 // Menu handling code is here for (possible) future use. |
|
464 //------------------------------------------------------------------------------ |
|
465 // |
|
466 void CMediaFileDialog::ProcessCommandL( TInt aCommandId ) |
|
467 { |
|
468 HideMenu(); |
|
469 |
|
470 switch (aCommandId) |
|
471 { |
|
472 case EAknCmdHelp: |
|
473 { |
|
474 break; |
|
475 } |
|
476 |
|
477 case EAknSoftkeySelect: |
|
478 { |
|
479 TBool ret = HandleOKL( EAttrSelect ); |
|
480 if ( ret ) |
|
481 { |
|
482 TryExitL( EEikCmdExit ); |
|
483 } |
|
484 break; |
|
485 } |
|
486 |
|
487 case EAknSoftkeyView: |
|
488 { |
|
489 PreviewL( CMediaFileList::EMediaFileTypeVideo ); |
|
490 break; |
|
491 } |
|
492 case EAknCmdOpen: |
|
493 { |
|
494 HandleOKL( EAttrOpen ); |
|
495 break; |
|
496 } |
|
497 |
|
498 case EAknCmdExit: |
|
499 case EEikCmdExit: |
|
500 { |
|
501 // close dialog and exit calling application |
|
502 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
503 break; |
|
504 } |
|
505 |
|
506 default: |
|
507 break; |
|
508 } |
|
509 } |
|
510 |
|
511 |
|
512 //------------------------------------------------------------------------------ |
|
513 // CMediaFileDialog::OkToExitL |
|
514 // |
|
515 // Hanlde commands from cba. |
|
516 //------------------------------------------------------------------------------ |
|
517 // |
|
518 TBool CMediaFileDialog::OkToExitL(TInt aButtonId) |
|
519 { |
|
520 if ( aButtonId == EEikBidCancel ) |
|
521 { |
|
522 return ETrue; // close dialog |
|
523 } |
|
524 |
|
525 if ( aButtonId == EEikBidOk ) |
|
526 { |
|
527 TBool ret = HandleOKL( EAttrSelect ); |
|
528 return ret; |
|
529 } |
|
530 |
|
531 if ( aButtonId == EAknSoftkeyBack ) |
|
532 { |
|
533 if ( !HandleBackL() ) |
|
534 { |
|
535 #ifdef _DEBUG |
|
536 // start test code |
|
537 TInt currentIndex = CurrentItemListIndex(); |
|
538 if ( iState->FolderId( currentIndex ) == EEFolderRecordings ) |
|
539 { |
|
540 if ( !iTest->TestL( 0 ) ) |
|
541 { |
|
542 return ETrue; // test canceled |
|
543 } |
|
544 return EFalse; // test accepted |
|
545 } |
|
546 // end test code |
|
547 #endif |
|
548 |
|
549 return ETrue; // Back pressed in top level folder |
|
550 } |
|
551 |
|
552 return EFalse; // leave dialog open |
|
553 } |
|
554 |
|
555 if ( aButtonId == EAknSoftkeyContextOptions ) |
|
556 { |
|
557 ShowContextMenuL( R_MEDIA_FILE_DIALOG_CONTEXT_MENU ); |
|
558 return EFalse; |
|
559 } |
|
560 |
|
561 if ( aButtonId == EAknSoftkeyOpen ) |
|
562 { |
|
563 TBool ret = HandleOKL( EAttrOpen ); |
|
564 return ret; |
|
565 } |
|
566 |
|
567 if ( aButtonId == EAknSoftkeySelect ) |
|
568 { |
|
569 TBool ret = HandleOKL( EAttrSelect ); |
|
570 return ret; |
|
571 } |
|
572 |
|
573 if ( aButtonId == EAknSoftkeyView ) |
|
574 { |
|
575 PreviewL( CMediaFileList::EMediaFileTypeVideo ); |
|
576 return EFalse; |
|
577 } |
|
578 |
|
579 if ( aButtonId == EAknSoftkeyEmpty ) |
|
580 { |
|
581 return EFalse; |
|
582 } |
|
583 |
|
584 return CAknDialog::OkToExitL( aButtonId ); |
|
585 } |
|
586 |
|
587 |
|
588 // ---------------------------------------------------------------------------- |
|
589 // CMediaFileDialog::OfferKeyEventL |
|
590 // |
|
591 // ---------------------------------------------------------------------------- |
|
592 // |
|
593 TKeyResponse CMediaFileDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
594 TEventCode aType) |
|
595 { |
|
596 |
|
597 iIsDoubleClicked = EFalse; |
|
598 // must pass escape event to dialog - findbox and listbox "eat" escape events |
|
599 TKeyResponse res = EKeyWasNotConsumed; |
|
600 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape ) |
|
601 { |
|
602 res = CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
603 } |
|
604 if ( res == EKeyWasConsumed ) |
|
605 { |
|
606 return res; |
|
607 } |
|
608 |
|
609 |
|
610 TBool backSpace = EFalse; |
|
611 |
|
612 if (aType == EEventKey) |
|
613 { |
|
614 switch (aKeyEvent.iCode) |
|
615 { |
|
616 case EKeyEnter: |
|
617 { |
|
618 break; |
|
619 } |
|
620 case EKeyUpArrow: |
|
621 case EKeyDownArrow: |
|
622 { |
|
623 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
624 if ( itemCount == 1 ) |
|
625 { |
|
626 PreviewL( CMediaFileList::EMediaFileTypeAudio ); |
|
627 } |
|
628 break; |
|
629 } |
|
630 |
|
631 case EKeyLeftArrow: |
|
632 { |
|
633 if (FindBox() && FindBox()->IsVisible() |
|
634 && FindBox()->TextLength() != 0) |
|
635 { |
|
636 FindBoxCursorMoveL( 0 ); |
|
637 res = EKeyWasConsumed; |
|
638 } |
|
639 else |
|
640 { |
|
641 HandleBackL(); |
|
642 return EKeyWasConsumed; |
|
643 } |
|
644 break; |
|
645 } |
|
646 |
|
647 case EKeyRightArrow: |
|
648 { |
|
649 if (FindBox() && FindBox()->IsVisible() |
|
650 && FindBox()->TextLength() != 0) |
|
651 { |
|
652 FindBoxCursorMoveL( 1 ); |
|
653 res = EKeyWasConsumed; |
|
654 } |
|
655 else |
|
656 { |
|
657 HandleOKL( EAttrOpen ); |
|
658 return EKeyWasConsumed; |
|
659 } |
|
660 break; |
|
661 } |
|
662 |
|
663 case EKeyBackspace: |
|
664 { |
|
665 backSpace = ETrue; |
|
666 break; |
|
667 } |
|
668 |
|
669 default: |
|
670 { |
|
671 break; |
|
672 } |
|
673 } |
|
674 |
|
675 if ( FindBox() && FindBox()->IsVisible() ) |
|
676 { |
|
677 res = FindBox()->OfferKeyEventL( aKeyEvent, aType ); |
|
678 |
|
679 if ( backSpace && FindBox()->TextLength() == 0 && |
|
680 ( iState->CurrentFolder() == EEFolderSearch || |
|
681 iState->CurrentFolder() == EEFolderSearchMusic ) && !iPeninputActive ) |
|
682 { |
|
683 // user cleared search field - go back to main view |
|
684 HandleBackL(); |
|
685 return EKeyWasConsumed; |
|
686 } |
|
687 } |
|
688 } |
|
689 |
|
690 |
|
691 if ( res == EKeyWasNotConsumed ) |
|
692 { |
|
693 res = CAknDialog::OfferKeyEventL( aKeyEvent, aType); |
|
694 } |
|
695 return res; |
|
696 } |
|
697 |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CMediaFileDialog::FindBoxCursorMoveL( TInt aType ) |
|
701 // |
|
702 // NOTE: This function is used to move the cursor of the find box. |
|
703 // ----------------------------------------------------------------------------- |
|
704 // |
|
705 void CMediaFileDialog::FindBoxCursorMoveL( TInt aType ) |
|
706 { |
|
707 if ( FindBox() && FindBox()->IsVisible() ) |
|
708 { |
|
709 TInt pos = FindBox()->Editor().CursorPos(); |
|
710 TInt textLength = FindBox()->Editor().TextLength(); |
|
711 if ( aType == 0 )//left |
|
712 { |
|
713 pos = pos - 1; |
|
714 if ( pos < 0 ) |
|
715 { |
|
716 pos = textLength; |
|
717 } |
|
718 } |
|
719 else if ( aType == 1 ) |
|
720 { |
|
721 pos = pos + 1; |
|
722 if ( pos > textLength ) |
|
723 { |
|
724 pos = 0; |
|
725 } |
|
726 } |
|
727 else |
|
728 { |
|
729 pos = textLength; |
|
730 } |
|
731 FindBox()->Editor().SetCursorPosL( pos ,EFalse ); |
|
732 } |
|
733 } |
|
734 // ----------------------------------------------------------------------------- |
|
735 // CMediaFileDialog::SetSizeAndPosition (from CAknDialog) |
|
736 // |
|
737 // NOTE: This code is copy paste from elsewhere. |
|
738 // ----------------------------------------------------------------------------- |
|
739 // |
|
740 void CMediaFileDialog::SetSizeAndPosition( const TSize& /*aSize*/ ) |
|
741 { |
|
742 TRect mainPane; |
|
743 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
744 |
|
745 SetRect( mainPane ); |
|
746 |
|
747 if ( FindBox() && FindBox()->IsVisible() ) |
|
748 { |
|
749 AknFind::HandleFixedFindSizeChanged( this, iListBox, FindBox() ); |
|
750 } |
|
751 |
|
752 Line( ESelectionListControl)->SetRect( iListBox->Rect() ); |
|
753 if ( FindBox() ) |
|
754 { |
|
755 Line( EFindControl )->SetRect( iListBox->Rect() ); |
|
756 } |
|
757 } |
|
758 |
|
759 |
|
760 // ---------------------------------------------------------------------------- |
|
761 // CMediaFileDialog::HandleResourceChange |
|
762 // |
|
763 // ---------------------------------------------------------------------------- |
|
764 // |
|
765 void CMediaFileDialog::HandleResourceChange(TInt aType) |
|
766 { |
|
767 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
768 { |
|
769 // handle change in layout orientation |
|
770 CAknDialog::HandleResourceChange( aType ); |
|
771 if ( FindBox() && FindBox()->IsVisible() ) |
|
772 { |
|
773 AknFind::HandleFixedFindSizeChanged( this, iListBox, FindBox() ); |
|
774 } |
|
775 return; |
|
776 } |
|
777 |
|
778 if (aType == KAknsMessageSkinChange) |
|
779 { |
|
780 TRAP_IGNORE( SetIconsL() ); |
|
781 } |
|
782 |
|
783 CCoeControl::HandleResourceChange( aType ); |
|
784 } |
|
785 |
|
786 |
|
787 //------------------------------------------------------------------------------ |
|
788 // CMediaFileDialog::DynInitMenuPaneL |
|
789 // |
|
790 // Called by system before menu is shown. NOTE: Menu currently not used. |
|
791 //------------------------------------------------------------------------------ |
|
792 // |
|
793 void CMediaFileDialog::DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane ) |
|
794 { |
|
795 TInt menu1 = R_MEDIA_FILE_DIALOG_MENU_PANE; |
|
796 TInt menu2 = R_MEDIA_FILE_DIALOG_CONTEXT_MENU_PANE; |
|
797 |
|
798 if ( aResourceID != menu1 && aResourceID != menu2 ) |
|
799 { |
|
800 return; // not one of our menus |
|
801 } |
|
802 |
|
803 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
804 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
805 TInt folderId = iState->FolderId( currentIndex ); |
|
806 TInt currentFolderId = iState->CurrentFolder(); |
|
807 |
|
808 |
|
809 // context menu only used in video folder |
|
810 if ( aResourceID == R_MEDIA_FILE_DIALOG_CONTEXT_MENU_PANE ) |
|
811 { |
|
812 if ( itemCount == 0 ) |
|
813 { |
|
814 // folder is empty |
|
815 DeleteMenuItem( aMenuPane, EAknSoftkeySelect ); |
|
816 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
817 } |
|
818 return; |
|
819 } |
|
820 |
|
821 |
|
822 if ( itemCount == 0 ) |
|
823 { |
|
824 // list has no items |
|
825 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
826 DeleteMenuItem( aMenuPane, EAknSoftkeySelect ); |
|
827 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
828 return; |
|
829 } |
|
830 |
|
831 if ( folderId == EEFolderDownload || folderId == EEFolderNullItemOne || |
|
832 folderId == EEFolderNullItemTwo ) |
|
833 { |
|
834 // selected item is null item |
|
835 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
836 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
837 } |
|
838 else if ( folderId != KErrNotFound ) |
|
839 { |
|
840 // selected item is folder |
|
841 DeleteMenuItem( aMenuPane, EAknSoftkeySelect ); |
|
842 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
843 } |
|
844 else |
|
845 { |
|
846 // selected item is file |
|
847 if ( iState->CurrentFolder() == EEFolderVideos ) |
|
848 { |
|
849 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
850 } |
|
851 else if ( iState->CurrentFolder() == EEFolderSearch ) |
|
852 { |
|
853 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
854 |
|
855 if ( !IsVideoFile( currentIndex ) ) |
|
856 { |
|
857 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
858 } |
|
859 } |
|
860 else |
|
861 { |
|
862 DeleteMenuItem( aMenuPane, EAknCmdOpen ); |
|
863 DeleteMenuItem( aMenuPane, EAknSoftkeyView ); |
|
864 } |
|
865 } |
|
866 } |
|
867 |
|
868 |
|
869 // --------------------------------------------------------------------------- |
|
870 // CMediaFileDialog::CountComponentControls |
|
871 // |
|
872 // Gets the number of controls contained in a compound control. |
|
873 // --------------------------------------------------------------------------- |
|
874 // |
|
875 TInt CMediaFileDialog::CountComponentControls() const |
|
876 { |
|
877 TInt newitems = 0; |
|
878 if ( FindBox() ) |
|
879 { |
|
880 newitems++; |
|
881 } |
|
882 return CAknDialog::CountComponentControls() + newitems; |
|
883 } |
|
884 |
|
885 |
|
886 // --------------------------------------------------------------------------- |
|
887 // CMediaFileDialog::CountComponentControls |
|
888 // |
|
889 // --------------------------------------------------------------------------- |
|
890 // |
|
891 CCoeControl* CMediaFileDialog::ComponentControl( TInt aIndex ) const |
|
892 { |
|
893 if ( aIndex == CAknDialog::CountComponentControls() ) |
|
894 { |
|
895 return FindBox(); |
|
896 } |
|
897 return CAknDialog::ComponentControl( aIndex ); |
|
898 } |
|
899 |
|
900 |
|
901 // ----------------------------------------------------------------------------- |
|
902 // CMediaFileDialog::FindBox |
|
903 // |
|
904 // ----------------------------------------------------------------------------- |
|
905 // |
|
906 CAknSearchField* CMediaFileDialog::FindBox() const |
|
907 { |
|
908 CFindControl* control = ( CFindControl* )ControlOrNull( EFindControl ); |
|
909 if ( control ) |
|
910 { |
|
911 return control->iFind; |
|
912 } |
|
913 else |
|
914 { |
|
915 return NULL; |
|
916 } |
|
917 } |
|
918 |
|
919 // --------------------------------------------------------------------------- |
|
920 // CMediaFileDialog::ResetFindBoxL |
|
921 // |
|
922 // --------------------------------------------------------------------------- |
|
923 // |
|
924 void CMediaFileDialog::ResetFindBoxL() |
|
925 { |
|
926 if ( !FindBox() ) |
|
927 { |
|
928 return; |
|
929 } |
|
930 |
|
931 CAknFilteredTextListBoxModel* model = |
|
932 STATIC_CAST( CAknFilteredTextListBoxModel*, iListBox->Model() ); |
|
933 CAknListBoxFilterItems* filter = model->Filter(); |
|
934 TInt currentFolder = iState->CurrentFolder(); |
|
935 |
|
936 // reset find box |
|
937 if ( filter ) |
|
938 { |
|
939 filter->ResetFilteringL(); |
|
940 filter->SetObserver( NULL ); |
|
941 model->RemoveFilter(); |
|
942 |
|
943 // CreateFilterL sets CAknSearchField to observe filter |
|
944 // (CAknListBoxFilterItems) but RemoveFilter does not remove observer |
|
945 FindBox()->SetObserver( NULL ); |
|
946 } |
|
947 |
|
948 if (FindBox()->TextLength() > 0 && (currentFolder != EEFolderSearch |
|
949 && currentFolder != EEFolderSearchMusic)) |
|
950 { |
|
951 FindBox()->SetSearchTextL( KNullDesC ); |
|
952 } |
|
953 |
|
954 |
|
955 // show/hide find box |
|
956 if ( iState->FindBoxNeeded() ) |
|
957 { |
|
958 if ( currentFolder != EEFolderSearch && |
|
959 currentFolder != EEFolderSearchMusic && |
|
960 currentFolder != EEFolderRoot && |
|
961 currentFolder != EEFolderMusic ) |
|
962 { |
|
963 // normal find only finds matches from listbox item texts |
|
964 model->CreateFilterL( iListBox, FindBox() ); |
|
965 filter = model->Filter(); |
|
966 filter->ResetFilteringL(); |
|
967 filter->SetObserver( this ); // MCoeControlObserver |
|
968 } |
|
969 else |
|
970 { |
|
971 // search and root folders have custom find that makes |
|
972 // database search |
|
973 FindBox()->SetObserver( this ); // MCoeControlObserver |
|
974 } |
|
975 // if ( currentFolder == EEFolderSearch || |
|
976 // currentFolder == EEFolderSearchMusic ) |
|
977 // { |
|
978 // FindBox()->SetSearchTextL( iSearchText ); |
|
979 // } |
|
980 |
|
981 FindBox()->MakeVisible( ETrue ); |
|
982 } |
|
983 else |
|
984 { |
|
985 FindBox()->MakeVisible( EFalse ); |
|
986 } |
|
987 |
|
988 TSize size; |
|
989 SetSizeAndPosition( size ); |
|
990 } |
|
991 |
|
992 |
|
993 // ----------------------------------------------------------------------------- |
|
994 // CMediaFileDialog::CreateCustomControlL (from CAknDialog) |
|
995 // |
|
996 // Create find control. |
|
997 // ----------------------------------------------------------------------------- |
|
998 // |
|
999 SEikControlInfo CMediaFileDialog::CreateCustomControlL( TInt aControlType ) |
|
1000 { |
|
1001 if ( aControlType != EAknCtSelectionListPopupFind && |
|
1002 aControlType != EAknCtSelectionListFixedFind ) |
|
1003 { |
|
1004 SEikControlInfo info; |
|
1005 info.iControl = NULL; |
|
1006 info.iFlags = 0; |
|
1007 info.iTrailerTextId = 0; |
|
1008 return info; |
|
1009 } |
|
1010 |
|
1011 CCoeControl* findControl = NULL; |
|
1012 findControl = new (ELeave) CFindControl; |
|
1013 |
|
1014 SEikControlInfo info; |
|
1015 info.iControl = findControl; |
|
1016 info.iFlags = 0; |
|
1017 info.iTrailerTextId = 0; |
|
1018 return info; |
|
1019 } |
|
1020 |
|
1021 |
|
1022 // ---------------------------------------------------------------------------- |
|
1023 // CMediaFileDialog::SetIconsL |
|
1024 // |
|
1025 // ---------------------------------------------------------------------------- |
|
1026 // |
|
1027 void CMediaFileDialog::SetIconsL() |
|
1028 { |
|
1029 _LIT( KBitmapFile, "mediafilelist.mbm" ); |
|
1030 |
|
1031 |
|
1032 if ( !iListBox ) |
|
1033 { |
|
1034 return; |
|
1035 } |
|
1036 |
|
1037 TMFDialogUtil::SetIconFileNameL( KBitmapFile, iIconFileName ); |
|
1038 |
|
1039 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(1); |
|
1040 CleanupStack::PushL( icons ); |
|
1041 |
|
1042 |
|
1043 // |
|
1044 // NOTE: append order must match TMediaFileListIcons |
|
1045 // |
|
1046 |
|
1047 // music item icon |
|
1048 icons->AppendL( IconL( KAknsIIDQgnIndiAiNtMusic, iIconFileName, |
|
1049 EMbmMediafilelistQgn_indi_ai_nt_music, |
|
1050 EMbmMediafilelistQgn_indi_ai_nt_music_mask ) ); |
|
1051 |
|
1052 // tone item icon, default tone icon |
|
1053 icons->AppendL( IconL( KAknsIIDQgnPropMupAudio, iIconFileName, |
|
1054 EMbmMediafilelistQgn_prop_mup_audio, |
|
1055 EMbmMediafilelistQgn_prop_mup_audio_mask ) ); |
|
1056 |
|
1057 // video item icon |
|
1058 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileVideo, iIconFileName, |
|
1059 EMbmMediafilelistQgn_prop_fmgr_file_video, |
|
1060 EMbmMediafilelistQgn_prop_fmgr_file_video_mask ) ); |
|
1061 |
|
1062 // recording item icon |
|
1063 icons->AppendL( IconL( KAknsIIDQgnPropFmgrFileVoicerec, iIconFileName, |
|
1064 EMbmMediafilelistQgn_prop_fmgr_file_voicerec, |
|
1065 EMbmMediafilelistQgn_prop_fmgr_file_voicerec_mask ) ); |
|
1066 |
|
1067 // artist icon |
|
1068 icons->AppendL( IconL( KAknsIIDQgnPropMupArtist, iIconFileName, |
|
1069 EMbmMediafilelistQgn_prop_mup_artist, |
|
1070 EMbmMediafilelistQgn_prop_mup_artist_mask ) ); |
|
1071 |
|
1072 // album icon |
|
1073 icons->AppendL( IconL( KAknsIIDQgnPropMupAlbum, iIconFileName, |
|
1074 EMbmMediafilelistQgn_prop_mup_album, |
|
1075 EMbmMediafilelistQgn_prop_mup_album_mask ) ); |
|
1076 |
|
1077 // genre icon |
|
1078 icons->AppendL( IconL( KAknsIIDQgnPropMupGenre, iIconFileName, |
|
1079 EMbmMediafilelistQgn_prop_mup_genre, |
|
1080 EMbmMediafilelistQgn_prop_mup_genre_mask ) ); |
|
1081 |
|
1082 // composer icon |
|
1083 icons->AppendL( IconL( KAknsIIDQgnPropMupComposer, iIconFileName, |
|
1084 EMbmMediafilelistQgn_prop_mup_composer, |
|
1085 EMbmMediafilelistQgn_prop_mup_composer_mask ) ); |
|
1086 |
|
1087 // folder icon (tones, music, videos, recordings, all music, artist, |
|
1088 // album, genre, composer, artist all) |
|
1089 icons->AppendL( IconL( KAknsIIDQgnPropFolderSmall, iIconFileName, |
|
1090 EMbmMediafilelistQgn_prop_folder_small, |
|
1091 EMbmMediafilelistQgn_prop_folder_small_mask ) ); |
|
1092 |
|
1093 // unknown folder icon |
|
1094 icons->AppendL( IconL( KAknsIIDQgnPropMceUnknownRead, iIconFileName, |
|
1095 EMbmMediafilelistQgn_prop_mce_unknown_read, |
|
1096 EMbmMediafilelistQgn_prop_mce_unknown_read ) ); |
|
1097 |
|
1098 // download item icon (null item) |
|
1099 icons->AppendL( IconL( KAknsIIDQgnPropLinkEmbdSmall, iIconFileName, |
|
1100 EMbmMediafilelistQgn_prop_link_embd_small, |
|
1101 EMbmMediafilelistQgn_prop_link_embd_small_mask ) ); |
|
1102 |
|
1103 // off item icon (null item) |
|
1104 icons->AppendL( IconL( KAknsIIDQgnPropSmlSyncOff, iIconFileName, |
|
1105 EMbmMediafilelistQgn_prop_sml_sync_off, |
|
1106 EMbmMediafilelistQgn_prop_sml_sync_off_mask ) ); |
|
1107 |
|
1108 // memory card icon |
|
1109 icons->AppendL( IconL( KAknsIIDQgnIndiMmcAdd, iIconFileName, |
|
1110 EMbmMediafilelistQgn_indi_mmc_add, |
|
1111 EMbmMediafilelistQgn_indi_mmc_add_mask, EAknsCIQsnIconColorsCG13 ) ); |
|
1112 |
|
1113 // mass storage icon |
|
1114 icons->AppendL( IconL( KAknsIIDQgnPropLinkEmbdSmall, iIconFileName, |
|
1115 EMbmMediafilelistQgn_indi_fmgr_ms_add, |
|
1116 EMbmMediafilelistQgn_indi_fmgr_ms_add_mask,EAknsCIQsnIconColorsCG13 ) ); |
|
1117 |
|
1118 // empty icon |
|
1119 icons->AppendL( IconL( KAknsIIDQgnPropEmpty, KAvkonBitmapFile, |
|
1120 EMbmAvkonQgn_prop_empty, |
|
1121 EMbmAvkonQgn_prop_empty_mask ) ); |
|
1122 |
|
1123 // delete old icons |
|
1124 CArrayPtr<CGulIcon>* arr = iListBox->ItemDrawer()->ColumnData()->IconArray(); |
|
1125 if ( arr ) |
|
1126 { |
|
1127 arr->ResetAndDestroy(); |
|
1128 delete arr; |
|
1129 arr = NULL; |
|
1130 } |
|
1131 |
|
1132 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
1133 CleanupStack::Pop( icons ); |
|
1134 } |
|
1135 |
|
1136 |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // CMediaFileDialog::IconL |
|
1139 // |
|
1140 // ----------------------------------------------------------------------------- |
|
1141 // |
|
1142 CGulIcon* CMediaFileDialog::IconL(TAknsItemID aId, const TDesC& aFileName, |
|
1143 TInt aFileIndex, TInt aFileMaskIndex) |
|
1144 { |
|
1145 CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(), aId, |
|
1146 aFileName, aFileIndex, aFileMaskIndex); |
|
1147 return icon; |
|
1148 } |
|
1149 |
|
1150 |
|
1151 // ----------------------------------------------------------------------------- |
|
1152 // CMediaFileDialog::IconL |
|
1153 // For MMC icon and Mass Storage icon |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // |
|
1156 CGulIcon* CMediaFileDialog::IconL(TAknsItemID aId, const TDesC& aFileName, |
|
1157 TInt aFileIndex, TInt aFileMaskIndex, TAknsQsnIconColorsIndex colorIndex) |
|
1158 { |
|
1159 TRgb defaultColour(KRgbBlack); |
|
1160 CFbsBitmap* bmap = NULL; |
|
1161 CFbsBitmap* mask = NULL; |
|
1162 |
|
1163 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), defaultColour, KAknsIIDQsnIconColors, |
|
1164 colorIndex); |
|
1165 AknsUtils::CreateColorIconLC(AknsUtils::SkinInstance(), KAknsIIDQgnIndiMmcAdd, |
|
1166 KAknsIIDQsnIconColors, colorIndex, bmap, mask, |
|
1167 aFileName, aFileIndex, aFileMaskIndex, defaultColour); |
|
1168 |
|
1169 CGulIcon* icon = CGulIcon::NewL(bmap, mask); |
|
1170 icon->SetBitmapsOwnedExternally(EFalse); |
|
1171 CleanupStack::Pop(2); |
|
1172 return icon; |
|
1173 } |
|
1174 |
|
1175 |
|
1176 // ---------------------------------------------------------------------------- |
|
1177 // CMediaFileDialog::ShowContextMenuL |
|
1178 // |
|
1179 // ---------------------------------------------------------------------------- |
|
1180 // |
|
1181 void CMediaFileDialog::ShowContextMenuL( TInt /*aResource*/ ) |
|
1182 { |
|
1183 // Switch to Context specific options menu, |
|
1184 if ( iMenuBar ) |
|
1185 { |
|
1186 TRAP_IGNORE( iMenuBar->TryDisplayContextMenuBarL() ); |
|
1187 } |
|
1188 } |
|
1189 |
|
1190 |
|
1191 //------------------------------------------------------------------------------ |
|
1192 // CMediaFileDialog::HandleBackL |
|
1193 // |
|
1194 //------------------------------------------------------------------------------ |
|
1195 // |
|
1196 TBool CMediaFileDialog::HandleBackL() |
|
1197 { |
|
1198 TInt err = KErrNone; |
|
1199 TBool ret = ETrue; |
|
1200 |
|
1201 TRAP( err, ret = DoHandleBackL() ); |
|
1202 |
|
1203 if ( err != KErrNone ) |
|
1204 { |
|
1205 FLOG( _L("### CMediaFileDialog::HandleBackL (%d) ###"), err ); |
|
1206 |
|
1207 ResetDialogL( err ); |
|
1208 return ETrue; |
|
1209 } |
|
1210 |
|
1211 return ret; |
|
1212 } |
|
1213 |
|
1214 |
|
1215 //------------------------------------------------------------------------------ |
|
1216 // CMediaFileDialog::DoHandleBackL |
|
1217 // |
|
1218 //------------------------------------------------------------------------------ |
|
1219 // |
|
1220 TBool CMediaFileDialog::DoHandleBackL() |
|
1221 { |
|
1222 if ( iState->CurrentFolder() == EEFolderRoot ) |
|
1223 { |
|
1224 // return EFalse only when called from root folder |
|
1225 return EFalse; |
|
1226 } |
|
1227 |
|
1228 if ( !iMediaFileHandler->QueryReady() ) |
|
1229 { |
|
1230 FLOG( _L("### CMediaFileDialog::DoHandleBackL: query in progress ###") ); |
|
1231 return ETrue; // query in progress |
|
1232 } |
|
1233 |
|
1234 TInt folderId = iState->NextFolderUp(); |
|
1235 TInt currentIndex = CurrentItemListIndex(); |
|
1236 |
|
1237 iState->SetQueryInfo( folderId, KNullDesC, currentIndex, EEQueryUp ); |
|
1238 QueryL( folderId ); |
|
1239 |
|
1240 return ETrue; |
|
1241 } |
|
1242 |
|
1243 |
|
1244 //------------------------------------------------------------------------------ |
|
1245 // CMediaFileDialog::HandleOKL |
|
1246 // |
|
1247 //------------------------------------------------------------------------------ |
|
1248 // |
|
1249 TBool CMediaFileDialog::HandleOKL( TInt aAttr ) |
|
1250 { |
|
1251 TInt err = KErrNone; |
|
1252 TBool ret = EFalse; |
|
1253 |
|
1254 TRAP( err, ret = DoHandleOKL( aAttr ) ); |
|
1255 |
|
1256 if ( err != KErrNone ) |
|
1257 { |
|
1258 FLOG( _L("### CMediaFileDialog::HandleOKL (%d) ###"), err ); |
|
1259 |
|
1260 ResetDialogL( err ); |
|
1261 return EFalse; |
|
1262 } |
|
1263 |
|
1264 return ret; |
|
1265 } |
|
1266 |
|
1267 |
|
1268 //------------------------------------------------------------------------------ |
|
1269 // CMediaFileDialog::DoHandleOKL |
|
1270 // |
|
1271 // Selects file or opens folder. If file is selected (ie dialog can |
|
1272 // be closed) return value is ETrue. |
|
1273 //------------------------------------------------------------------------------ |
|
1274 // |
|
1275 TBool CMediaFileDialog::DoHandleOKL( TInt aAttr ) |
|
1276 { |
|
1277 if ( !iMediaFileHandler->QueryReady() ) |
|
1278 { |
|
1279 FLOG( _L("### CMediaFileDialog::DoHandleOKL: query in progress ###") ); |
|
1280 return EFalse; // query in progress |
|
1281 } |
|
1282 |
|
1283 TInt currentIndex = CurrentItemListIndex(); |
|
1284 if ( currentIndex == KErrNotFound ) |
|
1285 { |
|
1286 return EFalse; // empty folder |
|
1287 } |
|
1288 |
|
1289 TBool isPersistent = EFalse; |
|
1290 TInt iconId = EEIconEmpty; |
|
1291 TInt folderId = KErrNotFound; |
|
1292 iState->GetFolderInfo( currentIndex, folderId, iBuf, |
|
1293 isPersistent, iconId ); |
|
1294 |
|
1295 if ( folderId == EEFolderDownload || folderId == EEFolderNullItemOne || |
|
1296 folderId == EEFolderNullItemTwo || folderId == KErrNotFound ) |
|
1297 { |
|
1298 if ( aAttr == EAttrOpen ) |
|
1299 { |
|
1300 return EFalse; // these can only be selected, not opened |
|
1301 } |
|
1302 } |
|
1303 |
|
1304 |
|
1305 if ( folderId == EEFolderDownload ) |
|
1306 { |
|
1307 *iNullItem = 0; |
|
1308 // user selected 'Download' item - launch browser |
|
1309 CWebBrowserLauncher* launcher = CWebBrowserLauncher::NewLC(); |
|
1310 launcher->LaunchBrowserL(); |
|
1311 CleanupStack::PopAndDestroy( launcher ); |
|
1312 return EFalse; |
|
1313 } |
|
1314 |
|
1315 if ( folderId == EEFolderNullItemOne ) |
|
1316 { |
|
1317 if ( iNullItemFileNameOne ) |
|
1318 { |
|
1319 TMFDialogUtil::StrCopy( *iFileName, *iNullItemFileNameOne ); |
|
1320 } |
|
1321 *iNullItem = 1; |
|
1322 return ETrue; |
|
1323 } |
|
1324 |
|
1325 if ( folderId == EEFolderNullItemTwo ) |
|
1326 { |
|
1327 if ( iNullItemFileNameTwo ) |
|
1328 { |
|
1329 TMFDialogUtil::StrCopy( *iFileName, *iNullItemFileNameTwo ); |
|
1330 } |
|
1331 *iNullItem = 2; |
|
1332 return ETrue; |
|
1333 } |
|
1334 |
|
1335 if ( folderId == KErrNotFound ) |
|
1336 { |
|
1337 // user has selected some media file |
|
1338 GetSelectedItemFileName( currentIndex, iBuf ); |
|
1339 |
|
1340 // protection check not done when item is double checked |
|
1341 // if ( aAttr != EAttrDoubleClicked ) |
|
1342 if (!ifilevalid) |
|
1343 { |
|
1344 iFileisvalid = iProtectionHandler->IsFileValid( iBuf, |
|
1345 CMFProtectionHandler::ESelect ); |
|
1346 ifilevalid=ETrue; |
|
1347 } |
|
1348 |
|
1349 if ( !iFileisvalid) |
|
1350 { |
|
1351 ifilevalid=EFalse; |
|
1352 } |
|
1353 if ( iFileisvalid ) |
|
1354 { |
|
1355 TMFDialogUtil::StrCopy( *iFileName, iBuf ); |
|
1356 } |
|
1357 |
|
1358 return iFileisvalid; // ret is ETrue is selected file's drm is OK |
|
1359 } |
|
1360 |
|
1361 |
|
1362 if ( folderId != KErrNotFound && aAttr != EAttrSelect ) |
|
1363 { |
|
1364 // Request vibra feedback when open the folder. |
|
1365 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1366 if ( feedback ) |
|
1367 { |
|
1368 TTouchLogicalFeedback logicalType = ETouchFeedbackList; |
|
1369 TTouchFeedbackType type = ETouchFeedbackVibra; |
|
1370 feedback->InstantFeedback( this, logicalType, type, TPointerEvent() ); |
|
1371 } |
|
1372 |
|
1373 iBuf = KNullDesC; |
|
1374 // selected list item is folder |
|
1375 if ( !isPersistent ) |
|
1376 { |
|
1377 // read non-persistent folder text from database |
|
1378 GetListItemText( currentIndex, iBuf ); |
|
1379 } |
|
1380 |
|
1381 iState->SetQueryInfo( folderId, iBuf, currentIndex, EEQueryDown ); |
|
1382 QueryL( folderId ); |
|
1383 } |
|
1384 |
|
1385 return EFalse; |
|
1386 } |
|
1387 |
|
1388 |
|
1389 //------------------------------------------------------------------------------ |
|
1390 // CMediaFileDialog::SearchL |
|
1391 // |
|
1392 //------------------------------------------------------------------------------ |
|
1393 // |
|
1394 void CMediaFileDialog::SearchL() |
|
1395 { |
|
1396 TInt err = KErrNone; |
|
1397 |
|
1398 TRAP( err, DoSearchL() ); |
|
1399 |
|
1400 if ( err != KErrNone ) |
|
1401 { |
|
1402 ResetDialogL( err ); |
|
1403 } |
|
1404 } |
|
1405 |
|
1406 |
|
1407 //------------------------------------------------------------------------------ |
|
1408 // CMediaFileDialog::DoSearchL |
|
1409 // |
|
1410 //------------------------------------------------------------------------------ |
|
1411 // |
|
1412 void CMediaFileDialog::DoSearchL() |
|
1413 { |
|
1414 if ( !FindBox() ) |
|
1415 { |
|
1416 return; |
|
1417 } |
|
1418 |
|
1419 if ( iPeninputActive) |
|
1420 { |
|
1421 return; |
|
1422 } |
|
1423 if ( !iMediaFileHandler->QueryReady() ) |
|
1424 { |
|
1425 FLOG( _L("### CMediaFileDialog::DoSearchL: query in progress ###") ); |
|
1426 return; // query in progress |
|
1427 } |
|
1428 |
|
1429 TInt currentFolder = iState->CurrentFolder(); |
|
1430 |
|
1431 if ( FindBox()->TextLength() == 0 ) |
|
1432 { |
|
1433 return; |
|
1434 } |
|
1435 FindBox()->GetSearchText( iSearchText ); |
|
1436 |
|
1437 _LIT(KSpecialChar, "%"); |
|
1438 _LIT(KReplaceChar, "\\%" ); |
|
1439 TBuf<10> buf; |
|
1440 buf.Copy( KSpecialChar ); |
|
1441 TInt position = iSearchText.FindF( buf ); |
|
1442 if ( position != KErrNotFound ) |
|
1443 { |
|
1444 buf.Copy( KReplaceChar ); |
|
1445 iSearchText.Replace( position,1,buf ); |
|
1446 } |
|
1447 |
|
1448 |
|
1449 if ( currentFolder == EEFolderRoot || currentFolder == EEFolderSearch ) |
|
1450 { |
|
1451 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
1452 iState->SetQueryInfo( EEFolderSearch, KNullDesC, currentIndex, EEQueryDown ); |
|
1453 |
|
1454 QueryL( EEFolderSearch ); |
|
1455 } |
|
1456 else if ( currentFolder == EEFolderMusic || currentFolder == EEFolderSearchMusic ) |
|
1457 { |
|
1458 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
1459 iState->SetQueryInfo( EEFolderSearchMusic, KNullDesC, currentIndex, EEQueryDown ); |
|
1460 |
|
1461 QueryL( EEFolderSearchMusic ); |
|
1462 } |
|
1463 } |
|
1464 |
|
1465 |
|
1466 //------------------------------------------------------------------------------ |
|
1467 // CMediaFileDialog::ResetDialogL |
|
1468 // |
|
1469 //------------------------------------------------------------------------------ |
|
1470 // |
|
1471 void CMediaFileDialog::ResetDialogL( TInt aError) |
|
1472 { |
|
1473 iMediaFileHandler->EnableObserverCall( EFalse ); |
|
1474 iMediaFileHandler->CancelQuery(); |
|
1475 iMediaFileHandler->EnableObserverCall( ETrue ); |
|
1476 |
|
1477 iState->Init(); |
|
1478 UpdateListBoxL(); |
|
1479 |
|
1480 if ( aError != KErrNone ) |
|
1481 { |
|
1482 ShowErrorNoteL( aError ); |
|
1483 } |
|
1484 } |
|
1485 |
|
1486 |
|
1487 //------------------------------------------------------------------------------ |
|
1488 // CMediaFileDialog::QueryL |
|
1489 // |
|
1490 //------------------------------------------------------------------------------ |
|
1491 // |
|
1492 void CMediaFileDialog::QueryL( TInt aFolderId, TBool aDatabaseChanged ) |
|
1493 { |
|
1494 if ( !iMediaFileHandler->QueryReady() || !iDatabaseOpen ) |
|
1495 { |
|
1496 FLOG( _L("### CMediaFileDialog::QueryL: query in progress ###") ); |
|
1497 return; |
|
1498 } |
|
1499 |
|
1500 iMediaFileHandler->EnableObserverCall( ETrue ); |
|
1501 |
|
1502 TInt folderId = aFolderId; |
|
1503 |
|
1504 iMediaFileHandler->SetQueryId( folderId ); |
|
1505 |
|
1506 if ( folderId == EEFolderAllMusic ) |
|
1507 { |
|
1508 iMediaFileHandler->QueryMusicL( 0 ); |
|
1509 } |
|
1510 |
|
1511 else if ( folderId == EEFolderVideos ) |
|
1512 { |
|
1513 iMediaFileHandler->QueryVideosL( 0 ); |
|
1514 } |
|
1515 |
|
1516 else if ( folderId == EEFolderArtistRoot || |
|
1517 folderId == EEFolderAlbumRoot || |
|
1518 folderId == EEFolderGenreRoot || |
|
1519 folderId == EEFolderComposerRoot ) |
|
1520 { |
|
1521 if ( iState->UnknownCount( folderId ) == KErrNotFound ) |
|
1522 { |
|
1523 TInt attr = MapAttribute( folderId ); |
|
1524 iMediaFileHandler->QueryMusicUnknownCountL( attr ); |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 TInt attr = MapAttribute( folderId ); |
|
1529 iMediaFileHandler->QueryAttributeValuesL( attr ); |
|
1530 } |
|
1531 } |
|
1532 |
|
1533 else if ( folderId == EEFolderAlbum || folderId == EEFolderGenre || |
|
1534 folderId == EEFolderComposer ) |
|
1535 { |
|
1536 TInt attr = MapAttribute( folderId ); |
|
1537 iState->GetText( folderId, iBuf ); |
|
1538 iMediaFileHandler->QueryMusicL( attr, iBuf ); |
|
1539 } |
|
1540 |
|
1541 else if ( folderId == EEFolderArtistUnknown || folderId == EEFolderAlbumUnknown || |
|
1542 folderId == EEFolderGenreUnknown ||folderId == EEFolderComposerUnknown ) |
|
1543 { |
|
1544 TInt attr = MapAttribute( folderId ); |
|
1545 iMediaFileHandler->QueryMusicUnknownL( attr ); |
|
1546 } |
|
1547 |
|
1548 else if ( folderId == EEFolderArtist ) |
|
1549 { |
|
1550 iState->GetText( EEFolderArtist, iBuf ); |
|
1551 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtist, |
|
1552 iBuf, KNullDesC, aDatabaseChanged ); |
|
1553 } |
|
1554 |
|
1555 else if ( folderId == EEFolderArtistAll ) |
|
1556 { |
|
1557 iState->GetText( EEFolderArtist, iBuf ); |
|
1558 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtistAll, |
|
1559 iBuf, KNullDesC, aDatabaseChanged ); |
|
1560 } |
|
1561 |
|
1562 else if ( folderId == EEFolderArtistAlbum ) |
|
1563 { |
|
1564 TBuf<KBufSize128> buf; |
|
1565 iState->GetText( EEFolderArtistAlbum, buf ); |
|
1566 iState->GetText( EEFolderArtist, iBuf ); |
|
1567 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtistAlbum, |
|
1568 iBuf, buf, aDatabaseChanged ); |
|
1569 } |
|
1570 |
|
1571 else if ( folderId == EEFolderArtistAlbumUnknown ) |
|
1572 { |
|
1573 iState->GetText( EEFolderArtist, iBuf ); |
|
1574 iMediaFileHandler->QueryArtistL( CMediaFileHandler::EQueryArtistUnknown, |
|
1575 iBuf, KNullDesC, aDatabaseChanged ); |
|
1576 } |
|
1577 |
|
1578 else if ( folderId == EEFolderTones ) |
|
1579 { |
|
1580 //iMediaFileHandler->QueryTonesL( 0 ); |
|
1581 iMediaFileHandler->QueryDefaultTonesL( 0 ); |
|
1582 ShowWaitNoteL( EFalse ); |
|
1583 } |
|
1584 |
|
1585 else if ( folderId == EEFolderRecordings ) |
|
1586 { |
|
1587 iMediaFileHandler->QueryRecordingsL( 0 ); |
|
1588 } |
|
1589 |
|
1590 else if ( folderId == EEFolderSearch ) |
|
1591 { |
|
1592 if ( iSearchText.Length() > 0 ) |
|
1593 { |
|
1594 iMediaFileHandler->SearchL( iSearchText ); |
|
1595 } |
|
1596 else |
|
1597 { |
|
1598 iMediaFileHandler->QueryEmptyL(); |
|
1599 } |
|
1600 } |
|
1601 else if ( folderId == EEFolderSearchMusic ) |
|
1602 { |
|
1603 if ( iSearchText.Length() > 0 ) |
|
1604 { |
|
1605 iMediaFileHandler->SearchAudioL( iSearchText ); |
|
1606 } |
|
1607 else |
|
1608 { |
|
1609 iMediaFileHandler->QueryEmptyL(); |
|
1610 } |
|
1611 } |
|
1612 else |
|
1613 { |
|
1614 // make empty query |
|
1615 iMediaFileHandler->QueryEmptyL(); |
|
1616 } |
|
1617 |
|
1618 if ( !iMediaFileHandler->QueryReady() |
|
1619 && aFolderId != EEFolderRoot && aFolderId != EEFolderMusic ) |
|
1620 { |
|
1621 // query is running - show wait note with delay. wait note is |
|
1622 // removed in HandleMFEventL |
|
1623 ShowWaitNoteL( aDatabaseChanged ); |
|
1624 } |
|
1625 |
|
1626 #ifdef _DEBUG |
|
1627 iTest->SetTime(); |
|
1628 #endif |
|
1629 } |
|
1630 |
|
1631 |
|
1632 // ----------------------------------------------------------------------------- |
|
1633 // CMediaFileDialog::MapAttribute |
|
1634 // |
|
1635 // ----------------------------------------------------------------------------- |
|
1636 // |
|
1637 TInt CMediaFileDialog::MapAttribute( TInt aFolderId ) |
|
1638 { |
|
1639 TInt attr = KErrNotFound; |
|
1640 |
|
1641 switch ( aFolderId ) |
|
1642 { |
|
1643 case EEFolderArtistRoot: |
|
1644 case EEFolderArtist: |
|
1645 case EEFolderArtistUnknown: |
|
1646 { |
|
1647 attr = CMediaFileHandler::EAttrArtist; |
|
1648 break; |
|
1649 } |
|
1650 case EEFolderAlbumRoot: |
|
1651 case EEFolderAlbum: |
|
1652 case EEFolderAlbumUnknown: |
|
1653 { |
|
1654 attr = CMediaFileHandler::EAttrAlbum; |
|
1655 break; |
|
1656 } |
|
1657 case EEFolderGenreRoot: |
|
1658 case EEFolderGenre: |
|
1659 case EEFolderGenreUnknown: |
|
1660 { |
|
1661 attr = CMediaFileHandler::EAttrGenre; |
|
1662 break; |
|
1663 } |
|
1664 case EEFolderComposerRoot: |
|
1665 case EEFolderComposer: |
|
1666 case EEFolderComposerUnknown: |
|
1667 { |
|
1668 attr = CMediaFileHandler::EAttrComposer; |
|
1669 break; |
|
1670 } |
|
1671 default: |
|
1672 { |
|
1673 break; |
|
1674 } |
|
1675 } |
|
1676 |
|
1677 return attr; |
|
1678 } |
|
1679 |
|
1680 |
|
1681 // ----------------------------------------------------------------------------- |
|
1682 // CMediaFileDialog::ShowDetailsPopupL |
|
1683 // |
|
1684 // ----------------------------------------------------------------------------- |
|
1685 // |
|
1686 void CMediaFileDialog::ShowDetailsPopupL() |
|
1687 { |
|
1688 if ( !iMediaFileHandler->QueryReady() ) |
|
1689 { |
|
1690 return; // query in progress |
|
1691 } |
|
1692 |
|
1693 TInt currentIndex = CurrentItemListIndex(); |
|
1694 TInt folderId = iState->CurrentFolder(); |
|
1695 |
|
1696 if ( folderId != EEFolderSearch && folderId != EEFolderSearchMusic ) |
|
1697 { |
|
1698 return; |
|
1699 } |
|
1700 if ( currentIndex < 0 ) |
|
1701 { |
|
1702 return; |
|
1703 } |
|
1704 |
|
1705 TInt id = iMediaFileHandler->Attribute( currentIndex, |
|
1706 CMediaFileHandler::EAttrMediaFileId, |
|
1707 iState->CurrentFolder() ); |
|
1708 if ( id == KErrNotFound ) |
|
1709 { |
|
1710 return; |
|
1711 } |
|
1712 |
|
1713 TInt mediaType = iMediaFileHandler->Attribute( currentIndex, |
|
1714 CMediaFileHandler::EAttrMediaType, |
|
1715 iState->CurrentFolder() ); |
|
1716 |
|
1717 TInt storageType = iMediaFileHandler->Attribute( currentIndex, |
|
1718 CMediaFileHandler::EAttrStorageType, |
|
1719 iState->CurrentFolder() ); |
|
1720 |
|
1721 CMediaFileData* data = NULL; |
|
1722 |
|
1723 if ( storageType == CMediaFileHandler::ERomStorage ) |
|
1724 { |
|
1725 if ( mediaType == CMediaFileHandler::EMediaTypeTone ) |
|
1726 { |
|
1727 data = iMediaFileHandler->RomMediaFileDataL( id , CMediaFileHandler::EMediaTypeTone ); |
|
1728 } |
|
1729 if ( mediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
1730 { |
|
1731 data = iMediaFileHandler->RomMediaFileDataL( id , CMediaFileHandler::EMediaTypeVideo ); |
|
1732 } |
|
1733 } |
|
1734 else |
|
1735 { |
|
1736 data = iMediaFileHandler->ReadMediaFileDataL( id ); |
|
1737 } |
|
1738 |
|
1739 CleanupStack::PushL( data ); |
|
1740 if ( data ) |
|
1741 { |
|
1742 GetPopupText( data, iPopupText ); |
|
1743 } |
|
1744 |
|
1745 CleanupStack::PopAndDestroy( data ); |
|
1746 |
|
1747 if ( iPopupText.Length() > 0 ) |
|
1748 { |
|
1749 ShowPopupNoteL( iPopupText ); |
|
1750 } |
|
1751 } |
|
1752 |
|
1753 |
|
1754 // ----------------------------------------------------------------------------- |
|
1755 // CMediaFileDialog::GetPopupText |
|
1756 // |
|
1757 // ----------------------------------------------------------------------------- |
|
1758 // |
|
1759 void CMediaFileDialog::GetPopupText( CMediaFileData* aData, TDes& aText ) |
|
1760 { |
|
1761 TBuf<KBufSize64> searchText; |
|
1762 TBuf<KBufSize64> attributeName; |
|
1763 |
|
1764 aText = KNullDesC; |
|
1765 |
|
1766 if ( FindBox()->TextLength() >= KBufSize64 ) |
|
1767 { |
|
1768 return; |
|
1769 } |
|
1770 FindBox()->GetSearchText( searchText ); |
|
1771 |
|
1772 aData->GetAttr( CMediaFileHandler::EAttrSongName, aText ); |
|
1773 if ( MatchFound( aText, searchText ) ) |
|
1774 { |
|
1775 aText = KNullDesC; |
|
1776 return; |
|
1777 } |
|
1778 |
|
1779 aData->GetAttr( CMediaFileHandler::EAttrArtist, aText ); |
|
1780 if ( MatchFound( aText, searchText ) ) |
|
1781 { |
|
1782 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_ARTIST ); |
|
1783 aText.Insert( 0, attributeName ); |
|
1784 return; |
|
1785 } |
|
1786 |
|
1787 aData->GetAttr( CMediaFileHandler::EAttrAlbum, aText ); |
|
1788 if ( MatchFound( aText, searchText ) ) |
|
1789 { |
|
1790 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_ALBUM ); |
|
1791 aText.Insert( 0, attributeName ); |
|
1792 return; |
|
1793 } |
|
1794 |
|
1795 aData->GetAttr( CMediaFileHandler::EAttrGenre, aText ); |
|
1796 if ( MatchFound( aText, searchText ) ) |
|
1797 { |
|
1798 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_GENRE ); |
|
1799 aText.Insert( 0, attributeName ); |
|
1800 return; |
|
1801 } |
|
1802 |
|
1803 aData->GetAttr( CMediaFileHandler::EAttrComposer, aText ); |
|
1804 if ( MatchFound( aText, searchText ) ) |
|
1805 { |
|
1806 StringLoader::Load( attributeName, R_QTN_PREVIEW_POPUP_COMPOSER ); |
|
1807 aText.Insert( 0, attributeName ); |
|
1808 return; |
|
1809 } |
|
1810 |
|
1811 aText = KNullDesC; |
|
1812 } |
|
1813 |
|
1814 |
|
1815 // ----------------------------------------------------------------------------- |
|
1816 // CMediaFileDialog::MatchFound |
|
1817 // |
|
1818 // ----------------------------------------------------------------------------- |
|
1819 // |
|
1820 TBool CMediaFileDialog::MatchFound( const TDesC& aAttribute, |
|
1821 const TDesC& aText ) |
|
1822 { |
|
1823 _LIT( KSpace, " " ); |
|
1824 |
|
1825 if ( aText.Length() >= KBufSize64 ) |
|
1826 { |
|
1827 return EFalse; // too long search text |
|
1828 } |
|
1829 |
|
1830 if ( aAttribute.FindC( aText ) == 0 ) |
|
1831 { |
|
1832 // match found from the beginning of the first word |
|
1833 return ETrue; |
|
1834 } |
|
1835 |
|
1836 TBuf<KBufSize64> buf; |
|
1837 buf = aText; |
|
1838 buf.Insert( 0, KSpace ); |
|
1839 |
|
1840 if ( aAttribute.FindC( buf ) != KErrNotFound ) |
|
1841 { |
|
1842 // match found from the beginning of the word |
|
1843 return ETrue; |
|
1844 } |
|
1845 |
|
1846 return EFalse; |
|
1847 } |
|
1848 |
|
1849 |
|
1850 // ----------------------------------------------------------------------------- |
|
1851 // CMediaFileDialog::PreviewL |
|
1852 // |
|
1853 // ----------------------------------------------------------------------------- |
|
1854 // |
|
1855 void CMediaFileDialog::PreviewL( TInt aMediaType ) |
|
1856 { |
|
1857 //FLOG( _L("CMediaFileDialog::PreviewL START") ); |
|
1858 |
|
1859 if ( !iMediaFileHandler->QueryReady() ) |
|
1860 { |
|
1861 FLOG( _L("### CMediaFileDialog::PreviewL: query in progress ###") ); |
|
1862 return; // query in progress |
|
1863 } |
|
1864 |
|
1865 if ( !iForeGround ) |
|
1866 { |
|
1867 return; // dialog is not visible |
|
1868 } |
|
1869 |
|
1870 TInt currentIndex = CurrentItemListIndex(); |
|
1871 if ( currentIndex == KErrNotFound ) |
|
1872 { |
|
1873 return; // list is empty |
|
1874 } |
|
1875 |
|
1876 TInt folderId = iState->FolderId( currentIndex ); |
|
1877 if ( folderId == EEFolderNullItemOne || folderId == EEFolderNullItemTwo ) |
|
1878 { |
|
1879 PreviewNullItemL( folderId ); |
|
1880 return; |
|
1881 } |
|
1882 |
|
1883 if ( folderId != KErrNotFound ) |
|
1884 { |
|
1885 return; // focused list item is folder |
|
1886 } |
|
1887 |
|
1888 |
|
1889 if ( iState->CurrentFolder() == EEFolderVideos && |
|
1890 aMediaType != CMediaFileList::EMediaFileTypeVideo ) |
|
1891 { |
|
1892 return; |
|
1893 } |
|
1894 |
|
1895 GetSelectedItemFileName( currentIndex, iBuf ); |
|
1896 if ( iBuf.Length() == 0 ) |
|
1897 { |
|
1898 return; |
|
1899 } |
|
1900 |
|
1901 |
|
1902 if ( iState->CurrentFolder() == EEFolderSearch ) |
|
1903 { |
|
1904 if ( IsVideoFile( currentIndex ) ) |
|
1905 { |
|
1906 return; // search folder may contain videos - no automatic preview |
|
1907 } |
|
1908 } |
|
1909 |
|
1910 if ( !iProtectionHandler->IsFileValid( iBuf, CMFProtectionHandler::EPlay ) ) |
|
1911 { |
|
1912 return; |
|
1913 } |
|
1914 |
|
1915 if ( aMediaType == CMediaFileList::EMediaFileTypeVideo ) |
|
1916 { |
|
1917 PreviewVideoL( iBuf ); |
|
1918 return; |
|
1919 } |
|
1920 |
|
1921 iAudioPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, iBuf ); |
|
1922 iAudioPreviewHandler->PlayL(); |
|
1923 |
|
1924 //FLOG( _L("CMediaFileDialog::PreviewL END") ); |
|
1925 } |
|
1926 |
|
1927 |
|
1928 // ----------------------------------------------------------------------------- |
|
1929 // CMediaFileDialog::PreviewVideoL |
|
1930 // |
|
1931 // ----------------------------------------------------------------------------- |
|
1932 // |
|
1933 void CMediaFileDialog::PreviewVideoL( const TDesC& aFileName ) |
|
1934 { |
|
1935 if ( !iProtectionHandler->IsVideoValid( aFileName, CMFProtectionHandler::EPlay ) ) |
|
1936 { |
|
1937 return; |
|
1938 } |
|
1939 |
|
1940 // in case "Beep once" one audio beep is played before showing video |
|
1941 TInt type = iAudioPreviewHandler->Attr( CMediaFileList::EAttrRingingType ); |
|
1942 if ( type == CMFPreviewHandlerBase::ERingingTypeBeepOnce ) |
|
1943 { |
|
1944 iAudioPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, aFileName ); |
|
1945 iAudioPreviewHandler->PlayL(); |
|
1946 } |
|
1947 |
|
1948 iVideoPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, aFileName ); |
|
1949 TInt err = KErrNone; |
|
1950 if ( iVideoPreviewDlg && iVideoPreviewHandler->IsPlaying() ) |
|
1951 { |
|
1952 iVideoPreviewDlg->CloseDialogL(); |
|
1953 iVideoPreviewDlg = NULL; |
|
1954 } |
|
1955 iVideoPreviewDlg = CVideoPreviewDialog::NewL( iVideoPreviewHandler ); |
|
1956 TBool ret = iVideoPreviewDlg->ShowDialogLD( &err ); |
|
1957 |
|
1958 if ( err != KErrNone ) |
|
1959 { |
|
1960 FLOG( _L("### CVideoPreviewDialog::ShowDialogLD (%d) ###"), err ); |
|
1961 } |
|
1962 |
|
1963 ShowPreviewErrorNoteL( err, CMediaFileHandler::EMediaTypeVideo ); |
|
1964 |
|
1965 if ( ret ) |
|
1966 { |
|
1967 CloseDialogWithDelayL(); |
|
1968 } |
|
1969 } |
|
1970 |
|
1971 |
|
1972 // ----------------------------------------------------------------------------- |
|
1973 // CMediaFileDialog::PreviewLNullItemL |
|
1974 // |
|
1975 // ----------------------------------------------------------------------------- |
|
1976 // |
|
1977 void CMediaFileDialog::PreviewNullItemL( TInt aFolderId ) |
|
1978 { |
|
1979 HBufC* fileName = NULL; |
|
1980 TInt fileType = KErrNotFound; |
|
1981 |
|
1982 if ( aFolderId == EEFolderNullItemOne ) |
|
1983 { |
|
1984 fileType = iNullItemFileTypeOne; |
|
1985 fileName = iNullItemFileNameOne; |
|
1986 } |
|
1987 if ( aFolderId == EEFolderNullItemTwo ) |
|
1988 { |
|
1989 fileType = iNullItemFileTypeTwo; |
|
1990 fileName = iNullItemFileNameTwo; |
|
1991 } |
|
1992 |
|
1993 if ( fileType != CMediaFileList::EMediaFileTypeAudio && |
|
1994 fileType != CMediaFileList::EMediaFileTypeVideo ) |
|
1995 { |
|
1996 return; |
|
1997 } |
|
1998 if ( !fileName ) |
|
1999 { |
|
2000 return; |
|
2001 } |
|
2002 |
|
2003 if ( fileType == CMediaFileList::EMediaFileTypeAudio ) |
|
2004 { |
|
2005 iAudioPreviewHandler->SetAttrL( TMFDialogUtil::EAttrFileName, *fileName ); |
|
2006 iAudioPreviewHandler->PlayL(); |
|
2007 } |
|
2008 if ( fileType == CMediaFileList::EMediaFileTypeVideo ) |
|
2009 { |
|
2010 // null item file type cannot be video |
|
2011 } |
|
2012 } |
|
2013 |
|
2014 |
|
2015 //------------------------------------------------------------------------------ |
|
2016 // CMediaFileDialog::CancelPreview |
|
2017 // |
|
2018 //------------------------------------------------------------------------------ |
|
2019 // |
|
2020 void CMediaFileDialog::CancelPreview() |
|
2021 { |
|
2022 iAudioPreviewHandler->Stop(); |
|
2023 iCaller->Cancel(); |
|
2024 } |
|
2025 |
|
2026 |
|
2027 // ----------------------------------------------------------------------------- |
|
2028 // CMediaFileDialog::StartPreviewWithDelay |
|
2029 // |
|
2030 // ----------------------------------------------------------------------------- |
|
2031 // |
|
2032 void CMediaFileDialog::StartPreviewWithDelay() |
|
2033 { |
|
2034 const TInt KOneSecond = 1000; |
|
2035 |
|
2036 iAudioPreviewHandler->Stop(); |
|
2037 |
|
2038 // automatic preview starts after delay. see HandleActiveCallL. |
|
2039 iCaller->Start( EAttrPreview, KOneSecond ); |
|
2040 } |
|
2041 |
|
2042 |
|
2043 // ----------------------------------------------------------------------------- |
|
2044 // CMediaFileDialog::StartSearchWithDelay |
|
2045 // |
|
2046 // ----------------------------------------------------------------------------- |
|
2047 // |
|
2048 void CMediaFileDialog::StartSearchWithDelay() |
|
2049 { |
|
2050 if ( iPeninputActive ) |
|
2051 { |
|
2052 // search does not start automatically in pen input mode |
|
2053 return; |
|
2054 } |
|
2055 |
|
2056 const TInt KOneSecond = 1000; |
|
2057 |
|
2058 // search starts after delay. see HandleActiveCallL. |
|
2059 iSearchCaller->Start( EAttrSearch, KOneSecond ); |
|
2060 } |
|
2061 |
|
2062 |
|
2063 // ----------------------------------------------------------------------------- |
|
2064 // CMediaFileDialog::StartRomScan() |
|
2065 // |
|
2066 // ----------------------------------------------------------------------------- |
|
2067 // |
|
2068 void CMediaFileDialog::StartRomScan() |
|
2069 { |
|
2070 delete iIdle; |
|
2071 iIdle = NULL; |
|
2072 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
2073 |
|
2074 if ( iIdle ) |
|
2075 { |
|
2076 iIdle->Start( TCallBack( StartRomScaning, iMediaFileHandler ) ); |
|
2077 } |
|
2078 } |
|
2079 |
|
2080 // ----------------------------------------------------------------------------- |
|
2081 // CMediaFileDialog::StartRomScaning() |
|
2082 // |
|
2083 // ----------------------------------------------------------------------------- |
|
2084 // |
|
2085 |
|
2086 TInt CMediaFileDialog::StartRomScaning( TAny* aInstance ) |
|
2087 { |
|
2088 CMediaFileHandler* handler = static_cast<CMediaFileHandler*> ( aInstance ); |
|
2089 handler->StartRomScaning( CMediaFileHandler::EQueryTone ); |
|
2090 return 0; |
|
2091 } |
|
2092 |
|
2093 // ----------------------------------------------------------------------------- |
|
2094 // CMediaFileDialog::IsVideoFile |
|
2095 // |
|
2096 // ----------------------------------------------------------------------------- |
|
2097 // |
|
2098 TBool CMediaFileDialog::IsVideoFile( TInt aCurrentIndex ) |
|
2099 { |
|
2100 if ( aCurrentIndex < 0 ) |
|
2101 { |
|
2102 return EFalse; |
|
2103 } |
|
2104 |
|
2105 TInt current = iState->CurrentFolder(); |
|
2106 |
|
2107 if ( current == EEFolderVideos ) |
|
2108 { |
|
2109 return ETrue; |
|
2110 } |
|
2111 |
|
2112 if ( current != EEFolderSearch ) |
|
2113 { |
|
2114 return EFalse; |
|
2115 } |
|
2116 |
|
2117 TInt mediaType = iMediaFileHandler->Attribute( aCurrentIndex, |
|
2118 CMediaFileHandler::EAttrMediaType, |
|
2119 current ); |
|
2120 |
|
2121 if ( mediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
2122 { |
|
2123 return ETrue; |
|
2124 } |
|
2125 |
|
2126 return EFalse; |
|
2127 } |
|
2128 |
|
2129 |
|
2130 // ----------------------------------------------------------------------------- |
|
2131 // CMediaFileDialog::IsValidVideoFileL |
|
2132 // |
|
2133 // ----------------------------------------------------------------------------- |
|
2134 // |
|
2135 TBool CMediaFileDialog::IsValidVideoFileL( TInt aCurrentIndex, TInt aIntention ) |
|
2136 { |
|
2137 TBuf<KBufSize128> buf; |
|
2138 |
|
2139 if ( !IsVideoFile( aCurrentIndex ) ) |
|
2140 { |
|
2141 return EFalse; |
|
2142 } |
|
2143 |
|
2144 CMFProtectionHandler::TIntention intention; |
|
2145 if ( aIntention == CMFProtectionHandler::EPlay ) |
|
2146 { |
|
2147 intention = CMFProtectionHandler::EPlay; |
|
2148 } |
|
2149 else |
|
2150 { |
|
2151 intention = CMFProtectionHandler::ESelect; |
|
2152 } |
|
2153 GetSelectedItemFileName( aCurrentIndex, buf ); |
|
2154 |
|
2155 if ( iProtectionHandler->IsVideoValid( buf, intention ) ) |
|
2156 { |
|
2157 return ETrue; |
|
2158 } |
|
2159 return EFalse; |
|
2160 } |
|
2161 |
|
2162 |
|
2163 |
|
2164 // ---------------------------------------------------------------------------- |
|
2165 // CMediaFileDialog::UpdateListBoxL |
|
2166 // |
|
2167 // Update listbox contents (currently open folder items). |
|
2168 // ---------------------------------------------------------------------------- |
|
2169 // |
|
2170 void CMediaFileDialog::UpdateListBoxL( TBool aRestFindBox ) |
|
2171 { |
|
2172 // prevent flickering during listbox update. ResetFindBoxL seems |
|
2173 // to draw listbox many times |
|
2174 iListBox->MakeVisible( EFalse ); |
|
2175 |
|
2176 TRAP_IGNORE( DoUpdateListBoxL( aRestFindBox ) ); |
|
2177 |
|
2178 iListBox->MakeVisible( ETrue ); |
|
2179 } |
|
2180 |
|
2181 // ---------------------------------------------------------------------------- |
|
2182 // CMediaFileDialog::FilterInvalidFiles |
|
2183 // |
|
2184 // Filters the invalid files from media file handler |
|
2185 // invalid files = rights expired DRM Protected files and no right files |
|
2186 // ---------------------------------------------------------------------------- |
|
2187 // |
|
2188 void CMediaFileDialog::FilterInvalidFiles() |
|
2189 { |
|
2190 TInt count = iMediaFileHandler->ResultCount(); |
|
2191 |
|
2192 for ( TInt idx = 0; idx < count; ) |
|
2193 { |
|
2194 // check the validity |
|
2195 GetSelectedItemFileName( idx, iBuf ); |
|
2196 if ( iProtectionHandler->IsFlieDRMExpired( iBuf ) ) |
|
2197 { |
|
2198 // remove the item from handler in case of invalid file |
|
2199 iMediaFileHandler->Remove( idx ); |
|
2200 |
|
2201 // if an item was removed from handler, the idx will not |
|
2202 // be changed and the count will be decreased one. after |
|
2203 // recalculate the count, the next item will be checked in next loop. |
|
2204 count = iMediaFileHandler->ResultCount(); |
|
2205 } |
|
2206 else |
|
2207 { |
|
2208 // just increase the idx in case of valid file |
|
2209 idx++; |
|
2210 } |
|
2211 } |
|
2212 } |
|
2213 |
|
2214 // ---------------------------------------------------------------------------- |
|
2215 // CMediaFileDialog::DoUpdateListBoxL |
|
2216 // |
|
2217 // Update listbox contents (currently open folder items). |
|
2218 // ---------------------------------------------------------------------------- |
|
2219 // |
|
2220 void CMediaFileDialog::DoUpdateListBoxL( TBool aRestFindBox ) |
|
2221 { |
|
2222 // filter the invalid files to avoid showing in the list box |
|
2223 FilterInvalidFiles(); |
|
2224 iState->SetUnknownFolderPosition( iMediaFileHandler->ResultCount() ); |
|
2225 |
|
2226 // check current item index in case media file database has changed |
|
2227 CheckListboxIndex(); |
|
2228 if ( aRestFindBox ) |
|
2229 { |
|
2230 ResetFindBoxL(); |
|
2231 iListBox->HandleItemAdditionL(); |
|
2232 } |
|
2233 |
|
2234 TInt index = iState->CurrentItemIndex(); |
|
2235 if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) |
|
2236 { |
|
2237 iListBox->SetCurrentItemIndex( index ); |
|
2238 } |
|
2239 else |
|
2240 { |
|
2241 iListBox->SetCurrentItemIndex( 0 ); |
|
2242 } |
|
2243 |
|
2244 TBuf<KBufSize128> buf; |
|
2245 if ( iState->CurrentFolder() == EEFolderSearch || |
|
2246 iState->CurrentFolder() == EEFolderSearchMusic ) |
|
2247 { |
|
2248 TInt count = iListBox->Model()->NumberOfItems(); |
|
2249 iState->GetSearchTitle( buf, count ); |
|
2250 } |
|
2251 else |
|
2252 { |
|
2253 iState->GetTitle( iState->CurrentFolder(), buf ); |
|
2254 //#ifdef _DEBUG |
|
2255 TInt folder = iState->CurrentFolder(); |
|
2256 if ( iState->FindBoxNeeded() && folder != EEFolderMusic && |
|
2257 folder != EEFolderRoot ) |
|
2258 { |
|
2259 TBuf<KBufSize128> buf2( buf ); |
|
2260 TInt count = iListBox->Model()->NumberOfItems(); |
|
2261 buf.Format( _L("%S (%d)"), &buf2, count ); |
|
2262 } |
|
2263 //#endif |
|
2264 } |
|
2265 |
|
2266 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf ); |
|
2267 iStatusPaneHandler->SetNaviPaneTitle( buf ); |
|
2268 |
|
2269 UpdateCbaL( 0 ); |
|
2270 |
|
2271 DrawNow(); |
|
2272 |
|
2273 if ( iState->QueryDirection() != EEQueryUpdate ) |
|
2274 { |
|
2275 CancelPreview(); |
|
2276 } |
|
2277 |
|
2278 ShowDetailsPopupL(); // for search view info popup |
|
2279 } |
|
2280 |
|
2281 |
|
2282 // ----------------------------------------------------------------------------- |
|
2283 // CMediaFileDialog::UpdateCbaL |
|
2284 // |
|
2285 // Update cba. NOTE: Commented code (menu cba) is for (possible) future use. |
|
2286 // ----------------------------------------------------------------------------- |
|
2287 // |
|
2288 void CMediaFileDialog::UpdateCbaL( TInt /*aAttr*/ ) |
|
2289 { |
|
2290 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
2291 TInt currentIndex = CurrentItemListIndex(); |
|
2292 TInt folderId = iState->FolderId( currentIndex ); |
|
2293 TInt currentFolderId = iState->CurrentFolder(); |
|
2294 |
|
2295 |
|
2296 CEikButtonGroupContainer& cba = ButtonGroupContainer(); // from eikbtgpc.h |
|
2297 |
|
2298 |
|
2299 // Videos folder |
|
2300 if ( currentFolderId == EEFolderVideos ) |
|
2301 { |
|
2302 if ( itemCount == 0 ) |
|
2303 { |
|
2304 cba.SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
2305 //cba.SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
2306 } |
|
2307 else |
|
2308 { |
|
2309 if ( IsValidVideoFileL( currentIndex, CMFProtectionHandler::EPlay ) ) |
|
2310 { |
|
2311 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_PREVIEW_SELECT_BACK ); |
|
2312 } |
|
2313 else |
|
2314 { |
|
2315 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2316 } |
|
2317 |
|
2318 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_CONTEXT_BACK ); |
|
2319 } |
|
2320 return; |
|
2321 } |
|
2322 |
|
2323 |
|
2324 // Search folder |
|
2325 if ( currentFolderId == EEFolderSearch || |
|
2326 currentFolderId == EEFolderSearchMusic ) |
|
2327 { |
|
2328 if ( itemCount == 0 ) |
|
2329 { |
|
2330 cba.SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
2331 // cba.SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
2332 } |
|
2333 else |
|
2334 { |
|
2335 if ( IsValidVideoFileL( currentIndex, CMFProtectionHandler::EPlay ) ) |
|
2336 { |
|
2337 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_PREVIEW_SELECT_BACK ); |
|
2338 } |
|
2339 else |
|
2340 { |
|
2341 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2342 } |
|
2343 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_SELECT_BACK ); |
|
2344 } |
|
2345 return; |
|
2346 } |
|
2347 |
|
2348 |
|
2349 // Root folder |
|
2350 if ( currentFolderId == EEFolderRoot ) |
|
2351 { |
|
2352 if ( folderId == EEFolderDownload || folderId == EEFolderNullItemOne || |
|
2353 folderId == EEFolderNullItemTwo ) |
|
2354 { |
|
2355 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_SELECT_BACK ); |
|
2356 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2357 } |
|
2358 else |
|
2359 { |
|
2360 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_OPEN_BACK ); |
|
2361 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPEN_OPEN_BACK ); |
|
2362 } |
|
2363 return; |
|
2364 } |
|
2365 |
|
2366 |
|
2367 // other folders |
|
2368 if ( itemCount == 0 ) |
|
2369 { |
|
2370 // folder is empty |
|
2371 cba.SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
2372 //cba.SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
2373 } |
|
2374 else if ( folderId != KErrNotFound ) |
|
2375 { |
|
2376 // list items are folders |
|
2377 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPEN_OPEN_BACK ); |
|
2378 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_OPEN_BACK ); |
|
2379 } |
|
2380 else |
|
2381 { |
|
2382 // list items are files |
|
2383 cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_SELECT_SELECT_BACK ); |
|
2384 //cba.SetCommandSetL( R_MEDIA_FILE_DIALOG_CBA_OPTIONS_SELECT_BACK ); |
|
2385 } |
|
2386 } |
|
2387 |
|
2388 |
|
2389 // ----------------------------------------------------------------------------- |
|
2390 // CMediaFileDialog::Panic |
|
2391 // |
|
2392 // ----------------------------------------------------------------------------- |
|
2393 // |
|
2394 void CMediaFileDialog::Panic( TInt aReason ) |
|
2395 { |
|
2396 _LIT( KPanicCategory, "CMediaFileDialog" ); |
|
2397 |
|
2398 User::Panic( KPanicCategory, aReason ); |
|
2399 } |
|
2400 |
|
2401 |
|
2402 // ----------------------------------------------------------------------------- |
|
2403 // CMediaFileDialog::ShowErrorNoteL |
|
2404 // |
|
2405 // ----------------------------------------------------------------------------- |
|
2406 // |
|
2407 void CMediaFileDialog::ShowErrorNoteL( TInt aError ) |
|
2408 { |
|
2409 TInt err = aError; |
|
2410 |
|
2411 if ( err == KErrNone ) |
|
2412 { |
|
2413 return; |
|
2414 } |
|
2415 |
|
2416 iBuf = KNullDesC; |
|
2417 CTextResolver* tr = CTextResolver::NewLC(); |
|
2418 iBuf = tr->ResolveErrorString( err, CTextResolver::ECtxNoCtxNoSeparator ); |
|
2419 CleanupStack::PopAndDestroy( tr ); |
|
2420 |
|
2421 if ( iBuf.Length() > 0 ) |
|
2422 { |
|
2423 TMFDialogUtil::ShowErrorNoteL( iBuf ); |
|
2424 } |
|
2425 } |
|
2426 |
|
2427 |
|
2428 // ----------------------------------------------------------------------------- |
|
2429 // CMediaFileDialog::ShowPreviewErrorNoteL |
|
2430 // |
|
2431 // ----------------------------------------------------------------------------- |
|
2432 // |
|
2433 void CMediaFileDialog::ShowPreviewErrorNoteL( TInt aError, TInt aMediaType ) |
|
2434 { |
|
2435 TInt err = KErrNone; |
|
2436 |
|
2437 if ( aError == KErrNoMemory || aError == KErrDiskFull ) |
|
2438 { |
|
2439 CTextResolver* tr = CTextResolver::NewLC(); |
|
2440 iBuf = tr->ResolveErrorString( aError, CTextResolver::ECtxNoCtxNoSeparator ); |
|
2441 CleanupStack::PopAndDestroy( tr ); |
|
2442 err = aError; |
|
2443 } |
|
2444 else if ( aError == KErrNotSupported || aError == KErrCorrupt ||aError == KErrMMPartialPlayback) |
|
2445 { |
|
2446 if ( aMediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
2447 { |
|
2448 StringLoader::Load( iBuf, R_QTN_INFO_CLIP_FORMAT_ERROR ); |
|
2449 } |
|
2450 else |
|
2451 { |
|
2452 StringLoader::Load( iBuf, R_QTN_INFO_FILE_FORMAT_ERROR ); |
|
2453 } |
|
2454 err = aError; |
|
2455 } |
|
2456 |
|
2457 if ( err == KErrNone ) |
|
2458 { |
|
2459 return; |
|
2460 } |
|
2461 |
|
2462 #ifdef _DEBUG |
|
2463 TMFDialogUtil::ShowErrorNoteL( iBuf, aError ); |
|
2464 #else |
|
2465 TMFDialogUtil::ShowErrorNoteL( iBuf ); |
|
2466 #endif |
|
2467 |
|
2468 } |
|
2469 |
|
2470 |
|
2471 //------------------------------------------------------------------------------ |
|
2472 // CMediaFileDialog::ShowWaitNoteL |
|
2473 // |
|
2474 //------------------------------------------------------------------------------ |
|
2475 // |
|
2476 void CMediaFileDialog::ShowWaitNoteL( TBool aDatabaseChanged ) |
|
2477 { |
|
2478 TBuf<KBufSize128> buf; |
|
2479 |
|
2480 if ( aDatabaseChanged ) |
|
2481 { |
|
2482 StringLoader::Load( buf, R_QTN_WAIT_NOTE_UPDATE ); |
|
2483 //buf = _L("Refreshing"); |
|
2484 } |
|
2485 else if ( iState->QueryFolder() == EEFolderSearch || |
|
2486 iState->QueryFolder() == EEFolderSearchMusic ) |
|
2487 { |
|
2488 StringLoader::Load( buf, R_QTN_WAIT_NOTE_SEARCH ); |
|
2489 } |
|
2490 else |
|
2491 { |
|
2492 StringLoader::Load( buf, R_QTN_WAIT_NOTE_OPEN ); |
|
2493 } |
|
2494 |
|
2495 iWaitNote->LaunchL( buf ); |
|
2496 } |
|
2497 |
|
2498 |
|
2499 // ----------------------------------------------------------------------------- |
|
2500 // CMediaFileDialog::DeleteMenuItem |
|
2501 // |
|
2502 // ----------------------------------------------------------------------------- |
|
2503 // |
|
2504 void CMediaFileDialog::DeleteMenuItem( CEikMenuPane* aMenuPane, TInt aCommandId ) |
|
2505 { |
|
2506 TInt pos = KErrNotFound; |
|
2507 if ( aMenuPane->MenuItemExists( aCommandId, pos ) ) |
|
2508 { |
|
2509 aMenuPane->DeleteMenuItem( aCommandId ); |
|
2510 } |
|
2511 } |
|
2512 |
|
2513 |
|
2514 // ----------------------------------------------------------------------------- |
|
2515 // CMediaFileDialog::ShowPopupNote |
|
2516 // |
|
2517 // ----------------------------------------------------------------------------- |
|
2518 // |
|
2519 void CMediaFileDialog::ShowPopupNoteL( const TDesC& aText ) |
|
2520 { |
|
2521 const TInt KPopupDisplayTime = 3*1000; |
|
2522 const TInt KPopupDelayTime = 500; |
|
2523 |
|
2524 iPopupNote->SetTextL( aText ); |
|
2525 iPopupNote->SetTimeDelayBeforeShow( KPopupDelayTime ); |
|
2526 iPopupNote->SetTimePopupInView( KPopupDisplayTime ); |
|
2527 iPopupNote->ShowInfoPopupNote(); |
|
2528 } |
|
2529 |
|
2530 |
|
2531 // ----------------------------------------------------------------------------- |
|
2532 // CMediaFileDialog::CurrentItemListIndex |
|
2533 // |
|
2534 // ----------------------------------------------------------------------------- |
|
2535 // |
|
2536 TInt CMediaFileDialog::CurrentItemListIndex() |
|
2537 { |
|
2538 TInt itemCount = iListBox->Model()->NumberOfItems(); |
|
2539 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
2540 |
|
2541 if ( itemCount == 0 || currentIndex < 0 ) |
|
2542 { |
|
2543 return KErrNotFound; // list or find box is empty |
|
2544 } |
|
2545 |
|
2546 // convert from findbox index into original list index |
|
2547 if ( FindBox() && FindBox()->IsVisible() ) |
|
2548 { |
|
2549 TInt tempIndex = currentIndex; |
|
2550 CAknFilteredTextListBoxModel* model = |
|
2551 STATIC_CAST(CAknFilteredTextListBoxModel*, iListBox->Model()); |
|
2552 |
|
2553 if ( model->Filter() ) |
|
2554 { |
|
2555 currentIndex = model->Filter()->FilteredItemIndex( tempIndex ); |
|
2556 } |
|
2557 } |
|
2558 |
|
2559 return currentIndex; |
|
2560 } |
|
2561 |
|
2562 |
|
2563 //------------------------------------------------------------------------------ |
|
2564 // CMediaFileDialog::GetSelectedItemFileName |
|
2565 // |
|
2566 //------------------------------------------------------------------------------ |
|
2567 // |
|
2568 void CMediaFileDialog::GetSelectedItemFileName( TInt aListboxIndex, TDes& aFileName ) |
|
2569 { |
|
2570 aFileName = KNullDesC; |
|
2571 |
|
2572 __ASSERT_DEBUG( iState->QueryNeeded(), Panic( KErrGeneral ) ); |
|
2573 |
|
2574 TInt id = iState->CurrentFolder(); |
|
2575 |
|
2576 // read selected list item text from metadata |
|
2577 TInt extraIndexes = iState->LeadingPersistentFolderCount(); |
|
2578 TInt queryIndex = aListboxIndex - extraIndexes; |
|
2579 |
|
2580 iMediaFileHandler->GetAttribute( queryIndex, CMediaFileHandler::EAttrFullName, |
|
2581 aFileName, id ); |
|
2582 } |
|
2583 |
|
2584 |
|
2585 // ----------------------------------------------------------------------------- |
|
2586 // CMediaFileDialog::ConstructListboxItem |
|
2587 // |
|
2588 // ----------------------------------------------------------------------------- |
|
2589 // |
|
2590 TPtrC CMediaFileDialog::ConstructListboxItem( TInt aListboxIndex ) |
|
2591 { |
|
2592 _LIT( KFormat2, "%d\t%S\t%d" ); |
|
2593 |
|
2594 TBool isPersistent = EFalse; |
|
2595 TInt mediaTypeIcon = EEIconEmpty; |
|
2596 TInt storageTypeIcon = EEIconEmpty; |
|
2597 TInt folderId = KErrNotFound; |
|
2598 iState->GetFolderInfo( aListboxIndex, folderId, iListboxItemText1, |
|
2599 isPersistent, mediaTypeIcon ); |
|
2600 if ( folderId != KErrNotFound ) |
|
2601 { |
|
2602 if ( !isPersistent ) |
|
2603 { |
|
2604 GetListItemText( aListboxIndex, iListboxItemText1 ); |
|
2605 } |
|
2606 } |
|
2607 else |
|
2608 { |
|
2609 GetListItemText( aListboxIndex, iListboxItemText1 ); |
|
2610 mediaTypeIcon = MediaTypeIcon( aListboxIndex ); |
|
2611 storageTypeIcon = StorageTypeIcon( aListboxIndex ); |
|
2612 } |
|
2613 |
|
2614 iListboxItemText2.Format( KFormat2, mediaTypeIcon, &iListboxItemText1, storageTypeIcon ); |
|
2615 return iListboxItemText2; |
|
2616 } |
|
2617 |
|
2618 |
|
2619 // ----------------------------------------------------------------------------- |
|
2620 // CMediaFileDialog::MediaTypeIcon |
|
2621 // |
|
2622 // ----------------------------------------------------------------------------- |
|
2623 // |
|
2624 TInt CMediaFileDialog::MediaTypeIcon( TInt aListboxIndex ) |
|
2625 { |
|
2626 if ( aListboxIndex < 0 ) |
|
2627 { |
|
2628 return EEIconEmpty; |
|
2629 } |
|
2630 |
|
2631 TInt mediaType = iMediaFileHandler->Attribute( aListboxIndex, |
|
2632 CMediaFileHandler::EAttrMediaType, |
|
2633 iState->CurrentFolder() ); |
|
2634 |
|
2635 TInt iconId = EEIconMusic; |
|
2636 if ( mediaType == CMediaFileHandler::EMediaTypeTone ) |
|
2637 { |
|
2638 iconId = EEIconTone; |
|
2639 } |
|
2640 else if ( mediaType == CMediaFileHandler::EMediaTypeVideo ) |
|
2641 { |
|
2642 iconId = EEIconVideo; |
|
2643 } |
|
2644 else if ( mediaType == CMediaFileHandler::EMediaTypeRecording ) |
|
2645 { |
|
2646 iconId = EEIconRecording; |
|
2647 } |
|
2648 |
|
2649 return iconId; |
|
2650 } |
|
2651 |
|
2652 |
|
2653 // ----------------------------------------------------------------------------- |
|
2654 // CMediaFileDialog::StorageTypeIcon |
|
2655 // |
|
2656 // ----------------------------------------------------------------------------- |
|
2657 // |
|
2658 TInt CMediaFileDialog::StorageTypeIcon( TInt aListboxIndex ) |
|
2659 { |
|
2660 if ( aListboxIndex < 0 ) |
|
2661 { |
|
2662 return EEIconEmpty; |
|
2663 } |
|
2664 |
|
2665 TInt storageType = iMediaFileHandler->Attribute( aListboxIndex, |
|
2666 CMediaFileHandler::EAttrStorageType, |
|
2667 iState->CurrentFolder() ); |
|
2668 TInt iconId = EEIconEmpty; |
|
2669 if ( storageType == CMediaFileHandler::EMassStorage ) |
|
2670 { |
|
2671 iconId = EEIconMassStorage; |
|
2672 } |
|
2673 |
|
2674 if ( storageType == CMediaFileHandler::EMemoryCard ) |
|
2675 { |
|
2676 iconId = EEIconMemoryCard; |
|
2677 } |
|
2678 |
|
2679 return iconId; |
|
2680 } |
|
2681 |
|
2682 |
|
2683 // ----------------------------------------------------------------------------- |
|
2684 // CMediaFileDialog::GetListItemText |
|
2685 // |
|
2686 // ----------------------------------------------------------------------------- |
|
2687 // |
|
2688 void CMediaFileDialog::GetListItemText( TInt aListboxIndex, TDes& aText ) |
|
2689 { |
|
2690 __ASSERT_DEBUG( iState->QueryNeeded(), Panic( KErrGeneral ) ); |
|
2691 |
|
2692 TInt id = iState->CurrentFolder(); |
|
2693 |
|
2694 // read selected list item text from metadata |
|
2695 TInt extraIndexes = iState->LeadingPersistentFolderCount(); |
|
2696 TInt queryIndex = aListboxIndex - extraIndexes; |
|
2697 |
|
2698 iMediaFileHandler->GetAttribute( queryIndex, |
|
2699 CMediaFileHandler::EAttrSongName, aText, id ); |
|
2700 } |
|
2701 |
|
2702 |
|
2703 |
|
2704 // ----------------------------------------------------------------------------- |
|
2705 // CMediaFileDialog::ListboxItemCount (from CMFListHandlerObserver) |
|
2706 // |
|
2707 // ----------------------------------------------------------------------------- |
|
2708 // |
|
2709 TInt CMediaFileDialog::ListboxItemCount() |
|
2710 { |
|
2711 TInt count1 = iState->PersistentFolderCount(); |
|
2712 TInt count2 = 0; |
|
2713 |
|
2714 if ( iState->QueryNeeded() ) |
|
2715 { |
|
2716 count2 = iMediaFileHandler->ResultCount(); |
|
2717 } |
|
2718 return count1 + count2; |
|
2719 } |
|
2720 |
|
2721 |
|
2722 // ----------------------------------------------------------------------------- |
|
2723 // CMediaFileDialog::HandleMFEventL (from MMediaFileHandlerObserver) |
|
2724 // |
|
2725 // ----------------------------------------------------------------------------- |
|
2726 // |
|
2727 void CMediaFileDialog::HandleMFEventL( TInt aEvent, TInt aError ) |
|
2728 { |
|
2729 // |
|
2730 // handle cancel button |
|
2731 // |
|
2732 if ( aEvent == MMediaFileHandlerObserver::EQueryCanceled ) |
|
2733 { |
|
2734 iWaitNote->CancelProgressDialogL(); |
|
2735 iSearchText = KNullDesC; |
|
2736 UpdateListBoxL(); |
|
2737 return; |
|
2738 } |
|
2739 |
|
2740 // |
|
2741 // handle error |
|
2742 // |
|
2743 if ( aError != KErrNone ) |
|
2744 { |
|
2745 iWaitNote->CancelProgressDialogL(); |
|
2746 ResetDialogL( aError ); |
|
2747 |
|
2748 FLOG( _L("### CMediaFileDialog::HandleMFEventL (%d) ###"), aError ); |
|
2749 return; |
|
2750 } |
|
2751 |
|
2752 |
|
2753 if ( aEvent != MMediaFileHandlerObserver::EUnknownQueryComplete ) |
|
2754 { |
|
2755 // unknown query is always followed by another query |
|
2756 iWaitNote->CancelProgressDialogL(); |
|
2757 } |
|
2758 |
|
2759 |
|
2760 if ( aEvent == MMediaFileHandlerObserver::EUnknownQueryComplete ) |
|
2761 { |
|
2762 TInt count = iMediaFileHandler->ResultCount(); |
|
2763 TInt folderId = iState->QueryFolder(); |
|
2764 iState->SetUnknownCount( folderId, count ); |
|
2765 |
|
2766 TInt err = KErrNone; |
|
2767 TRAP( err, QueryL( folderId ) ); |
|
2768 if ( err != KErrNone ) |
|
2769 { |
|
2770 iWaitNote->CancelProgressDialogL(); |
|
2771 User::Leave( err ); |
|
2772 } |
|
2773 } |
|
2774 |
|
2775 if ( aEvent == MMediaFileHandlerObserver::EQueryComplete ) |
|
2776 { |
|
2777 // query was successful - update dialog state |
|
2778 iState->SetStateAfterQuery(); |
|
2779 |
|
2780 TInt count = iMediaFileHandler->ResultCount(); |
|
2781 |
|
2782 if ( iState->CurrentFolder() == EEFolderArtist ) |
|
2783 { |
|
2784 TInt count = iMediaFileHandler->UnknownArtistCount(); |
|
2785 iState->SetUnknownCount( EEFolderArtist, count ); |
|
2786 } |
|
2787 iState->HideUnknownFolders(); |
|
2788 UpdateListBoxL(); |
|
2789 |
|
2790 #ifdef _DEBUG |
|
2791 iTest->PrintTimeL( _L("query took") ); // test code |
|
2792 #endif |
|
2793 } |
|
2794 |
|
2795 if ( aEvent == MMediaFileHandlerObserver::EMediaFileChanged ) |
|
2796 { |
|
2797 HandleMediaFileChanged(); |
|
2798 } |
|
2799 |
|
2800 if ( aEvent == MMediaFileHandlerObserver::EScanRomComplete ) |
|
2801 { |
|
2802 iWaitNote->CancelProgressDialogL(); |
|
2803 } |
|
2804 |
|
2805 if ( aEvent == MMediaFileHandlerObserver::EInitComplete ) |
|
2806 { |
|
2807 iDatabaseOpen = ETrue; |
|
2808 |
|
2809 StartRomScan(); |
|
2810 } |
|
2811 } |
|
2812 |
|
2813 |
|
2814 // ----------------------------------------------------------------------------- |
|
2815 // CMediaFileDialog::HandleMediaFileChanged |
|
2816 // |
|
2817 // Handle situation where file system changes and media files are added / |
|
2818 // removed. This function makes a query to update current folder and |
|
2819 // stores name or id of the currently selected item. Current item info |
|
2820 // is needed to restore current item after query. |
|
2821 // ----------------------------------------------------------------------------- |
|
2822 // |
|
2823 void CMediaFileDialog::HandleMediaFileChanged() |
|
2824 { |
|
2825 // query is ongoing - ignore this file change event |
|
2826 if ( !iMediaFileHandler->QueryReady() ) |
|
2827 { |
|
2828 FLOG( _L("### CMediaFileDialog::HandleMediaFileChanged: query in progress ###") ); |
|
2829 return; |
|
2830 } |
|
2831 |
|
2832 iState->ResetUnknownCount(); |
|
2833 TMFCurrentItemInfo& info = iState->CurrentItemInfo(); |
|
2834 info.Reset(); |
|
2835 info.iIndexCheckNeeded = ETrue; // set to false when dialog is opened |
|
2836 |
|
2837 TInt currentFolder = iState->CurrentFolder(); |
|
2838 TInt currentIndex = CurrentItemListIndex(); |
|
2839 |
|
2840 TBool isPersistent = EFalse; |
|
2841 TInt iconId = EEIconEmpty; |
|
2842 TInt id = KErrNotFound; |
|
2843 TBuf<KBufSize64> buf; |
|
2844 iState->GetFolderInfo( currentIndex, id, buf, |
|
2845 isPersistent, iconId ); |
|
2846 if ( id == KErrNotFound ) |
|
2847 { |
|
2848 // get media file id |
|
2849 info.iMediaFileId = iMediaFileHandler->Attribute( currentIndex, |
|
2850 CMediaFileHandler::EAttrMediaFileId, currentFolder ); |
|
2851 } |
|
2852 else if ( !isPersistent ) |
|
2853 { |
|
2854 // get non-persistent folder name (eg some album name) |
|
2855 GetListItemText( currentIndex, info.iFolderText ); |
|
2856 } |
|
2857 else |
|
2858 { |
|
2859 // get persistent folder id (eg "Unknown" folder) |
|
2860 info.iFolderId = id; |
|
2861 } |
|
2862 |
|
2863 info.iItemIndex = currentIndex; |
|
2864 |
|
2865 iState->SetQueryInfo( 0, KNullDesC, 0, EEQueryUpdate ); |
|
2866 |
|
2867 TBool databaseChanged = ETrue; |
|
2868 QueryL( currentFolder, databaseChanged ); |
|
2869 } |
|
2870 |
|
2871 |
|
2872 // ----------------------------------------------------------------------------- |
|
2873 // CMediaFileDialog::CheckListboxIndex |
|
2874 // |
|
2875 // Check that current item selection is correct. Function is used in case |
|
2876 // file system has changed (media files added / removed. |
|
2877 // ----------------------------------------------------------------------------- |
|
2878 // |
|
2879 void CMediaFileDialog::CheckListboxIndex() |
|
2880 { |
|
2881 TMFCurrentItemInfo& info = iState->CurrentItemInfo(); |
|
2882 if ( !info.iIndexCheckNeeded ) |
|
2883 { |
|
2884 return; |
|
2885 } |
|
2886 |
|
2887 TInt direction = iState->QueryDirection(); |
|
2888 TInt newListIndex = KErrNotFound; |
|
2889 |
|
2890 if ( direction == EEQueryUp ) |
|
2891 { |
|
2892 FLOG( _L("query up") ); |
|
2893 TInt prevId = iState->PreviousFolderId(); |
|
2894 TInt listIndex = iState->ListIndex( prevId ); |
|
2895 if ( !iState->IsPersistent( prevId ) ) |
|
2896 { |
|
2897 iState->GetText( prevId, info.iFolderText ); |
|
2898 TInt num = iState->LeadingPersistentFolderCount(); |
|
2899 newListIndex = iMediaFileHandler->ItemIndex( |
|
2900 info.iFolderText, listIndex ); |
|
2901 iState->SetCurrentItemIndex( newListIndex + num ); |
|
2902 } |
|
2903 else |
|
2904 { |
|
2905 iState->SetCurrentItemIndex( listIndex ); |
|
2906 } |
|
2907 } |
|
2908 |
|
2909 if ( direction == EEQueryUpdate ) |
|
2910 { |
|
2911 if ( info.iMediaFileId != KErrNotFound ) |
|
2912 { |
|
2913 newListIndex = iMediaFileHandler->ItemIndex( |
|
2914 info.iMediaFileId, info.iItemIndex ); |
|
2915 } |
|
2916 else if ( info.iFolderText.Length() > 0 ) |
|
2917 { |
|
2918 newListIndex = iMediaFileHandler->ItemIndex( |
|
2919 info.iFolderText, info.iItemIndex ); |
|
2920 TInt num = iState->LeadingPersistentFolderCount(); |
|
2921 newListIndex = newListIndex + num; |
|
2922 } |
|
2923 else if ( info.iFolderId != KErrNotFound ) |
|
2924 { |
|
2925 newListIndex = iState->ListIndex( info.iFolderId ); |
|
2926 } |
|
2927 |
|
2928 iState->SetCurrentItemIndex( newListIndex ); |
|
2929 } |
|
2930 } |
|
2931 |
|
2932 |
|
2933 // ----------------------------------------------------------------------------- |
|
2934 // CMediaFileDialog::HandlePreviewEventL (from MPreviewHandlerObserver) |
|
2935 // |
|
2936 // ----------------------------------------------------------------------------- |
|
2937 // |
|
2938 void CMediaFileDialog::HandlePreviewEventL( TInt aEvent, TInt aError ) |
|
2939 { |
|
2940 if ( aEvent == MPreviewHandlerObserver::EAudioPreviewComplete ) |
|
2941 { |
|
2942 ShowPreviewErrorNoteL( aError, CMediaFileHandler::EMediaTypeMusic ); |
|
2943 } |
|
2944 |
|
2945 if ( aEvent == MPreviewHandlerObserver::EVideoPreviewComplete ) |
|
2946 { |
|
2947 ShowPreviewErrorNoteL( aError, CMediaFileHandler::EMediaTypeVideo ); |
|
2948 } |
|
2949 |
|
2950 if ( aEvent == MPreviewHandlerObserver::EPreviewError ) |
|
2951 { |
|
2952 FLOG( _L("### CMediaFileDialog::HandlePreviewEventL (%d) ###"), aError ); |
|
2953 |
|
2954 ShowPreviewErrorNoteL( aError, CMediaFileHandler::EMediaTypeMusic ); |
|
2955 } |
|
2956 } |
|
2957 |
|
2958 |
|
2959 // ----------------------------------------------------------------------------- |
|
2960 // CMediaFileDialog::HandleLosingForeground (from MCoeForegroundObserver) |
|
2961 // |
|
2962 // ----------------------------------------------------------------------------- |
|
2963 // |
|
2964 void CMediaFileDialog::HandleLosingForeground() |
|
2965 { |
|
2966 iForeGround = EFalse; |
|
2967 //Record the current item info |
|
2968 if ( iState && iListBox) |
|
2969 { |
|
2970 iState->SetCurrentItemIndex( CurrentItemListIndex() ); |
|
2971 } |
|
2972 |
|
2973 CancelPreview(); |
|
2974 } |
|
2975 |
|
2976 |
|
2977 // ----------------------------------------------------------------------------- |
|
2978 // CMediaFileDialog::HandleGainingForeground (from MCoeForegroundObserver) |
|
2979 // |
|
2980 // ----------------------------------------------------------------------------- |
|
2981 // |
|
2982 void CMediaFileDialog::HandleGainingForeground() |
|
2983 { |
|
2984 iForeGround = ETrue; |
|
2985 if ( iListBox ) |
|
2986 { |
|
2987 UpdateListBoxL( EFalse ); |
|
2988 } |
|
2989 } |
|
2990 |
|
2991 |
|
2992 // ----------------------------------------------------------------------------- |
|
2993 // CMediaFileDialog::HandleControlEventL (from MCoeControlObserver) |
|
2994 // |
|
2995 // ----------------------------------------------------------------------------- |
|
2996 // |
|
2997 void CMediaFileDialog::HandleControlEventL( CCoeControl* aControl, |
|
2998 TCoeEvent aEventType ) |
|
2999 { |
|
3000 TInt currentFolderId = iState->CurrentFolder(); |
|
3001 |
|
3002 if ( aEventType == EEventStateChanged ) |
|
3003 { |
|
3004 CancelPreview(); |
|
3005 if ( aControl == iListBox ) |
|
3006 { |
|
3007 if ( currentFolderId == EEFolderRoot || |
|
3008 currentFolderId == EEFolderSearch || |
|
3009 currentFolderId == EEFolderVideos ) |
|
3010 { |
|
3011 UpdateCbaL( 0 ); // only these folders need dynamic cba update |
|
3012 } |
|
3013 StartPreviewWithDelay(); |
|
3014 ShowDetailsPopupL(); // show search details in Search view |
|
3015 |
|
3016 // forward listbox state change events to this control's |
|
3017 // observers |
|
3018 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
3019 } |
|
3020 |
|
3021 if ( FindBox() && aControl == FindBox() ) |
|
3022 { |
|
3023 User::InfoPrint(_L("find box event arrived")); |
|
3024 |
|
3025 // this event is received when user enters or deletes |
|
3026 // chars in find box. Backspace key in empty find box does not |
|
3027 // generate this event. |
|
3028 |
|
3029 if ( currentFolderId == EEFolderSearch || |
|
3030 currentFolderId == EEFolderRoot || |
|
3031 currentFolderId == EEFolderMusic || |
|
3032 currentFolderId == EEFolderSearchMusic ) |
|
3033 { |
|
3034 StartSearchWithDelay(); |
|
3035 return; |
|
3036 } |
|
3037 |
|
3038 // StartPreviewWithDelay(); |
|
3039 |
|
3040 UpdateCbaL( 0 ); |
|
3041 |
|
3042 //#ifdef _DEBUG |
|
3043 TBuf<KBufSize128> buf; |
|
3044 iState->GetTitle( iState->CurrentFolder(), buf ); |
|
3045 TBuf<KBufSize128> buf2( buf ); |
|
3046 TInt count = iListBox->Model()->NumberOfItems(); |
|
3047 buf.Format( _L("%S (%d)"), &buf2, count ); |
|
3048 iStatusPaneHandler->SetNaviPaneTitle( buf ); |
|
3049 //#endif |
|
3050 |
|
3051 // Forward listbox state change events to this control's |
|
3052 // observers |
|
3053 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
3054 } |
|
3055 } |
|
3056 } |
|
3057 |
|
3058 |
|
3059 // ----------------------------------------------------------------------------- |
|
3060 // CMediaFileDialog::HandleWaitNoteL (from MMediaFileWaitNoteObserver) |
|
3061 // |
|
3062 // ----------------------------------------------------------------------------- |
|
3063 // |
|
3064 void CMediaFileDialog::HandleWaitNoteL( TInt /*aButtonId*/ ) |
|
3065 { |
|
3066 iMediaFileHandler->CancelQuery(); |
|
3067 } |
|
3068 |
|
3069 |
|
3070 // ----------------------------------------------------------------------------- |
|
3071 // CMediaFileDialog::AdaptiveSearchTextChanged (from MAdaptiveSearchTextObserver) |
|
3072 // |
|
3073 // ----------------------------------------------------------------------------- |
|
3074 // |
|
3075 void CMediaFileDialog::AdaptiveSearchTextChanged( CAknSearchField* /*aSearchField*/ ) |
|
3076 { |
|
3077 // not used |
|
3078 } |
|
3079 |
|
3080 |
|
3081 // ----------------------------------------------------------------------------- |
|
3082 // CMediaFileDialog::OnPeninputUiDeactivated |
|
3083 // |
|
3084 // ----------------------------------------------------------------------------- |
|
3085 // |
|
3086 void CMediaFileDialog::OnPeninputUiDeactivated() |
|
3087 { |
|
3088 iPeninputActive = EFalse; |
|
3089 |
|
3090 if ( FindBox()->TextLength() == 0 && |
|
3091 ( iState->CurrentFolder() == EEFolderSearch || |
|
3092 iState->CurrentFolder() == EEFolderSearchMusic ) ) |
|
3093 { |
|
3094 HandleBackL(); |
|
3095 } |
|
3096 else |
|
3097 { |
|
3098 // search starts immediately after user closes pen input |
|
3099 TRAP_IGNORE( StartSearchWithDelay() ); |
|
3100 } |
|
3101 } |
|
3102 |
|
3103 |
|
3104 // ----------------------------------------------------------------------------- |
|
3105 // CMediaFileDialog::OnPeninputUiActivated |
|
3106 // |
|
3107 // ----------------------------------------------------------------------------- |
|
3108 // |
|
3109 void CMediaFileDialog::OnPeninputUiActivated() |
|
3110 { |
|
3111 iPeninputActive = ETrue; |
|
3112 CancelPreview(); |
|
3113 } |
|
3114 |
|
3115 |
|
3116 // ----------------------------------------------------------------------------- |
|
3117 // CMediaFileDialog::HandleListBoxEventL (from MEikListBoxObserver) |
|
3118 // |
|
3119 // ----------------------------------------------------------------------------- |
|
3120 // |
|
3121 void CMediaFileDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
3122 TListBoxEvent aEventType ) |
|
3123 { |
|
3124 TInt current = iState->CurrentFolder(); |
|
3125 if ( aEventType == EEventPenDownOnItem) |
|
3126 { |
|
3127 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EPressedDownState ); |
|
3128 return; |
|
3129 } |
|
3130 |
|
3131 if ( aEventType == EEventItemClicked ) |
|
3132 { |
|
3133 iIsDoubleClicked = EFalse; |
|
3134 if ( current != KErrNotFound ) |
|
3135 { |
|
3136 HandleOKL( EAttrOpen ); // open folder item |
|
3137 } |
|
3138 return; |
|
3139 } |
|
3140 |
|
3141 if ( aEventType == EEventItemDoubleClicked || aEventType == EEventEnterKeyPressed ) |
|
3142 { |
|
3143 iIsDoubleClicked = ETrue; |
|
3144 TBool closeDialog = HandleOKL( EAttrDoubleClicked ); |
|
3145 |
|
3146 if ( closeDialog ) |
|
3147 { |
|
3148 // close after short delay (dialog cannot be closed from this function) |
|
3149 CloseDialogWithDelayL(); |
|
3150 } |
|
3151 } |
|
3152 if ( aEventType == EEventItemDraggingActioned ) |
|
3153 { |
|
3154 UpdateCbaL( KErrNone ); |
|
3155 DrawNow(); |
|
3156 } |
|
3157 } |
|
3158 |
|
3159 |
|
3160 // ----------------------------------------------------------------------------- |
|
3161 // CMediaFileDialog::CloseDialogWithDelayL |
|
3162 // |
|
3163 // ----------------------------------------------------------------------------- |
|
3164 // |
|
3165 void CMediaFileDialog::CloseDialogWithDelayL() |
|
3166 { |
|
3167 delete iIdle; |
|
3168 iIdle = NULL; |
|
3169 iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
3170 |
|
3171 if ( iIdle ) |
|
3172 { |
|
3173 iIdle->Start( TCallBack( CloseDialog, this ) ); |
|
3174 } |
|
3175 delete iInputBlock; |
|
3176 iInputBlock = NULL; |
|
3177 iInputBlock = CAknInputBlock::NewLC(); |
|
3178 CleanupStack::Pop( iInputBlock ); |
|
3179 } |
|
3180 |
|
3181 |
|
3182 // ----------------------------------------------------------------------------- |
|
3183 // CMediaFileDialog::CloseDialog |
|
3184 // |
|
3185 // ----------------------------------------------------------------------------- |
|
3186 // |
|
3187 TInt CMediaFileDialog::CloseDialog( TAny *aObj ) |
|
3188 { |
|
3189 CMediaFileDialog *dlg = (CMediaFileDialog*) aObj; |
|
3190 delete dlg->iInputBlock; |
|
3191 dlg->iInputBlock = NULL; |
|
3192 |
|
3193 TRAP_IGNORE( dlg->TryExitL( EAknSoftkeyOk ) ); |
|
3194 |
|
3195 return 0; |
|
3196 } |
|
3197 |
|
3198 |
|
3199 // ----------------------------------------------------------------------------- |
|
3200 // CMediaFileDialog::HandleActiveCallL (from MMFActiveCallerObserver) |
|
3201 // |
|
3202 // ----------------------------------------------------------------------------- |
|
3203 // |
|
3204 void CMediaFileDialog::HandleActiveCallL( TInt aCallId ) |
|
3205 { |
|
3206 if ( aCallId == EAttrPreview ) |
|
3207 { |
|
3208 //double click the item of the listbox to select the tones, do not preview it. |
|
3209 if ( iIsDoubleClicked ) |
|
3210 { |
|
3211 iIsDoubleClicked = EFalse; |
|
3212 } |
|
3213 else |
|
3214 { |
|
3215 // start preview after delay |
|
3216 PreviewL( CMediaFileList::EMediaFileTypeAudio ); |
|
3217 } |
|
3218 } |
|
3219 |
|
3220 if ( aCallId == EAttrSearch ) |
|
3221 { |
|
3222 // start search after delay |
|
3223 SearchL(); |
|
3224 } |
|
3225 } |
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 /****************************************************************************** |
|
3231 * class CMFListHandler |
|
3232 ******************************************************************************/ |
|
3233 |
|
3234 // ----------------------------------------------------------------------------- |
|
3235 // CMFListHandler::NewL |
|
3236 // |
|
3237 // ----------------------------------------------------------------------------- |
|
3238 // |
|
3239 CMFListHandler* CMFListHandler::NewL() |
|
3240 { |
|
3241 CMFListHandler* self = new (ELeave) CMFListHandler(); |
|
3242 CleanupStack::PushL(self); |
|
3243 self->ConstructL(); |
|
3244 CleanupStack::Pop(self); |
|
3245 return self; |
|
3246 } |
|
3247 |
|
3248 |
|
3249 // ----------------------------------------------------------------------------- |
|
3250 // CMFListHandler::~CMFListHandler |
|
3251 // |
|
3252 // ----------------------------------------------------------------------------- |
|
3253 // |
|
3254 CMFListHandler::~CMFListHandler() |
|
3255 { |
|
3256 } |
|
3257 |
|
3258 |
|
3259 // ----------------------------------------------------------------------------- |
|
3260 // CMFListHandler::ConstructL |
|
3261 // |
|
3262 // ----------------------------------------------------------------------------- |
|
3263 // |
|
3264 void CMFListHandler::ConstructL( void ) |
|
3265 { |
|
3266 } |
|
3267 |
|
3268 |
|
3269 // ----------------------------------------------------------------------------- |
|
3270 // CMFListHandler::CMFListHandler |
|
3271 // |
|
3272 // ----------------------------------------------------------------------------- |
|
3273 // |
|
3274 CMFListHandler::CMFListHandler() |
|
3275 { |
|
3276 } |
|
3277 |
|
3278 |
|
3279 // ----------------------------------------------------------------------------- |
|
3280 // CMFListHandler::SetObserver |
|
3281 // |
|
3282 // ----------------------------------------------------------------------------- |
|
3283 // |
|
3284 void CMFListHandler::SetObserver( CMFListHandlerObserver* aObserver ) |
|
3285 { |
|
3286 iObserver = aObserver; |
|
3287 } |
|
3288 |
|
3289 |
|
3290 // ----------------------------------------------------------------------------- |
|
3291 // CMFListHandler::MdcaCount (from MDesCArray) |
|
3292 // |
|
3293 // ----------------------------------------------------------------------------- |
|
3294 // |
|
3295 TInt CMFListHandler::MdcaCount() const |
|
3296 { |
|
3297 return iObserver->ListboxItemCount(); |
|
3298 } |
|
3299 |
|
3300 |
|
3301 // ----------------------------------------------------------------------------- |
|
3302 // CMFListHandler::MdcaPoint (from MDesCArray) |
|
3303 // |
|
3304 // CEikListBox calls this function just before it draws list box item. |
|
3305 // ----------------------------------------------------------------------------- |
|
3306 // |
|
3307 TPtrC16 CMFListHandler::MdcaPoint( TInt aIndex ) const |
|
3308 { |
|
3309 return iObserver->ConstructListboxItem( aIndex ); |
|
3310 } |
|
3311 |
|
3312 |
|
3313 // ----------------------------------------------------------------------------- |
|
3314 // CMFListHandler::Panic |
|
3315 // |
|
3316 // ----------------------------------------------------------------------------- |
|
3317 // |
|
3318 void CMFListHandler::Panic( TInt aReason ) |
|
3319 { |
|
3320 _LIT( KPanicCategory, "CMFListHandler" ); |
|
3321 |
|
3322 User::Panic( KPanicCategory, aReason ); |
|
3323 } |
|
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 |
|
3332 // End of File |