|
1 /* |
|
2 * Copyright (c) 2006 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: Music Player album art editor dialog implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <akntitle.h> |
|
20 #include <aknnavide.h> |
|
21 #include <StringLoader.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <aknViewAppUi.h> |
|
24 #include <aknnavilabel.h> |
|
25 #include <coeutils.h> |
|
26 #include <hlplch.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <bautils.h> |
|
29 |
|
30 #include <mpxcollectionmessage.h> |
|
31 #include <mpxcollectionutility.h> |
|
32 #include <mpxmedia.h> |
|
33 #include <mpxmediaarray.h> |
|
34 #include <mpxmediamusicdefs.h> |
|
35 #include <mpxmediageneraldefs.h> |
|
36 #include <mpxmediacontainerdefs.h> |
|
37 #include <mpxcollectionpath.h> |
|
38 #include <mpxalbumarteditordialog.rsg> |
|
39 #include <mpxmessagegeneraldefs.h> |
|
40 #include <mpxconstants.h> |
|
41 #include <mpxlog.h> |
|
42 #include <mpxcommandgeneraldefs.h> |
|
43 #include <mpxcollectioncommanddefs.h> |
|
44 #include <mpxcollectionmessagedefs.h> |
|
45 #include <mpxuser.h> |
|
46 |
|
47 #include "mpxalbumartutil.h" |
|
48 #include "mpxcommonuihelper.h" |
|
49 #include "mpxalbumarteditordialog.hlp.hrh" |
|
50 #include "mpxalbumarteditordialog.hrh" |
|
51 #include "mpxalbumarteditordialogcustomcontrol.h" |
|
52 #include "mpxalbumarteditorcustomcontrolcontainer.h" |
|
53 #include "mpxalbumarteditordialogimagethumbnailutil.h" |
|
54 #include "mpxalbumarteditordialog.h" |
|
55 #include "mpxviewprivatepskeys.h" |
|
56 |
|
57 // CONSTANTS |
|
58 const TInt KMPXAlbumArtBorder = 24; |
|
59 |
|
60 _LIT( KMPXAlubmArtEditorRscPath, "mpxalbumarteditordialog.rsc" ); |
|
61 |
|
62 // ============================ MEMBER FUNCTIONS =============================== |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMPXAlbumArtEditorDialog::NewL |
|
66 // Two-phased constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C CMPXAlbumArtEditorDialog* CMPXAlbumArtEditorDialog::NewL() |
|
70 { |
|
71 MPX_FUNC( "CMPXAlbumArtEditorDialog::NewL" ); |
|
72 CMPXAlbumArtEditorDialog* self = |
|
73 new ( ELeave ) CMPXAlbumArtEditorDialog(); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL( R_MPX_CUI_ALBUM_ART_DIALOG_MENUBAR ); |
|
76 CleanupStack::Pop( self ); // this, it will be PushL-d by executeLD... |
|
77 return self; |
|
78 } |
|
79 |
|
80 // Destructor |
|
81 EXPORT_C CMPXAlbumArtEditorDialog::~CMPXAlbumArtEditorDialog() |
|
82 { |
|
83 MPX_FUNC( "CMPXAlbumArtEditorDialog::~CMPXAlbumArtEditorDialog" ); |
|
84 if ( iResourceOffset ) |
|
85 { |
|
86 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
87 } |
|
88 if ( iCollectionUtility ) |
|
89 { |
|
90 iCollectionUtility->Close(); |
|
91 } |
|
92 |
|
93 delete iCommonUiHelper; |
|
94 delete iOrigTitle; |
|
95 delete iNaviLabelPane; |
|
96 delete iMPXUtility; |
|
97 delete iParam; |
|
98 delete iMedia; |
|
99 delete iAlbumInfo; |
|
100 delete iMediaArray; |
|
101 delete iNewFileName; |
|
102 delete iAsyncCallNext; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CMPXAlbumArtEditorDialog::OfferKeyEventL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TKeyResponse CMPXAlbumArtEditorDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
110 TEventCode aType) |
|
111 { |
|
112 if( iFetchingPicture ) |
|
113 { |
|
114 // fix for ou1cimx1#176793 |
|
115 if ( aKeyEvent.iScanCode == EStdKeyEnter || aKeyEvent.iCode == EKeyEnter ) |
|
116 { |
|
117 return EKeyWasConsumed; |
|
118 } |
|
119 // When the fetcher is open ignore all key presses. |
|
120 // Needed to avoid closing of the dialog before the fetcher is closed. |
|
121 return EKeyWasNotConsumed; |
|
122 } |
|
123 |
|
124 //response enter key as select key |
|
125 if( aKeyEvent.iScanCode == EStdKeyEnter || aKeyEvent.iScanCode == EKeyEnter ) |
|
126 { |
|
127 if( aType == EEventKeyUp ) |
|
128 { |
|
129 DoProcessCommandL( EMPXCmdAlbumArtEditorDlgChange ); |
|
130 } |
|
131 |
|
132 return EKeyWasConsumed; |
|
133 } |
|
134 |
|
135 return CAknDialog::OfferKeyEventL(aKeyEvent,aType); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMPXAlbumArtEditorDialog::CMPXAlbumArtEditorDialog |
|
140 // C++ default constructor can NOT contain any code, that |
|
141 // might leave. |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 CMPXAlbumArtEditorDialog::CMPXAlbumArtEditorDialog() : |
|
145 iNewFileName( NULL ) |
|
146 { |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------- |
|
150 // CMPXAlbumArtEditorDialog::SetParamL |
|
151 // parameter passed in from viewframework |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C void CMPXAlbumArtEditorDialog::SetParamL( const TDesC* aParam ) |
|
155 { |
|
156 MPX_FUNC( "CMPXAlbumArtEditorDialog::SetParamL" ); |
|
157 delete iParam; |
|
158 iParam = NULL; |
|
159 iParam = aParam->AllocL(); |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CMPXAlbumArtEditorDialog::ConstructL |
|
164 // (other items were commented in a header). |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void CMPXAlbumArtEditorDialog::ConstructL( TInt aResource ) |
|
168 { |
|
169 MPX_FUNC( "CMPXAlbumArtEditorDialog::ConstructL" ); |
|
170 CCoeEnv* coeEnv = iEikonEnv; |
|
171 TParse parse; |
|
172 parse.Set( KMPXAlubmArtEditorRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
173 TFileName resourceFile( parse.FullName() ); |
|
174 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
175 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
176 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
177 |
|
178 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault ); |
|
179 iMPXUtility = CMPXAlbumArtUtil::NewL(); |
|
180 |
|
181 iCommonUiHelper = CMPXCommonUiHelper::NewL(); |
|
182 |
|
183 CAknDialog::ConstructL( aResource ); |
|
184 |
|
185 iAsyncCallNext = new ( ELeave ) CAsyncCallBack( |
|
186 TCallBack( CMPXAlbumArtEditorDialog::ExtractNextAlbumArtCallBackL, this ), |
|
187 CActive::EPriorityStandard ); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // From MMPXCollectionObserver |
|
192 // Handle collection message. |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CMPXAlbumArtEditorDialog::HandleCollectionMessage( |
|
196 CMPXMessage* aMessage, TInt aError ) |
|
197 { |
|
198 if ( aError == KErrNone && aMessage ) |
|
199 { |
|
200 TRAP_IGNORE( DoHandleCollectionMessageL( *aMessage ) ); |
|
201 } |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // From MMPXCollectionObserver |
|
206 // Handles the collection entries being opened. Typically called |
|
207 // when client has Open()'d a folder |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CMPXAlbumArtEditorDialog::HandleOpenL( |
|
211 const CMPXMedia& /*aEntries*/, |
|
212 TInt /*aIndex*/, TBool /*aComplete*/, TInt /*aError*/ ) |
|
213 { |
|
214 // do nothing |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // From MMPXCollectionObserver |
|
219 // Handles the item being opened. Typically called |
|
220 // when client has Open()'d an item. Client typically responds by |
|
221 // 'playing' the item via the playlist |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CMPXAlbumArtEditorDialog::HandleOpenL( |
|
225 const CMPXCollectionPlaylist& /*aPlaylist*/, TInt /*aError*/ ) |
|
226 { |
|
227 // do nothing |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // From MMPXCollectionObserver |
|
232 // Handle collection media. |
|
233 // Notes: The client is responsible for delete the object of aMedia. |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void CMPXAlbumArtEditorDialog::HandleCollectionMediaL( |
|
237 const CMPXMedia& aMedia, |
|
238 TInt aError ) |
|
239 { |
|
240 MPX_FUNC( "CMPXAlbumArtEditorDialog::HandleCollectionMediaL" ); |
|
241 if ( KErrNone == aError ) |
|
242 { |
|
243 switch ( iCurrentMediaLOp ) |
|
244 { |
|
245 case EMPXOpMediaLGetCurrentMode: |
|
246 { |
|
247 TMPXGeneralType type( aMedia.ValueTObjectL<TMPXGeneralType>( |
|
248 KMPXMediaGeneralType ) ); |
|
249 TMPXGeneralCategory category( |
|
250 aMedia.ValueTObjectL<TMPXGeneralCategory>( |
|
251 KMPXMediaGeneralCategory ) ); |
|
252 |
|
253 if ( type != EMPXItem || category != EMPXSong ) |
|
254 { |
|
255 delete iMedia; |
|
256 iMedia = NULL; |
|
257 iMedia = CMPXMedia::NewL(); |
|
258 TMPXItemId albumId( aMedia.ValueTObjectL<TMPXItemId>( |
|
259 KMPXMediaGeneralId ) ); |
|
260 iMedia->SetTObjectValueL<TMPXItemId>( |
|
261 KMPXMediaGeneralId, |
|
262 albumId ); |
|
263 // not on tracks level, get container ID |
|
264 iCurrentMediaLOp = EMPXOpMediaLGetContainerId; |
|
265 CMPXCollectionPath* path( iCollectionUtility->Collection().PathL() ); |
|
266 CleanupStack::PushL( path ); |
|
267 path->Back(); |
|
268 RArray<TMPXAttribute> attrs; |
|
269 CleanupClosePushL( attrs ); |
|
270 // get attributes as if it's tracks level so that we don't need to |
|
271 // make another async call if that's the case. if it's album level, those |
|
272 // attributes are ignored |
|
273 attrs.Append( |
|
274 TMPXAttribute( KMPXMediaIdGeneral, |
|
275 EMPXMediaGeneralId | EMPXMediaGeneralCategory ) ); |
|
276 iCollectionUtility->Collection().MediaL( *path, attrs.Array() ); |
|
277 CleanupStack::PopAndDestroy( &attrs ); |
|
278 CleanupStack::PopAndDestroy( path ); |
|
279 } |
|
280 else |
|
281 { |
|
282 delete iMedia; |
|
283 iMedia = NULL; |
|
284 iMedia = CMPXMedia::NewL( aMedia ); |
|
285 delete iAlbumInfo; |
|
286 iAlbumInfo = NULL; |
|
287 iAlbumInfo = CMPXMedia::NewL( aMedia ); |
|
288 const TDesC& albumArtFileName = |
|
289 aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
290 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleCollectionMediaL album art file name = %S", &albumArtFileName ); |
|
291 const TDesC& origAlbumArtFileName = |
|
292 aMedia.ValueText( KMPXMediaMusicOriginalAlbumArtFileName ); |
|
293 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleCollectionMediaL original album art file name = %S", &origAlbumArtFileName ); |
|
294 if ( albumArtFileName.Length() > 0 ) |
|
295 { |
|
296 if ( albumArtFileName.Compare( origAlbumArtFileName ) == 0 ) |
|
297 { |
|
298 iAlbumArtChanged = EFalse; |
|
299 } |
|
300 else |
|
301 { |
|
302 iAlbumArtChanged = ETrue; |
|
303 } |
|
304 } |
|
305 ExtractAlbumArtL( aMedia ); |
|
306 iCurrentMediaLOp = EMPXOpMediaLIdle; |
|
307 } |
|
308 // Navipane title should be the title of the artist/album/genre/composer or song/item |
|
309 // |
|
310 UpdateNaviPaneL(aMedia.ValueText(KMPXMediaGeneralTitle )); |
|
311 break; |
|
312 } |
|
313 case EMPXOpMediaLGetContainerId: |
|
314 { |
|
315 delete iAlbumInfo; |
|
316 iAlbumInfo = NULL; |
|
317 iAlbumInfo = CMPXMedia::NewL(); |
|
318 TMPXGeneralCategory category( |
|
319 aMedia.ValueTObjectL<TMPXGeneralCategory>( |
|
320 KMPXMediaGeneralCategory ) ); |
|
321 TMPXItemId albumId( |
|
322 iMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
323 iAlbumInfo->SetTObjectValueL<TMPXItemId>( |
|
324 KMPXMediaGeneralId, albumId ); |
|
325 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleCollectionMediaL album id = 0x%x", albumId.iId1 ); |
|
326 RArray<TMPXAttribute> attrs; |
|
327 CleanupClosePushL( attrs ); |
|
328 AppendCommonAttributes( attrs ); |
|
329 CMPXMedia* criteria = CMPXMedia::NewL(); |
|
330 CleanupStack::PushL( criteria ); |
|
331 criteria->SetTObjectValueL<TMPXGeneralType>( |
|
332 KMPXMediaGeneralType, EMPXGroup ); |
|
333 criteria->SetTObjectValueL<TMPXGeneralCategory>( |
|
334 KMPXMediaGeneralCategory, EMPXSong ); |
|
335 criteria->SetTObjectValueL<TMPXItemId>( |
|
336 KMPXMediaGeneralId, albumId ); |
|
337 if ( category == EMPXAlbum ) |
|
338 { |
|
339 // in albums view |
|
340 iAlbumArtMode = EMPXModeAlbumView; |
|
341 } |
|
342 else |
|
343 { |
|
344 // in artist/albums view |
|
345 iAlbumArtMode = EMPXModeArtistAlbumView; |
|
346 TMPXItemId containerId( aMedia.ValueTObjectL<TMPXItemId>( |
|
347 KMPXMediaGeneralId ) ); |
|
348 iAlbumInfo->SetTObjectValueL<TMPXItemId>( |
|
349 KMPXMediaGeneralContainerId, containerId ); |
|
350 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleCollectionMediaL container id = 0x%x", containerId.iId1 ); |
|
351 criteria->SetTObjectValueL<TMPXItemId>( |
|
352 KMPXMediaGeneralContainerId, containerId ); |
|
353 } |
|
354 iCurrentFindAllLOp = EMPXOpFindAllLGetAlbumArtInfo; |
|
355 iCollectionUtility->Collection().FindAllL( *criteria, attrs.Array(), *this ); |
|
356 CleanupStack::PopAndDestroy( criteria ); |
|
357 CleanupStack::PopAndDestroy( &attrs ); |
|
358 iCurrentMediaLOp = EMPXOpMediaLIdle; |
|
359 break; |
|
360 } |
|
361 case EMPXOpMediaLGetAlbumArtInfo: |
|
362 { |
|
363 delete iMedia; |
|
364 iMedia = NULL; |
|
365 iMedia = CMPXMedia::NewL( aMedia ); |
|
366 const TDesC& albumArtFileName = |
|
367 aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
368 if ( albumArtFileName.Length() > 0 ) |
|
369 { |
|
370 if ( albumArtFileName.Compare( |
|
371 aMedia.ValueText( KMPXMediaMusicOriginalAlbumArtFileName ) ) == 0 ) |
|
372 { |
|
373 iAlbumArtChanged = EFalse; |
|
374 } |
|
375 else |
|
376 { |
|
377 iAlbumArtChanged = ETrue; |
|
378 } |
|
379 } |
|
380 ExtractAlbumArtL( aMedia ); |
|
381 iCurrentMediaLOp = EMPXOpMediaLIdle; |
|
382 break; |
|
383 } |
|
384 default: |
|
385 { |
|
386 iCurrentMediaLOp = EMPXOpMediaLIdle; |
|
387 break; |
|
388 } |
|
389 } |
|
390 } |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CMPXAlbumArtEditorDialog::HandleCommandComplete |
|
395 // Handle completion of async commands |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CMPXAlbumArtEditorDialog::HandleCommandComplete(CMPXCommand* /*aCommandResult*/, |
|
399 TInt aError ) |
|
400 { |
|
401 MPX_FUNC( "CMPXAlbumArtEditorDialog::HandleCommandComplete" ); |
|
402 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleCommandComplete aError = %d", aError ); |
|
403 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::HandleCommandComplete dismiss wait note" ); |
|
404 if( !iInvalidFileExist ) |
|
405 { |
|
406 TRAP_IGNORE( DoHandleOperationCompleteL( aError ) ); |
|
407 } |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CMPXAlbumArtEditorDialog::GetCurrentModeL |
|
412 // Sends request to determine if it's album level or track level |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 void CMPXAlbumArtEditorDialog::GetCurrentModeL() |
|
416 { |
|
417 MPX_FUNC( "CMPXAlbumArtEditorDialog::GetCurrentModeL" ); |
|
418 iCurrentMediaLOp = EMPXOpMediaLGetCurrentMode; |
|
419 CMPXCollectionPath* path = iCollectionUtility->Collection().PathL(); |
|
420 CleanupStack::PushL( path ); |
|
421 if ( iParam ) |
|
422 { |
|
423 TLex indexLex( iParam->Des() ); |
|
424 TInt lexToInt = NULL; |
|
425 if ( indexLex.Val( lexToInt ) == KErrNone ) |
|
426 { |
|
427 path->Set( lexToInt ); |
|
428 } |
|
429 } |
|
430 RArray<TMPXAttribute> attrs; |
|
431 CleanupClosePushL( attrs ); |
|
432 // get attributes as if it's tracks level so that we don't need to |
|
433 // make another async call if that's the case. if it's album level, those |
|
434 // attributes are ignored |
|
435 AppendCommonAttributes( attrs ); |
|
436 attrs.Append( KMPXMediaGeneralTitle ); |
|
437 iCollectionUtility->Collection().MediaL( *path, attrs.Array() ); |
|
438 CleanupStack::PopAndDestroy( &attrs ); |
|
439 CleanupStack::PopAndDestroy( path ); |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CMPXAlbumArtEditorDialog::BackupPreviousStatusPaneL |
|
444 // Backs up Status Pane information. |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 void CMPXAlbumArtEditorDialog::BackupPreviousStatusPaneL() |
|
448 { |
|
449 MPX_FUNC( "CMPXAlbumArtEditorDialog::BackupPreviousStatusPaneL" ); |
|
450 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
451 // Create and Push navi lable |
|
452 iNaviPane = static_cast< CAknNavigationControlContainer* > |
|
453 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
454 iNaviLabelPane = iNaviPane->CreateNavigationLabelL(); |
|
455 iNaviPane->PushL( *iNaviLabelPane ); |
|
456 // Backup title pane |
|
457 iTitlePane = static_cast< CAknTitlePane* > |
|
458 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
459 iOrigTitle = iTitlePane->Text()->AllocL(); |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CMPXAlbumArtEditorDialog::RestorePreviousStatusPaneL() |
|
464 // Restores previous status pane. |
|
465 // ----------------------------------------------------------------------------- |
|
466 // |
|
467 void CMPXAlbumArtEditorDialog::RestorePreviousStatusPaneL() |
|
468 { |
|
469 MPX_FUNC( "CMPXAlbumArtEditorDialog::RestorePreviousStatusPaneL" ); |
|
470 if ( iOrigTitle ) |
|
471 { |
|
472 // Set original title pane |
|
473 iTitlePane->SetTextL( *iOrigTitle ); |
|
474 } |
|
475 // Restore original navi pane |
|
476 iNaviPane->Pop( iNaviLabelPane ); |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CMPXAlbumArtEditorDialog::FindCustomControlContainer |
|
481 // Returns the Custom Control Container. |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 CMPXAlbumArtEditorDialogCustomControl *CMPXAlbumArtEditorDialog:: |
|
485 GetAlbumArtEditorDialogCustomControl() const |
|
486 { |
|
487 MPX_FUNC( "CMPXAlbumArtEditorDialog::GetAlbumArtEditorDialogCustomControl" ); |
|
488 CMPXAlbumArtEditorCustomControlContainer *control = |
|
489 ( CMPXAlbumArtEditorCustomControlContainer* ) |
|
490 ControlOrNull ( EMPXAlbumArtEditorDlgCtrlId ); |
|
491 if ( control ) |
|
492 { |
|
493 return control->iDialogCustomControl; |
|
494 } |
|
495 return NULL; |
|
496 } |
|
497 |
|
498 // ---------------------------------------------------------------------------- |
|
499 // CMPXAlbumArtEditorDialog::LoadAlbumArtL |
|
500 // loads album art information from the database |
|
501 // ---------------------------------------------------------------------------- |
|
502 // |
|
503 void CMPXAlbumArtEditorDialog::LoadAlbumArtL( TBool aShowWaitNote ) |
|
504 { |
|
505 MPX_FUNC( "CMPXAlbumArtEditorDialog::LoadAlbumArtL" ); |
|
506 HBufC* string = StringLoader::LoadLC( R_MPX_QTN_NMP_NOTE_OPENING ); |
|
507 |
|
508 if( aShowWaitNote ) // show wait note only when needed |
|
509 { |
|
510 iCommonUiHelper->ShowWaitNoteL( *string, R_AVKON_SOFTKEYS_EMPTY, EFalse, this ); |
|
511 } |
|
512 |
|
513 CleanupStack::PopAndDestroy( string ); |
|
514 RArray<TMPXAttribute> attrs; |
|
515 CleanupClosePushL( attrs ); |
|
516 if ( !iAlbumInfo ) |
|
517 { |
|
518 if ( iCurrentMediaLOp == EMPXOpMediaLIdle ) |
|
519 { |
|
520 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL Using MediaL" ); |
|
521 if ( iAlbumArtMode == EMPXModeTracksView ) |
|
522 { |
|
523 iCurrentMediaLOp = EMPXOpMediaLGetAlbumArtInfo; |
|
524 AppendCommonAttributes( attrs ); |
|
525 } |
|
526 else |
|
527 { |
|
528 iCurrentMediaLOp = EMPXOpMediaLGetCurrentMode; |
|
529 // get attributes as if it's tracks level so that we don't need to |
|
530 // make another async call if that's the case. if it's album level, those |
|
531 // attributes are ignored |
|
532 attrs.Append( |
|
533 TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralType | |
|
534 EMPXMediaGeneralCategory | EMPXMediaGeneralId | EMPXMediaGeneralTitle ) ); |
|
535 } |
|
536 |
|
537 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
538 CleanupStack::PushL( cpath ); |
|
539 if ( iParam ) |
|
540 { |
|
541 TLex indexLex( iParam->Des() ); |
|
542 TInt lexToInt = NULL; |
|
543 if ( indexLex.Val( lexToInt ) == KErrNone ) |
|
544 { |
|
545 cpath->Set( lexToInt ); |
|
546 } |
|
547 } |
|
548 iCollectionUtility->Collection().MediaL( *cpath, attrs.Array() ); |
|
549 CleanupStack::PopAndDestroy( cpath ); |
|
550 } |
|
551 else |
|
552 { |
|
553 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL is busy, not loading again" ); |
|
554 } |
|
555 } |
|
556 else |
|
557 { |
|
558 if ( iCurrentFindAllLOp == EMPXOpFindAllLIdle ) |
|
559 { |
|
560 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL Using FindAllL" ); |
|
561 // iAlbumInfo is valid, something has been fetched before |
|
562 CMPXMedia* criteria = CMPXMedia::NewL(); |
|
563 CleanupStack::PushL( criteria ); |
|
564 criteria->SetTObjectValueL<TMPXGeneralCategory>( |
|
565 KMPXMediaGeneralCategory, EMPXSong ); |
|
566 TMPXItemId itemId( |
|
567 iAlbumInfo->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
568 criteria->SetTObjectValueL<TMPXItemId>( |
|
569 KMPXMediaGeneralId, itemId ); |
|
570 AppendCommonAttributes( attrs ); |
|
571 switch ( iAlbumArtMode ) |
|
572 { |
|
573 case EMPXModeTracksView: |
|
574 { |
|
575 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL EMPXModeTracksView" ); |
|
576 criteria->SetTObjectValueL<TMPXGeneralType>( |
|
577 KMPXMediaGeneralType, EMPXItem ); |
|
578 iCurrentFindAllLOp = EMPXOpFindAllLGetTrackArtInfo; |
|
579 break; |
|
580 } |
|
581 case EMPXModeArtistAlbumView: |
|
582 { |
|
583 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL EMPXModeArtistAlbumView" ); |
|
584 TMPXItemId containerId( |
|
585 iAlbumInfo->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralContainerId ) ); |
|
586 criteria->SetTObjectValueL<TMPXItemId>( |
|
587 KMPXMediaGeneralContainerId, containerId ); |
|
588 } // fall through on purpose |
|
589 case EMPXModeAlbumView: |
|
590 { |
|
591 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL EMPXModeAlbumView" ); |
|
592 criteria->SetTObjectValueL<TMPXGeneralType>( |
|
593 KMPXMediaGeneralType, EMPXGroup ); |
|
594 iCurrentFindAllLOp = EMPXOpFindAllLGetAlbumArtInfo; |
|
595 break; |
|
596 } |
|
597 } |
|
598 iCollectionUtility->Collection().FindAllL( *criteria, attrs.Array(), *this ); |
|
599 CleanupStack::PopAndDestroy( criteria ); |
|
600 } |
|
601 else |
|
602 { |
|
603 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::LoadAlbumArtL is busy, not loading again" ); |
|
604 } |
|
605 } |
|
606 |
|
607 CleanupStack::PopAndDestroy( &attrs ); |
|
608 } |
|
609 |
|
610 // ---------------------------------------------------------------------------- |
|
611 // CMPXAlbumArtEditorDialog::ExtractAlbumArtL |
|
612 // extracts the album art |
|
613 // ---------------------------------------------------------------------------- |
|
614 // |
|
615 void CMPXAlbumArtEditorDialog::ExtractAlbumArtL( |
|
616 const CMPXMedia& aMedia, TBool aDismissWaitNoteOnError ) |
|
617 { |
|
618 MPX_FUNC( "CMPXAlbumArtEditorDialog::ExtractAlbumArtL" ); |
|
619 TInt err( KErrNone ); |
|
620 |
|
621 CMPXAlbumArtEditorDialogCustomControl* control = |
|
622 GetAlbumArtEditorDialogCustomControl(); |
|
623 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::ExtractAlbumArtL filename length = %d", aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).Length() ); |
|
624 MPX_TRAP( err, |
|
625 iMPXUtility->ExtractAlbumArtL( |
|
626 aMedia, |
|
627 *control, |
|
628 iModRect.Size() ) ); |
|
629 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::ExtractAlbumArtL err = %d", err ); |
|
630 if ( KErrNone != err ) |
|
631 { |
|
632 if ( aDismissWaitNoteOnError ) |
|
633 { |
|
634 // If error, show default album art |
|
635 GetAlbumArtEditorDialogCustomControl()->SetModeL( |
|
636 CMPXAlbumArtEditorDialogCustomControl:: |
|
637 EMPXAlbumArtEditorDialogNoAlbumArt ); |
|
638 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::ExtractAlbumArtL show default album art" ); |
|
639 iCommonUiHelper->DismissWaitNoteL(); |
|
640 DrawDeferred(); |
|
641 } |
|
642 else |
|
643 { |
|
644 User::Leave( err ); |
|
645 } |
|
646 } |
|
647 } |
|
648 |
|
649 // ---------------------------------------------------------------------------- |
|
650 // CMPXAlbumArtEditorDialog::ExtractMultipleAlbumArtL |
|
651 // control extract of multiple album art |
|
652 // ---------------------------------------------------------------------------- |
|
653 // |
|
654 void CMPXAlbumArtEditorDialog::ExtractMultipleAlbumArtL() |
|
655 { |
|
656 MPX_FUNC( "CMPXAlbumArtEditorDialog::ExtractMultipleAlbumArtL" ); |
|
657 if ( iMediaArray ) |
|
658 { |
|
659 if ( !iAsyncCallNext->IsActive() ) |
|
660 { |
|
661 iAsyncCallNext->Call(); |
|
662 } |
|
663 } |
|
664 else |
|
665 { |
|
666 User::Leave( KErrArgument ); |
|
667 } |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // CMPXAlbumArtEditorDialog::SaveMediaL |
|
672 // Saves the updated media. |
|
673 // ----------------------------------------------------------------------------- |
|
674 // |
|
675 CMPXMedia* CMPXAlbumArtEditorDialog::SaveMediaLC( |
|
676 const TDesC& aFileName, TBool aIsRestore ) |
|
677 { |
|
678 MPX_FUNC( "CMPXAlbumArtEditorDialog::SaveMediaL" ); |
|
679 CMPXMedia* media = CMPXMedia::NewL(); |
|
680 CleanupStack::PushL( media ); |
|
681 TBool ret( ETrue ); |
|
682 |
|
683 if ( iMedia->IsSupported( KMPXMediaGeneralUri ) ) |
|
684 { |
|
685 const TDesC& uri = iMedia->ValueText( KMPXMediaGeneralUri ); |
|
686 TBool isCorrupted( EFalse ); |
|
687 if ( iMedia->IsSupported( KMPXMediaGeneralFlags ) ) |
|
688 { |
|
689 TUint flags = iMedia->ValueTObjectL<TUint>( KMPXMediaGeneralFlags ); |
|
690 isCorrupted = ( ( flags ) & ( KMPXMediaGeneralFlagsIsCorrupted ) ); |
|
691 } |
|
692 if ( ConeUtils::FileExists( uri ) && !isCorrupted ) |
|
693 { |
|
694 media->SetTextValueL( KMPXMediaGeneralUri, uri ); |
|
695 } |
|
696 else |
|
697 { |
|
698 iInvalidFileExist = ETrue; |
|
699 ret = EFalse; |
|
700 if ( !isCorrupted ) |
|
701 { |
|
702 // set invalid flag in database if it's invalid |
|
703 TUint flags( KMPXMediaGeneralFlagsSetOrUnsetBit ); |
|
704 flags |= KMPXMediaGeneralFlagsIsInvalid; |
|
705 CMPXMedia* entry = CMPXMedia::NewL(); |
|
706 CleanupStack::PushL( entry ); |
|
707 TMPXItemId id( iMedia->ValueTObjectL<TMPXItemId>( |
|
708 KMPXMediaGeneralId ) ); |
|
709 TMPXGeneralType type( |
|
710 iMedia->ValueTObjectL<TMPXGeneralType>( |
|
711 KMPXMediaGeneralType ) ); |
|
712 TMPXGeneralCategory category( |
|
713 iMedia->ValueTObjectL<TMPXGeneralCategory>( |
|
714 KMPXMediaGeneralCategory ) ); |
|
715 TUid collectionId( iMedia->ValueTObjectL<TUid>( |
|
716 KMPXMediaGeneralCollectionId ) ); |
|
717 entry->SetTObjectValueL<TMPXItemId>( |
|
718 KMPXMediaGeneralId, id ); |
|
719 entry->SetTObjectValueL<TMPXGeneralType>( |
|
720 KMPXMediaGeneralType, type ); |
|
721 entry->SetTObjectValueL<TMPXGeneralCategory>( |
|
722 KMPXMediaGeneralCategory, category ); |
|
723 entry->SetTObjectValueL<TUid>( |
|
724 KMPXMediaGeneralCollectionId, collectionId ); |
|
725 entry->SetTObjectValueL<TUint>( |
|
726 KMPXMediaGeneralFlags, flags ); |
|
727 |
|
728 DoSetCollectionL( entry, ETrue ); |
|
729 CleanupStack::PopAndDestroy( entry ); |
|
730 } |
|
731 } |
|
732 } |
|
733 if ( ret ) |
|
734 { |
|
735 if ( iMedia->IsSupported( KMPXMediaGeneralType ) ) |
|
736 { |
|
737 media->SetTObjectValueL<TInt>( |
|
738 KMPXMediaGeneralType, |
|
739 *iMedia->Value<TInt>( KMPXMediaGeneralType ) ); |
|
740 } |
|
741 |
|
742 if ( iMedia->IsSupported( KMPXMediaGeneralCategory ) ) |
|
743 { |
|
744 media->SetTObjectValueL<TInt>( |
|
745 KMPXMediaGeneralCategory, |
|
746 *iMedia->Value<TInt>( KMPXMediaGeneralCategory ) ); |
|
747 } |
|
748 |
|
749 if ( iMedia->IsSupported( KMPXMediaGeneralId ) ) |
|
750 { |
|
751 TMPXItemId id( iMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
752 media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id ); |
|
753 } |
|
754 |
|
755 if ( iMedia->IsSupported( KMPXMediaGeneralCollectionId ) ) |
|
756 { |
|
757 media->SetTObjectValueL<TUid>( |
|
758 KMPXMediaGeneralCollectionId, |
|
759 *iMedia->Value<TUid>( KMPXMediaGeneralCollectionId ) ); |
|
760 } |
|
761 |
|
762 media->SetTextValueL( |
|
763 KMPXMediaMusicAlbumArtFileName, aFileName ); |
|
764 |
|
765 } |
|
766 else // Broken link, cannot ben saved |
|
767 { |
|
768 CleanupStack::PopAndDestroy( media ); |
|
769 media = NULL; |
|
770 } |
|
771 |
|
772 iAlbumArtChanged = !aIsRestore; |
|
773 return media; // ownership transferred |
|
774 } |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CMPXAlbumArtEditorDialog::SaveMultipleMediaL |
|
778 // Saves multiple media. |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 void CMPXAlbumArtEditorDialog::SaveMultipleMediaL( TBool aIsRestore ) |
|
782 { |
|
783 MPX_FUNC( "CMPXAlbumArtEditorDialog::SaveMultipleMediaL" ); |
|
784 TInt currentAlbumArtIndex = iMediaArray->Count(); |
|
785 |
|
786 CMPXMediaArray* setArray( CMPXMediaArray::NewL() ); |
|
787 CleanupStack::PushL( setArray ); |
|
788 for ( TInt i = 0; i < currentAlbumArtIndex && iIsSaving; i++ ) |
|
789 { |
|
790 delete iMedia; |
|
791 iMedia = NULL; |
|
792 CMPXMedia* origMedia( iMediaArray->AtL( i ) ); |
|
793 iMedia = CMPXMedia::NewL( *origMedia ); |
|
794 if ( iNewFileName ) |
|
795 { |
|
796 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::SaveMultipleMediaL setting %d", i ); |
|
797 CMPXMedia* media = SaveMediaLC( *iNewFileName, aIsRestore ); |
|
798 if( media ) |
|
799 { |
|
800 setArray->AppendL( *media ); |
|
801 CleanupStack::PopAndDestroy(); |
|
802 } |
|
803 } |
|
804 else |
|
805 { |
|
806 const TDesC& originalAlbumArtFileName = |
|
807 iMedia->ValueText( KMPXMediaMusicOriginalAlbumArtFileName ); |
|
808 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::SaveMultipleMediaL restoring %d", i ); |
|
809 CMPXMedia* media = SaveMediaLC( originalAlbumArtFileName, aIsRestore ); |
|
810 if( media ) |
|
811 { |
|
812 setArray->AppendL( *media ); |
|
813 CleanupStack::PopAndDestroy(); |
|
814 } |
|
815 } |
|
816 } |
|
817 // Save the list of changes |
|
818 // |
|
819 if( setArray->Count() > 0 ) |
|
820 { |
|
821 CMPXMedia* groupMedia( CMPXMedia::NewL() ); |
|
822 CleanupStack::PushL( groupMedia ); |
|
823 groupMedia->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup); |
|
824 groupMedia->SetCObjectValueL<CMPXMediaArray>(KMPXMediaArrayContents, setArray ); |
|
825 CMPXMedia* first( setArray->AtL( 0 ) ); |
|
826 TUid colId( first->ValueTObjectL<TUid>(KMPXMediaGeneralCollectionId) ); |
|
827 groupMedia->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, colId ); |
|
828 DoSetCollectionL( groupMedia, EFalse ); |
|
829 CleanupStack::PopAndDestroy( groupMedia ); |
|
830 } |
|
831 CleanupStack::PopAndDestroy( setArray ); |
|
832 |
|
833 if ( iInvalidFileExist ) |
|
834 { |
|
835 if ( !aIsRestore ) |
|
836 { |
|
837 // if it's a change operation and nothing is changed |
|
838 iAlbumArtChanged = EFalse; |
|
839 } |
|
840 // all songs are invalid, show note right now instead |
|
841 // there will be no callback from collection |
|
842 MPX_DEBUG1("CMPXAlbumArtEditorDialog::SaveMultipleMediaL DoHandleOperationCompleteL"); |
|
843 DoHandleOperationCompleteL( KErrNone ); |
|
844 } |
|
845 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::SaveMultipleMediaL valid count = %d", currentAlbumArtIndex ); |
|
846 } |
|
847 |
|
848 // ----------------------------------------------------------------------------- |
|
849 // CMPXAlbumArtEditorDialog::DoHandleOperationCompleteL |
|
850 // Handle save operation complete. |
|
851 // ----------------------------------------------------------------------------- |
|
852 // |
|
853 void CMPXAlbumArtEditorDialog::DoHandleOperationCompleteL( TInt aError ) |
|
854 { |
|
855 MPX_FUNC( "CMPXAlbumArtEditorDialog::DoHandleOperationCompleteL" ); |
|
856 iCurrentAlbumArtIndex = KErrNotFound; |
|
857 iIsSaving = EFalse; |
|
858 iCommonUiHelper->DismissWaitNoteL(); |
|
859 if (( aError == KErrNone ) && (!iInvalidFileExist )) |
|
860 { |
|
861 if (iAlbumArtMode == EMPXModeTracksView ) |
|
862 { |
|
863 if (iMedia ) |
|
864 { |
|
865 if (iNewFileName ) |
|
866 { |
|
867 iMedia->SetTextValueL (KMPXMediaMusicAlbumArtFileName, |
|
868 *iNewFileName ); |
|
869 } |
|
870 else |
|
871 { |
|
872 const TDesC& originalAlbumArtFileName = |
|
873 iMedia->ValueText ( KMPXMediaMusicOriginalAlbumArtFileName ); |
|
874 iMedia->SetTextValueL (KMPXMediaMusicAlbumArtFileName, |
|
875 originalAlbumArtFileName ); |
|
876 } |
|
877 } |
|
878 } |
|
879 else |
|
880 { |
|
881 if (iMediaArray ) |
|
882 { |
|
883 TInt currentAlbumArtIndex = iMediaArray->Count ( ); |
|
884 |
|
885 for (TInt i = 0; i < currentAlbumArtIndex && iIsSaving; i++ ) |
|
886 { |
|
887 delete iMedia; |
|
888 iMedia = NULL; |
|
889 CMPXMedia* origMedia( iMediaArray->AtL ( i )); |
|
890 iMedia = CMPXMedia::NewL ( *origMedia ); |
|
891 if ( iNewFileName ) |
|
892 { |
|
893 iMedia->SetTextValueL (KMPXMediaMusicAlbumArtFileName, |
|
894 *iNewFileName ); |
|
895 } |
|
896 else |
|
897 { |
|
898 const TDesC& originalAlbumArtFileName = |
|
899 iMedia->ValueText ( KMPXMediaMusicOriginalAlbumArtFileName ); |
|
900 iMedia->SetTextValueL (KMPXMediaMusicAlbumArtFileName, |
|
901 originalAlbumArtFileName ); |
|
902 } |
|
903 } |
|
904 } |
|
905 } |
|
906 } |
|
907 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::DoHandleOperationCompleteL iOpCanceled = %d", iOpCanceled ); |
|
908 if ( aError == KErrNone ) |
|
909 { |
|
910 if ( !iOpCanceled ) |
|
911 { |
|
912 HBufC* string = NULL; |
|
913 if ( iInvalidFileExist ) |
|
914 { |
|
915 if ( iNewFileName ) |
|
916 { |
|
917 // new filename is defined, albumart change |
|
918 // invalid file exist |
|
919 string = StringLoader::LoadLC( |
|
920 R_MPX_QTN_NMP_NOTE_CHANGE_WITH_INVALID ); |
|
921 } |
|
922 else |
|
923 { |
|
924 // new file name not defined, albumart restore |
|
925 // invalid file exist |
|
926 string = StringLoader::LoadLC( |
|
927 R_MPX_QTN_NMP_NOTE_RESTORE_WITH_INVALID ); |
|
928 } |
|
929 iCommonUiHelper->DisplayInfoNoteL( *string ); |
|
930 } |
|
931 else |
|
932 { |
|
933 if ( iNewFileName ) |
|
934 { |
|
935 // new filename is defined, albumart change |
|
936 string = StringLoader::LoadLC( |
|
937 R_MPX_QTN_NMP_NOTE_ART_CHANGED ); |
|
938 } |
|
939 else |
|
940 { |
|
941 // new file name not defined, albumart restore |
|
942 string = StringLoader::LoadLC( |
|
943 R_MPX_QTN_NMP_NOTE_ART_RESTORED ); |
|
944 } |
|
945 iCommonUiHelper->DisplayConfirmNoteL( *string ); |
|
946 } |
|
947 CleanupStack::PopAndDestroy( string ); |
|
948 } |
|
949 } |
|
950 else |
|
951 { |
|
952 iCommonUiHelper->HandleErrorL( aError ); |
|
953 } |
|
954 iOpCanceled = EFalse; |
|
955 iCurrentFindAllLOp = EMPXOpFindAllLIdle; |
|
956 LoadAlbumArtL( ETrue ); |
|
957 } |
|
958 |
|
959 // ----------------------------------------------------------------------------- |
|
960 // Handle collection message |
|
961 // ----------------------------------------------------------------------------- |
|
962 // |
|
963 void CMPXAlbumArtEditorDialog::DoHandleCollectionMessageL( const CMPXMessage& aMessage ) |
|
964 { |
|
965 MPX_FUNC( "CMPXAlbumArtEditorDialog::DoHandleCollectionMessageL" ); |
|
966 TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
967 if ( KMPXMessageGeneral == id ) |
|
968 { |
|
969 TInt event( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ); |
|
970 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::DoHandleCollectionMessageL Event = %d", event ); |
|
971 if ( event == TMPXCollectionMessage::EItemChanged ) |
|
972 { |
|
973 if ( iOpCanceled ) |
|
974 { |
|
975 DoHandleOperationCompleteL( KErrNone ); |
|
976 } |
|
977 } |
|
978 else if ( KMPXMessageIdItemChanged == id ) |
|
979 { |
|
980 if ( !iIsSaving ) |
|
981 { |
|
982 // ignore all the item change events when saving |
|
983 LoadAlbumArtL( ETrue ); |
|
984 } |
|
985 } |
|
986 } |
|
987 } |
|
988 |
|
989 // ----------------------------------------------------------------------------- |
|
990 // CMPXAlbumArtEditorDialog::DoSetCollectionL |
|
991 // Perform a set operation |
|
992 // ----------------------------------------------------------------------------- |
|
993 // |
|
994 void CMPXAlbumArtEditorDialog::DoSetCollectionL( CMPXMedia* aMedia, TBool aSync ) |
|
995 { |
|
996 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
997 CleanupStack::PushL( cmd ); |
|
998 |
|
999 cmd->SetTObjectValueL( KMPXCommandGeneralId, KMPXCommandIdCollectionSet ); |
|
1000 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync ); |
|
1001 TUid colId( aMedia->ValueTObjectL<TUid>( KMPXMediaGeneralCollectionId ) ); |
|
1002 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, colId.iUid ); |
|
1003 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColSetMedia, aMedia ); |
|
1004 |
|
1005 iCollectionUtility->Collection().CommandL( *cmd ); |
|
1006 CleanupStack::PopAndDestroy( cmd ); |
|
1007 } |
|
1008 |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // CMPXAlbumArtEditorDialog::AppendCommonAttributes |
|
1011 // Appends the common attributes to attributes array |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // |
|
1014 void CMPXAlbumArtEditorDialog::AppendCommonAttributes( |
|
1015 RArray<TMPXAttribute>& aAryAttribute ) |
|
1016 { |
|
1017 aAryAttribute.Append( |
|
1018 TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralUri |
|
1019 | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
|
1020 | EMPXMediaGeneralId | EMPXMediaGeneralCollectionId |
|
1021 | EMPXMediaGeneralFlags ) ); |
|
1022 aAryAttribute.Append( TMPXAttribute( KMPXMediaIdMusic, |
|
1023 EMPXMediaMusicAlbumArtFileName | |
|
1024 EMPXMediaMusicOriginalAlbumArtFileName ) ); |
|
1025 } |
|
1026 |
|
1027 // ----------------------------------------------------------------------------- |
|
1028 // CMPXAlbumArtEditorDialog::HandleAlbumArtEventL |
|
1029 // Handle album art events |
|
1030 // ----------------------------------------------------------------------------- |
|
1031 // |
|
1032 void CMPXAlbumArtEditorDialog::HandleAlbumArtEventL( |
|
1033 TMPXAlbumArtEvents /*aEvent*/, TInt aError ) |
|
1034 { |
|
1035 MPX_FUNC( "CMPXAlbumArtEditorDialog::HandleAlbumArtEventL" ); |
|
1036 if ( aError != KErrNone && iAlbumArtMode != EMPXModeTracksView ) |
|
1037 { |
|
1038 // continue to extract next album art if current one is not found |
|
1039 ExtractMultipleAlbumArtL(); |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleAlbumArtEventL extract Error = %d", aError ); |
|
1044 iCommonUiHelper->DismissWaitNoteL(); |
|
1045 } |
|
1046 } |
|
1047 |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 // CMPXAlbumArtEditorDialog::HandleFindAllL |
|
1050 // Handle callback for "find" operation |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // |
|
1053 void CMPXAlbumArtEditorDialog::HandleFindAllL( |
|
1054 const CMPXMedia& aResults, |
|
1055 TBool /*aComplete*/, |
|
1056 TInt aError ) |
|
1057 { |
|
1058 MPX_DEBUG2( "-->CMPXAlbumArtEditorDialog::HandleFindAllL Error = %d", aError ); |
|
1059 switch ( iCurrentFindAllLOp ) |
|
1060 { |
|
1061 case EMPXOpFindAllLGetAlbumArtInfo: |
|
1062 { |
|
1063 if ( aError == KErrNone ) |
|
1064 { |
|
1065 delete iMediaArray; |
|
1066 iMediaArray= NULL; |
|
1067 CMPXMediaArray* mediaAry( aResults.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
1068 if (!mediaAry ) |
|
1069 { |
|
1070 iCommonUiHelper->DismissWaitNoteL(); |
|
1071 User::Leave(KErrNoMemory); |
|
1072 } |
|
1073 iMediaArray = CMPXMediaArray::NewL( *mediaAry ); |
|
1074 if ( iMediaArray ) |
|
1075 { |
|
1076 TInt count = iMediaArray->Count(); |
|
1077 for ( TInt i = 0; i < count && !iAlbumArtChanged; i++ ) |
|
1078 { |
|
1079 // check if album art has changed |
|
1080 CMPXMedia* media = iMediaArray->AtL( i ); |
|
1081 const TDesC& albumArtFileName = |
|
1082 media->ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
1083 if ( albumArtFileName.Length() > 0 ) |
|
1084 { |
|
1085 if ( albumArtFileName.Compare( media->ValueText( |
|
1086 KMPXMediaMusicOriginalAlbumArtFileName ) ) != 0 ) |
|
1087 { |
|
1088 iAlbumArtChanged = ETrue; |
|
1089 } |
|
1090 } |
|
1091 } |
|
1092 iCurrentAlbumArtIndex = 0; |
|
1093 ExtractMultipleAlbumArtL(); |
|
1094 iCurrentFindAllLOp = EMPXOpFindAllLIdle; |
|
1095 return; |
|
1096 } |
|
1097 } |
|
1098 iCommonUiHelper->DismissWaitNoteL(); |
|
1099 break; |
|
1100 } |
|
1101 case EMPXOpFindAllLGetTrackArtInfo: |
|
1102 { |
|
1103 CMPXMediaArray* tempArray = |
|
1104 aResults.Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1105 if (!tempArray ) |
|
1106 { |
|
1107 iCommonUiHelper->DismissWaitNoteL(); |
|
1108 User::Leave (KErrNoMemory ); |
|
1109 } |
|
1110 if ( tempArray->Count() == 1 ) |
|
1111 { |
|
1112 delete iMedia; |
|
1113 iMedia = NULL; |
|
1114 CMPXMedia* origMedia( tempArray->AtL( 0 ) ); |
|
1115 iMedia = CMPXMedia::NewL( *origMedia ); |
|
1116 const TDesC& albumArtFileName = |
|
1117 iMedia->ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
1118 if ( albumArtFileName.Length() > 0 ) |
|
1119 { |
|
1120 if ( albumArtFileName.Compare( |
|
1121 iMedia->ValueText( KMPXMediaMusicOriginalAlbumArtFileName ) ) == 0 ) |
|
1122 { |
|
1123 iAlbumArtChanged = EFalse; |
|
1124 } |
|
1125 else |
|
1126 { |
|
1127 iAlbumArtChanged = ETrue; |
|
1128 } |
|
1129 } |
|
1130 ExtractAlbumArtL( *iMedia ); |
|
1131 } |
|
1132 else |
|
1133 { |
|
1134 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleFindAllL invalid array length %d", tempArray->Count() ); |
|
1135 iCommonUiHelper->DismissWaitNoteL(); |
|
1136 } |
|
1137 break; |
|
1138 } |
|
1139 default: |
|
1140 { |
|
1141 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::HandleFindAllL unknown op %d", iCurrentFindAllLOp ); |
|
1142 iCommonUiHelper->DismissWaitNoteL(); |
|
1143 break; |
|
1144 } |
|
1145 } |
|
1146 iCurrentFindAllLOp = EMPXOpFindAllLIdle; |
|
1147 MPX_DEBUG1( "<--CMPXAlbumArtEditorDialog::HandleFindAllL" ); |
|
1148 } |
|
1149 |
|
1150 // ----------------------------------------------------------------------------- |
|
1151 // CMPXAlbumArtEditorDialog::ProcessCommandL |
|
1152 // Act on the menu selection if menu is showing. |
|
1153 // ----------------------------------------------------------------------------- |
|
1154 // |
|
1155 void CMPXAlbumArtEditorDialog::ProcessCommandL( TInt aCommandId ) |
|
1156 { |
|
1157 MPX_FUNC( "CMPXAlbumArtEditorDialog::ProcessCommandL" ); |
|
1158 CAknDialog::ProcessCommandL( aCommandId ); |
|
1159 if ( MenuShowing() ) |
|
1160 { |
|
1161 HideMenu(); |
|
1162 } |
|
1163 DoProcessCommandL( aCommandId ); |
|
1164 } |
|
1165 |
|
1166 // ----------------------------------------------------------------------------- |
|
1167 // CMPXAlbumArtEditorDialog::CreateCustomControlL |
|
1168 // Creates a Custom Control for the dialog. |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // |
|
1171 SEikControlInfo CMPXAlbumArtEditorDialog::CreateCustomControlL( |
|
1172 TInt aControlType ) |
|
1173 { |
|
1174 MPX_FUNC( "CMPXAlbumArtEditorDialog::CreateCustomControlL" ); |
|
1175 SEikControlInfo controlInfo; |
|
1176 controlInfo.iControl = NULL; |
|
1177 controlInfo.iTrailerTextId = 0; |
|
1178 controlInfo.iFlags = 0; |
|
1179 |
|
1180 switch (aControlType) |
|
1181 { |
|
1182 case EMPXAlbumArtEditorDlg: |
|
1183 { |
|
1184 controlInfo.iControl = new ( ELeave ) |
|
1185 CMPXAlbumArtEditorCustomControlContainer; |
|
1186 break; |
|
1187 } |
|
1188 default: |
|
1189 { |
|
1190 break; |
|
1191 } |
|
1192 } |
|
1193 return controlInfo; |
|
1194 } |
|
1195 |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 // CMPXAlbumArtEditorDialog::PreLayoutDynInitL |
|
1198 // Initialises the dialog's controls before the dialog is sized and layed out. |
|
1199 // ----------------------------------------------------------------------------- |
|
1200 // |
|
1201 void CMPXAlbumArtEditorDialog::PreLayoutDynInitL() |
|
1202 { |
|
1203 MPX_FUNC( "CMPXAlbumArtEditorDialog::PreLayoutDynInitL" ); |
|
1204 |
|
1205 // determine current mode |
|
1206 GetCurrentModeL(); |
|
1207 |
|
1208 AknLayoutUtils::LayoutMetricsRect( |
|
1209 AknLayoutUtils::EMainPane, iModRect ); |
|
1210 |
|
1211 CMPXAlbumArtEditorCustomControlContainer *control1 = |
|
1212 ( CMPXAlbumArtEditorCustomControlContainer* ) ControlOrNull ( |
|
1213 EMPXAlbumArtEditorDlgCtrlId ); |
|
1214 CMPXAlbumArtEditorDialogCustomControl *control = NULL; |
|
1215 |
|
1216 if ( control1 ) |
|
1217 { |
|
1218 control = CMPXAlbumArtEditorDialogCustomControl::NewL( |
|
1219 *control1, iModRect, this ); |
|
1220 control1->iDialogCustomControl = control; |
|
1221 GetAlbumArtEditorDialogCustomControl()->MakeVisible( ETrue ); |
|
1222 } |
|
1223 |
|
1224 BackupPreviousStatusPaneL(); |
|
1225 |
|
1226 // Set new title pane |
|
1227 HBufC* title = StringLoader::LoadLC( |
|
1228 R_MPX_CUI_COLLECTION_ALBUM_ART_DIALOG_TITLE ); |
|
1229 iTitlePane->SetTextL( *title ); |
|
1230 CleanupStack::PopAndDestroy( title ); |
|
1231 |
|
1232 TSize size( iModRect.Width() - KMPXAlbumArtBorder, |
|
1233 iModRect.Height() - KMPXAlbumArtBorder ); |
|
1234 CAknDialog::PreLayoutDynInitL(); |
|
1235 iAvkonAppUi->AddToStackL( this ); |
|
1236 |
|
1237 HBufC* string = StringLoader::LoadLC( R_MPX_QTN_NMP_NOTE_OPENING ); |
|
1238 // display waiting note |
|
1239 iCommonUiHelper->ShowWaitNoteL( *string, R_AVKON_SOFTKEYS_EMPTY, |
|
1240 EFalse, this ); |
|
1241 CleanupStack::PopAndDestroy( string ); |
|
1242 } |
|
1243 |
|
1244 // ----------------------------------------------------------------------------- |
|
1245 // CMPXAlbumArtEditorDialog::OkToExitL |
|
1246 // This function ALWAYS returns ETrue. |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // |
|
1249 TBool CMPXAlbumArtEditorDialog::OkToExitL( TInt aButtonId ) |
|
1250 { |
|
1251 MPX_FUNC( "CMPXAlbumArtEditorDialog::OkToExitL" ); |
|
1252 if ( iFetchingPicture ) |
|
1253 { |
|
1254 return EFalse; |
|
1255 } |
|
1256 TBool retVal = EFalse; |
|
1257 switch (aButtonId) |
|
1258 { |
|
1259 case EAknSoftkeyBack: |
|
1260 { |
|
1261 retVal = ETrue; |
|
1262 break; |
|
1263 } |
|
1264 case EAknSoftkeyOk: |
|
1265 { |
|
1266 // middle softkey should not dismiss dialog |
|
1267 retVal = EFalse; |
|
1268 break; |
|
1269 } |
|
1270 case EAknSoftkeyChange: |
|
1271 { |
|
1272 DoProcessCommandL(EMPXCmdAlbumArtEditorDlgChange); |
|
1273 break; |
|
1274 } |
|
1275 default: |
|
1276 { |
|
1277 retVal = CAknDialog::OkToExitL( aButtonId ); |
|
1278 break; |
|
1279 } |
|
1280 } |
|
1281 if (retVal) // if dialog is dismissed |
|
1282 { |
|
1283 RestorePreviousStatusPaneL(); |
|
1284 } |
|
1285 return retVal; |
|
1286 } |
|
1287 |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // CMPXAlbumArtEditorDialog::DynInitMenuPaneL |
|
1290 // Dynamically initialises a menu pane. |
|
1291 // ----------------------------------------------------------------------------- |
|
1292 // |
|
1293 void CMPXAlbumArtEditorDialog::DynInitMenuPaneL( |
|
1294 TInt aResourceId, |
|
1295 CEikMenuPane* aMenuPane ) |
|
1296 { |
|
1297 MPX_FUNC( "CMPXAlbumArtEditorDialog::DynInitMenuPaneL" ); |
|
1298 if ( aResourceId == R_MPX_CUI_ALBUM_ART_DIALOG_MENU ) |
|
1299 { |
|
1300 aMenuPane->SetItemDimmed( EAknCmdExit, ETrue ); |
|
1301 TInt usbUnblockingStatus; |
|
1302 RProperty::Get( KMPXViewPSUid, |
|
1303 KMPXUSBUnblockingPSStatus, |
|
1304 usbUnblockingStatus ); |
|
1305 |
|
1306 if ( usbUnblockingStatus == EMPXUSBUnblockingPSStatusActive ) |
|
1307 { |
|
1308 aMenuPane->SetItemDimmed( EMPXCmdAlbumArtEditorDlgChange, ETrue ); |
|
1309 aMenuPane->SetItemDimmed( EMPXCmdAlbumArtEditorDlgRestore, ETrue ); |
|
1310 } |
|
1311 if ( !iAlbumArtChanged ) |
|
1312 { |
|
1313 aMenuPane->SetItemDimmed( EMPXCmdAlbumArtEditorDlgRestore, ETrue ); |
|
1314 } |
|
1315 } |
|
1316 CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
1317 } |
|
1318 |
|
1319 // ----------------------------------------------------------------------------- |
|
1320 // CMPXAlbumArtEditorDialog::DoProcessCommandL |
|
1321 // Process menu command. |
|
1322 // ----------------------------------------------------------------------------- |
|
1323 // |
|
1324 void CMPXAlbumArtEditorDialog::DoProcessCommandL( TInt aCommandId ) |
|
1325 { |
|
1326 MPX_FUNC( "CMPXAlbumArtEditorDialog::DoProcessCommandL" ); |
|
1327 switch ( aCommandId ) |
|
1328 { |
|
1329 case EMPXCmdAlbumArtEditorDlgChange: |
|
1330 { |
|
1331 // Renders Image Selection Query |
|
1332 CMPXAlbumArtEditorDialogImageThumbnailUtil* thumbnailCmd = |
|
1333 CMPXAlbumArtEditorDialogImageThumbnailUtil::NewL(); |
|
1334 CleanupStack::PushL( thumbnailCmd ); |
|
1335 CDesCArray* selectedFile = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
1336 CleanupStack::PushL( selectedFile ); |
|
1337 // selectedFile includes the pathname to the img |
|
1338 // Check if any img is selected |
|
1339 iFetchingPicture = ETrue; // Set the flag for async retrieval |
|
1340 TBool fecthOK( EFalse ); |
|
1341 TRAP_IGNORE( fecthOK = thumbnailCmd->FetchThumbnailL( *selectedFile ) ) |
|
1342 iFetchingPicture = EFalse; // Now we can safely process events |
|
1343 // Restore dialog size |
|
1344 AknLayoutUtils::LayoutMetricsRect( |
|
1345 AknLayoutUtils::EMainPane, iModRect ); |
|
1346 CMPXAlbumArtEditorCustomControlContainer *control = |
|
1347 ( CMPXAlbumArtEditorCustomControlContainer* ) |
|
1348 ControlOrNull ( EMPXAlbumArtEditorDlgCtrlId ); |
|
1349 if( control ) |
|
1350 { |
|
1351 control->SetRect( iModRect ); |
|
1352 control->iDialogCustomControl->SetRect( iModRect ); |
|
1353 SetRect(iModRect); |
|
1354 } |
|
1355 |
|
1356 if ( fecthOK ) |
|
1357 { |
|
1358 TInt err = KErrNone; |
|
1359 if ( iAlbumArtMode != EMPXModeTracksView ) |
|
1360 { |
|
1361 // show confirmation in album level |
|
1362 CAknQueryDialog* confirmationDlg = CAknQueryDialog::NewL(); |
|
1363 CleanupStack::PushL( confirmationDlg ); |
|
1364 |
|
1365 HBufC* promptTxt = StringLoader::LoadLC( |
|
1366 R_MPX_CUI_CHANGE_ALBUM_ART_CONFIRMATION ); |
|
1367 |
|
1368 confirmationDlg->SetPromptL( *promptTxt ); |
|
1369 CleanupStack::PopAndDestroy( promptTxt ); |
|
1370 CleanupStack::Pop( confirmationDlg ); |
|
1371 |
|
1372 if ( !confirmationDlg->ExecuteLD( |
|
1373 R_MPX_CUI_RESTORE_ALBUM_ART_CONFIRMATION_QUERY ) ) |
|
1374 { |
|
1375 err = KErrCancel; |
|
1376 } |
|
1377 } |
|
1378 if ( err == KErrNone ) |
|
1379 { |
|
1380 HBufC* string = StringLoader::LoadLC( |
|
1381 R_MPX_QTN_NMP_NOTE_ADDING_ALBUM_ART ); |
|
1382 // display waiting note |
|
1383 iCommonUiHelper->ShowWaitNoteL( *string, |
|
1384 R_MPX_WAITNOTE_SOFTKEYS_EMPTY_STOP, EFalse, this ); |
|
1385 CleanupStack::PopAndDestroy( string ); |
|
1386 string = NULL; |
|
1387 const TDesC& fileName = selectedFile->MdcaPoint( 0 ); |
|
1388 delete iNewFileName; |
|
1389 iNewFileName = NULL; |
|
1390 iNewFileName = fileName.AllocL(); |
|
1391 iInvalidFileExist = EFalse; |
|
1392 if ( iMediaArray ) |
|
1393 { |
|
1394 iIsSaving = ETrue; |
|
1395 SaveMultipleMediaL( EFalse ); |
|
1396 } |
|
1397 else |
|
1398 { |
|
1399 CMPXMedia* media = SaveMediaLC( fileName, EFalse ); |
|
1400 if( media ) |
|
1401 { |
|
1402 DoSetCollectionL( media, EFalse ); |
|
1403 CleanupStack::PopAndDestroy( media ); |
|
1404 } |
|
1405 } |
|
1406 } |
|
1407 } |
|
1408 CleanupStack::PopAndDestroy( selectedFile ); |
|
1409 CleanupStack::PopAndDestroy( thumbnailCmd ); |
|
1410 break; |
|
1411 } |
|
1412 case EMPXCmdAlbumArtEditorDlgRestore: |
|
1413 { |
|
1414 TInt err = KErrNone; |
|
1415 if ( iAlbumArtMode != EMPXModeTracksView ) |
|
1416 { |
|
1417 // show confirmation in album level |
|
1418 CAknQueryDialog* confirmationDlg = CAknQueryDialog::NewL(); |
|
1419 CleanupStack::PushL( confirmationDlg ); |
|
1420 |
|
1421 HBufC* promptTxt = StringLoader::LoadLC( |
|
1422 R_MPX_CUI_RESTORE_ALBUM_ART_CONFIRMATION ); |
|
1423 |
|
1424 confirmationDlg->SetPromptL( *promptTxt ); |
|
1425 CleanupStack::PopAndDestroy( promptTxt ); |
|
1426 CleanupStack::Pop( confirmationDlg ); |
|
1427 |
|
1428 if ( !confirmationDlg->ExecuteLD( |
|
1429 R_MPX_CUI_RESTORE_ALBUM_ART_CONFIRMATION_QUERY ) ) |
|
1430 { |
|
1431 err = KErrCancel; |
|
1432 } |
|
1433 } |
|
1434 if ( err == KErrNone ) |
|
1435 { |
|
1436 HBufC* string = StringLoader::LoadLC( |
|
1437 R_MPX_QTN_NMP_NOTE_RESTORING_ALBUM_ART ); |
|
1438 // display waiting note |
|
1439 iCommonUiHelper->ShowWaitNoteL( *string, |
|
1440 R_MPX_WAITNOTE_SOFTKEYS_EMPTY_STOP, EFalse, this ); |
|
1441 CleanupStack::PopAndDestroy( string ); |
|
1442 string = NULL; |
|
1443 delete iNewFileName; |
|
1444 iNewFileName = NULL; |
|
1445 iInvalidFileExist = EFalse; |
|
1446 if ( iMediaArray ) |
|
1447 { |
|
1448 // save for all songs |
|
1449 iIsSaving = ETrue; |
|
1450 SaveMultipleMediaL( ETrue ); |
|
1451 } |
|
1452 else |
|
1453 { |
|
1454 // Everything ok, now the original album art can be restored |
|
1455 const TDesC& originalAlbumArtFileName = |
|
1456 iMedia->ValueText( KMPXMediaMusicOriginalAlbumArtFileName ); |
|
1457 CMPXMedia* media = SaveMediaLC( originalAlbumArtFileName, ETrue ); |
|
1458 if( media ) |
|
1459 { |
|
1460 DoSetCollectionL( media, EFalse ); |
|
1461 CleanupStack::PopAndDestroy( media ); |
|
1462 } |
|
1463 } |
|
1464 } |
|
1465 break; |
|
1466 } |
|
1467 case EMPXCmdAlbumArtEditorDlgHelp: |
|
1468 { |
|
1469 TCoeHelpContext helpContext; |
|
1470 GetHelpContext( helpContext ); |
|
1471 |
|
1472 CArrayFixFlat<TCoeHelpContext>* array = |
|
1473 new(ELeave)CArrayFixFlat<TCoeHelpContext>( 1 ); |
|
1474 |
|
1475 CleanupStack::PushL( array ); |
|
1476 array->AppendL( helpContext ); |
|
1477 CleanupStack::Pop(); // array |
|
1478 |
|
1479 // HlpLauncher deletes array |
|
1480 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), array ); |
|
1481 break; |
|
1482 } |
|
1483 case EAknCmdExit: |
|
1484 { |
|
1485 static_cast<MEikCommandObserver*>(iEikonEnv->EikAppUi())-> |
|
1486 ProcessCommandL(aCommandId); |
|
1487 } |
|
1488 default: |
|
1489 { |
|
1490 break; |
|
1491 } |
|
1492 } |
|
1493 } |
|
1494 |
|
1495 // ----------------------------------------------------------------------------- |
|
1496 // CMPXAlbumArtEditorDialog::CountComponentControls |
|
1497 // Counts the number of components. |
|
1498 // ----------------------------------------------------------------------------- |
|
1499 // |
|
1500 TInt CMPXAlbumArtEditorDialog::CountComponentControls() const |
|
1501 { |
|
1502 MPX_FUNC( "CMPXAlbumArtEditorDialog::CountComponentControls" ); |
|
1503 TInt newitems = 0; |
|
1504 if ( GetAlbumArtEditorDialogCustomControl() ) newitems++; |
|
1505 return CAknDialog::CountComponentControls() + newitems; |
|
1506 } |
|
1507 |
|
1508 // ----------------------------------------------------------------------------- |
|
1509 // CMPXAlbumArtEditorDialog::ComponentControl |
|
1510 // Returns component control. |
|
1511 // ----------------------------------------------------------------------------- |
|
1512 // |
|
1513 CCoeControl* CMPXAlbumArtEditorDialog::ComponentControl( TInt aIndex ) const |
|
1514 { |
|
1515 MPX_FUNC( "CMPXAlbumArtEditorDialog::ComponentControl" ); |
|
1516 if (aIndex == CAknDialog::CountComponentControls() ) |
|
1517 { |
|
1518 return GetAlbumArtEditorDialogCustomControl(); |
|
1519 } |
|
1520 return CAknDialog::ComponentControl( aIndex ); |
|
1521 } |
|
1522 |
|
1523 // ----------------------------------------------------------------------------- |
|
1524 // CMPXAlbumArtEditorDialog::UpdateNaviPane |
|
1525 // Update the dialogs navipane. |
|
1526 // ----------------------------------------------------------------------------- |
|
1527 // |
|
1528 |
|
1529 void CMPXAlbumArtEditorDialog::UpdateNaviPaneL(const TDesC& aText) |
|
1530 { |
|
1531 MPX_FUNC( "CMPXAlbumArtEditorDialog::UpdateNaviPane" ); |
|
1532 |
|
1533 // Set the navi text |
|
1534 CAknNaviLabel* naviLabel = static_cast<CAknNaviLabel*> |
|
1535 ( iNaviLabelPane->DecoratedControl() ); |
|
1536 naviLabel->SetTextL( aText ); |
|
1537 iNaviLabelPane->DrawNow(); |
|
1538 } |
|
1539 |
|
1540 // ----------------------------------------------------------------------------- |
|
1541 // CMPXAlbumArtEditorDialog::GetHelpContext |
|
1542 // Gets Help |
|
1543 // (other items were commented in a header). |
|
1544 // ----------------------------------------------------------------------------- |
|
1545 // |
|
1546 void CMPXAlbumArtEditorDialog::GetHelpContext( |
|
1547 TCoeHelpContext& aContext ) const |
|
1548 { |
|
1549 MPX_FUNC( "CMPXAlbumArtEditorDialog::GetHelpContext" ); |
|
1550 aContext.iMajor = KAppUidMusicPlayerX; |
|
1551 aContext.iContext = KMUS_HLP_ALBUM_ART_EDITING; |
|
1552 } |
|
1553 |
|
1554 // --------------------------------------------------------------------------- |
|
1555 // From CCoeControl |
|
1556 // Handles a change to the control's resources. |
|
1557 // --------------------------------------------------------------------------- |
|
1558 // |
|
1559 void CMPXAlbumArtEditorDialog::HandleResourceChange( TInt aType ) |
|
1560 { |
|
1561 MPX_DEBUG2( "-->CMPXAlbumArtEditorDialog::HandleResourceChange type = 0x%x", aType ); |
|
1562 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
1563 { |
|
1564 AknLayoutUtils::LayoutMetricsRect( |
|
1565 AknLayoutUtils::EMainPane, iModRect ); |
|
1566 |
|
1567 CMPXAlbumArtEditorCustomControlContainer *control = |
|
1568 ( CMPXAlbumArtEditorCustomControlContainer* ) |
|
1569 ControlOrNull ( EMPXAlbumArtEditorDlgCtrlId ); |
|
1570 if ( control ) |
|
1571 { |
|
1572 TRAP_IGNORE( |
|
1573 control->iDialogCustomControl->SetModeL( |
|
1574 CMPXAlbumArtEditorDialogCustomControl::EMPXAlbumArtEditorDialogBlank) |
|
1575 ); |
|
1576 control->SetRect( iModRect ); |
|
1577 control->iDialogCustomControl->SetRect( iModRect ); |
|
1578 } |
|
1579 TRAP_IGNORE( LoadAlbumArtL( EFalse ) ); |
|
1580 } |
|
1581 else if ( aType == KAknsMessageSkinChange ) |
|
1582 { |
|
1583 CMPXAlbumArtEditorCustomControlContainer *control = |
|
1584 ( CMPXAlbumArtEditorCustomControlContainer* ) |
|
1585 ControlOrNull ( EMPXAlbumArtEditorDlgCtrlId ); |
|
1586 if ( control ) |
|
1587 { |
|
1588 TRAP_IGNORE( |
|
1589 control->iDialogCustomControl->HandleSkinChangedL() ); |
|
1590 } |
|
1591 } |
|
1592 CAknDialog::HandleResourceChange( aType ); |
|
1593 MPX_DEBUG1( "<--CMPXAlbumArtEditorDialog::HandleResourceChange" ); |
|
1594 } |
|
1595 |
|
1596 // --------------------------------------------------------------------------- |
|
1597 // From MProgressDialogCallback |
|
1598 // Callback method. Get's called when a dialog is dismissed |
|
1599 // --------------------------------------------------------------------------- |
|
1600 // |
|
1601 void CMPXAlbumArtEditorDialog::DialogDismissedL( TInt aButtonId ) |
|
1602 { |
|
1603 MPX_FUNC( "CMPXAlbumArtEditorDialog::DialogDismissedL" ); |
|
1604 switch ( aButtonId ) |
|
1605 { |
|
1606 case EAknSoftkeyCancel: |
|
1607 { |
|
1608 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::DialogDismissedL canceled, sending cancel requet" ); |
|
1609 // after canceling, the current request will still be completed |
|
1610 // handle the canceling in the callback |
|
1611 iCollectionUtility->Collection().CancelRequest(); |
|
1612 // setup flag so that confirmation note is not displayed |
|
1613 iOpCanceled = ETrue; |
|
1614 break; |
|
1615 } |
|
1616 default: |
|
1617 { |
|
1618 break; |
|
1619 } |
|
1620 } |
|
1621 } |
|
1622 |
|
1623 TInt CMPXAlbumArtEditorDialog::ExtractNextAlbumArtCallBackL(TAny* aPtr) |
|
1624 { |
|
1625 static_cast<CMPXAlbumArtEditorDialog*>(aPtr)->ExtractNextAlbumArtL(); |
|
1626 return KErrNone; |
|
1627 } |
|
1628 |
|
1629 void CMPXAlbumArtEditorDialog::ExtractNextAlbumArtL() |
|
1630 { |
|
1631 MPX_FUNC( "CMPXAlbumArtEditorDialog::ExtractNextAlbumArtL" ); |
|
1632 if ( iCurrentAlbumArtIndex < iMediaArray->Count() ) |
|
1633 { |
|
1634 MPX_DEBUG2( "CMPXAlbumArtEditorDialog::ExtractNextAlbumArtL extracting %d", iCurrentAlbumArtIndex ); |
|
1635 CMPXMedia* media( iMediaArray->AtL( iCurrentAlbumArtIndex ) ); |
|
1636 MPX_TRAPD( err, ExtractAlbumArtL( *media, EFalse ) ); |
|
1637 iCurrentAlbumArtIndex++; |
|
1638 if (err != KErrNone) |
|
1639 { |
|
1640 iAsyncCallNext->Call(); |
|
1641 } |
|
1642 } |
|
1643 else |
|
1644 { |
|
1645 // when no Album art found: |
|
1646 GetAlbumArtEditorDialogCustomControl()->SetModeL( |
|
1647 CMPXAlbumArtEditorDialogCustomControl:: |
|
1648 EMPXAlbumArtEditorDialogNoAlbumArt ); |
|
1649 MPX_DEBUG1( "CMPXAlbumArtEditorDialog::ExtractNextAlbumArtL show default album art" ); |
|
1650 iCommonUiHelper->DismissWaitNoteL(); |
|
1651 DrawDeferred(); |
|
1652 } |
|
1653 } |
|
1654 |
|
1655 |
|
1656 // End of File |