mmappcomponents/mmmtpdataprovider/inc/cmmmtpdpmetadatampxaccess.h
changeset 25 d881023c13eb
parent 0 a2952bb97e68
child 27 cbb1bfb7ebfb
equal deleted inserted replaced
21:a05c44bc3c61 25:d881023c13eb
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:  Meta data Mpx access
    14  * Description:  Meta data Mpx access
    15 *
    15  *
    16 */
    16  */
    17 
       
    18 
    17 
    19 #ifndef CMMMTPDPMETADATAMPXACCESS_H
    18 #ifndef CMMMTPDPMETADATAMPXACCESS_H
    20 #define CMMMTPDPMETADATAMPXACCESS_H
    19 #define CMMMTPDPMETADATAMPXACCESS_H
    21 
    20 
    22 #include <badesca.h>
    21 #include <badesca.h>
    23 
    22 
    24 #include "cmmmtpdpperflog.h"
    23 #include "cmmmtpdpperflog.h"
    25 
       
    26 // keep here to avoid warning on urel
       
    27 _LIT( KMpxCollectionNewL, "MpxCollectionNewL" );
       
    28 _LIT( KMpxCollectionAddL, "MpxCollectionAddL" );
       
    29 _LIT( KMpxCollectionGetL, "MpxCollectionGetL" );
       
    30 _LIT( KMpxCollectionSetL, "MpxCollectionSetL" );
       
    31 _LIT( KMpxCollectionGetPlaylist, "MpxCollectionGetPlaylist" );
       
    32 _LIT( KMpxCollectionGetReference, "MpxCollectionGetReference" );
       
    33 _LIT( KMpxCollectionFindAllLValidate, "MpxCollectionValidate" );
       
    34 _LIT( KMpxCollectionFindAllLBeforeAdd, "KMpxCollectionFindAllLBeforeAdd" );
       
    35 
    24 
    36 // forward declacration
    25 // forward declacration
    37 class CMPXMedia;
    26 class CMPXMedia;
    38 class CMTPObjectMetaData;
    27 class CMTPObjectMetaData;
    39 class MMPXCollectionHelper;
    28 class MMPXCollectionHelper;
    48     TMTPObjectPropertyCode iPropCode;
    37     TMTPObjectPropertyCode iPropCode;
    49     TMPXAttributeData iMpxAttrib;
    38     TMPXAttributeData iMpxAttrib;
    50     } TMetadataTable;
    39     } TMetadataTable;
    51 
    40 
    52 /**
    41 /**
    53 * Controls access to the music MPX store database.  Allows access to the
    42  * Controls access to the music MPX store database.  Allows access to the
    54 * information about any of the music stored in any of the MPX db's on any
    43  * information about any of the music stored in any of the MPX db's on any
    55 * of the drives. Also supports deletions and insertions into the db.
    44  * of the drives. Also supports deletions and insertions into the db.
    56 */
    45  */
    57 class CMmMtpDpMetadataMpxAccess : public CBase
    46 class CMmMtpDpMetadataMpxAccess : public CBase
    58     {
    47     {
    59 public:
    48 public:
    60 
    49 
    61     static CMmMtpDpMetadataMpxAccess* NewL( RFs& aRfs, MMTPDataProviderFramework& aFramework );
    50     static CMmMtpDpMetadataMpxAccess* NewL( RFs& aRfs );
    62 
    51 
    63     /**
    52     /**
    64     * Destructor
    53      * Destructor
    65     */
    54      */
    66     ~CMmMtpDpMetadataMpxAccess();
    55     ~CMmMtpDpMetadataMpxAccess();
    67 
    56 
    68 public:
    57 public:
    69     /**
    58     /**
    70     * Get all playlists from MPX database in the assigned store
    59      * Get all abstract medias from MPX database in the assigned store
    71     * @param aStoreRoot, specify in which drive playlists are stored
    60      * @param aStoreRoot, specify in which drive abstract medias are stored
    72     * @param aPlaylists, return result array
    61      * @param aAbstractMedias, return result array
    73     */
    62      * @param aCategory, indicate the category of abstract medias
    74     void GetAllPlaylistL( const TDesC& aStoreRoot, CMPXMediaArray** aPlaylists );
    63      */
    75 
    64     void GetAllAbstractMediaL( const TDesC& aStoreRoot,
    76     /**
    65         CMPXMediaArray** aAbstractMedias,
    77     * Get all references of specified playlist
    66         TMPXGeneralCategory aCategory );
    78     * @param aPlaylist, specify of which reference should be get
    67 
    79     * @param aReferences, return result array which stored handles of all references
    68     /**
    80     */
    69      * Get all references of specified abstract media
    81     void GetAllReferenceL( CMPXMedia* aPlaylist, CDesCArray& aReferences );
    70      * @param aAbstractMedia, specify of which reference should be get
    82 
    71      * @param aReferences, return result array which stored handles of all references
    83     /**
    72      */
    84     * Get an playlist name from CMPXMedia object
    73     void GetAllReferenceL( CMPXMedia* aAbstractMedia,
    85     * @param aPlaylist, specify the source
    74         CDesCArray& aReferences );
    86     * @param aPlaylistName, return result
    75 
    87     */
    76     /**
    88     void GetPlaylistNameL( CMPXMedia* aPlaylist, TDes& aPlaylistName );
    77      * Get an abstract media name from CMPXMedia object
    89 
    78      * @param aAbstractMedia, specify the source
    90     /**
    79      * @param aCategory, specify the category
    91     * Adds Songs info to Mpx DB
    80      * @return, name of the source, ownership transferred
    92     * @param aFullFileName, full file name of Media file
    81      */
    93     */
    82     HBufC* GetAbstractMediaNameL( CMPXMedia* aAbstractMedia,
       
    83         TMPXGeneralCategory aCategory );
       
    84 
       
    85     /**
       
    86      * Adds Songs info to Mpx DB
       
    87      * @param aFullFileName, full file name of Media file
       
    88      */
    94     void AddSongL( const TDesC& aFullFileName );
    89     void AddSongL( const TDesC& aFullFileName );
    95 
    90 
    96     /**
    91     /**
    97     * Adds Playlist to Mpx DB
    92      * Adds abstract media to Mpx DB
    98     * @param aFullFileName, full file name of Playlist file
    93      * @param aFullFileName, full file name of abstract media file
    99     */
    94      * @param aCategory, indicate the category of abstract media
   100     void AddPlaylistL( const TDesC& aFullFileName );
    95      */
   101 
    96     void AddAbstractMediaL( const TDesC& aFullFileName,
   102     /**
    97         TMPXGeneralCategory aCategory );
   103     * Set playlist to DB
    98 
   104     * @param aPlaylistFileName, full file name of playlist file
    99     /**
   105     * @param aRefFileArray, a array to store the full file name of media files
   100      * Set abstract media to DB
   106     */
   101      * @param aRefOwnerName, full file name of abstract media file
   107     void SetPlaylistL( const TDesC& aPlaylistFileName,
   102      * @param aRefFileArray, a array to store the full file name of media files
   108             CDesCArray& aRefFileArray );
   103      * @param aCategory, indicate the category of abstract media
       
   104      */
       
   105     void SetReferenceL( const TDesC& aRefOwnerName,
       
   106         CDesCArray& aRefFileArray,
       
   107         TMPXGeneralCategory aCategory );
   109 
   108 
   110     void GetObjectMetadataValueL( const TUint16 aPropCode,
   109     void GetObjectMetadataValueL( const TUint16 aPropCode,
   111             MMTPType& aNewData,
   110         MMTPType& aNewData,
   112             const CMTPObjectMetaData& aObjectMetaData );
   111         const TDesC& aFullFileName,
   113 
   112         TMPXGeneralCategory aCategory );
   114     /**
   113 
   115     * Set object property and updated object in DB according property code,
   114     /**
   116     * only for update, not for creation
   115      * Set object property and updated object in DB according property code,
   117     * @param aPropCode, property code of aObjectMetaData
   116      * only for update, not for creation
   118     * @param aNewData, object property value which will be set into
   117      * @param aPropCode, property code of aObjectMetaData
   119     *     aObjectMetaData
   118      * @param aNewData, object property value which will be set into
   120     * @param aObjectMetaData, owner of the property which should be
   119      *     aObjectMetaData
   121     *     updated into database
   120      * @param aObjectMetaData, owner of the property which should be
   122     */
   121      *     updated into database
       
   122      */
   123     void SetObjectMetadataValueL( const TUint16 aPropCode,
   123     void SetObjectMetadataValueL( const TUint16 aPropCode,
   124             const MMTPType& aNewData,
   124         const MMTPType& aNewData,
   125             const CMTPObjectMetaData& aObjectMetaData );
   125         const TDesC& aFullFileName,
   126 
   126         TMPXGeneralCategory aCategory );
   127     /**
   127 
   128     * Set object property and updated object in DB according property code,
   128     CMPXMedia* FindWMPMediaLC( TMPXAttributeData aWMPMediaID,
   129     * only for update, not for creation
   129         TBool aFlag );
   130     * @param aPropCode, property code of aObjectMetaData
   130 
   131     * @param aNewData, object property value which will be set into
   131     /**
   132     *     aObjectMetaData
   132      * Update the Sync flag for those not synchronized, Update the Modified
   133     * @param aSuid, full file name of object of which properties need to set
   133      * flag for those have been modified, and delete the stale records for
   134     */
   134      * files that have been deleted.
   135     void SetObjectMetadataValueL( const TUint16 aPropCode,
   135      */
   136             const MMTPType& aNewData,
       
   137             const TDesC& aSuid );
       
   138 
       
   139     CMPXMedia* FindWMPMediaLC( TMPXAttributeData aWMPMediaID, TBool aFlag );
       
   140 
       
   141     /**
       
   142     * Update the Sync flag for those not synchronized, Update the Modified
       
   143     * flag for those have been modified, and delete the stale records for
       
   144     * files that have been deleted.
       
   145     */
       
   146     void UpdateMusicCollectionL();
   136     void UpdateMusicCollectionL();
   147 
   137 
   148     /**
   138     /**
   149     * Remove the file from MPX DB
   139      * Remove the file from MPX DB
   150     * @param aFullFileName, the file to remove
   140      * @param aFullFileName, the file to remove
   151     * @param aCategory, the category of the file
   141      * @param aCategory, the category of the file
   152     */
   142      */
   153     void DeleteObjectL( const TDesC& aFullFileName, TMPXGeneralCategory aCategory );
   143     void DeleteObjectL( const TDesC& aFullFileName,
   154 
   144         TMPXGeneralCategory aCategory );
   155     /**
   145 
   156     * Rename the filename onto MPX DB
   146     /**
   157     * @param aOldFileName, the old file to rename
   147      * Rename the filename onto MPX DB
   158     * @param aNewFileName, the new file name
   148      * @param aOldFileName, the old file to rename
   159     * @param aFormatCode, the format of object
   149      * @param aNewFileName, the new file name
   160     */
   150      * @param aCategory, the category of object
   161     void RenameObjectL( const TDesC& aOldFileName, const TDesC& aNewFileName,
   151      */
   162             TUint aFormatCode );
   152     void RenameObjectL( const TDesC& aOldFileName,
   163 
   153         const TDesC& aNewFileName,
   164     /**
   154         TMPXGeneralCategory aCategory );
   165     * Set current  drive info
   155 
   166     * @param aStorageRoot, current drive info
   156     /**
   167     */
   157      * Set current  drive info
       
   158      * @param aStorageRoot, current drive info
       
   159      */
   168     void SetStorageRootL( const TDesC& aStorageRoot );
   160     void SetStorageRootL( const TDesC& aStorageRoot );
   169 
   161 
   170     /**
   162     /**
   171     * Get modified content
   163      * Get modified content
   172     * @param arrayCount, count of modified content
   164      * @param arrayCount, count of modified content
   173     * @param aModifiedcontent, modified files name list
   165      * @param aModifiedcontent, modified files name list
   174     */
   166      */
   175     void GetModifiedContentL( TInt& arrayCount, CDesCArray& aModifiedcontent );
   167     void GetModifiedContentL( TInt& arrayCount,
   176     
   168         CDesCArray& aModifiedcontent );
   177     /**
   169 
   178     * if the playlsit exist in the MPX DB
   170     /**
   179     * @param aSuid, the suid of playlsit
   171      * if the playlsit exist in the MPX DB
   180     */
   172      * @param aSuid, the suid of playlsit
       
   173      */
   181     TBool IsExistL( const TDesC& aSuid );
   174     TBool IsExistL( const TDesC& aSuid );
   182 
   175 
   183 private:
   176 private:
   184     CMmMtpDpMetadataMpxAccess( RFs& aFs, MMTPDataProviderFramework& aFramework );
   177     CMmMtpDpMetadataMpxAccess( RFs& aFs );
   185 
   178 
   186     void ConstructL();
   179     void ConstructL();
   187 
   180 
   188     void SetDefaultL( CMPXMedia& aMediaProp );
   181     void SetDefaultL( CMPXMedia& aMediaProp );
   189 
   182 
   190     /**
   183     /**
   191     * Set property value into MPX object according to property code,
   184      * Set property value into MPX object according to property code,
   192     * only used by member functions of this class.
   185      * only used by member functions of this class.
   193     * @param aPropCode, specify property code of aMediaProp
   186      * @param aPropCode, specify property code of aMediaProp
   194     * @param aNewData, object property value which will be set into
   187      * @param aNewData, object property value which will be set into
   195     *     aObjectMetaData
   188      *     aObjectMetaData
   196     * @param aObjectMetaData, owner of the property which should be
   189      * @param aObjectMetaData, owner of the property which should be
   197     *     inserted or updated into database
   190      *     inserted or updated into database
   198     */
   191      */
   199     void SetMetadataValueL( const TUint16 aPropCode,
   192     void SetMetadataValueL( const TUint16 aPropCode,
   200             const MMTPType& aNewData,
   193         const MMTPType& aNewData,
   201             CMPXMedia& aMediaProp );
   194         CMPXMedia& aMediaProp );
   202 
   195 
   203     TMPXAttributeData MpxAttribFromPropL( const CMPXMedia& aMedia,
   196     TMPXAttributeData MpxAttribFromPropL( const TUint16 aPropCode );
   204             const TUint16 aPropCode );
       
   205 
   197 
   206     MMPXCollectionHelper* CollectionHelperL();
   198     MMPXCollectionHelper* CollectionHelperL();
   207 
   199 
   208 private:
   200 private:
   209     // File server to allow file access
       
   210     RFs& iRfs;
   201     RFs& iRfs;
   211 
   202 
   212     TBuf<KStorageRootMaxLength> iStoreRoot;
   203     TBuf<KStorageRootMaxLength> iStoreRoot;
   213 
   204 
   214     MMPXCollectionHelper* iCollectionHelper;
   205     MMPXCollectionHelper* iCollectionHelper;
   215     
       
   216     MMTPDataProviderFramework& iFramework;  
       
   217 
   206 
   218 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
   207 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
   219     CMmMtpDpPerfLog* iPerfLog;
   208     CMmMtpDpPerfLog* iPerfLog;
   220 #endif
   209 #endif
   221 
   210