|
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: One Storage folder management |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CPENGSTORAGEFOLDER_H__ |
|
21 #define __CPENGSTORAGEFOLDER_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <bamdesca.h> |
|
26 #include "MPEngStorageFolder.h" |
|
27 #include "TPEngStorageServerBTreeKeys.h" |
|
28 #include "TPEngStorageServerMessages.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CPEngRequestHandler; |
|
32 class RPEngMessage; |
|
33 class RFs; |
|
34 class CPEngSessionSlotState; |
|
35 class CPEngSessionSlotEvent; |
|
36 |
|
37 /** |
|
38 * One Storage folder management |
|
39 * Manages data in one storage folder |
|
40 * |
|
41 * @since 3.0 |
|
42 */ |
|
43 class CPEngStorageFolder : public CObject, |
|
44 public MPEngStorageFolder |
|
45 { |
|
46 public: // Constructors and destructor |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 */ |
|
51 static CPEngStorageFolder* NewL( RFs& aFs, |
|
52 const TDesC& aTempFolder, |
|
53 RBuf16& aCommBuff ); |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 */ |
|
58 static CPEngStorageFolder* NewLC( RFs& aFs, |
|
59 const TDesC& aTempFolder, |
|
60 RBuf16& aCommBuff ); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 virtual ~CPEngStorageFolder(); |
|
66 |
|
67 public: // Overwritten virtual functions of the CObject |
|
68 |
|
69 /** |
|
70 * Close reference to this reference counted object |
|
71 * if state of folder is active, do not delete it |
|
72 * |
|
73 * @since 3.0 |
|
74 */ |
|
75 void Close (); |
|
76 |
|
77 public: // new from MPEngStorageFolder |
|
78 |
|
79 /** |
|
80 * Get data entry |
|
81 * @see MPEngStorageFolder |
|
82 */ |
|
83 CPEngDataEntry* DataEntryL( const TDesC& aSId ); |
|
84 |
|
85 |
|
86 public: // New functions used by the Server |
|
87 |
|
88 /** |
|
89 * Session slot state |
|
90 * |
|
91 * @since 3.0 |
|
92 * @return returns session slot state |
|
93 */ |
|
94 CPEngSessionSlotState& SessionSlotState(); |
|
95 |
|
96 /** |
|
97 * Set Session slot state |
|
98 * Ownership of the parameter is transfered |
|
99 * |
|
100 * @since 3.0 |
|
101 * @param aState state of session, ownership is transfered |
|
102 */ |
|
103 void SetSessionSlotState( CPEngSessionSlotState& aState ); |
|
104 |
|
105 /** |
|
106 * Set Session Slot base folder |
|
107 * Ownership of the parameter is transfered |
|
108 * |
|
109 * @since 3.0 |
|
110 * @param aFolder des buffer with the base folder |
|
111 * ownership is transfered |
|
112 */ |
|
113 void SetSessionFolder( HBufC& aFolder ); |
|
114 |
|
115 /** |
|
116 * Commited folder session state update |
|
117 * It does necessary cleaning of the folder |
|
118 * |
|
119 * @since 3.0 |
|
120 */ |
|
121 void CommiteStateUpdate(); |
|
122 |
|
123 |
|
124 public: // New Functions of Storage Engine |
|
125 |
|
126 /** |
|
127 * Store store entry into the store |
|
128 * |
|
129 * @since 3.0 |
|
130 * @param aMessage message from client, which carries |
|
131 * Store ID, store type and buffer of store entry |
|
132 * @param aNotifyActive flag if notification is active |
|
133 * if ETrue, change if notified to listeners |
|
134 * @return data entry which was stored |
|
135 */ |
|
136 const CPEngDataEntry* WriteStoreEntryL( |
|
137 const RPEngMessage& aMessage, |
|
138 TBool aNotifyActive, |
|
139 TUint32 aSessionId, |
|
140 TInt aSubSessionId ); |
|
141 |
|
142 /** |
|
143 * Read store entry from the store |
|
144 * |
|
145 * @since 3.0 |
|
146 * @param aMessage message from client, which carries |
|
147 * Store ID, store type and buffer of store entry |
|
148 */ |
|
149 void ReadStoreEntryL( const RPEngMessage& aMessage ); |
|
150 |
|
151 /** |
|
152 * Get store entry length |
|
153 * |
|
154 * @since 3.0 |
|
155 * @param aMessage message from client, which carries |
|
156 * Store ID, store type |
|
157 */ |
|
158 void GetStoreEntryLengthL( const RPEngMessage& aMessage ); |
|
159 |
|
160 /** |
|
161 * Remove store entry from the store |
|
162 * |
|
163 * @since 3.0 |
|
164 * @param aMessage message from client, which carries |
|
165 * Store ID, store type |
|
166 */ |
|
167 void RemoveStoreEntryL( const RPEngMessage& aMessage ); |
|
168 |
|
169 /** |
|
170 * Lock store entry in the store |
|
171 * |
|
172 * @since 3.0 |
|
173 * @param aMessage message from client, which carries |
|
174 * Store ID, store type |
|
175 */ |
|
176 void LockStoreEntryL( const RPEngMessage& aMessage, |
|
177 TUint32 aSessionId, |
|
178 TInt aSubSessionId ); |
|
179 |
|
180 /** |
|
181 * Un Lock store entry in the store |
|
182 * |
|
183 * @since 3.0 |
|
184 * @param aMessage message from client, which carries |
|
185 * Store ID, store type |
|
186 */ |
|
187 const CPEngDataEntry* UnlockStoreEntryL( |
|
188 const RPEngMessage& aMessage, |
|
189 TBool aNotifyActive, |
|
190 TUint32 aSessionId, |
|
191 TInt aSubSessionId ); |
|
192 |
|
193 /** |
|
194 * Un Lock store entry in the store |
|
195 * |
|
196 * @since 3.0 |
|
197 * @param aMessage message from client, which carries |
|
198 * Store ID, store type |
|
199 */ |
|
200 void IsStoreEntryLockedL( const RPEngMessage& aMessage ); |
|
201 |
|
202 public: // New Functions of Notification Engine |
|
203 |
|
204 /** |
|
205 * Start listening of defined Storage IDs |
|
206 * |
|
207 * @since 3.0 |
|
208 * @param aMessage message with request details |
|
209 * @param aSessionId Session ID |
|
210 * @param aSubSessionId Sub Session ID |
|
211 */ |
|
212 void ListenSIDsChangesL( const RPEngMessage& aMessage, |
|
213 TUint32 aSessionId, |
|
214 TInt aSubSessionId ); |
|
215 |
|
216 /** |
|
217 * Update Listen Storage IDs Request handler with new SIDs |
|
218 * |
|
219 * @since 3.0 |
|
220 * @param aMessage message with request details |
|
221 * @param aSessionId Session ID |
|
222 * @param aSubSessionId Sub Session ID |
|
223 */ |
|
224 void UpdateListenSIDsScoutL( const RPEngMessage& aMessage, |
|
225 TUint32 aSessionId, |
|
226 TInt aSubSessionId ); |
|
227 |
|
228 /** |
|
229 * Fetch Changed Storage IDs Indexes |
|
230 * |
|
231 * @since 3.0 |
|
232 * @param aMessage message with request details |
|
233 * @param aSessionId Session ID |
|
234 * @param aSubSessionId Sub Session ID |
|
235 */ |
|
236 void FetchChangedIdsIndexesL( const RPEngMessage& aMessage, |
|
237 TUint32 aSessionId, |
|
238 TInt aSubSessionId ); |
|
239 |
|
240 /** |
|
241 * Reload Asynchronou request with new Message( TRequestStatus) |
|
242 * |
|
243 * @since 3.0 |
|
244 * @param aMessage message with request details |
|
245 * @param aSessionId Session ID |
|
246 * @param aSubSessionId Sub Session ID |
|
247 */ |
|
248 void ReloadAsyncScoutL( const RPEngMessage& aMessage, |
|
249 TUint32 aSessionId, |
|
250 TInt aSubSessionId ); |
|
251 |
|
252 |
|
253 /** |
|
254 * |
|
255 * |
|
256 * @since 3.0 |
|
257 * @param aSessionId Session ID |
|
258 * @param aSubSessionId Sub Session ID |
|
259 */ |
|
260 void CancelSubSessionRequests( TUint32 aSessionId, |
|
261 TInt aSubSessionId ); |
|
262 |
|
263 /** |
|
264 * Cancel defined pending asynchronous request |
|
265 * |
|
266 * @since 3.0 |
|
267 * @param aSessionId session ID |
|
268 * @param aSubSessionId sub-session ID |
|
269 * @param aRequest request to be canceled |
|
270 */ |
|
271 void CancelRequest( const RPEngMessage& aMessage, |
|
272 TUint32 aSessionId, |
|
273 TInt aSubSessionId ); |
|
274 |
|
275 /** |
|
276 * Notify about change of the Storage ID, except the |
|
277 * session from which request came |
|
278 * |
|
279 * @since 3.0 |
|
280 * @param aMessage message with request details |
|
281 * @param aNotifyActive flag if notification is active |
|
282 * if ETrue, change if notified to listeners |
|
283 * @return data entry which was stored |
|
284 */ |
|
285 const CPEngDataEntry* NotifyChangedStorageIdL( const RPEngMessage& aMessage, |
|
286 TBool aNotifyActive ); |
|
287 |
|
288 |
|
289 /** |
|
290 * Notify changed SIDs to the listening clients |
|
291 * |
|
292 * @since 3.0 |
|
293 * @param aEntries |
|
294 * @param aSessionId |
|
295 */ |
|
296 void NotifySIDChanges( const RPointerArray<CPEngDataEntry>& aEntries ); |
|
297 |
|
298 private: // New Private Functions of the class |
|
299 |
|
300 /** |
|
301 * Find Request Handler |
|
302 * |
|
303 * @since 3.0 |
|
304 * @param aSessionId Session ID |
|
305 * @param aSubSessionId Sub Session ID |
|
306 * @param aFunction request function |
|
307 * @return pointer to Request Handler it it exists or NULL |
|
308 */ |
|
309 CPEngRequestHandler* FindRequestHandler( |
|
310 TUint32 aSessionId, |
|
311 TInt aSubSessionId, |
|
312 TPEngStorageServerMessages aFunction ); |
|
313 |
|
314 /** |
|
315 * Get Store Entry instance |
|
316 * If request store Entry does not exists, it will be created |
|
317 * |
|
318 * @since 3.0 |
|
319 * @param aMessage clients message with Store ID and store type |
|
320 * @param aCreateIfNotPressent flag if store entry shall be |
|
321 * created if it does not exists ( ETrue = Yes ) |
|
322 * @return pointer to the Data entry |
|
323 */ |
|
324 CPEngDataEntry* GetStoreEntryL( const RPEngMessage& aMessage, |
|
325 TBool aCreateIfNotPressent, |
|
326 TBtreePos& aPos, |
|
327 TBool aTrueSearch = EFalse ); |
|
328 |
|
329 /** |
|
330 * Load Store entry and add it to the tree |
|
331 * If store entry does not exists in the store, created it |
|
332 * if flag is switched on |
|
333 * |
|
334 * @since 3.0 |
|
335 * @param aKey key of the Storage Entry |
|
336 * @param aCreateIfNotPressent flag if store entry shall be |
|
337 * created if it does not exists ( ETrue = Yes ) |
|
338 * @return pointer to the Data entry |
|
339 */ |
|
340 CPEngDataEntry* LoadStoreEntryL( TDesC& aKey, |
|
341 TBool aCreateIfNotPressent, |
|
342 TBtreePos& aPos, |
|
343 const RPEngMessage& aMessage ); |
|
344 |
|
345 /** |
|
346 * Notify observer that all observer SIds changed |
|
347 * |
|
348 * @since 3.0 |
|
349 */ |
|
350 void NofifyAllAboutAll(); |
|
351 |
|
352 /** |
|
353 * Look in buffered data entries |
|
354 * |
|
355 */ |
|
356 CPEngDataEntry* CheckBufferedDataEntries( const TDesC& aKey ); |
|
357 |
|
358 /** |
|
359 * Add buffered data entry pointer |
|
360 */ |
|
361 void AddBufferedDataEntry( CPEngDataEntry* aDataEntry ); |
|
362 |
|
363 private: // New private Functions of the class |
|
364 /** |
|
365 * Clean B tree from all entries |
|
366 * It will remove all entries from the B tree |
|
367 * |
|
368 * @since 3.0 |
|
369 */ |
|
370 void CleanTreeFromAllEntriesL(); |
|
371 |
|
372 private: |
|
373 |
|
374 /** |
|
375 * C++ default constructor. |
|
376 */ |
|
377 CPEngStorageFolder( RFs& aFs, |
|
378 const TDesC& aTempFolder, |
|
379 RBuf16& aCommBuff ); |
|
380 |
|
381 /** |
|
382 * Symbian 2nd phase constructor |
|
383 */ |
|
384 void ConstructL(); |
|
385 |
|
386 private: // Data |
|
387 |
|
388 /// REF: File server, owned by the server class |
|
389 RFs& iFs; |
|
390 |
|
391 /// REF: Temp folder of the Storage |
|
392 const TDesC& iTempFolder; |
|
393 |
|
394 /// REF: buffer used for communication, to minimize |
|
395 RBuf16& iBuffer; |
|
396 |
|
397 |
|
398 /// OWN: Folder name, Hashed |
|
399 HBufC* iSessionFolder; |
|
400 |
|
401 /// OWN: Session slot state, also has session Identification |
|
402 CPEngSessionSlotState* iSessionState; |
|
403 |
|
404 /// OWN: B-tree with cached entries |
|
405 TBtreeFix<CPEngDataEntry*, TDesC*> iDataEntryTree; |
|
406 |
|
407 /// OWN: Key for ordering of B-tree of cached entries |
|
408 TPEngDataEntryKey iDataEntryTreeKey; |
|
409 |
|
410 /// OWN: Handles memory management for B-Tree |
|
411 CMemPagePool* iPool; |
|
412 |
|
413 /// OWN: Flag if B-tree is connected |
|
414 TBool iTreeConnected; |
|
415 |
|
416 /// OWN: Container with the Observers, owned and also members are owned |
|
417 CObjectCon* iObservers; |
|
418 |
|
419 /// REF: Last used data entries |
|
420 CPEngDataEntry* iBuffDataEntry0; |
|
421 CPEngDataEntry* iBuffDataEntry1; |
|
422 CPEngDataEntry* iBuffDataEntry2; |
|
423 }; |
|
424 |
|
425 #endif // __CPENGSTORAGEFOLDER_H__ |
|
426 |
|
427 // End of File |