mmappcomponents/harvester/filehandler/inc/mpxharvesterdbtable.h
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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:  Encapsulates db operations on a table
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXHARVESTERDBTABLE_H
       
    20 #define CMPXHARVESTERDBTABLE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <d32dbms.h>
       
    24 
       
    25 //#define __PRINTDB__
       
    26 
       
    27 // Forward Declarations
       
    28 //
       
    29 class CMPXHarvesterDbItem;
       
    30        
       
    31 /**
       
    32  *  CMPXHarvesterDatabaseTable
       
    33  *  Encapsulates operations on the database
       
    34  *
       
    35  *  @lib mpxfilehandler.lib
       
    36  *  @since S60 v3.0
       
    37  */
       
    38 NONSHARABLE_CLASS( CMPXHarvesterDatabaseTable ): public CBase
       
    39     {
       
    40 
       
    41 public:
       
    42 
       
    43     /**
       
    44     * Two-Phased Constructor
       
    45     * @param aDb database to create the table from
       
    46     * @return CMPXHarvesterDatabaseTable instance
       
    47     */
       
    48     static CMPXHarvesterDatabaseTable* NewLC( RDbStoreDatabase& aDB );
       
    49     
       
    50     /**
       
    51     * Virtual Destructor
       
    52     */
       
    53     virtual ~CMPXHarvesterDatabaseTable();
       
    54 
       
    55 public: 
       
    56 
       
    57     /**
       
    58     * Open a table to list all files
       
    59     */
       
    60     void OpenAllFilesTableL();
       
    61     
       
    62     /**
       
    63     * Opens a table to a specific directory
       
    64     * @param aDirectory directory to list the files
       
    65     */ 
       
    66     void OpenDirectoryL( const TDesC& aDirectory );
       
    67     
       
    68     /**
       
    69     * Open a table to a specific song
       
    70     * @param aSongName song to open
       
    71     */
       
    72     void OpenItemL( const TDesC& aSongName );
       
    73     
       
    74     /**
       
    75     * Open a table to list of files with DRM flag set.
       
    76     * @param aSongName song to open
       
    77     */
       
    78     void OpenDrmL();
       
    79     
       
    80     /**
       
    81     * Add an item
       
    82     * @param aPath path of the file
       
    83     * @param aFileName file to add
       
    84     * @param aLastModTime last modified time
       
    85     * @param aDRM is the file a drm file
       
    86     */
       
    87     void AddItemL( const TDesC& aPath, const TDesC& aFileName, 
       
    88                    const TTime aLastModTime, const TInt aColId,
       
    89                    const TBool aDRM );
       
    90     
       
    91     /**
       
    92     * Updates an item
       
    93     * @param aPath, file path
       
    94     * @paran aLastModTime, last modified time
       
    95     * @param aColID, collection id
       
    96     * @param aDrm, is this file drm'd?
       
    97     * @param aNewTransaction create new transaction for operation
       
    98     */
       
    99     void UpdateItemL( const TDesC& aPath, const TTime aLastModTime,
       
   100                       const TInt aColID, const TBool aDRM, 
       
   101                       TBool aNewTransaction = ETrue);
       
   102     
       
   103     /**
       
   104     * Updates an item (don't care about drm)
       
   105     * @paran aLastModTime, last modified time
       
   106     * @param aColID, collection id
       
   107     * @param aNewTransaction create new transaction for operation
       
   108     * @param aPath, path of the item
       
   109     */
       
   110     void UpdateItemL( const TTime aLastModTime,
       
   111                       const TInt aColID = KNullUid.iUid,
       
   112                       TBool aNewTransaction = ETrue,
       
   113                       const TDesC& aPath = KNullDesC );
       
   114                       
       
   115     /**
       
   116     * Delete the current song
       
   117     */
       
   118     void DeleteItemL(TBool aEndTransaction);
       
   119     
       
   120     /**
       
   121     * Return the count of the current view
       
   122     */
       
   123     TInt CountL();
       
   124     
       
   125     /**
       
   126     * Generates a RPointerArray to represent the table
       
   127     * @return pointer array containing the list of items
       
   128     */
       
   129     RPointerArray<CMPXHarvesterDbItem>* CreateTableRepresentationL();
       
   130     
       
   131 #ifdef __PRINTDB__
       
   132     /**
       
   133     * Debug function to print out all of the elements
       
   134     */
       
   135     void PrintItemsInTableL();
       
   136 #endif
       
   137 
       
   138 private: // New Functions
       
   139     
       
   140     /**
       
   141     * Read a long text string from db at the specified column
       
   142     * @param aColumn
       
   143     * @return string left on cleanup stack
       
   144     */
       
   145     HBufC* ReadLongTextLC( TInt aColumn );
       
   146     
       
   147     /**
       
   148     * Replaces single quotes with two single quotes
       
   149     * @param aSrc source descriptor
       
   150     * @param aTrg destination descriptor
       
   151     */
       
   152     void FindAndReplaceSingleQuote(const TDesC& aSrc, TDes& aTrg);
       
   153          
       
   154 private:
       
   155 
       
   156     /**
       
   157     * Private Constructor
       
   158     * @param aDb database to create the table from
       
   159     */
       
   160     CMPXHarvesterDatabaseTable( RDbStoreDatabase& aDB );
       
   161 
       
   162 private: 
       
   163 
       
   164     // Enumeration of what state this table is
       
   165     //
       
   166     enum TTableState
       
   167         {
       
   168         EInvalidState,
       
   169         EAllItems,   // Listing all items
       
   170         EDirectory,  // Listing only a directory
       
   171         EFile,       // Listing only a file
       
   172         EDrm         // Listing files with DRM flag
       
   173         };
       
   174      
       
   175 private: // data
       
   176     RDbStoreDatabase&  iDb;
       
   177     RDbView            iView;
       
   178     TTableState        iState;
       
   179     };
       
   180 
       
   181 #endif // CMPXHARVESTERDBTABLE_H