mmappcomponents/harvester/filehandler/inc/mpxharvesterdb.h
changeset 0 a2952bb97e68
child 8 bee149131e4b
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:  Harvester internal database
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXHARVESTERDB_H
       
    20 #define CMPXHARVESTERDB_H
       
    21 
       
    22 #include <d32dbms.h>
       
    23 #include <s32file.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CMPXHarvesterDatabaseTable;
       
    27 
       
    28 /**
       
    29  *  Database class for the Harvester Component
       
    30  *
       
    31  *  @lib mpxfilehandler.lib
       
    32  *  @since S60 3.0
       
    33  */
       
    34 NONSHARABLE_CLASS( CMPXHarvesterDB ) : public CBase
       
    35     {
       
    36 
       
    37 public:
       
    38 
       
    39     /**
       
    40     * Two-phased constructor
       
    41     * @param aDrive drive of the database
       
    42     * @param aFs file session
       
    43     * @return new instance of CMPXHarvesterDB
       
    44     */
       
    45     static CMPXHarvesterDB* NewL( TDriveNumber aDrive, RFs& aFs );
       
    46 
       
    47     /**
       
    48     * Virtual destructor
       
    49     */
       
    50     virtual ~CMPXHarvesterDB();
       
    51 
       
    52     /**
       
    53     * Open the database
       
    54     */
       
    55     TInt OpenL();
       
    56 
       
    57     /**
       
    58     * Close the database
       
    59     */
       
    60     void Close();
       
    61 
       
    62     /**
       
    63     * Gets what drive this db object represents
       
    64     * @return TDriveNumber
       
    65     */
       
    66     TDriveNumber GetDbDrive();
       
    67 
       
    68     /**
       
    69     * Creates a table to open all files
       
    70     * @return CMPXHarvesterDatabaseTable instance, ownership x-fer
       
    71     */
       
    72     CMPXHarvesterDatabaseTable* OpenAllFilesTableL();
       
    73 
       
    74     /**
       
    75     * Creates a table to open to a specific directory
       
    76     * @return CMPXHarvesterDatabaseTable instance, ownership x-fer
       
    77     */
       
    78     CMPXHarvesterDatabaseTable* OpenDirectoryL( const TDesC& aDir );
       
    79 
       
    80     /**
       
    81     * Creates a table to open to a specific file
       
    82     * @return CMPXHarvesterDatabaseTable instance, ownership x-fer
       
    83     */
       
    84     CMPXHarvesterDatabaseTable* OpenFileL( const TDesC& aFile );
       
    85 
       
    86     /**
       
    87     * Creates a table to open to all files with DRM flag set
       
    88     * @return CMPXHarvesterDatabaseTable instance, ownership x-fer
       
    89     */
       
    90     CMPXHarvesterDatabaseTable* OpenDrmFileL();
       
    91     
       
    92     /**
       
    93     * Delete a file using SQL
       
    94     * @param aFile file to remove
       
    95     */
       
    96     void DeleteFileL( const TDesC& aFile );
       
    97 
       
    98     /**
       
    99     * Removes ALL files from this db
       
   100     */
       
   101     void RemoveAllFilesL();
       
   102 
       
   103     /**
       
   104     * Deletes the physical database file
       
   105     * Call Close() before calling delete!
       
   106     * If Close() isn't called KErrInUse will be returned
       
   107     * @return error for the operation
       
   108     */
       
   109     TInt DeleteDatabase();
       
   110 
       
   111     /**
       
   112     * Retrieve the unique ID of this db
       
   113     * The unique id is set as the volume id of the drive from
       
   114     * which the database was created
       
   115     */
       
   116     TUint UniqueIdL();
       
   117 
       
   118     /**
       
   119     * Count ALL files from this db
       
   120     * @return count for the operation
       
   121     */
       
   122     TInt CountAllFilesL();
       
   123     
       
   124     /**
       
   125     * Begin transaction on this db
       
   126     */
       
   127     void BeginL();
       
   128 
       
   129     /**
       
   130     * Check if the db is in transaction
       
   131     */
       
   132     TBool InTransaction();
       
   133     
       
   134     /**
       
   135     * Commit all changes in the transaction on this db
       
   136     */
       
   137     void CommitL();
       
   138     
       
   139     /**
       
   140     * Rollbacks the current transaction
       
   141     */
       
   142     void Rollback();
       
   143     
       
   144     
       
   145 private: // private functions
       
   146 
       
   147     /**
       
   148     * Create a database
       
   149     */
       
   150     void CreateDBL();
       
   151 
       
   152     /**
       
   153     * Opens a database
       
   154     * @return error for the operation
       
   155     */
       
   156     TInt OpenDBL();
       
   157 
       
   158     /**
       
   159     * Replace quotes
       
   160     * @param aSrc source
       
   161     * @param aTrg destination
       
   162     */
       
   163     void FindAndReplaceSingleQuote(const TDesC& aSrc,
       
   164                                    TDes& aTrg);
       
   165 
       
   166 private:
       
   167 
       
   168     /**
       
   169     * Default constructor
       
   170     */
       
   171     CMPXHarvesterDB( TDriveNumber aDrive, RFs& aFs  );
       
   172 
       
   173     /**
       
   174     * 2nd phase constructor
       
   175     */
       
   176     void ConstructL();
       
   177 
       
   178 private: // data
       
   179     TDriveNumber      iDrive;
       
   180     RFs&              iFs;
       
   181     // Internal database
       
   182     CFileStore*       iStore;
       
   183     RDbStoreDatabase* iDatabase;  // Local single client db
       
   184     TBool             iDBOpen;    // Is the db open and ready
       
   185     };
       
   186 
       
   187 #endif // CMPXHARVESTERDB_H