musicplayer_plat/mpx_music_player_app_api/inc/mpxcommonuihelper.h
changeset 0 ff3acec5bc43
child 56 2cbbefa9af78
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:  Definition of helper utility for Common UI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CMPXCOMMONUIHELPER_H
       
    21 #define C_CMPXCOMMONUIHELPER_H
       
    22 
       
    23 #ifdef __ENABLE_MSK
       
    24 #include <eikbtgpc.h>
       
    25 #endif // __ENABLE_MSK
       
    26 #include <mpxcollectionuihelperobserver.h>
       
    27 #include <mpxcollectionuihelper.h>
       
    28 #include <mpxcommonui.rsg>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CMPXMedia;
       
    32 class CMPXDrmUiHelper;
       
    33 class MProgressDialogCallback;
       
    34 class CAknWaitDialog;
       
    35 class MMPXCollectionUtility;
       
    36 class CEikButtonGroupContainer;
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43  * Common UI helper utility class.
       
    44  *
       
    45  * @lib mpxcommonui.lib
       
    46  * @since S60 3.2.3
       
    47  */
       
    48 NONSHARABLE_CLASS( CMPXCommonUiHelper ) : public CBase,
       
    49                                           public MMPXCHelperObserver
       
    50     {
       
    51 public:
       
    52 
       
    53     /**  Duration display mode */
       
    54     enum TMPXDuratDisplayMode
       
    55         {
       
    56         EMPXDuratAuto = 0,
       
    57         EMPXDuratHMS
       
    58         };
       
    59 
       
    60     /**
       
    61     * Two-phased constructor.
       
    62     *
       
    63     * @since S60 3.2.3
       
    64     * @aCollectionUtility Collection utility to use for this helper
       
    65     * @return Pointer to newly created object.
       
    66     */
       
    67     IMPORT_C static CMPXCommonUiHelper* NewL(MMPXCollectionUtility* aCollectionUtility = NULL);
       
    68 
       
    69     /**
       
    70     * Destructor.
       
    71     */
       
    72     virtual ~CMPXCommonUiHelper();
       
    73 
       
    74     /**
       
    75     * Check if the host application is messaging or browser
       
    76     * @since S60 3.2.3
       
    77     * @return ETrue if host is messaging or browser, EFalse otherwise
       
    78     */
       
    79     IMPORT_C TBool IsHostMessagingBrowserL();
       
    80 
       
    81     /**
       
    82     * Check if the host application is the Podcasting Application
       
    83     * @since S60 3.2.3
       
    84     * @return ETrue if host is Podcasting Application, EFalse otherwise
       
    85     */
       
    86     IMPORT_C TBool IsHostPodcastingAppL();
       
    87 
       
    88     /**
       
    89     * Check if the host application is messaging
       
    90     * @since S60 3.2.3
       
    91     * @return ETrue if host is messaging, EFalse otherwise
       
    92     */
       
    93     IMPORT_C TBool IsHostMessagingL();
       
    94 
       
    95     /**
       
    96     * Check if the host application is browser
       
    97     * @since S60 3.2.3
       
    98     * @return ETrue if host is browser, EFalse otherwise
       
    99     */
       
   100     IMPORT_C TBool IsHostBrowserL();
       
   101 
       
   102     /**
       
   103     * Convert to displayable duration
       
   104     *
       
   105     * @since S60 3.2.3
       
   106     * @param aduration Duration in seconds
       
   107     * @param aMode time display mode
       
   108     * @return A heap descriptor that contains displayable duration
       
   109     *         (ownership transferred). Caller must destroy this object
       
   110     *         after use.
       
   111     */
       
   112     IMPORT_C HBufC* DisplayableDurationL(
       
   113         TInt64 aDuration,
       
   114         TMPXDuratDisplayMode aMode = EMPXDuratAuto );
       
   115 
       
   116     /**
       
   117     * Convert to displayable duration in text format
       
   118     *
       
   119     * @since S60 3.2.3
       
   120     * @param aduration Duration in seconds
       
   121     * @return A heap descriptor that contains displayable duration
       
   122     *         (ownership transferred). Caller must destroy this object
       
   123     *         after use.
       
   124     */
       
   125     IMPORT_C HBufC* DisplayableDurationInTextL(
       
   126         TInt64 aDuration );
       
   127 
       
   128     /**
       
   129     * Set current file as ringing tone.
       
   130     *
       
   131 	* @since S60 3.2.3
       
   132     * @param aMedia Media properties of the current track. the media must
       
   133     *               contain the following attributes:
       
   134     *               TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralUri )
       
   135     *               TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralTitle )
       
   136     *               TMPXAttribute( KMPXMediaIdDrm, EMPXMediaDrmProtected )
       
   137     *               TMPXAttribute( KMPXMediaIdDrm, EMPXMediaDrmRightsStatus )
       
   138     *               TMPXAttribute( KMPXMediaIdDrm, EMPXMediaDrmCanSetAutomated )
       
   139     * @param aSetToAllProfiles ETrue if set ringtone to all profiles.
       
   140     *                          EFalse if set ringtone to active profile.
       
   141     * @param aShowQuery If ETrue, a confirmation query is shown before
       
   142     *                   setting ringtone. This setting will only apply if
       
   143     *                   aSetToAllProfiles is set to ETrue. No effect if
       
   144     *                   aSetToAllProfiles is set to EFalse.
       
   145     */
       
   146     IMPORT_C void DoSetAsRingingToneL(
       
   147         const CMPXMedia& aMedia,
       
   148         TBool aSetToAllProfiles,
       
   149         TBool aShowQuery = EFalse );
       
   150 
       
   151     /**
       
   152     * Check if current profile mode is offline mode.
       
   153     *
       
   154     * @since S60 3.2.3
       
   155     * @return ETrue if in Offline mode. Otherwise, EFalse.
       
   156     */
       
   157     IMPORT_C TBool IsProfileOfflineModeL();
       
   158 
       
   159     /*
       
   160     * Returns path of the default drive used to store playlist, attachments,
       
   161     * downloads and ringtones.
       
   162     * @return a path of the default drive
       
   163     * @since S60 3.2.3
       
   164     */
       
   165     IMPORT_C HBufC* DefaultDriveLC();
       
   166 
       
   167     /*
       
   168     * Returns a path of the next available drive used for saving playlists, ringtones,
       
   169     * downloads and attachments. The order of priority is internal mass store,
       
   170     * MMC, then phone memory.
       
   171     *
       
   172     * @since S60 3.2.3
       
   173     * @param aSize
       
   174     */
       
   175     IMPORT_C HBufC* AvailableDriveLC( TInt aSize );
       
   176 
       
   177     /**
       
   178     * Display information note
       
   179     *
       
   180     * @since S60 3.2.3
       
   181     * @param aResourceId Resource id of the text string
       
   182     */
       
   183     IMPORT_C void DisplayInfoNoteL( TInt aResourceId );
       
   184 
       
   185     /**
       
   186     * Display information note
       
   187     *
       
   188     * @since S60 3.2.3
       
   189     * @param aText Text to be shown on the note
       
   190     */
       
   191     IMPORT_C void DisplayInfoNoteL( const TDesC& aText );
       
   192 
       
   193     /**
       
   194     * Display confirmation note
       
   195     *
       
   196     * @since S60 3.2.3
       
   197     * @param aResourceId Resource id of the text string
       
   198     */
       
   199     IMPORT_C void DisplayConfirmNoteL( TInt aResourceId );
       
   200 
       
   201     /**
       
   202     * Display confirmation note
       
   203     *
       
   204     * @since S60 3.2.3
       
   205     * @param aText Text to be shown on the note
       
   206     */
       
   207     IMPORT_C void DisplayConfirmNoteL( const TDesC& aText );
       
   208 
       
   209 // Cover UI start
       
   210 //#ifdef __COVER_DISPLAY
       
   211     void DisplayConfirmNoteL( const TDesC& aText, TInt aResourceId );
       
   212 //#endif // __COVER_DISPLAY
       
   213 // Cover UI end
       
   214 
       
   215     /**
       
   216     * Convert a value from bytes to kB/MB/GB.
       
   217     *
       
   218     * @since S60 3.2.3
       
   219     * @param aByte Number of bytes
       
   220     * @param ETrue to append " free" at the end of the string
       
   221     */
       
   222     IMPORT_C HBufC* UnitConversionL( TInt64 aByte, TBool aFree = EFalse );
       
   223 
       
   224     /**
       
   225     * Finds all user playlists in the given collection
       
   226     *
       
   227     * @since S60 3.2.3
       
   228     */
       
   229     IMPORT_C CMPXMedia* FindPlaylistsL();
       
   230 
       
   231     /**
       
   232     * Add to saved playlist
       
   233     *
       
   234     * @since S60 3.2.3
       
   235     * @param aPlaylists media containing a media array
       
   236     *         each entry in the array must contain the following attributes
       
   237     *         TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralTitle )
       
   238     *         TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralId )
       
   239     *         TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralDrive )
       
   240     * @param aTracks Tracks to be add to the playlist
       
   241     *          media containing a media array
       
   242     *          must contain at least 1 element
       
   243     *          each entry in the arry must contain the following attributes
       
   244     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralType )
       
   245     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralCategory )
       
   246     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralId )
       
   247     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralTitle )
       
   248     * @param aObserver pointer to callback
       
   249     * @param aCallback call back for wait dialog
       
   250     *
       
   251     * @return ETrue if the user accepts the save dialog, EFalse otherwise
       
   252     */
       
   253     IMPORT_C TBool AddToSavedPlaylistL(
       
   254         const CMPXMedia& aPlaylists, const CMPXMedia& aTracks,
       
   255         MMPXCHelperObserver* aObserver,
       
   256         MProgressDialogCallback* aCallback );
       
   257 
       
   258     /**
       
   259     * Create new playlist
       
   260     *
       
   261     * @since S60 3.2.3
       
   262     * @param aTracks Tracks to be add to the playlist
       
   263     *          media containing a media array
       
   264     *          can be a valid array with 0 length
       
   265     *          each entry in the arry must contain the following attributes
       
   266     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralType )
       
   267     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralCategory )
       
   268     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralId )
       
   269     *          TMPXAttribute( KMPXMediaIdGeneral, EMPXMediaGeneralTitle )
       
   270     * @param aObserver pointer to callback
       
   271     * @param aCallback call back for wait dialog
       
   272     *
       
   273     * @return ETrue if user accepts the query, EFalse otherwise
       
   274     */
       
   275     IMPORT_C TBool CreatePlaylistL( const CMPXMedia& aTracks,
       
   276         MMPXCHelperObserver* aObserver,
       
   277         MProgressDialogCallback* aCallback );
       
   278 
       
   279     /**
       
   280 	* Launches rename dialog
       
   281 	*
       
   282 	* @since S60 3.2.3
       
   283 	* @param aOldName original name, with the extension (e.g. a.mp3)
       
   284 	* @param aNewName on return, this will be populated with the new name
       
   285 	*                 inputed by the user
       
   286 	* @param aPath    the path to the file, without the file name (e.g. c:\\data\\)
       
   287 	* @return generic return code from AknDialog
       
   288 	*/
       
   289 	IMPORT_C TInt LaunchRenameDialogL(
       
   290         const TDesC& aOldName,
       
   291 		TDes& aNewName,
       
   292 		const TDesC& aPath );
       
   293 
       
   294     /**
       
   295     * Shows wait note
       
   296     *
       
   297     * @since S60 3.2.3
       
   298     * @param aText text to display
       
   299     * @param aCBAId button group ID
       
   300     * @param aVisibilityDelayOff If set ETrue the dialog will be visible
       
   301     *                            immediality. Use only when the length of
       
   302     *                            the process is ALWAYS over 1.5 seconds.
       
   303     * @param aCallback call back
       
   304     * @param aResId resource Id for the WaitNote, default is R_MPX_GENERIC_WAIT_NOTE
       
   305     */
       
   306     IMPORT_C void ShowWaitNoteL( TDesC& aText, TInt aCBAId,
       
   307         TBool aVisibilityDelayOff, MProgressDialogCallback* aCallback, TInt aResId = R_MPX_GENERIC_WAIT_NOTE );
       
   308 
       
   309     /**
       
   310      * Dismiss wait note
       
   311      */
       
   312     IMPORT_C void DismissWaitNoteL();
       
   313 
       
   314     /**
       
   315     * Handles displaying the error message for given error code
       
   316     * according to the media object provided
       
   317     *
       
   318     * @since S60 3.2.3
       
   319     * @param aError Error code
       
   320     * @param aMedia MPXMedia object
       
   321     * @param aFile Handle to file
       
   322     * @return KErrNone if no error, or else if a dialog is displayed will
       
   323     *         return the Button ID used to dismiss dialog.
       
   324     */
       
   325     IMPORT_C TInt HandleErrorL( TInt aError,
       
   326                                 const CMPXMedia* aMedia=NULL,
       
   327                                 RFile* aFile=NULL );
       
   328 
       
   329     /**
       
   330     * Adds given resource text as MSK to CBA.
       
   331     *
       
   332     * @since S60 3.2.3
       
   333     * @param aCba a button group container
       
   334     * @param aResourceId middle softkey label.
       
   335     * @param aCommandId command that should be performed when MSK
       
   336     *        is pressed.
       
   337     */
       
   338     IMPORT_C void SetMiddleSoftKeyLabelL(
       
   339         CEikButtonGroupContainer& aCba,
       
   340         TInt aResourceId,
       
   341         TInt aCommandId );
       
   342 
       
   343     /**
       
   344     * Removes current MSK label
       
   345     *
       
   346     * @since S60 3.2.3
       
   347     * @param aCba a button group container
       
   348     */
       
   349     IMPORT_C void RemoveMiddleSoftKeyLabel(
       
   350         CEikButtonGroupContainer& aCba );
       
   351 
       
   352     /**
       
   353     * Adds given resource icon as MSK to CBA.
       
   354     *
       
   355     * @since S60 3.2.3
       
   356     * @param aCba a button group container
       
   357     * @param aBitmap a bitmap
       
   358     * @param aMask a bitmap mask
       
   359     */
       
   360     IMPORT_C void SetMiddleSoftKeyIconL(
       
   361         CEikButtonGroupContainer& aCba,
       
   362         CFbsBitmap* aBitmap,
       
   363         CFbsBitmap* aMask );
       
   364 
       
   365     /**
       
   366     * Generate the next available title from the given title for the category.
       
   367     * The generated title is unique within the category regardless of the
       
   368     * media type within the category and its location.
       
   369     * e.g. c:\data\playlists\Playlist.m3u exists in the collection, the next
       
   370     * available title for the playlist category will be Playlist(01) regardless
       
   371     * if the title is going to be used for a playlist located in e:\data\playlists
       
   372     * or if it's a xml playlist file.
       
   373     *
       
   374     * @since S60 3.2.3
       
   375     * @param aCategory specifies the category for the title
       
   376     * @param aBaseTitle specifies the base title for new title generation
       
   377     * @return the next available title in the category in "BaseTitle(number)"
       
   378     *         format where number is the lowest available number.
       
   379     */
       
   380     IMPORT_C HBufC* GenerateTitleL(
       
   381         TMPXGeneralCategory aCategory,
       
   382         const TDesC& aBaseTitle );
       
   383 
       
   384     /**
       
   385     * Checks if Exit option should be hidden
       
   386     *
       
   387     * @since S60 3.2.3
       
   388     * @return ETrue if exit option should be hidden, EFalse otherwise
       
   389     */
       
   390     IMPORT_C TBool ExitOptionHiddenL();
       
   391 
       
   392     /**
       
   393     * Sets standalone mode process ID
       
   394     *
       
   395     * @since S60 3.2.3
       
   396     * @param aPId Process ID for standalone mode, 0 to reset
       
   397     * @return ETrue if successful, EFalse otherwise
       
   398     */
       
   399     IMPORT_C static TBool SetStandAloneModePId( TInt64 aPId );
       
   400 
       
   401     /**
       
   402     * Gets stand alone mode's process id
       
   403     *
       
   404     * @since S60 3.2.3
       
   405     * @return Stand alone mode's process ID, or 0 if not found
       
   406     */
       
   407     IMPORT_C static TInt64 StandAloneModePId();
       
   408 
       
   409 
       
   410     /**
       
   411     * Checks if the application with the provided group id is in foreground
       
   412     * This method is required because AppUi()->IsForeground() does not work
       
   413     * properly when the screen saver is active
       
   414     *
       
   415     * @since S60 3.2.3
       
   416     * @param aWindowGroupId application group identifier
       
   417     * @return ETrue if the application is in foreground, EFalse otherwise
       
   418     */
       
   419     IMPORT_C TBool IsForegroundApplication(TInt aWindowGroupId);
       
   420 
       
   421     /**
       
   422     * Get the Drive Number for the MMC card
       
   423     *
       
   424     * @since S60 3.2.3
       
   425     * @return Drive Number as defined in TDriveNumber or error code
       
   426     */
       
   427     IMPORT_C static TInt MMCDriveNumber();
       
   428 
       
   429 
       
   430     /**
       
   431      * Cancel all subsequent operations scheduled by CollectionUiHelper
       
   432      * Currently, this method is only used to cancel adding songs incrementally
       
   433      * to the playlist (user clicks on Cancel on the wait note)
       
   434      */
       
   435     IMPORT_C void CancelCollectionOperation();
       
   436     
       
   437                             
       
   438 private:
       
   439 
       
   440     /**
       
   441     * C++ default constructor.
       
   442     *
       
   443     * @since S60 3.2.3
       
   444     * @param aCollectionUtility Collection utility to use for this helper
       
   445     */
       
   446     CMPXCommonUiHelper(MMPXCollectionUtility* aCollectionUtility);
       
   447 
       
   448     /**
       
   449     * By default Symbian 2nd phase constructor is private.
       
   450     */
       
   451     void ConstructL();
       
   452 
       
   453     /**
       
   454     * Check if memory card is present and writable.
       
   455     *
       
   456     * @since S60 3.2.3
       
   457     * @param aDrive If return is ETrue, aDrive contains the drive letter
       
   458     * @return ETrue if memory card is present and writable.
       
   459     */
       
   460     TBool IsMemoryCardWritable( TChar& aDrive );
       
   461 
       
   462     /**
       
   463     * Show playlist creation queries: memory selection and name query.
       
   464     *
       
   465     * @since S60 3.2.3
       
   466     * @param aPath Descriptor to receive the full path and
       
   467     *              name of the playlist file
       
   468     */
       
   469     TBool PlaylistCreationQueriesL( TDes& aPath );
       
   470 
       
   471     /**
       
   472     * Get next available playlist full pathname based on the information passed.
       
   473     *
       
   474     * @since S60 3.2.3
       
   475     * @param aBuf Buffer contains the file path and initial playlist name (optional).
       
   476     *             This buffer must be big enough to hold all texts.
       
   477     * @return KErrNone if everything ok.
       
   478     */
       
   479     TInt GetNextPlaylistNameL( TDes& aBuf );
       
   480 
       
   481     /**
       
   482     * Finds all medias in the specified category. Matching medias should
       
   483     * return the specified attributes
       
   484     *
       
   485     * @since S60 3.2.3
       
   486     * @param aAttrs attributes to return for the matching media(s)
       
   487     * @return matching media(s)
       
   488     */
       
   489     CMPXMedia* FindAllL(TMPXGeneralCategory aCategory, const TArray<TMPXAttribute>& aAttrs);
       
   490 
       
   491     /**
       
   492     * From MMPXCHelperObserver
       
   493     * Handles the completion of any collection helper event.
       
   494     *
       
   495     * @since S60 3.2.3
       
   496     * @param aOperation, operation completed
       
   497     * @param aErr. the error code
       
   498     * @param aArgument Argument returned from the operation
       
   499     */
       
   500     void HandleOperationCompleteL( TCHelperOperation aOperation,
       
   501                                    TInt aErr,
       
   502                                    void* aArgument );
       
   503 
       
   504     TBool PlaylistCreateNameExistL( TDes& aName, const TParseBase& aParse );
       
   505 private:    // Data
       
   506 
       
   507     TInt                        iResourceOffset;   // must be freed
       
   508     CMPXDrmUiHelper*            iMpxDrmHelper; // owned
       
   509     MMPXCollectionUiHelper*     iCollectionUiHelper;
       
   510     MMPXCHelperObserver*        iAddObserver;
       
   511     CAknWaitDialog*             iWaitDialog;
       
   512     MMPXCollectionUtility*      iCollectionUtility; // not owned
       
   513     TInt                        iAppUiResourceOffset;
       
   514 
       
   515 // Cover UI start
       
   516 //#ifdef __COVER_DISPLAY
       
   517     TBool iCoverDisplay;
       
   518 //#endif
       
   519 // Cover UI end
       
   520 
       
   521     };
       
   522 
       
   523 #endif  // C_CMPXCOMMONUIHELPER_H
       
   524 
       
   525 // End of File