|
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 metadata editor dialog implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MPXMETADATAEDITORDIALOG_H |
|
20 #define MPXMETADATAEDITORDIALOG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknForm.h> |
|
24 #include <mpxcollectionobserver.h> |
|
25 #include <mpxcollectionuihelper.h> |
|
26 #include <mpxcollectionuihelperobserver.h> |
|
27 #include <mpxattribute.h> |
|
28 #include <AknQueryDialog.h> |
|
29 #include <DRMHelper.h> |
|
30 |
|
31 // CONSTANTS |
|
32 const TInt KMPXMetadataTextFieldMaxLen = 255; |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CAknTitlePane; |
|
36 class CAknNavigationControlContainer; |
|
37 class CAknNavigationDecorator; |
|
38 class CAknQueryValueText; |
|
39 class CAknQueryValueTextArray; |
|
40 class MMPXCollectionUtility; |
|
41 class CMPXCommonUiHelper; |
|
42 class CMPXMedia; |
|
43 class MMPXCollectionUiHelper; |
|
44 class CAknPopupField; |
|
45 class CIdle; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 /* |
|
49 * Provides query dialog for changing track's library. |
|
50 */ |
|
51 NONSHARABLE_CLASS( CMPXQueryDialog ) : public CAknQueryDialog |
|
52 { |
|
53 public: |
|
54 /** |
|
55 * Two-phased constructor. |
|
56 */ |
|
57 static CMPXQueryDialog* NewL(); |
|
58 |
|
59 /** |
|
60 * From CAknDialog |
|
61 * Handle key events. When a key event occurs, |
|
62 * until one of them returns EKeyWasConsumed to indicate that it processed the key event. |
|
63 * CONE calls this function for each control on the control stack, |
|
64 * @param aKeyEvent The key event. |
|
65 * @param aType The type of the event: EEventKey, EEventKeyUp or EEventKeyDown. |
|
66 * @return Indicates whether or not the key event was used by this control. |
|
67 */ |
|
68 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
69 }; |
|
70 |
|
71 /* |
|
72 * Provides factory to create concrete document object. |
|
73 */ |
|
74 NONSHARABLE_CLASS( CMPXMetadataEditorDialog ) : public CAknForm, |
|
75 public MMPXCollectionObserver, |
|
76 public MMPXCollectionFindObserver, |
|
77 public MMPXCHelperObserver |
|
78 { |
|
79 public: |
|
80 // File Details headings |
|
81 enum TMPXSongsFileDetailsHeadings |
|
82 { |
|
83 EMPXSongsFileDetailsHeadingFilename = 0, // Start from index 0 |
|
84 EMPXSongsFileDetailsHeadingFormat, |
|
85 EMPXSongsFileDetailsHeadingDuration, |
|
86 EMPXSongsFileDetailsHeadingBitrate, |
|
87 EMPXSongsFileDetailsHeadingSamplingRate, |
|
88 EMPXSongsFileDetailsHeadingSize, |
|
89 EMPXSongsFileDetailsHeadingModified, |
|
90 EMPXSongsFileDetailsHeadingCopyright, |
|
91 EMPXSongsFileDetailsHeadingUrl, |
|
92 EMPXSongsFileDetailsHeadingCount |
|
93 }; |
|
94 |
|
95 enum TMPXPodcastsFileDetailsHeadings |
|
96 { |
|
97 EMPXPodcastsFileDetailsHeadingFilename = 0, // Start from index 0 |
|
98 EMPXPodcastsFileDetailsHeadingFormat, |
|
99 EMPXPodcastsFileDetailsHeadingDuration, |
|
100 EMPXPodcastsFileDetailsHeadingBitrate, |
|
101 EMPXPodcastsFileDetailsHeadingSamplingRate, |
|
102 EMPXPodcastsFileDetailsHeadingSize, |
|
103 EMPXPodcastsFileDetailsHeadingLastPlaybackPosition, |
|
104 EMPXPodcastsFileDetailsHeadingPublished, |
|
105 EMPXPodcastsFileDetailsHeadingModified, |
|
106 EMPXPodcastsFileDetailsHeadingCopyright, |
|
107 EMPXPodcastsFileDetailsHeadingUrl, |
|
108 EMPXPodcastsFileDetailsHeadingCount |
|
109 }; |
|
110 |
|
111 public: // Constructor and destructor |
|
112 /** |
|
113 * Two-phased constructor. |
|
114 */ |
|
115 IMPORT_C static CMPXMetadataEditorDialog* NewL(); |
|
116 |
|
117 /** |
|
118 * Destructor. |
|
119 */ |
|
120 IMPORT_C virtual ~CMPXMetadataEditorDialog(); |
|
121 |
|
122 /** |
|
123 * Parameter passed in from viewframework |
|
124 * |
|
125 * @param aParam Parameter pass in from viewframework. |
|
126 */ |
|
127 IMPORT_C void SetParamL( const TDesC* aParam ); |
|
128 |
|
129 /** |
|
130 * From CAknDialog update member variables of CAknExEditorDialog. |
|
131 * @param aButtonId The ID of the button that was activated. |
|
132 * @return Should return ETrue if the dialog should exit, |
|
133 * and EFalse if it should not |
|
134 */ |
|
135 TBool OkToExitL(TInt aButtonId); |
|
136 |
|
137 /** |
|
138 * From CAknDialog. |
|
139 * |
|
140 * @param aResourceId The resource ID of the dialog to load. |
|
141 * @return Zero, unless it is a waiting dialog. For a waiting dialog, |
|
142 * the return value is the ID of the button that closed the |
|
143 * dialog, or zero if it was the cancel button |
|
144 * (@c EEikBidCancel). |
|
145 */ |
|
146 TInt ExecuteLD( TInt aResourceId ); |
|
147 |
|
148 /** |
|
149 * Display file details popup window |
|
150 */ |
|
151 void ViewFileDetailsPopupL(); |
|
152 |
|
153 private: // from base class MMPXCollectionObserver |
|
154 |
|
155 /** |
|
156 * Handle collection message. |
|
157 * |
|
158 * @param aMessage Collection message |
|
159 * @param aErr system error code. |
|
160 */ |
|
161 void HandleCollectionMessage( |
|
162 CMPXMessage* aMessage, TInt aError ); |
|
163 |
|
164 /** |
|
165 * Handles the collection entries being opened. Typically called |
|
166 * when client has Open()'d a folder |
|
167 * |
|
168 * @param aEntries collection entries opened |
|
169 * @param aIndex focused entry |
|
170 * @param aComplete ETrue no more entries. EFalse more entries |
|
171 * expected |
|
172 * @param aError error code |
|
173 */ |
|
174 void HandleOpenL( |
|
175 const CMPXMedia& aEntries, |
|
176 TInt aIndex, TBool aComplete, TInt aError); |
|
177 |
|
178 /** |
|
179 * Handles the item being opened. Typically called |
|
180 * when client has Open()'d an item. Client typically responds by |
|
181 * 'playing' the item via the playlist |
|
182 * |
|
183 * @param aPlaylist collection playlist |
|
184 * @param aError error code |
|
185 */ |
|
186 void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError ); |
|
187 |
|
188 /** |
|
189 * Handle media properties |
|
190 * |
|
191 * @param aMedia media |
|
192 * @param aError error code |
|
193 */ |
|
194 void HandleCollectionMediaL( |
|
195 const CMPXMedia& aMedia, |
|
196 TInt aError); |
|
197 |
|
198 private: // Constructor |
|
199 /** |
|
200 * Default constructor. |
|
201 */ |
|
202 CMPXMetadataEditorDialog(); |
|
203 |
|
204 /** |
|
205 * Second-phase constructor. |
|
206 */ |
|
207 void ConstructL(); |
|
208 |
|
209 private: // New functions |
|
210 |
|
211 /** |
|
212 * Clean up function for genre related members. |
|
213 */ |
|
214 void CleanUpGenreText(); |
|
215 |
|
216 /** |
|
217 * Populates genre popup with genre list for tracks. |
|
218 */ |
|
219 void FetchGenreL(); |
|
220 |
|
221 /** |
|
222 * Handle media properties. |
|
223 * |
|
224 * @param aMedia media properties |
|
225 * @param aError error code |
|
226 */ |
|
227 void DoHandleMediaL( |
|
228 const CMPXMedia& aMedia, |
|
229 TInt aError ); |
|
230 |
|
231 /** |
|
232 * Saves media back to collection engine |
|
233 * |
|
234 * @param aMedia media property to save back |
|
235 */ |
|
236 void SaveMediaPropertiesL( CMPXMedia* aMedia ); |
|
237 |
|
238 /** |
|
239 * Appends the value to the array, if the vaule has zero length, |
|
240 * appends "unavailable" |
|
241 * |
|
242 * @param aArray array to append to |
|
243 * @param aValue value to append |
|
244 */ |
|
245 void AppendStringToArrayL( CDesCArrayFlat* aArray, const TDesC& aValue ); |
|
246 |
|
247 /** |
|
248 * Sets control text |
|
249 * |
|
250 * @param aControlId The ID of the control |
|
251 * @param aValue value to set |
|
252 * @param aAlternateValue if aValue is zero length, |
|
253 * this value will be used instead |
|
254 * |
|
255 */ |
|
256 void SetControlTextL( TInt aControlId, const TDesC& aValue, |
|
257 const TDesC& aAlternateValue ); |
|
258 |
|
259 /** |
|
260 * Sets control text |
|
261 * |
|
262 * @param aControlId The ID of the control |
|
263 * @param aValue value to set |
|
264 * @param aMinValue minimum value allowed for this control |
|
265 * @param aMaxValue maximum value allowed for this control |
|
266 * |
|
267 */ |
|
268 void SetControlNumberL( TInt aControlId, const TDesC& aValue, |
|
269 TInt aMinValue, TInt aMaxValue ); |
|
270 |
|
271 /** |
|
272 * prompt user for library change |
|
273 * |
|
274 * @param aMoveToLibrary enum for library to move to |
|
275 * @return ETrue if the user confirms the change, EFalse if cancel |
|
276 */ |
|
277 TBool PromptForLibraryChangeL( TInt aMoveToLibrary ); |
|
278 |
|
279 /** |
|
280 * Updates media object with current control text, this will also |
|
281 * update iMedia |
|
282 * |
|
283 * @param aControlId the id of the control |
|
284 * @param aMedia media object to update |
|
285 * @param aAttribute attribute to save to |
|
286 * |
|
287 * @return EFalse if the control being checked has not been changed (equal) |
|
288 * ETrue if the control being checked has been changed |
|
289 */ |
|
290 TBool UpdateMediaObjectWithControlL( |
|
291 TInt aControlId, CMPXMedia* aMedia, TMPXAttribute aAttribute ); |
|
292 |
|
293 static TInt DeferredExitCallback( TAny* aPtr ); |
|
294 |
|
295 static TInt DeferredFileDetailsCallback( TAny* aPtr ); |
|
296 |
|
297 #ifdef __ENABLE_MSK |
|
298 /** |
|
299 * Update softkey. |
|
300 */ |
|
301 void UpdateSoftkeyL(); |
|
302 #endif // __ENABLE_MSK |
|
303 |
|
304 private: // Functions from base class |
|
305 |
|
306 #ifdef __ENABLE_MSK |
|
307 /** |
|
308 * From CAknForm, handles key-events. |
|
309 * @param aKeyEvent Key event. |
|
310 * @param aType Type of key event(EEventKey, EEventKeyUp or |
|
311 * EEventKeyDown). |
|
312 * @return If key-event is consumed, EKeyWasConsumed. Else |
|
313 * EKeyWasNotConsumed. |
|
314 */ |
|
315 TKeyResponse OfferKeyEventL( |
|
316 const TKeyEvent& aKeyEvent, |
|
317 TEventCode aType ); |
|
318 #endif // __ENABLE_MSK |
|
319 |
|
320 /** |
|
321 * From CAknForm |
|
322 * Save the contents of the form. |
|
323 */ |
|
324 TBool SaveFormDataL(); |
|
325 |
|
326 /** |
|
327 * From CAknForm |
|
328 * Does not save the contents of the form. |
|
329 */ |
|
330 void DoNotSaveFormDataL(); |
|
331 |
|
332 /** |
|
333 * Store the old title pane text and set the new one |
|
334 */ |
|
335 void SetTitlePaneL(); |
|
336 |
|
337 /** |
|
338 * Restore the old title pane text |
|
339 */ |
|
340 void RestoreTitlePaneL(); |
|
341 |
|
342 /** |
|
343 * Store the old title navi label and set the new one |
|
344 */ |
|
345 void SetNaviLabelL(); |
|
346 |
|
347 /** |
|
348 * Restore the old navi label text |
|
349 */ |
|
350 void RestoreNaviLabelL(); |
|
351 |
|
352 /** |
|
353 * From MEikMenuObserver. |
|
354 * Dynamically initialises a menu pane. This function can be overridden |
|
355 * by the derived class for its own purpose. |
|
356 * @param aResourceId Resource ID identifying the menu pane to initialise. |
|
357 * @param aMenuPane The in-memory representation of the menu pane. |
|
358 */ |
|
359 void DynInitMenuPaneL( TInt aResourceId, |
|
360 CEikMenuPane* aMenuPane ); |
|
361 |
|
362 /** |
|
363 * Act on the menu selection if menu is showing |
|
364 */ |
|
365 void ProcessCommandL(TInt aCommandId); |
|
366 |
|
367 /** |
|
368 * Populates file details window for songs |
|
369 * @param aHeadingsArray array of the headers |
|
370 * @param aDataArray array to populate |
|
371 */ |
|
372 void PopulateFileDetailsL( |
|
373 CDesCArrayFlat* aHeadingsArray, CDesCArrayFlat* aDataArray ); |
|
374 |
|
375 /** |
|
376 * Populates file details window for podcasts |
|
377 * @param aHeadingsArray array of the headers |
|
378 * @param aDataArray array to populate |
|
379 */ |
|
380 void PopulatePodcastFileDetailsL( |
|
381 CDesCArrayFlat* aHeadingsArray, CDesCArrayFlat* aDataArray ); |
|
382 |
|
383 /** |
|
384 * Constructs DRM items. |
|
385 * @param aHeadingsArray array of the headers |
|
386 * @param aDataArray array to populate |
|
387 */ |
|
388 void MakeDrmItemsL( |
|
389 CDesCArrayFlat* aHeadingsArray, CDesCArrayFlat* aDataArray ); |
|
390 |
|
391 /** |
|
392 * Constructs restricted drm items. E.g. count, interval |
|
393 * @param aRights Drm right type "Play" |
|
394 * @param aCurrentIndex current index of the listbox to insert into |
|
395 * @param aHeadingsArray array of the headers |
|
396 * @param aDataArray array to populate |
|
397 */ |
|
398 void MakeRestrictedDrmItemsL( |
|
399 HBufC* aRights, TInt& aCurrentIndex, |
|
400 CDesCArrayFlat* aHeadingsArray, CDesCArrayFlat* aDataArray ); |
|
401 |
|
402 /** |
|
403 * Add parts Of time. |
|
404 * @param aIntYrs year information |
|
405 * @param aIntMon month information |
|
406 * @param aIntDay day information |
|
407 * @param aIntHrs hour information |
|
408 * @param aIntMin minute information |
|
409 * @param aIntSec second information |
|
410 * @return Buffer where to add the elements |
|
411 */ |
|
412 HBufC* AddPartsOfTimeLC( TInt aIntYrs, TInt aIntMon, TInt aIntDay, |
|
413 TInt aIntHrs, TInt aIntMin, TInt aIntSec ); |
|
414 |
|
415 /** |
|
416 * Add a single element of time to the string array |
|
417 * @param aNumOfElements Number of elements of the interval |
|
418 * @param aResourceIdSingle Resource id to be used in case of |
|
419 * single unit |
|
420 * @param aResourceIdOneFinal Resource id to be used in case of |
|
421 * units ending with 1, from 21 |
|
422 * (requested by Slavic languages) |
|
423 * @param aResourceIdTwoFour Resource id to be used in case of |
|
424 * units included from two to four, except |
|
425 * 12-14 (requested by Slavic languages) |
|
426 * @param aResourceIdFiveZero Resource id to be used in case of |
|
427 * units ending from 5 to 9, plus range |
|
428 * from 11 to 14 (requested by Slavic |
|
429 * languages) |
|
430 * @param aStrings DesCArrayFlat where to add the element |
|
431 */ |
|
432 |
|
433 void AddSinglePartOfTimeL( TInt aNumOfElements, |
|
434 TInt aResourceIdSingle, |
|
435 TInt aResourceIdOneFinal, |
|
436 TInt aResourceIdTwoFour, |
|
437 TInt aResourceIdFiveZero, |
|
438 CDesCArrayFlat* aStrings ); |
|
439 |
|
440 /** |
|
441 * Split TimeIntervalSeconds into parts Of time. |
|
442 * @param aIntYrs year information |
|
443 * @param aIntMon month information |
|
444 * @param aIntDay day information |
|
445 * @param aIntHrs hour information |
|
446 * @param aIntMin minute information |
|
447 * @param aIntSec second information |
|
448 * @return void |
|
449 */ |
|
450 void SplitTime( const TTimeIntervalSeconds& aInterval, |
|
451 TInt& aIntYrs, TInt& aIntMon, TInt& aIntDay, |
|
452 TInt& aIntHrs, TInt& aIntMin, TInt& aIntSec ); |
|
453 /** |
|
454 * Add a single element of time to the string array |
|
455 * @param aNumOfElements Number of elements of the interval |
|
456 * @param aResourceIdSingle Resource id to be used in case of |
|
457 * single unit |
|
458 * @param aResourceIdOneFinal Resource id to be used in case of |
|
459 * units ending with 1, from 21 |
|
460 * (requested by Slavic languages) |
|
461 * @param aResourceIdTwoFour Resource id to be used in case of |
|
462 * units included from two to four, except |
|
463 * 12-14 (requested by Slavic languages) |
|
464 * @param aResourceIdFiveZero Resource id to be used in case of |
|
465 * units ending from 5 to 9, plus range |
|
466 * from 11 to 14 (requested by Slavic |
|
467 * languages) |
|
468 * @param aStrings Buffer where to add the element |
|
469 */ |
|
470 void AddSinglePartOfTimeL( TInt aNumOfElements, |
|
471 TInt aResourceIdSingle, |
|
472 TInt aResourceIdOneFinal, |
|
473 TInt aResourceIdTwoFour, |
|
474 TInt aResourceIdFiveZero, |
|
475 HBufC*& aStrings ); |
|
476 |
|
477 /** |
|
478 * Converts between arabic-indic digits and european digits. |
|
479 * @param aText numbers to be converted. |
|
480 * @return void |
|
481 */ |
|
482 void LanguageSpecificNumberConversion( TDes& aText ) const; |
|
483 |
|
484 /** |
|
485 * Converts the time value to localtime |
|
486 * @param aTime contains the UTC time to be converted, and the converted value on exit |
|
487 */ |
|
488 void ConvertToLocalTimeL(TTime& aTime ); |
|
489 |
|
490 /** |
|
491 * Adds header and value to list. |
|
492 * @param aHeading Heading |
|
493 * @param aValue Value |
|
494 * @param aItemArray Array where value and header are added. |
|
495 * @return void |
|
496 */ |
|
497 void AddItemToListBoxL( const TDesC& aHeading, |
|
498 const TDesC& aValue, |
|
499 CDesCArray* aItemArray ); |
|
500 |
|
501 /** |
|
502 * This is used to decide when to save changes. If a leave occurs the |
|
503 * framework generates a Symbian Leave code. |
|
504 * @param aControlId. Control id. |
|
505 */ |
|
506 void HandleControlStateChangeL( TInt aControlId ); |
|
507 |
|
508 /** |
|
509 * Function from @c CEikDialog and thence from c@ MEikDialogPageObserver. |
|
510 * Checks if either year or track control id's are empty, and if so set to 0. |
|
511 */ |
|
512 void PrepareForFocusTransitionL(); |
|
513 |
|
514 /** |
|
515 * Required for help. |
|
516 */ |
|
517 void GetHelpContext( TCoeHelpContext& aContext ) const; |
|
518 |
|
519 // from MMPXCollectionFindObserver |
|
520 |
|
521 /** |
|
522 * Handle callback for "find" operation |
|
523 * @param aEntries, CMPXMedia to be returned |
|
524 * @param aComplete ETrue no more entries. EFalse more entries |
|
525 * expected |
|
526 * @param aError error code |
|
527 */ |
|
528 void HandleFindAllL( const CMPXMedia& aResults, |
|
529 TBool aComplete,TInt aError ); |
|
530 |
|
531 // from MMPXCHelperObserver |
|
532 |
|
533 /** |
|
534 * Handle callback for the ui helper |
|
535 * @param aOperation operation performed |
|
536 * @param aErr error code |
|
537 * @param aArgument argument returned |
|
538 */ |
|
539 void HandleOperationCompleteL( TCHelperOperation aOperation, |
|
540 TInt aErr, |
|
541 void* aArgument ); |
|
542 |
|
543 private: // From CEikDialog |
|
544 /** |
|
545 * From CEikDialog, PreLayoutDynInitL. |
|
546 * Initialises the dialog's controls before the dialog is sized |
|
547 * and layed out. |
|
548 */ |
|
549 void PreLayoutDynInitL(); |
|
550 |
|
551 /** |
|
552 * From CEikDialog, PostLayoutDynInitL. |
|
553 * Initialises the dialog's controls after the dialog has been sized |
|
554 * but before it has been activated. |
|
555 */ |
|
556 void PostLayoutDynInitL(); |
|
557 |
|
558 private: |
|
559 enum TMPXMetadataEditorCurrentMediaLOp |
|
560 { |
|
561 EMPXMetadataEditorIdle = 0, |
|
562 EMPXMetadataEditorGetSongInfo, |
|
563 EMPXMetadataEditorGetDrmInfo |
|
564 }; |
|
565 |
|
566 private: |
|
567 CAknTitlePane* iTitlePane; |
|
568 CAknNavigationControlContainer* iNaviPane; |
|
569 CAknNavigationDecorator* iNaviDecorator; // Navi decorator |
|
570 CAknNavigationDecorator* iEmptyNaviDecorator; // Navi decorator |
|
571 CAknPopupField* iPopup; |
|
572 CAknQueryValueText* iTextValues; |
|
573 CAknQueryValueTextArray* iValueTextArray; |
|
574 CDesCArray* iGenreArr; |
|
575 CAknQueryValueText* iLibraryTextValues; |
|
576 CAknQueryValueTextArray* iLibraryValueTextArray; |
|
577 CDesCArray* iLibraryArr; |
|
578 |
|
579 HBufC* iTitlePaneText; |
|
580 HBufC* iParam; |
|
581 |
|
582 MMPXCollectionUiHelper* iCollectionUiHelper; |
|
583 MMPXCollectionUtility* iCollectionUtility; |
|
584 CMPXMedia* iMedia; // own |
|
585 CMPXMedia* iDrmInfo; |
|
586 CMPXCommonUiHelper* iCommonUiHelper; // own |
|
587 |
|
588 TInt iResourceOffset; // must be freed |
|
589 TInt iDrmResourceOffset; // must be freed |
|
590 TInt iCurrentLibrary; |
|
591 TInt iYear; // special handling needed for year |
|
592 TInt iCurrentMediaLOp; |
|
593 TInt iIsDrmProtected; |
|
594 |
|
595 TBool iUnknownGenre; |
|
596 TBool iDrmDetails; // Flags if DRMRightsManager.rsc was loaded |
|
597 TBool iDisablePodcasting; |
|
598 CIdle* iIdle; |
|
599 TBool iTryingExit; |
|
600 }; |
|
601 |
|
602 #endif // MPXMETADATAEDITORDIALOG_H |
|
603 |
|
604 // End of File |