|
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: Store entry abstract class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CPENGSTOREENTRY_H__ |
|
21 #define __CPENGSTOREENTRY_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <s32strm.h> |
|
26 |
|
27 #include "PEngStorageGlobals.h" |
|
28 #include "MPEngSIDChangeObserver.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class MPEngStorageManagerWatcher; |
|
32 class MPEngStorageManager; |
|
33 class CPEngStorageManager; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 /** |
|
37 * One store entry template |
|
38 * Each store entry of the storage manager has to be derived from |
|
39 * this abstract class. |
|
40 * Pure virtual function must be implemented by derived class. |
|
41 * However virtual functions have default implementation. |
|
42 * |
|
43 * @lib PEngStoreMan2.dll |
|
44 * @since 3.0 |
|
45 */ |
|
46 class CPEngStoreEntry : |
|
47 public CBase, |
|
48 public MPEngSIDChangeObserver |
|
49 { |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 IMPORT_C virtual ~CPEngStoreEntry(); |
|
56 |
|
57 protected: // Protected constructor to allow derivation |
|
58 |
|
59 /** |
|
60 * C++ default constructor. |
|
61 * |
|
62 * @param aStoragetype storage type of the Store Entry |
|
63 */ |
|
64 IMPORT_C CPEngStoreEntry( TPEngStorageType aStorageType ); |
|
65 |
|
66 /** |
|
67 * Base constructor of the Base class |
|
68 * It registeres store entry to listen its changes |
|
69 * |
|
70 * @since 3.0 |
|
71 * @param aStorageManager Storage manager |
|
72 * @param aRegister register store entry to observer its updates |
|
73 */ |
|
74 IMPORT_C void BaseConstructL( |
|
75 MPEngStorageManager& aStorageManager, |
|
76 TBool aRegister = ETrue ); |
|
77 |
|
78 /** |
|
79 * Base constructor of the Base class |
|
80 * Overloaded version which does not register to listen changes |
|
81 * |
|
82 * @since 3.0 |
|
83 */ |
|
84 IMPORT_C void BaseConstructL(); |
|
85 |
|
86 public: // Clean up support for the Lock of the Entry |
|
87 |
|
88 /** |
|
89 * Release lock of the store entry |
|
90 * It is also used for clean up stack of the entry's lock support |
|
91 * |
|
92 * @since 3.0 |
|
93 */ |
|
94 IMPORT_C virtual void Release(); |
|
95 |
|
96 /** |
|
97 * Lock store entry and leave lock on the clean up stack |
|
98 * |
|
99 * @since 3.0 |
|
100 * @return count of the lock on the server side or KErrDisconected |
|
101 */ |
|
102 IMPORT_C TInt LockLC(); |
|
103 |
|
104 /** |
|
105 * Locks store entry |
|
106 * |
|
107 * @since 3.0 |
|
108 * @param aPriority priority of the Lock to be done |
|
109 * @param aCreateEntry if store entry does not exists, it is created |
|
110 * default value is ETrue = store entry is created if needed |
|
111 * @return count of the lock on the server side, KErrDisconected or |
|
112 * KErrNotFound if aCreateEntry = EFalse and entry does not exist. |
|
113 */ |
|
114 IMPORT_C TInt Lock( TPengStorageLockPriority |
|
115 aPriority = EStorageLockLevelBasic, |
|
116 TBool aCreateEntry = ETrue ) const; |
|
117 |
|
118 /** |
|
119 * Unlocks store entry |
|
120 * |
|
121 * @since 3.0 |
|
122 * @return count of the lock on the server side or KErrDisconected |
|
123 */ |
|
124 IMPORT_C TInt Unlock() const; |
|
125 |
|
126 /* |
|
127 * Stops sending of SID changes done through Storage Manager |
|
128 * More in <MPEngStorageManager.h> |
|
129 * |
|
130 * @since 3.0 |
|
131 * @return positive number represents number on the server side |
|
132 * counter, negative some system wide error |
|
133 */ |
|
134 IMPORT_C TInt BufferServerSideNotifications(); |
|
135 |
|
136 |
|
137 /* |
|
138 * Decreases counter of the Server Side Notification buffering, |
|
139 * More in <MPEngStorageManager.h> |
|
140 * |
|
141 * @since 3.0 |
|
142 * @return positive number represents number on the server side |
|
143 * counter, negative some system wide error |
|
144 */ |
|
145 IMPORT_C TInt ReleaseServerSideBuffering(); |
|
146 |
|
147 |
|
148 /** |
|
149 * Store this store entry |
|
150 * |
|
151 * @since 3.0 |
|
152 */ |
|
153 IMPORT_C void StoreL(); |
|
154 |
|
155 public: // New functions of the base class |
|
156 |
|
157 /** |
|
158 * ExternalizeL provides way to externalize data from store entry. |
|
159 * For behavior of this function based on the different |
|
160 * storage type check <PEngStorageGlobals.h> |
|
161 * |
|
162 * @since 3.0 |
|
163 * @param aStream stream to write to |
|
164 * @param aStorageType storage type to externalized |
|
165 */ |
|
166 virtual void ExternalizeL( RWriteStream& aStream, |
|
167 TPEngStorageType aStorageType ) const = 0; |
|
168 |
|
169 /** |
|
170 * InternalizeL provides way to internalise data to store entry. |
|
171 * For behavior of this function based on the different |
|
172 * storage type check <PEngStorageGlobals.h> |
|
173 * |
|
174 * @since 3.0 |
|
175 * @param aStream stream to read from |
|
176 * @param aStorageType storage type to internalized |
|
177 */ |
|
178 virtual void InternalizeL( RReadStream& aStream, |
|
179 TPEngStorageType aStorageType ) = 0; |
|
180 |
|
181 /** |
|
182 * This method is used to retrieve ID for storing. |
|
183 * |
|
184 * @since 3.0 |
|
185 * @return Store Id |
|
186 */ |
|
187 virtual const TDesC& StorageId() const = 0; |
|
188 |
|
189 /* |
|
190 * This method is used to ask entry size in bytes. |
|
191 * It is called before actual call of the InternalizeL and |
|
192 * ExternalizeL to get estimation of the buffer needed for the |
|
193 * operation. If Size is incorrect before the ExternalizeL, |
|
194 * externalize operation will fail to fit data in the stream. |
|
195 * If size is incorrect before InternalizeL, operation will |
|
196 * be more time consuming (extra client/server)call involved |
|
197 * |
|
198 * For more behavior of this function based on the different |
|
199 * storage type check <PEngStorageGlobals.h> |
|
200 * |
|
201 * @since 3.0 |
|
202 * @return size as TInt |
|
203 */ |
|
204 virtual TUint32 EntrySize() const = 0; |
|
205 |
|
206 public: // Storage type support |
|
207 |
|
208 /** |
|
209 * Returns storage type |
|
210 * |
|
211 * @since 3.0 |
|
212 * @return one of the enum values of type TPEngStorageType |
|
213 */ |
|
214 IMPORT_C TPEngStorageType StorageType() const; |
|
215 |
|
216 /** |
|
217 * Change storage type |
|
218 * When storage type is changes, this store entry should be |
|
219 * valid. Fisrt data are clean from the storage server and |
|
220 * then storage entry is stored with new type. |
|
221 * This function is available when |
|
222 * BaseConstructL( MPEngStorageManager& aStorageManager ) |
|
223 * was called. |
|
224 * |
|
225 * @since 3.0 |
|
226 * @param aNewType ne storage type |
|
227 */ |
|
228 IMPORT_C void ChangeStorageTypeL( TPEngStorageType aNewType ); |
|
229 |
|
230 |
|
231 public: // New functions of MPEngSIDChangeObserver with default implementation |
|
232 |
|
233 /** |
|
234 * Handle change of the Storage IDs |
|
235 * More information can be found in <MPEngSIDChangeObserver.h> |
|
236 * |
|
237 * @since 3.0 |
|
238 */ |
|
239 IMPORT_C virtual void HandleSIDsChangeL( CPtrCArray& aChangedSIDs ); |
|
240 |
|
241 /** |
|
242 * Called when SIDs notifier fails |
|
243 * More information can be found in <MPEngSIDChangeObserver.h> |
|
244 * |
|
245 * @since 3.0 |
|
246 */ |
|
247 IMPORT_C virtual void HandleSIDNotifyError( TInt aError ); |
|
248 |
|
249 protected: // Data protected to allow derivation |
|
250 |
|
251 /// OWN: Reference accessed Storage Manager |
|
252 MPEngStorageManager* iStorageManager; |
|
253 |
|
254 /// OWN: Size of the store entry, updated by the storage manager |
|
255 TInt iSize; |
|
256 |
|
257 private: // Data, not visible to derived classes |
|
258 |
|
259 /// OWN: Storage Type, cannot be modified by derived class |
|
260 TPEngStorageType iStorageType; |
|
261 |
|
262 /// Last Version of the Store retrieved from Storage Manager |
|
263 TInt32 iEntryVersion; |
|
264 |
|
265 friend class CPEngStorageManager; // CSI: 36 # |
|
266 }; |
|
267 |
|
268 #endif // __CPENGSTOREENTRY_H__ |
|
269 |
|
270 // End of File |
|
271 |
|
272 |