|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Multiple context manager. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CWPMULTICONTEXTMANAGER_H |
|
21 #define CWPMULTICONTEXTMANAGER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <d32dbms.h> |
|
26 #include "MWPContextManager.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KDbTableData, "C" ); |
|
32 _LIT( KDbIndexDataContextId, "CA" ); |
|
33 _LIT( KDbColumnDataContextId, "CB" ); |
|
34 _LIT( KDbColumnDataAdapterId, "CC" ); |
|
35 _LIT( KDbColumnDataSaveData, "CE" ); |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * CWPMultiContextManager handles data in contexts. |
|
41 * |
|
42 * @lib ProvisioningEngine |
|
43 * @since 2.1 |
|
44 */ |
|
45 class CWPMultiContextManager : public CActive, public MWPContextManager |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 * @return Context manager |
|
52 */ |
|
53 static CWPMultiContextManager* NewL(); |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * @return Context manager |
|
58 */ |
|
59 static CWPMultiContextManager* NewLC(); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 ~CWPMultiContextManager(); |
|
65 |
|
66 protected: // From CActive |
|
67 void DoCancel(); |
|
68 void RunL(); |
|
69 |
|
70 public: // From MWPContextManager |
|
71 |
|
72 TUint32 CreateContextL( const TDesC& aName, const TDesC& aTPS, |
|
73 const MDesC16Array& aProxies ); |
|
74 void DeleteContextL( MWPContextExtensionArray& aArray, TUint32 aUid ); |
|
75 CArrayFix<TUint32>* ContextUidsL(); |
|
76 HBufC* ContextNameL( TUint32 aUid ); |
|
77 HBufC* ContextTPSL( TUint32 aUid ); |
|
78 CDesC16Array* ContextProxiesL( TUint32 aUid ); |
|
79 TUint32 ContextL( const TDesC& aTPS ); |
|
80 TBool ContextExistsL( TUint32 aUid ); |
|
81 TBool ContextExistsL( const TDesC& aTPS ); |
|
82 void SaveL( MWPContextExtension& aExtension, TInt aItem ); |
|
83 TBool DeleteContextDataL( |
|
84 MWPContextExtensionArray& aArray, TUint32 aUid ); |
|
85 TInt ContextDataCountL( TUint32 aUid ); |
|
86 TUint32 CurrentContextL(); |
|
87 void SetCurrentContextL( TUint32 aUid ); |
|
88 void RegisterContextObserverL( |
|
89 MWPContextObserver* aObserver ); |
|
90 TInt UnregisterContextObserver( |
|
91 MWPContextObserver* aObserver ); |
|
92 |
|
93 protected: // New methods |
|
94 /** |
|
95 * C++ default constructor. |
|
96 */ |
|
97 CWPMultiContextManager(); |
|
98 |
|
99 /** |
|
100 * By default Symbian 2nd phase constructor is private. |
|
101 */ |
|
102 void ConstructL(); |
|
103 |
|
104 /** |
|
105 * Opens the context database. |
|
106 */ |
|
107 void OpenDatabaseL(); |
|
108 |
|
109 /** |
|
110 * Creates the context database. |
|
111 */ |
|
112 void CreateDatabaseL(); |
|
113 |
|
114 /** |
|
115 * Checks the database and performs recovery if needed. |
|
116 */ |
|
117 void CheckDatabaseL(); |
|
118 |
|
119 /** |
|
120 * Creates the names table. |
|
121 * @param aDb The database |
|
122 */ |
|
123 void CreateNamesTableL( RDbDatabase& aDb ); |
|
124 |
|
125 /** |
|
126 * Creates the proxies table. |
|
127 * @param aDb The database |
|
128 */ |
|
129 void CreateProxiesTableL( RDbDatabase& aDb ); |
|
130 |
|
131 /** |
|
132 * Creates the data table. |
|
133 * @param aDb The database |
|
134 */ |
|
135 void CreateDataTableL( RDbDatabase& aDb ); |
|
136 |
|
137 /** |
|
138 * Pushes a database rollback cleanup item and starts a transaction. |
|
139 */ |
|
140 void DatabaseBeginLC(); |
|
141 |
|
142 /** |
|
143 * Pops a database rollback cleanup item and commits a transaction. |
|
144 */ |
|
145 void DatabaseCommitLP(); |
|
146 |
|
147 /** |
|
148 * Cleanup item. Rolls back database transaction. |
|
149 * @param aAny The RDbDatabase pointer |
|
150 */ |
|
151 static void CleanupRollback( TAny* aAny ); |
|
152 |
|
153 /** |
|
154 * Pushes a cancel cleanup item on stack. |
|
155 * @param aTable The table to cancel on failure |
|
156 */ |
|
157 void InsertBeginLC( RDbTable& aTable ) const; |
|
158 |
|
159 /** |
|
160 * Puts changes performed on a row. |
|
161 * @param aTable The table to change |
|
162 */ |
|
163 void InsertCommitLP( RDbTable& aTable ) const; |
|
164 |
|
165 /** |
|
166 * Cleanup item. Cancels table update. |
|
167 * @param aAny The RDbTable pointer |
|
168 */ |
|
169 static void CleanupCancel( TAny* aAny ); |
|
170 |
|
171 /** |
|
172 * Cleanup item. Deletes the database. |
|
173 * @param aAny The RFs pointer |
|
174 */ |
|
175 static void CleanupDeleteDb( TAny* aAny ); |
|
176 |
|
177 /** |
|
178 * Opens a table and puts it on cleanup stack. |
|
179 * @param aName Name of the table |
|
180 * @param aTable The table object to fill |
|
181 * @param aAccess The access type |
|
182 */ |
|
183 void OpenLC( const TDesC& aName, RDbTable& aTable, |
|
184 RDbTable::TAccess aAccess=RDbTable::EUpdatable ); |
|
185 |
|
186 /** |
|
187 * Issues a change notify event to the context database. |
|
188 */ |
|
189 void IssueRequest(); |
|
190 |
|
191 protected: |
|
192 |
|
193 // Database manager |
|
194 RDbs iDbSession; |
|
195 // Database |
|
196 RDbNamedDatabase iDataBase; |
|
197 // The current context |
|
198 TUint32 iCurrentContext; |
|
199 // The database change notifier |
|
200 RDbNotifier iNotifier; |
|
201 // The context observers. Observers referred. |
|
202 RPointerArray<MWPContextObserver> iObservers; |
|
203 TFileName iDataBasePath; |
|
204 }; |
|
205 |
|
206 #endif /* CWPMULTICONTEXTMANAGER_H */ |