epoc32/include/mw/activeapdb.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
     1.1 --- a/epoc32/include/mw/activeapdb.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/mw/activeapdb.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,195 @@
     1.4 -activeapdb.h
     1.5 +/*
     1.6 +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:  Declaration of classes CActiveApDb
    1.19 +*               and MActiveApDbObserver.
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +#ifndef ACTIVE_APDB_H
    1.25 +#define ACTIVE_APDB_H
    1.26 +
    1.27 +// Deprecation warning
    1.28 +#warning This header file has been deprecated. Will be removed in one of the next SDK releases.
    1.29 +
    1.30 +
    1.31 +//  INCLUDES
    1.32 +#include <commdb.h>
    1.33 +#include <ApEngineVer.h>
    1.34 +
    1.35 +/*
    1.36 +// Enum for DATABASE_TYPE field
    1.37 +// Will be deprecated in 7.0
    1.38 +enum TCommDbDatabaseType
    1.39 +    {
    1.40 +    EUnspecified = 0,   // not specifying which type it is - any type of 
    1.41 +                        // database can be opened with this parameter
    1.42 +    EIAP,
    1.43 +    EISP
    1.44 +    };
    1.45 +*/
    1.46 +
    1.47 +// CONSTANTS
    1.48 +const TInt KErrActiveApDbObserverNotFound = -500;
    1.49 +
    1.50 +// FORWARD DECLARATION
    1.51 +class CActiveApDbNotifier;
    1.52 +
    1.53 +// CLASS DECLARATION
    1.54 +
    1.55 +/**
    1.56 +* Mixin protocol for handling events from a CCommsDatabase.
    1.57 +* Events are related to database changes and availability.
    1.58 +*/
    1.59 +class MActiveApDbObserver
    1.60 +    {
    1.61 +    public:     // types
    1.62 +        enum TEvent       /// Events reported to the database observer.
    1.63 +            {
    1.64 +            EDbChanged,   ///< Database has changed.
    1.65 +            EDbClosing,   ///< Database is about to close.
    1.66 +            EDbAvailable  ///< Database is available again.(E.g. after unlock)
    1.67 +            };
    1.68 +
    1.69 +    public:     // new methods
    1.70 +
    1.71 +        /**
    1.72 +        * Derived classes should implement this method, and act accordingly
    1.73 +        * to database events.
    1.74 +        * @param anEvent Database-related event.
    1.75 +        *
    1.76 +        * @deprecated
    1.77 +        */
    1.78 +        IMPORT_C virtual void HandleApDbEventL( TEvent anEvent ) = 0;
    1.79 +
    1.80 +    };
    1.81 +
    1.82 +/**
    1.83 +* This class manages and guards database integrity
    1.84 +* by handling all events that are related to the database. These events
    1.85 +* may originate from the system (Shutdown, Backup/Restore) and from the
    1.86 +* database itself. The events are transformed into a simple protocol,
    1.87 +* defined by MActiveApDbObserver.
    1.88 +* Expects an active scheduler to be installed and running.
    1.89 +*/
    1.90 +NONSHARABLE_CLASS( CActiveApDb ) : public CBase
    1.91 +    {
    1.92 +
    1.93 +    public:     // Constructors and destructor
    1.94 +        /**
    1.95 +        * Two-phased constructor. Leaves on failure.
    1.96 +        * @param aType The desired type of the CCommsDatabase object.
    1.97 +        * Defaults to EDatabaseTypeIAP.
    1.98 +        * @return The constructed CActiveApDb object.
    1.99 +        *
   1.100 +        * @deprecated
   1.101 +        */
   1.102 +        IMPORT_C static CActiveApDb* NewL
   1.103 +            ( TCommDbDatabaseType aType = EDatabaseTypeIAP );
   1.104 +
   1.105 +
   1.106 +
   1.107 +        /**
   1.108 +        * Destructor.
   1.109 +        *
   1.110 +        * @deprecated
   1.111 +        */
   1.112 +        IMPORT_C virtual ~CActiveApDb();
   1.113 +
   1.114 +    protected:  // Constructors
   1.115 +
   1.116 +        /**
   1.117 +        * Second phase constructor. Leaves on failure.
   1.118 +        * @param aType The desired type of the CCommsDatabase object.
   1.119 +        * events.
   1.120 +        */
   1.121 +        void ConstructL();
   1.122 +
   1.123 +    public:     // new methods
   1.124 +        /**
   1.125 +        * Adds an observer to the list of observers to be notified
   1.126 +        * about the DB events.
   1.127 +        * Also automatically starts observation and notification.
   1.128 +        * The order of notification will be exactly the order of registration.
   1.129 +        * @param anObserver Observer to be notified about database-related
   1.130 +        * events.
   1.131 +        *
   1.132 +        * @deprecated
   1.133 +        */
   1.134 +        IMPORT_C void AddObserverL( MActiveApDbObserver* anObserver );
   1.135 +
   1.136 +
   1.137 +        /**
   1.138 +        * Removes an observer. If not added, silently ignores.
   1.139 +        * @param anObserver The observer.
   1.140 +        *
   1.141 +        * @deprecated
   1.142 +        */
   1.143 +        IMPORT_C void RemoveObserver( MActiveApDbObserver* anObserver );
   1.144 +
   1.145 +
   1.146 +        /**
   1.147 +        * Returns the CCommsDatabase.
   1.148 +        * Required because we can not derive from CCommsDatabase...
   1.149 +        *
   1.150 +        * @deprecated
   1.151 +        */
   1.152 +        IMPORT_C CCommsDatabase*  Database();
   1.153 +
   1.154 +    private:
   1.155 +        /**
   1.156 +        * Handle events from the database (DBMS).
   1.157 +        * The order of notification is the order of registration.
   1.158 +        * @param anEvent Event generated by DBMS. Values from
   1.159 +        * RDbNotifier::TEvent, or KErrCancel.
   1.160 +        */
   1.161 +        void HandleDbEventL( TInt anEvent );
   1.162 +
   1.163 +
   1.164 +        /**
   1.165 +        * Notify all observers about an event.
   1.166 +        * @param anEvent Event to be sent to observers.
   1.167 +        */
   1.168 +        void NotifyObserversL( MActiveApDbObserver::TEvent anEvent );
   1.169 +
   1.170 +    friend class CActiveApDbNotifier;
   1.171 +
   1.172 +    private:    // types
   1.173 +        /**
   1.174 +        * Default constructor. Can not leave.
   1.175 +        */
   1.176 +        CActiveApDb();
   1.177 +
   1.178 +
   1.179 +        enum TState             /// State of the finite state machine.
   1.180 +            {
   1.181 +            EClosed,            ///< Closed and idle.
   1.182 +            EReady,             ///< Open and ready for use.
   1.183 +            EWaitClose,         ///< Closed, waiting for other users to close.
   1.184 +            EWaitBackupRestore, ///< Closed, waiting Backup/Restore to finish.
   1.185 +            EWaitShutdown       ///< Closed, waiting to die.
   1.186 +            };
   1.187 +
   1.188 +    private:        // Data
   1.189 +        CArrayPtrFlat<MActiveApDbObserver>* iObservers;   ///< Observers.
   1.190 +
   1.191 +        CCommsDatabase*     iDb;    // Creates & owns it !
   1.192 +        // CommsDb has its own RDbNotifier...
   1.193 +        TState iState;  ///< Current state of the database.
   1.194 +        CActiveApDbNotifier*    iDbNotifier;
   1.195 +    };
   1.196 +
   1.197 +#endif
   1.198 +
   1.199 +// End of File