williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: Declaration of classes CActiveApDb
|
williamr@2
|
15 |
* and MActiveApDbObserver.
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
*/
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
#ifndef ACTIVE_APDB_H
|
williamr@2
|
21 |
#define ACTIVE_APDB_H
|
williamr@2
|
22 |
|
williamr@2
|
23 |
// Deprecation warning
|
williamr@2
|
24 |
#warning This header file has been deprecated. Will be removed in one of the next SDK releases.
|
williamr@2
|
25 |
|
williamr@2
|
26 |
|
williamr@2
|
27 |
// INCLUDES
|
williamr@2
|
28 |
#include <commdb.h>
|
williamr@2
|
29 |
#include <ApEngineVer.h>
|
williamr@2
|
30 |
|
williamr@2
|
31 |
/*
|
williamr@2
|
32 |
// Enum for DATABASE_TYPE field
|
williamr@2
|
33 |
// Will be deprecated in 7.0
|
williamr@2
|
34 |
enum TCommDbDatabaseType
|
williamr@2
|
35 |
{
|
williamr@2
|
36 |
EUnspecified = 0, // not specifying which type it is - any type of
|
williamr@2
|
37 |
// database can be opened with this parameter
|
williamr@2
|
38 |
EIAP,
|
williamr@2
|
39 |
EISP
|
williamr@2
|
40 |
};
|
williamr@2
|
41 |
*/
|
williamr@2
|
42 |
|
williamr@2
|
43 |
// CONSTANTS
|
williamr@2
|
44 |
const TInt KErrActiveApDbObserverNotFound = -500;
|
williamr@2
|
45 |
|
williamr@2
|
46 |
// FORWARD DECLARATION
|
williamr@2
|
47 |
class CActiveApDbNotifier;
|
williamr@2
|
48 |
|
williamr@2
|
49 |
// CLASS DECLARATION
|
williamr@2
|
50 |
|
williamr@2
|
51 |
/**
|
williamr@2
|
52 |
* Mixin protocol for handling events from a CCommsDatabase.
|
williamr@2
|
53 |
* Events are related to database changes and availability.
|
williamr@2
|
54 |
*/
|
williamr@2
|
55 |
class MActiveApDbObserver
|
williamr@2
|
56 |
{
|
williamr@2
|
57 |
public: // types
|
williamr@2
|
58 |
enum TEvent /// Events reported to the database observer.
|
williamr@2
|
59 |
{
|
williamr@2
|
60 |
EDbChanged, ///< Database has changed.
|
williamr@2
|
61 |
EDbClosing, ///< Database is about to close.
|
williamr@2
|
62 |
EDbAvailable ///< Database is available again.(E.g. after unlock)
|
williamr@2
|
63 |
};
|
williamr@2
|
64 |
|
williamr@2
|
65 |
public: // new methods
|
williamr@2
|
66 |
|
williamr@2
|
67 |
/**
|
williamr@2
|
68 |
* Derived classes should implement this method, and act accordingly
|
williamr@2
|
69 |
* to database events.
|
williamr@2
|
70 |
* @param anEvent Database-related event.
|
williamr@2
|
71 |
*
|
williamr@2
|
72 |
* @deprecated
|
williamr@2
|
73 |
*/
|
williamr@2
|
74 |
IMPORT_C virtual void HandleApDbEventL( TEvent anEvent ) = 0;
|
williamr@2
|
75 |
|
williamr@2
|
76 |
};
|
williamr@2
|
77 |
|
williamr@2
|
78 |
/**
|
williamr@2
|
79 |
* This class manages and guards database integrity
|
williamr@2
|
80 |
* by handling all events that are related to the database. These events
|
williamr@2
|
81 |
* may originate from the system (Shutdown, Backup/Restore) and from the
|
williamr@2
|
82 |
* database itself. The events are transformed into a simple protocol,
|
williamr@2
|
83 |
* defined by MActiveApDbObserver.
|
williamr@2
|
84 |
* Expects an active scheduler to be installed and running.
|
williamr@2
|
85 |
*/
|
williamr@2
|
86 |
NONSHARABLE_CLASS( CActiveApDb ) : public CBase
|
williamr@2
|
87 |
{
|
williamr@2
|
88 |
|
williamr@2
|
89 |
public: // Constructors and destructor
|
williamr@2
|
90 |
/**
|
williamr@2
|
91 |
* Two-phased constructor. Leaves on failure.
|
williamr@2
|
92 |
* @param aType The desired type of the CCommsDatabase object.
|
williamr@2
|
93 |
* Defaults to EDatabaseTypeIAP.
|
williamr@2
|
94 |
* @return The constructed CActiveApDb object.
|
williamr@2
|
95 |
*
|
williamr@2
|
96 |
* @deprecated
|
williamr@2
|
97 |
*/
|
williamr@2
|
98 |
IMPORT_C static CActiveApDb* NewL
|
williamr@2
|
99 |
( TCommDbDatabaseType aType = EDatabaseTypeIAP );
|
williamr@2
|
100 |
|
williamr@2
|
101 |
|
williamr@2
|
102 |
|
williamr@2
|
103 |
/**
|
williamr@2
|
104 |
* Destructor.
|
williamr@2
|
105 |
*
|
williamr@2
|
106 |
* @deprecated
|
williamr@2
|
107 |
*/
|
williamr@2
|
108 |
IMPORT_C virtual ~CActiveApDb();
|
williamr@2
|
109 |
|
williamr@2
|
110 |
protected: // Constructors
|
williamr@2
|
111 |
|
williamr@2
|
112 |
/**
|
williamr@2
|
113 |
* Second phase constructor. Leaves on failure.
|
williamr@2
|
114 |
* @param aType The desired type of the CCommsDatabase object.
|
williamr@2
|
115 |
* events.
|
williamr@2
|
116 |
*/
|
williamr@2
|
117 |
void ConstructL();
|
williamr@2
|
118 |
|
williamr@2
|
119 |
public: // new methods
|
williamr@2
|
120 |
/**
|
williamr@2
|
121 |
* Adds an observer to the list of observers to be notified
|
williamr@2
|
122 |
* about the DB events.
|
williamr@2
|
123 |
* Also automatically starts observation and notification.
|
williamr@2
|
124 |
* The order of notification will be exactly the order of registration.
|
williamr@2
|
125 |
* @param anObserver Observer to be notified about database-related
|
williamr@2
|
126 |
* events.
|
williamr@2
|
127 |
*
|
williamr@2
|
128 |
* @deprecated
|
williamr@2
|
129 |
*/
|
williamr@2
|
130 |
IMPORT_C void AddObserverL( MActiveApDbObserver* anObserver );
|
williamr@2
|
131 |
|
williamr@2
|
132 |
|
williamr@2
|
133 |
/**
|
williamr@2
|
134 |
* Removes an observer. If not added, silently ignores.
|
williamr@2
|
135 |
* @param anObserver The observer.
|
williamr@2
|
136 |
*
|
williamr@2
|
137 |
* @deprecated
|
williamr@2
|
138 |
*/
|
williamr@2
|
139 |
IMPORT_C void RemoveObserver( MActiveApDbObserver* anObserver );
|
williamr@2
|
140 |
|
williamr@2
|
141 |
|
williamr@2
|
142 |
/**
|
williamr@2
|
143 |
* Returns the CCommsDatabase.
|
williamr@2
|
144 |
* Required because we can not derive from CCommsDatabase...
|
williamr@2
|
145 |
*
|
williamr@2
|
146 |
* @deprecated
|
williamr@2
|
147 |
*/
|
williamr@2
|
148 |
IMPORT_C CCommsDatabase* Database();
|
williamr@2
|
149 |
|
williamr@2
|
150 |
private:
|
williamr@2
|
151 |
/**
|
williamr@2
|
152 |
* Handle events from the database (DBMS).
|
williamr@2
|
153 |
* The order of notification is the order of registration.
|
williamr@2
|
154 |
* @param anEvent Event generated by DBMS. Values from
|
williamr@2
|
155 |
* RDbNotifier::TEvent, or KErrCancel.
|
williamr@2
|
156 |
*/
|
williamr@2
|
157 |
void HandleDbEventL( TInt anEvent );
|
williamr@2
|
158 |
|
williamr@2
|
159 |
|
williamr@2
|
160 |
/**
|
williamr@2
|
161 |
* Notify all observers about an event.
|
williamr@2
|
162 |
* @param anEvent Event to be sent to observers.
|
williamr@2
|
163 |
*/
|
williamr@2
|
164 |
void NotifyObserversL( MActiveApDbObserver::TEvent anEvent );
|
williamr@2
|
165 |
|
williamr@2
|
166 |
friend class CActiveApDbNotifier;
|
williamr@2
|
167 |
|
williamr@2
|
168 |
private: // types
|
williamr@2
|
169 |
/**
|
williamr@2
|
170 |
* Default constructor. Can not leave.
|
williamr@2
|
171 |
*/
|
williamr@2
|
172 |
CActiveApDb();
|
williamr@2
|
173 |
|
williamr@2
|
174 |
|
williamr@2
|
175 |
enum TState /// State of the finite state machine.
|
williamr@2
|
176 |
{
|
williamr@2
|
177 |
EClosed, ///< Closed and idle.
|
williamr@2
|
178 |
EReady, ///< Open and ready for use.
|
williamr@2
|
179 |
EWaitClose, ///< Closed, waiting for other users to close.
|
williamr@2
|
180 |
EWaitBackupRestore, ///< Closed, waiting Backup/Restore to finish.
|
williamr@2
|
181 |
EWaitShutdown ///< Closed, waiting to die.
|
williamr@2
|
182 |
};
|
williamr@2
|
183 |
|
williamr@2
|
184 |
private: // Data
|
williamr@2
|
185 |
CArrayPtrFlat<MActiveApDbObserver>* iObservers; ///< Observers.
|
williamr@2
|
186 |
|
williamr@2
|
187 |
CCommsDatabase* iDb; // Creates & owns it !
|
williamr@2
|
188 |
// CommsDb has its own RDbNotifier...
|
williamr@2
|
189 |
TState iState; ///< Current state of the database.
|
williamr@2
|
190 |
CActiveApDbNotifier* iDbNotifier;
|
williamr@2
|
191 |
};
|
williamr@2
|
192 |
|
williamr@2
|
193 |
#endif
|
williamr@2
|
194 |
|
williamr@2
|
195 |
// End of File
|