|
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: Factory of Storage Manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CPENGSTORAGEMANAGERFACTORY_H__ |
|
21 #define __CPENGSTORAGEMANAGERFACTORY_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "RPEngStorageClient.h" |
|
26 #include "MPEngStorageFactory.h" |
|
27 |
|
28 #include "RObjectArray.h" |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CPEngStorageManagerWatcher; |
|
33 class CPEngStorageManager; |
|
34 class CPEngSessionSlotId; |
|
35 class CPEngSessionSlotState; |
|
36 class MPEngGlobalEventObserver; |
|
37 |
|
38 |
|
39 /** |
|
40 * Factory of Storage Manager |
|
41 * It holds all active Watchers of the storage manager |
|
42 * There is always one watcher per each session slot which is |
|
43 * shared by all storage manager instances accessing this session slot |
|
44 * |
|
45 * @lib PEngStoreMan2.dll |
|
46 * @since 3.0 |
|
47 */ |
|
48 NONSHARABLE_CLASS( CPEngStorageManagerFactory ): |
|
49 public CActive, |
|
50 public MPEngStorageFactory |
|
51 { |
|
52 public: // Constructors and destructor |
|
53 |
|
54 /** |
|
55 * Instance of the storage factory, it is created if needed |
|
56 * |
|
57 * @since 3.0 |
|
58 * @param |
|
59 * @return |
|
60 */ |
|
61 static CPEngStorageManagerFactory* InstanceLC(); |
|
62 |
|
63 /** |
|
64 * Gets pointer to the Manager factory it is exists |
|
65 * if not then NULL pointer |
|
66 * |
|
67 * @since 3.0 |
|
68 * @param |
|
69 * @return |
|
70 */ |
|
71 static CPEngStorageManagerFactory* Instance(); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CPEngStorageManagerFactory(); |
|
77 |
|
78 public: // New functions for reference counting support |
|
79 |
|
80 /** |
|
81 * Openes handle new handle to Storage Manager Factory |
|
82 * |
|
83 * @since 3.0 |
|
84 */ |
|
85 void Open(); |
|
86 |
|
87 /** |
|
88 * Closes handle to the Storage Manager Factory |
|
89 * |
|
90 * @since 3.0 |
|
91 */ |
|
92 void Close(); |
|
93 |
|
94 public: // virtual Functions of the CActive |
|
95 |
|
96 /** |
|
97 * Handles an active object’s request completion event. |
|
98 * @since 3.0 |
|
99 */ |
|
100 void RunL(); |
|
101 |
|
102 /** |
|
103 * Handles a leave occurring in the request completion |
|
104 * event handler RunL() |
|
105 * @since 3.0 |
|
106 */ |
|
107 TInt RunError( TInt aError ); |
|
108 |
|
109 /** |
|
110 * Implements cancellation of an outstanding request. |
|
111 * This function is called as part of the active object’s Cancel(). |
|
112 * @since 3.0 |
|
113 */ |
|
114 void DoCancel(); |
|
115 |
|
116 public: // New Functions from MPEngStorageFactory |
|
117 |
|
118 /** |
|
119 * Remove Storage watcher, |
|
120 * @see <MPEngStorageFactory.h> |
|
121 */ |
|
122 void CloseStorageWatcher( |
|
123 CPEngStorageManagerWatcher* aStorageWatcher ); |
|
124 |
|
125 /** |
|
126 * Increases reference counter of Factory |
|
127 * @see <MPEngStorageFactory.h> |
|
128 */ |
|
129 void OpenWatcher(); |
|
130 |
|
131 /** |
|
132 * Storage Manager main client |
|
133 * @see <MPEngStorageFactory.h> |
|
134 */ |
|
135 RPEngStorageClient& MainClient(); |
|
136 |
|
137 public: // New Functions of the base class |
|
138 |
|
139 /** |
|
140 * Retrieves Storage Manager instance |
|
141 * Ownership is passed to the caller |
|
142 * To get Storage manager which has handle to the correct |
|
143 * sub-folder of the Storage, |
|
144 * Server address and user name has to be specified. |
|
145 * |
|
146 * @since 3.0 |
|
147 * @param aSessionSlot session slot Class which caries |
|
148 * unique information about the session |
|
149 * @return MPEngStorageManager type pointer, |
|
150 * ownership is passed to the caller |
|
151 */ |
|
152 CPEngStorageManager* StorageManagerL( |
|
153 const CPEngSessionSlotId& aSessionSlot ); |
|
154 |
|
155 |
|
156 /** |
|
157 * Retrieves Storage Manager Watcher pointer |
|
158 * When this method is called, |
|
159 * Reference counter is increased and when user does not |
|
160 * need watcher, close shall be called |
|
161 * |
|
162 * To get Storage manager Watcher which has handle to |
|
163 * the correct sub-folder of the Storage, |
|
164 * Server address and user name has to be specified |
|
165 * |
|
166 * @since 3.0 |
|
167 * @param aSessionSlot session slot Class which caries |
|
168 * unique information about the session |
|
169 * @return MPEngStorageManagerWatcher type pointer, |
|
170 * ownership is passed to the caller |
|
171 */ |
|
172 CPEngStorageManagerWatcher* StorageManagerWatcherL( |
|
173 const CPEngSessionSlotId& aSessionSlot ); |
|
174 |
|
175 /** |
|
176 * Create Session folder in the storage |
|
177 * This will ensure existence of the session slot folder till the |
|
178 * moment calling application will not unregister from the |
|
179 * session slot folder ( RemoveSessionFolderL) |
|
180 * |
|
181 * @since 3.0 |
|
182 * @param aSessionSlot session slot Class which caries |
|
183 * unique information about the session |
|
184 * @param aApplicationId application Id |
|
185 */ |
|
186 void CreateSessionFolderL( |
|
187 const CPEngSessionSlotId& aSessionSlot, |
|
188 const TDesC& aApplicationId ); |
|
189 |
|
190 /** |
|
191 * Remove Session folder from the storage, |
|
192 * Session folder Session is deleted from the storage, |
|
193 * only if the calling application was the last one registered |
|
194 * @see CreateSessionFolderL() |
|
195 * |
|
196 * @since 3.0 |
|
197 * @param aSessionSlot session slot Class which caries |
|
198 * unique information about the session |
|
199 * @param aApplicationId application Id |
|
200 */ |
|
201 void RemoveSessionFolderL( |
|
202 const CPEngSessionSlotId& aSessionSlot, |
|
203 const TDesC& aApplicationId ); |
|
204 |
|
205 /** |
|
206 * Get Session slot state |
|
207 * returns class where is described state of the session slot |
|
208 * ownership is passed |
|
209 * |
|
210 * @since 3.0 |
|
211 * @param aSessionSlot session slot Class which caries |
|
212 * unique information about the session |
|
213 * @param aSessionSlotState state class is updated on the |
|
214 * return with actual state |
|
215 */ |
|
216 void SessionSlotStateL( const CPEngSessionSlotId& aSessionSlot, |
|
217 CPEngSessionSlotState& aSessionSlotState ); |
|
218 |
|
219 /** |
|
220 * Get list of existing Session slots |
|
221 * Returns array of all existing session slots, no matter if |
|
222 * session is opened or closed. |
|
223 * |
|
224 * @since 3.0 |
|
225 * @param aSessionSlot session slot Class which caries |
|
226 * unique information about the session |
|
227 */ |
|
228 void AllSessionSlotsStatesL( |
|
229 RObjectArray<CPEngSessionSlotState>& aSessionSlots ); |
|
230 |
|
231 |
|
232 /** |
|
233 * Register Global event observer |
|
234 * Global event observer will be notified about all events |
|
235 * of the PEC engine |
|
236 * |
|
237 * @since 3.0 |
|
238 * @param aGlobalObserver call back interface implemented by the |
|
239 * observer |
|
240 * Function leaves with KErrAlreadyExists |
|
241 * , if same observer is already registered |
|
242 */ |
|
243 void RegisterGlobalEventObserverL( |
|
244 MPEngGlobalEventObserver& aGlobalObserver ); |
|
245 |
|
246 /** |
|
247 * Unregister Global event observer |
|
248 * Global observer is unregistered, if observer is not found |
|
249 * among the registered observers, function is ignored |
|
250 * |
|
251 * @since 3.0 |
|
252 * @param aGlobalObserver call back interface implemented by the |
|
253 * observer |
|
254 */ |
|
255 void UnregisterGlobalObserver( |
|
256 MPEngGlobalEventObserver& aGlobalObserver ); |
|
257 |
|
258 private: // New private Functions |
|
259 |
|
260 /** |
|
261 * Start global event listener |
|
262 * @since 3.0 |
|
263 */ |
|
264 void StartGlobalEventListenerL(); |
|
265 |
|
266 |
|
267 private: // private constructors |
|
268 |
|
269 /** |
|
270 * C++ default constructor. |
|
271 */ |
|
272 CPEngStorageManagerFactory(); |
|
273 |
|
274 /** |
|
275 * Symbian 2nd phase constructor |
|
276 */ |
|
277 void ConstructL(); |
|
278 |
|
279 private: // Data |
|
280 |
|
281 /// Listener of global events is activated |
|
282 TBool iListening; |
|
283 |
|
284 /// Is listening scout created on the server side |
|
285 TInt iScoutCreated; |
|
286 |
|
287 /// Access count of the reference counted object |
|
288 TInt iAccessCount; |
|
289 |
|
290 /// OWN: Storage manager main client |
|
291 RPEngStorageClient iStoreManagerClient; |
|
292 |
|
293 /// REF: Container with all Storage ID watchers |
|
294 RPointerArray<CPEngStorageManagerWatcher> iStorageWatchers; |
|
295 |
|
296 /// REF: Global Events Observers |
|
297 RPointerArray<MPEngGlobalEventObserver> iObservers; |
|
298 |
|
299 /// OWN:New Global Event receive Buffer |
|
300 HBufC8* iGlobalEventBuff; |
|
301 |
|
302 /// New Global Event |
|
303 TPtr8 iGlobalEventDes; |
|
304 |
|
305 /// Last All states buffer size |
|
306 TInt iAllStatesBuffSize; |
|
307 |
|
308 /// OWN: Flag is object is still alive |
|
309 TBool* iAliveFlag; |
|
310 }; |
|
311 |
|
312 #endif // __CPENGSTORAGEMANAGERFACTORY_H__ |
|
313 |
|
314 // End of File |