mpxplugins/viewplugins/inc/mpxalbumarteditordialog.h
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     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 declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MPXALBUMARTEDITORDIALOG_H
       
    20 #define MPXALBUMARTEDITORDIALOG_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <AknDialog.h>
       
    24 #include <mpxcollectionobserver.h>
       
    25 #include <mpxcommonframeworkdefs.h>
       
    26 #include <AknProgressDialog.h>  // MProgressDialogCallback
       
    27 
       
    28 #include "mpxalbumarteventobserver.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CMPXAlbumArtEditorDialogCustomControl;
       
    32 class CAknTitlePane;
       
    33 class CAknNavigationControlContainer;
       
    34 class CAknNavigationDecorator;
       
    35 class MMPXCollectionUtility;
       
    36 class CMPXAlbumArtUtil;
       
    37 class CMPXMedia;
       
    38 class CMPXMediaArray;
       
    39 class CMPXCommonUiHelper;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44  *  CMPXAlbumArtEditorDialog dialog class for Changing/Restoring
       
    45  *  Album Art
       
    46  */
       
    47 NONSHARABLE_CLASS( CMPXAlbumArtEditorDialog ) :  public CAknDialog,
       
    48                                                  public MMPXCollectionObserver,
       
    49                                                  public MProgressDialogCallback,
       
    50                                                  public MMPXAlbumArtEventObserver,
       
    51                                                  public MMPXCollectionFindObserver
       
    52     {
       
    53 public:  // Constructors and destructor
       
    54 
       
    55     /**
       
    56      * Symbian OS two-phased constructor
       
    57      * @return MP Album Art Dialog.
       
    58      */
       
    59     IMPORT_C static CMPXAlbumArtEditorDialog* NewL();
       
    60 
       
    61     /**
       
    62      * Destructor.
       
    63      */
       
    64     IMPORT_C virtual ~CMPXAlbumArtEditorDialog();
       
    65 
       
    66     /**
       
    67      * Parameter passed in from viewframework
       
    68      *
       
    69      * @param aParam Parameter pass in from viewframework.
       
    70      */
       
    71     IMPORT_C void SetParamL( const TDesC* aParam );
       
    72 
       
    73 private:
       
    74 
       
    75     /**
       
    76      * C++ default constructor.
       
    77      */
       
    78     CMPXAlbumArtEditorDialog();
       
    79 
       
    80     void ConstructL( TInt aResource );
       
    81 
       
    82 private: // from base class MMPXCollectionObserver
       
    83 
       
    84     /**
       
    85      * Handle collection message.
       
    86      *
       
    87      * @param aMessage Collection message
       
    88      * @param aErr system error code.
       
    89      */
       
    90     void HandleCollectionMessage(
       
    91         CMPXMessage* aMessage, TInt aError );
       
    92 
       
    93     /**
       
    94      * Handles the collection entries being opened. Typically called
       
    95      * when client has Open()'d a folder
       
    96      *
       
    97      * @param aEntries collection entries opened
       
    98      * @param aIndex focused entry
       
    99      * @param aComplete ETrue no more entries. EFalse more entries
       
   100      *                  expected
       
   101      * @param aError error code
       
   102      */
       
   103     void HandleOpenL(
       
   104         const CMPXMedia& aEntries,
       
   105         TInt aIndex, TBool aComplete, TInt aError);
       
   106 
       
   107     /**
       
   108      * Handles the item being opened. Typically called
       
   109      * when client has Open()'d an item. Client typically responds by
       
   110      * 'playing' the item via the playlist
       
   111      *
       
   112      * @param aPlaylist collection playlist, owner ship is transfered
       
   113      * @param aError error code
       
   114      */
       
   115     void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError );
       
   116 
       
   117     /**
       
   118      * Handle collection media
       
   119      *
       
   120      * @param aMedia media
       
   121      * @param aError error code
       
   122      */
       
   123     void HandleCollectionMediaL(
       
   124         const CMPXMedia& aMedia,
       
   125         TInt aError);
       
   126 
       
   127     /**
       
   128     * From MMPXCollectionObserver
       
   129     */
       
   130     void HandleCommandComplete(CMPXCommand* aCommandResult,
       
   131                                TInt aError);
       
   132 private:    // New functions
       
   133 
       
   134     /**
       
   135      * Sends request to determine if it's album level
       
   136      * or track level
       
   137      */
       
   138     void GetCurrentModeL();
       
   139 
       
   140     /**
       
   141      * Backs up Status Pane.
       
   142      */
       
   143     void BackupPreviousStatusPaneL();
       
   144 
       
   145     /**
       
   146      * Restores Previous Status Pane.
       
   147      */
       
   148     void RestorePreviousStatusPaneL();
       
   149 
       
   150     /**
       
   151      * Find the components custom control.
       
   152      */
       
   153     CMPXAlbumArtEditorDialogCustomControl *GetAlbumArtEditorDialogCustomControl() const;
       
   154 
       
   155     /**
       
   156      * loads album art information from database
       
   157      * @param aShowWaitNote ETrue if the wait note is shown, EFalse otherwise
       
   158      */
       
   159     void LoadAlbumArtL( TBool aShowWaitNote );
       
   160 
       
   161     /**
       
   162      * extracts the album art
       
   163      *
       
   164      * @param aMedia media object containing album art info
       
   165      * @param aDismissWaitNoteOnError ETrue to dismiss wait note if error occurs,
       
   166      *                                EFalse otherwise
       
   167      */
       
   168     void ExtractAlbumArtL( const CMPXMedia& aMedia,
       
   169         TBool aDismissWaitNoteOnError = ETrue );
       
   170 
       
   171     /**
       
   172      * control extract of multiple album art
       
   173      */
       
   174     void ExtractMultipleAlbumArtL();
       
   175 
       
   176     /**
       
   177      * Saves the updated media
       
   178      *
       
   179      * @param aFileName the file name for the album art
       
   180      * @param aIsRestore ETrue if this is a restore operation,
       
   181      *                   EFalse if this is a change operation
       
   182      * @return NULL if media is broken, CMPXMedia* ownership if saving is required
       
   183      */
       
   184     CMPXMedia* SaveMediaLC( const TDesC& aFileName, TBool aIsRestore );
       
   185 
       
   186     /**
       
   187      * Saves multiple media
       
   188      *
       
   189      * @param aIsRestore ETrue if this is a restore operation,
       
   190      *                   EFalse if this is a change operation
       
   191      */
       
   192     void SaveMultipleMediaL( TBool aIsRestore );
       
   193 
       
   194     /**
       
   195      * Handle save operation complete
       
   196      *
       
   197      * @param aError Error code, if any
       
   198      */
       
   199     void DoHandleOperationCompleteL( TInt aError );
       
   200 
       
   201     /**
       
   202      * Handle collection message
       
   203      *
       
   204      * @param aMessage collection message
       
   205      */
       
   206     void DoHandleCollectionMessageL( const CMPXMessage& aMessage );
       
   207 
       
   208     /**
       
   209      * Updates a media to the collection
       
   210      * @param aMedia media to update
       
   211      * @param aSync synchronous operation or not
       
   212      */
       
   213     void DoSetCollectionL( CMPXMedia* aMedia, TBool aSync );
       
   214 
       
   215     /**
       
   216      * Appends the common attributes to attributes array
       
   217      *
       
   218      * @param aAryAttribute Array to append to
       
   219      */
       
   220     void AppendCommonAttributes( RArray<TMPXAttribute>& aAryAttribute );
       
   221 
       
   222 private: // Functions from base classes
       
   223 
       
   224     /**
       
   225     * From MMPXAlbumArtEventObserver
       
   226     * Handle album art events
       
   227     *
       
   228     * @param aEvent album art event
       
   229     * @param aError error code
       
   230     */
       
   231     void HandleAlbumArtEventL( TMPXAlbumArtEvents aEvent, TInt aError );
       
   232 
       
   233     /**
       
   234     *  from MMPXCollectionFindObserver
       
   235     *  Handle callback for "find" operation
       
   236     *  @param aEntries, CMPXMedia to be returned
       
   237     *  @param aComplete ETrue no more entries. EFalse more entries
       
   238     *                   expected
       
   239     *  @param aError error code
       
   240     */
       
   241     void HandleFindAllL(const CMPXMedia& aResults,
       
   242                         TBool aComplete,TInt aError);
       
   243 
       
   244     /**
       
   245      * Process menu command
       
   246      * @param aCommandId command ID
       
   247      */
       
   248 	void ProcessCommandL( TInt aCommandId ) ;
       
   249 
       
   250     /**
       
   251      * Creates custom control for the dialog
       
   252      * @param aControlType control type
       
   253      */
       
   254     SEikControlInfo CreateCustomControlL( TInt aControlType );
       
   255 
       
   256     /**
       
   257      * Initialises the dialog's controls before the dialog is sized and layed out.
       
   258      */
       
   259     void PreLayoutDynInitL();
       
   260 
       
   261     /**
       
   262      * This function ALWAYS returns ETrue.
       
   263      * @param aButtonId button ID
       
   264      */
       
   265     TBool OkToExitL( TInt aButtonId );
       
   266 
       
   267 	/**
       
   268 	 * Called when key events happen
       
   269 	 */
       
   270     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   271                                  TEventCode aType );
       
   272 
       
   273     /**
       
   274      * Dynamically initializes the menu pane.
       
   275      * @param aResourceId resource identifier.
       
   276      * @param aMenuPane menu pane
       
   277      */
       
   278     void DynInitMenuPaneL( TInt aResourceId,
       
   279                            CEikMenuPane* aMenuPane );
       
   280 
       
   281     /**
       
   282      * Processes menu command.
       
   283      * @param aCommandId menu command
       
   284      */
       
   285     void DoProcessCommandL( TInt aCommandId );
       
   286 
       
   287     /**
       
   288      * Returns the number of component controls.
       
   289      */
       
   290     TInt CountComponentControls() const;
       
   291 
       
   292     /**
       
   293      * Returns the component control.
       
   294      * @param aIndex index of the component
       
   295      */
       
   296     CCoeControl* ComponentControl(TInt aIndex) const;
       
   297 
       
   298     /**
       
   299      * Updates the dialogs navipane.
       
   300      */
       
   301     void UpdateNaviPaneL(const TDesC& aText);
       
   302 
       
   303     /**
       
   304      * Required for help.
       
   305      */
       
   306     void GetHelpContext( TCoeHelpContext& aContext ) const;
       
   307 
       
   308     /**
       
   309      * From CoeControl.
       
   310      * Handles a change to the control's resources.
       
   311      *
       
   312      * @param aType A message UID value.
       
   313      */
       
   314     void HandleResourceChange( TInt aType );
       
   315 
       
   316     /**
       
   317      * From MProgressDialogCallback
       
   318      * Callback method
       
   319      * Get's called when a dialog is dismissed.
       
   320      */
       
   321     void DialogDismissedL( TInt aButtonId );
       
   322 
       
   323 
       
   324     /**
       
   325      * Callback function
       
   326      * Get called by iAsyncCallNext.
       
   327      */
       
   328     static TInt ExtractNextAlbumArtCallBackL(TAny* aPtr);
       
   329 
       
   330     /**
       
   331      * Extract next Album Art
       
   332      * Get called by ExtractNextAlbumArtCallBackL.
       
   333      */
       
   334     void ExtractNextAlbumArtL();
       
   335 
       
   336 private:    // Data
       
   337 
       
   338     HBufC*                                  iOrigTitle;             // Original title text
       
   339     HBufC*                                  iParam;
       
   340     HBufC*                                  iNewFileName;
       
   341 
       
   342     CAknTitlePane*                          iTitlePane;             // Not owned
       
   343     CAknNavigationControlContainer*         iNaviPane;              // Not owned
       
   344     CAknNavigationDecorator*                iNaviLabelPane;         // New navi label pane
       
   345 
       
   346     MMPXCollectionUtility*                  iCollectionUtility;  // not own
       
   347     CMPXAlbumArtUtil*                       iMPXUtility;   // own
       
   348     CMPXMedia*                              iMedia;
       
   349     CMPXMedia*                              iAlbumInfo;
       
   350     CMPXMediaArray*                         iMediaArray;
       
   351     CMPXCommonUiHelper*                     iCommonUiHelper;
       
   352 
       
   353     TRect                                   iModRect;
       
   354     TInt                                    iResourceOffset; // must be freed
       
   355     TInt                                    iCurrentMediaLOp;   // current mediaL operation
       
   356     TInt                                    iCurrentFindAllLOp;   // current FindAllL operation
       
   357     TInt                                    iAlbumArtMode;
       
   358     TInt                                    iCurrentAlbumArtIndex;
       
   359 
       
   360     TBool                                   iAlbumArtChanged;
       
   361     TBool                                   iIsSaving;
       
   362     TBool                                   iInvalidFileExist;
       
   363     TBool                                   iOpCanceled;
       
   364     CAsyncCallBack*                         iAsyncCallNext;
       
   365     TBool                                   iFetchingPicture; // To indicate if picture fetching is ongoing
       
   366     };
       
   367 
       
   368 #endif      // MPXALBUMARTEDITORDIALOG_H
       
   369 
       
   370 // End of File