mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbplugin/inc/mpxdbartist.h
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     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 "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 Artist table.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef MPXDBARTIST_H
       
    21 #define MPXDBARTIST_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "mpxdbcategory.h"
       
    25 
       
    26 // CLASS DECLARATION
       
    27 class MMPXDbArtistObserver
       
    28     {
       
    29     public:
       
    30 		virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aId) = 0;
       
    31 	};
       
    32 
       
    33 /**
       
    34 * Responsible for managing all music databases
       
    35 *
       
    36 * @lib MPXDbPlugin.lib
       
    37 */
       
    38 
       
    39 class CMPXDbArtist :
       
    40     public CMPXDbCategory
       
    41     {
       
    42     public:
       
    43         /**
       
    44         * Two-phased constructor.
       
    45         * @param aDbManager database manager to use for database interactions
       
    46         * @param aCategory identifies the category
       
    47         * @return New CMPXDbArtist instance.
       
    48         */
       
    49         static CMPXDbArtist* NewL(CMPXDbManager& aDbManager,
       
    50             TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
       
    51 
       
    52         /**
       
    53         * Two-phased constructor.
       
    54         * @param aDbManager database manager to use for database interactions
       
    55         * @param aCategory identifies the category
       
    56         * @return New CMPXDbArtist instance on the cleanup stack.
       
    57         */
       
    58         static CMPXDbArtist* NewLC(CMPXDbManager& aDbManager,
       
    59             TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
       
    60 
       
    61         /**
       
    62         * Destructor
       
    63         */
       
    64         virtual ~CMPXDbArtist();
       
    65        
       
    66     public:
       
    67         /**
       
    68         * Add a category item. If the record already exists, its counter will
       
    69         * be incremented.
       
    70         * @param aName: This is the name to be entered into the row
       
    71         * @param aDriveId: The Drive Id the name (category) belongs
       
    72         * @param aNewRecord: indicates to the caller if a new record is created.
       
    73         *        ETrue if a new row is created in the table; otherwise EFalse.
       
    74         * @param aCaseSensitive indicates whether case sensitivity should be taken
       
    75         *        into consideration when generating the unique row id
       
    76         * @return The unique id of the row added.
       
    77         */
       
    78         TUint32 AddItemL(const TDesC& aName, const TDesC& aArt, TInt aDriveId, TBool& aNewRecord,
       
    79             TBool aCaseSensitive = ETrue);
       
    80         
       
    81         /**
       
    82         * Gets the details for all category items.
       
    83         * @param aAttrs attributes to be returned
       
    84         * @param aMediaArray returns the requested attributes for all items
       
    85         */
       
    86         void GetAllCategoryItemsL(const TArray<TMPXAttribute>& aAttrs,
       
    87             CMPXMediaArray& aMediaArray);
       
    88         
       
    89         /**
       
    90         * Update a category item. 
       
    91         * @param aId: The ID of the category to update
       
    92         * @param aMedia: The media data
       
    93         * @param aDriveId: The Drive Id the name (category) belongs
       
    94         * @param aItemChangedMessages: if valid on return contains a updated message if the
       
    95         *        category was updated
       
    96         */
       
    97         void UpdateItemL(TUint32 aId, const CMPXMedia& aMedia, TInt aDriveId, CMPXMessageArray* aItemChangedMessages);
       
    98         
       
    99         /*
       
   100         * Checks if the specified artist item is unknown
       
   101         * @param aId identifies the artist item
       
   102         * @return ETrue if it is unknown, EFalse otherwise
       
   103         */        
       
   104         TBool IsUnknownArtistL(TUint32 aId);
       
   105         
       
   106     private:
       
   107 
       
   108         /**
       
   109         * Updates the media with information from the table
       
   110         * @param aRecord record containing the source fields
       
   111         * @param aAttrs attributes to be returned
       
   112         * @param aMedia returns the requested attributes
       
   113         */
       
   114         void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
       
   115             CMPXMedia& aMedia);
       
   116 
       
   117         /**
       
   118         * Generate searching criteria for artist table from the given criteria
       
   119         * @param aMedia media data
       
   120         * @param aFields fields of Artist table
       
   121         * @param aValues values of each field of Artist table
       
   122         * @return a string containing the selection criteria. The ownership is passed to the caller.
       
   123         */
       
   124         void GenerateArtistFieldsValuesL(const CMPXMedia& aMedia, 
       
   125             CDesCArray& aFields, CDesCArray& aValues);
       
   126        
       
   127         /**
       
   128         * Gets the Album counts for a Artist item
       
   129         * @param aId identifies the Artist item
       
   130         * @return value of the Album counts
       
   131         */
       
   132         TInt GetAlbumsCountL(TUint32 aId);
       
   133 
       
   134     private:    // from MMPXTable
       
   135 
       
   136         /**
       
   137         * @see MMPXTable
       
   138         */
       
   139         virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
       
   140 
       
   141         /**
       
   142         * @see MMPXTable
       
   143         */
       
   144         virtual TBool CheckTableL(RSqlDatabase& aDatabase);
       
   145         
       
   146     private:
       
   147 
       
   148         /**
       
   149         * C++ constructor.
       
   150         * @param aDbManager database manager to use for database interactions
       
   151         * @param aCategory identifies the category
       
   152         */
       
   153         CMPXDbArtist(CMPXDbManager& aDbManager, TMPXGeneralCategory aCategory, MMPXDbArtistObserver& aObserver);
       
   154 
       
   155         /**
       
   156         * Second phase constructor.
       
   157         */
       
   158         void ConstructL();
       
   159 
       
   160     private:
       
   161 
       
   162         /**
       
   163         * Column indexes in the category tables
       
   164         */
       
   165         enum TArtistColumns
       
   166             {
       
   167             EArtistUniqueId = KMPXTableDefaultIndex,
       
   168             EArtistName,
       
   169             EArtistSongCount,
       
   170             EArtistArt,
       
   171             EArtistFieldCount
       
   172             };
       
   173 
       
   174     private:    // Data
       
   175         MMPXDbArtistObserver& iObserver;
       
   176     };
       
   177 #endif // MPXDBARTIST_H
       
   178 
       
   179 // End of File