mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/inc/mpxdbabstractalbum.h
branchRCL_3
changeset 17 c8156a91d13c
child 18 c54d95799c80
equal deleted inserted replaced
15:171e07ac910f 17:c8156a91d13c
       
     1 /*
       
     2 * Copyright (c) 2007 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 the License "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:  This class is responsible for all category tables (Artist,
       
    15 *                Album, Genre, Composer, AbstractAlbum).
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef MPXDBABSTRACTALBUM_H
       
    22 #define MPXDBABSTRACTALBUM_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <thumbnailmanager.h>
       
    26 #include <thumbnailmanagerobserver.h>
       
    27 #include "mpxdbcategory.h"
       
    28 
       
    29 
       
    30 // CLASS FORWARDS
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 * Responsible for managing all music databases
       
    36 *
       
    37 * @lib MPXDbPlugin.lib
       
    38 */
       
    39 
       
    40 class CMPXDbAbstractAlbum :
       
    41     public CMPXDbCategory,
       
    42     public MThumbnailManagerObserver
       
    43     {
       
    44     public:
       
    45 
       
    46         /**
       
    47         * Two-phased constructor.
       
    48         * @param aDbManager database manager to use for database interactions
       
    49         * @param aCategory identifies the category
       
    50         * @return New CMPXDbCategory instance.
       
    51         */
       
    52         static CMPXDbAbstractAlbum* NewL(CMPXDbManager& aDbManager,
       
    53             TMPXGeneralCategory aCategory);
       
    54 
       
    55         /**
       
    56         * Two-phased constructor.
       
    57         * @param aDbManager database manager to use for database interactions
       
    58         * @param aCategory identifies the category
       
    59         * @return New CMPXDbCategory instance on the cleanup stack.
       
    60         */
       
    61         static CMPXDbAbstractAlbum* NewLC(CMPXDbManager& aDbManager,
       
    62             TMPXGeneralCategory aCategory);
       
    63 
       
    64         /**
       
    65         * Destructor
       
    66         */
       
    67         virtual ~CMPXDbAbstractAlbum();
       
    68 
       
    69         /**
       
    70         * Find the drive Id for a abstractalbum
       
    71         * @param aAbstractAlbumId identifies the abstractalbum
       
    72         * @return corresponding drive id
       
    73         */
       
    74         TInt GetDriveIdL(TUint32 aAbstractAlbumId);
       
    75 
       
    76         /**
       
    77         * Add a category item. If the record already exists, its counter will
       
    78         * be incremented.
       
    79         * @param aName: This is the name to be entered into the row
       
    80         * @param aDriveId: The Drive Id the name (category) belongs
       
    81         * @param aNewRecord: indicates to the caller if a new record is created.
       
    82         *        ETrue if a new row is created in the table; otherwise EFalse.
       
    83         * @param aCaseSensitive indicates whether case sensitivity should be taken
       
    84         *        into consideration when generating the unique row id
       
    85         * @return The unique id of the row added.
       
    86         */
       
    87         TUint32 AddItemL( const TDesC& aName, const TDesC& aAlbumArtist, const TDesC& aGenre, TInt aDriveId, TBool& aNewRecord,
       
    88             TBool aCaseSensitive = ETrue);
       
    89         
       
    90         /**
       
    91         * Decrement the number of songs for the item. If the count gets to 0, remove
       
    92         * the item.
       
    93         * @param aId: The ID of the category to delete.
       
    94         * @param aDriveId: The drive Id the name (category) belongs to. Songs on different
       
    95         *                  drives may belong to the same album or artist; consequently, one
       
    96         *                  row for each artist/album id and drive ID pair will exist in the
       
    97         *                  lookup table with a count existing for each row that tracks the
       
    98         *                  number number of songs on that drive with that album/artist.
       
    99         * @param aItemChangedMessages if valid on return contains a deleted message if the
       
   100         *                  category was deleted
       
   101         * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete,
       
   102         *        EFalse otherwise
       
   103         */
       
   104         void DecrementSongsForCategoryL(TUint32 aId, TInt aDriveId,
       
   105             CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, TBool aMtpInUse);
       
   106   
       
   107         /**
       
   108         * Remove a abstractalbum and return its URI
       
   109         * @param aAbstractAlbumId identifies the abstractalbum
       
   110         * @return HBufC containing the URI. Ownership is transferred.
       
   111         */
       
   112         HBufC* DeleteAbstractAlbumL(TUint32 aAbstractAlbumId, TInt aDriveId = 0);
       
   113         
       
   114         /**
       
   115         * Update a category item.
       
   116         * @param aId: The ID of the category to update
       
   117         * @param aMedia: The media data
       
   118         * @param aDriveId: The Drive Id the name (category) belongs
       
   119         * @param aItemChangedMessages: if valid on return contains a updated message if the
       
   120         *        category was updated
       
   121         */
       
   122         void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
       
   123 
       
   124     private:
       
   125 
       
   126 
       
   127         /**
       
   128         * Updates the media with information from the table
       
   129         * @param aRecord record containing the source fields
       
   130         * @param aAttrs attributes to be returned
       
   131         * @param aMedia returns the requested attributes
       
   132         */
       
   133         void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
       
   134             CMPXMedia& aMedia);
       
   135 
       
   136         /**
       
   137         * Generate searching criteria for album table from the given criteria
       
   138         * @param aMedia media data
       
   139         * @param aFields fields of Album table
       
   140         * @param aValues values of each field of Album table
       
   141         * @return a string containing the selection criteria. The ownership is passed to the caller.
       
   142         */
       
   143         void GenerateAbstractAlbumFieldsValuesL(const CMPXMedia& aMedia,
       
   144             CDesCArray& aFields, CDesCArray& aValues);
       
   145 
       
   146 
       
   147         /**
       
   148         * @see MMPXTable
       
   149         */
       
   150         virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
       
   151 
       
   152 
       
   153         
       
   154         /**
       
   155         * @see MMPXTable
       
   156         */
       
   157         virtual TBool CheckTableL(RSqlDatabase& aDatabase);
       
   158         
       
   159         
       
   160     
       
   161         /**
       
   162         * C++ constructor.
       
   163         * @param aDbManager database manager to use for database interactions
       
   164         * @param aCategory identifies the category
       
   165         */
       
   166         CMPXDbAbstractAlbum(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory);
       
   167 
       
   168         /**
       
   169         * Second phase constructor.
       
   170         */
       
   171         void ConstructL();
       
   172         
       
   173         
       
   174         /**
       
   175         * MThumbnailManagerObserver
       
   176         */
       
   177         void ThumbnailPreviewReady(
       
   178             MThumbnailData& aThumbnail, TThumbnailRequestId aId );
       
   179         /**
       
   180         * MThumbnailManagerObserver
       
   181         */
       
   182         void ThumbnailReady(
       
   183             TInt aError, 
       
   184             MThumbnailData& aThumbnail, TThumbnailRequestId aId );
       
   185 
       
   186     public:
       
   187 
       
   188         /**
       
   189         * Column indexes in the category tables
       
   190         */
       
   191         enum TAbstractAlbumColumns
       
   192             {
       
   193             EAbstractAlbumUniqueId = KMPXTableDefaultIndex,
       
   194             EAbstractAlbumName,
       
   195             EAbstractAlbumArtist,
       
   196             EAbstractAlbumGenre,
       
   197             EAbstractAlbumSongCount,
       
   198             EAbstractAlbumVolumeId,
       
   199             EAbstractAlbumFieldCount
       
   200             };
       
   201 
       
   202     private:    // Data
       
   203         CThumbnailManager*        iTNManager;
       
   204 
       
   205     };
       
   206 #endif // MPXDBAbstractAlbum_H
       
   207 
       
   208 // End of File