wvuing/wvuistorage/src/CCAStorage.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003-2005 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:  Class for persistent storaging
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCASTORAGE_H
       
    21 #define CCASTORAGE_H
       
    22 
       
    23 //  INCLUDES
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <e32std.h>
       
    27 
       
    28 #include <s32file.h>
       
    29 #include <d32dbms.h>
       
    30 
       
    31 #include "CCAGroupStorage.h"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 class MCAExtendedStoredContact;
       
    36 class MCAExtendedStoredGroup;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 /**
       
    40  * This class handles the persistent storaging, i.e. interfacing with the
       
    41  * database. It offers an internal interface to the database for the
       
    42  * CCAStorageManager.
       
    43  *
       
    44  * @lib CAStorage
       
    45  * @since 2.1
       
    46  */
       
    47 class CCAStorage : public CBase
       
    48     {
       
    49     public:
       
    50 
       
    51         /**
       
    52          * Destructor
       
    53          */
       
    54         ~CCAStorage();
       
    55 
       
    56         /**
       
    57          * Two-phased constructor.
       
    58          */
       
    59         static CCAStorage* NewL();
       
    60 
       
    61         /*
       
    62          * Loads group
       
    63          * @since	2.1
       
    64          * @param	aGroup	Group is read to this object
       
    65          */
       
    66         void	LoadL( MCAExtendedStoredGroup* aGroup );
       
    67 
       
    68         /*
       
    69          * Saves group
       
    70          * @since	2.1
       
    71          * @param	aGroup	Group that is saved
       
    72          */
       
    73         void	SaveL( MCAExtendedStoredGroup* aGroup );
       
    74 
       
    75         /*
       
    76          * Deletes group
       
    77          * @since	2.1
       
    78          * @param	aGroup	Group that is deleted
       
    79          */
       
    80         void	DeleteL( MCAExtendedStoredGroup* aGroup );
       
    81 
       
    82         /*
       
    83          * Loads first group from database
       
    84          * @since	2.1
       
    85          * @param	aGroup	Group is read to this object
       
    86          * @return	KErrNone, if ok. KErrNotFound, if group is not found.
       
    87          */
       
    88         TInt	LoadFirstL( MCAExtendedStoredGroup* aGroup );
       
    89 
       
    90         /*
       
    91          * Loads next group from database
       
    92          * @since	2.1
       
    93          * @param	aGroup	Group is read to this object
       
    94          * @return	KErrNone, if ok. KErrNotFound, if group is not found.
       
    95          */
       
    96         TInt	LoadNextL( MCAExtendedStoredGroup* aGroup );
       
    97 
       
    98         /*
       
    99          * Does free diskspace check before writing to database
       
   100          * @since	2.1
       
   101          * @param	aGroup group that is written to database
       
   102          * Function leaves with KErrDiskFull, if freespace goes below critical level
       
   103          */
       
   104         void	CheckFreespaceLevelL( MCAExtendedStoredGroup* aGroup );
       
   105 
       
   106     protected:
       
   107 
       
   108         /**
       
   109          * C++ default constructor.
       
   110          */
       
   111         CCAStorage();
       
   112 
       
   113         /**
       
   114          * By default Symbian 2nd phase constructor is private.
       
   115          */
       
   116         void		ConstructL();
       
   117 
       
   118     private:
       
   119 
       
   120         /**
       
   121          * Check if database exists
       
   122          * @since	2.1
       
   123          * @return	ETrue, if database exists.
       
   124          */
       
   125         TBool		DbExists();
       
   126 
       
   127         /**
       
   128          * Creates new CPermanentFileStore stream and creates database on it.
       
   129          * @since	2.1
       
   130          */
       
   131         void		CreateDbL();
       
   132 
       
   133         /**
       
   134          * Open existing database.
       
   135          * @since	2.1
       
   136          */
       
   137         void		OpenDbL();
       
   138 
       
   139         /**
       
   140          * Close database.
       
   141          * @since	2.1
       
   142          */
       
   143         void		CloseDb();
       
   144 
       
   145         /*
       
   146          * Create tables to database
       
   147          * @since	2.1
       
   148          */
       
   149         void		CreateTablesL();
       
   150 
       
   151         /**
       
   152          * Add a column to colset
       
   153          * @since	2.1
       
   154          * @param	aName Name of column
       
   155          * @param	aType Type of column
       
   156          * @param	aColset Colset, where column is added.
       
   157          * @param   aMaxLength Maximum column length
       
   158          *          0 = use columns default value
       
   159          */
       
   160         void	AddColumnL( const TDesC& aName, TDbColType aType,
       
   161                          CDbColSet* aColset, TInt aMaxLength = 0 );
       
   162 
       
   163         /*
       
   164          * Leaves if free diskspace is low.
       
   165          * @since	2.1
       
   166          * @param	aSize amount of free diskspace needed.
       
   167          */
       
   168         void	DoFreespaceLevelCheckL( TInt aSize );
       
   169 
       
   170     private:
       
   171 
       
   172         // storage for groups, owned
       
   173         CCAGroupStorage*		iGroupStorage;
       
   174 
       
   175 
       
   176         CPermanentFileStore*	iFileStore;
       
   177 
       
   178         RFs		iFs;
       
   179 
       
   180         TStreamId				iStreamId;
       
   181         RDbStoreDatabase		iDb;
       
   182     };
       
   183 
       
   184 #endif // CCASTORAGE_H
       
   185 
       
   186 //  End of File