cbs/CbsServer/ServerInc/CCbsDbImp.H
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2003 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 file contains the header file of the CCbsDbImp class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef     CCBSDBIMP_H
       
    22 #define     CCBSDBIMP_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <f32file.h>
       
    26 
       
    27 // CONSTANTS
       
    28 enum TCbsBackupRequest
       
    29     {
       
    30     ECbsNoBackup,
       
    31     ECbsBackup,
       
    32     ECbsRestore,
       
    33     ECbsBackupNotDefined
       
    34     };
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CCbsDbImpSettings;
       
    38 class CCbsDbImpTopicList;
       
    39 class CCbsDbImpTopicCollection;
       
    40 class CCbsDbImpTopicMessages;
       
    41 class CBaBackupSessionWrapper;
       
    42 class CCbsBackupMonitor;
       
    43 class CCbsDiskSpaceMonitor;
       
    44 
       
    45 //  CLASS DECLARATION 
       
    46 
       
    47 /**
       
    48 *   Basis for the implementation of the database.
       
    49 *
       
    50 *   Constructs instances of database subclasses CCbsDbImpSettings,
       
    51 *   CCbsDbImpTopicCollection, CCbsDbTopicList and CCbsDbTopicMessages.
       
    52 *   On initialization determines whether datafiles already exist.
       
    53 *   If all of them are present and valid, no special action is taken.
       
    54 *
       
    55 *   If some or all datafiles are missing or corrupt, all datafiles
       
    56 *   are deleted and new files created.
       
    57 *   Factory default settings, if available, are then loaded from
       
    58 *   Shared Data and stored in server datafiles. This is done by
       
    59 *   database subinstances.
       
    60 */
       
    61 class CCbsDbImp : public CBase
       
    62     {
       
    63     public:        // New functions
       
    64 
       
    65         /**
       
    66         *   Creates an instance of the class.
       
    67         */
       
    68         static CCbsDbImp* NewL();
       
    69 
       
    70         /**
       
    71          *   The destructor.
       
    72          */
       
    73         ~CCbsDbImp();
       
    74     
       
    75     public:
       
    76 
       
    77         /**
       
    78         *   Returns a reference to the current active topic list. 
       
    79         *   
       
    80         *   Using that instance the clients of the database can manage the 
       
    81         *   topic list such as add and delete topics.
       
    82         *
       
    83         *   @return reference to the topic list.
       
    84         */
       
    85         CCbsDbImpTopicList& TopicListL();
       
    86     
       
    87         /**
       
    88         *   Returns a reference to the current topic messages DB object.
       
    89         *
       
    90         *   @return reference to the topic messages.
       
    91         */
       
    92         CCbsDbImpTopicMessages& TopicMessagesL();
       
    93 
       
    94         /**
       
    95         *   Returns a reference to the settings DB object.
       
    96         *    
       
    97         *   @return reference to the settings.
       
    98         */
       
    99         CCbsDbImpSettings& SettingsL();
       
   100 
       
   101         /**
       
   102         *   Returns a reference to the topic collection. 
       
   103         *   
       
   104         *   @return reference to the topic collection.
       
   105         */
       
   106         CCbsDbImpTopicCollection& TopicCollectionL();
       
   107 
       
   108         /**
       
   109         *   Returns a reference to the backup wrapper. 
       
   110         *   
       
   111         *   @return reference to the backup wrapper.
       
   112         */
       
   113         CBaBackupSessionWrapper& BackupWrapperL();
       
   114 
       
   115         /**
       
   116         *   Checks if the database is initialized.
       
   117         *
       
   118         *   @return     ETrue if database has been initialized.
       
   119         */
       
   120         TBool IsInitialized() const;
       
   121 
       
   122         /**
       
   123         *   Registers for a notification for critical level.
       
   124         */
       
   125         void WaitForCriticalLevel();
       
   126 
       
   127         /**
       
   128         *   Deregisters from critical level notification.
       
   129         */
       
   130         void WaitForCriticalLevelCancel();
       
   131         
       
   132         /**
       
   133         *   Changes file lock states as requested.
       
   134         */
       
   135         void ChangeFileLocksL( const TCbsBackupRequest& aRequest );
       
   136         
       
   137         /**
       
   138         *   Constructs DB components.
       
   139         *
       
   140         */
       
   141         void CreateComponentsL();
       
   142 
       
   143     private:
       
   144 
       
   145         /**
       
   146         *   Constructor.
       
   147         */
       
   148         CCbsDbImp();
       
   149 
       
   150         /**
       
   151         *   The method creates the member variables and so finalizes 
       
   152         *   the construction. It will leave if the construction fails.
       
   153         */
       
   154         void ConstructL();
       
   155 
       
   156         /**
       
   157         *   Constructs CCbsDbImpSettings.
       
   158         *
       
   159         *   @param  aFileName               Name of the settings file.
       
   160         *   @return                         A ready-made CCbsDbImpSettings object.
       
   161         */
       
   162         CCbsDbImpSettings* CreateSettingsL();
       
   163 
       
   164         /**
       
   165         *   Constructs CCbsDbImpTopicList.
       
   166         *
       
   167         *   @param  aTopicsFile             Name of the topics file.
       
   168         *   @param  aMessagesFile           Name of the messages file.
       
   169         *   @return                         A ready-made CCbsDbImpTopicList object.
       
   170         */
       
   171         CCbsDbImpTopicList* CreateTopicListL( const TDesC& aTopicsFile,
       
   172                                               const TDesC& aMessagesFile );
       
   173 
       
   174         /**
       
   175         *   Constructs CCbsDbImpTopicMessages.
       
   176         *
       
   177         *   @param  aTopicList              The CCbsDbImpTopicList to link to.
       
   178         *   @return                         A ready-made CCbsDbImpTopicMessages object.
       
   179         */
       
   180         CCbsDbImpTopicMessages* CreateTopicMessagesL( CCbsDbImpTopicList& aTopicList );
       
   181 
       
   182         /**
       
   183         *   Constructs CCbsDbImpTopicCollection.
       
   184         *
       
   185         *   @param  aTopicList              The CCbsDbImpTopicList to link to.
       
   186         *   @return                         A ready-made CCbsDbImpTopicCollection object.
       
   187         */
       
   188         CCbsDbImpTopicCollection* CreateTopicCollectionL();
       
   189 
       
   190         /**
       
   191         *   Free DB components.
       
   192         */
       
   193         void DeleteComponents();        
       
   194         
       
   195     private:
       
   196         // Owns: DB settings object.
       
   197         CCbsDbImpSettings* iSettings;
       
   198 
       
   199         // Owns: DB topic list object.
       
   200         CCbsDbImpTopicList* iTopicList;
       
   201 
       
   202         // Owns: DB topic collection object. 
       
   203         CCbsDbImpTopicCollection* iTopicCollection;
       
   204 
       
   205         // Owns: DB topic messages object.
       
   206         CCbsDbImpTopicMessages* iTopicMessages;
       
   207 
       
   208         // File server session shared by all DB objects. 
       
   209         RFs iFs;
       
   210 
       
   211         // Owns: The backup wrapper
       
   212         CBaBackupSessionWrapper* iBackupWrapper;
       
   213         
       
   214         // Owns: The backup monitor, uses PubSub
       
   215         CCbsBackupMonitor* iBackupMonitor;
       
   216         
       
   217         // Owns: Disk space monitor, uses PubSub
       
   218         CCbsDiskSpaceMonitor* iDiskSpaceMonitor;
       
   219 
       
   220     };
       
   221 
       
   222 #endif      //  CCBSDBIMP_H   
       
   223             
       
   224 // End of File