|
1 /* |
|
2 * Copyright (c) 2005-2009 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: This is Metadata engine server session file* |
|
15 */ |
|
16 |
|
17 |
|
18 #ifndef __MDESERVERSESSION_H__ |
|
19 #define __MDESERVERSESSION_H__ |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "mdscommoninternal.h" |
|
25 #include "mdcserializationbuffer.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CMdSServer; |
|
29 class CMdSFindEngine; |
|
30 class CMdCSerializationBuffer; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 /** |
|
34 * CServerSession. |
|
35 * An instance of class CServerSession is created for each client. |
|
36 */ |
|
37 class CMdSServerSession : public CSession2 |
|
38 { |
|
39 public: // Constructors and destructors |
|
40 |
|
41 /** |
|
42 * NewL. |
|
43 * Two-phased constructor. |
|
44 * @param aClient The Client's thread. |
|
45 * @param aServer The server. |
|
46 * @return Pointer to created CMdEServerSession object. |
|
47 */ |
|
48 static CMdSServerSession* NewL( CMdSServer& aServer ); |
|
49 |
|
50 /** |
|
51 * NewLC. |
|
52 * Two-phased constructor. |
|
53 * @param aClient The Client's thread. |
|
54 * @param aServer The server. |
|
55 * @return Pointer to created CMdEServerSession object. |
|
56 */ |
|
57 static CMdSServerSession* NewLC( CMdSServer& aServer ); |
|
58 |
|
59 /** |
|
60 * ~CMdEServerSession. |
|
61 * Destructor. |
|
62 */ |
|
63 virtual ~CMdSServerSession(); |
|
64 |
|
65 /** |
|
66 * Cache a notification for an entry; |
|
67 * @param aId notification ID |
|
68 * @param aCompleteCode complete code |
|
69 * @param aData serialized notification data, ownership of data changes |
|
70 * even if method leaves |
|
71 */ |
|
72 void CacheNotificationL(TInt aId, TUint32 aCompleteCode, CMdCSerializationBuffer* aData); |
|
73 |
|
74 CMdSServer& GetServer() const; |
|
75 |
|
76 private: // Internal helper methods |
|
77 /** |
|
78 * Check that all queries are complete. |
|
79 */ |
|
80 void QueriesCompleteL(); |
|
81 |
|
82 protected: // Methods for own use |
|
83 |
|
84 /** |
|
85 * Adds items to database. |
|
86 * @param aMessage Message from client |
|
87 */ |
|
88 void AddL( const RMessage2& aMsg ); |
|
89 |
|
90 /** |
|
91 * Adds relation to database. |
|
92 * @param aMessage message from client |
|
93 */ |
|
94 void AddRelationDefL(const RMessage2 &aMsg); |
|
95 |
|
96 /** |
|
97 * Adds event to database. |
|
98 * @param aMessage message from client |
|
99 */ |
|
100 void AddEventDefL(const RMessage2 &aMsg); |
|
101 |
|
102 /** |
|
103 * Removes item from database. |
|
104 * @param aMessage Message from client |
|
105 */ |
|
106 void RemoveL( const RMessage2& aMsg ); |
|
107 |
|
108 /** |
|
109 * Removes item from database. |
|
110 * @param aMessage Message from client |
|
111 */ |
|
112 void RemoveByUriL( const RMessage2& aMsg, TBool aRemoveEvents ); |
|
113 |
|
114 /** |
|
115 * Finds item from database. |
|
116 * @param aMessage Message from client |
|
117 */ |
|
118 void FindL( const RMessage2& aMsg ); |
|
119 |
|
120 /** |
|
121 * Finds item from database. |
|
122 * @param aMessage Message from client |
|
123 */ |
|
124 void FindAsyncL( const RMessage2& aMsg ); |
|
125 |
|
126 /** |
|
127 * Finds item from database. |
|
128 * @param aMessage Message from client |
|
129 */ |
|
130 void FindContinueAsyncL( const RMessage2& aMsg ); |
|
131 |
|
132 /** |
|
133 * Finds item from database and completes message. |
|
134 * @param aMessage Message from client |
|
135 */ |
|
136 void FindCancel( const RMessage2& aMsg, TInt aError ); |
|
137 |
|
138 /** |
|
139 * Get object's "base" values from database and completes message. |
|
140 * @param aMessage Message from client |
|
141 */ |
|
142 void CheckObjectL( const RMessage2& aMsg ); |
|
143 |
|
144 /** |
|
145 * Transfers data from server to client. |
|
146 * @param aMessage Message from client |
|
147 */ |
|
148 void GetDataL( const RMessage2& aMsg ); |
|
149 |
|
150 /** |
|
151 * Cancels the modifying of object and unlocks the object. |
|
152 * @param aMessage Message from client |
|
153 */ |
|
154 void CancelObjectL( const RMessage2& aMsg ); |
|
155 |
|
156 /** |
|
157 * Commits the modified items to database. |
|
158 * @param aMessage Message from client |
|
159 */ |
|
160 void UpdateL( const RMessage2& aMsg ); |
|
161 |
|
162 /** |
|
163 * Registers the client for notifications. |
|
164 * @param aMessage Message from client |
|
165 */ |
|
166 void RegisterL( const RMessage2& aMsg ); |
|
167 |
|
168 /** |
|
169 * Continues registration for an existing client. |
|
170 * @param aMessage Message from client |
|
171 */ |
|
172 void ListenL( const RMessage2& aMsg ); |
|
173 |
|
174 /** |
|
175 * Unregisters a client for notifications. |
|
176 * @param aMessage Message from client |
|
177 */ |
|
178 void UnregisterL( const RMessage2& aMsg ); |
|
179 |
|
180 /** |
|
181 * Executes session shutdown. |
|
182 * @param aMessage Message from client |
|
183 */ |
|
184 void ShutdownL( const RMessage2& aMsg ); |
|
185 |
|
186 /** |
|
187 * Import metadata. |
|
188 * @param aMessage Message from client |
|
189 */ |
|
190 void ImportMetadataL( const RMessage2& aMsg ); |
|
191 |
|
192 /** |
|
193 * Export metadata |
|
194 * @param aMessage Message from client |
|
195 */ |
|
196 void ExportMetadataL( const RMessage2& aMsg ); |
|
197 |
|
198 /** |
|
199 * Import schema |
|
200 */ |
|
201 void ImportSchemaL( const RMessage2& aMsg ); |
|
202 |
|
203 /** |
|
204 * Add memory card media ID |
|
205 * @param aMessage Message from client where first argument is media ID |
|
206 */ |
|
207 void AddMemoryCardL(const RMessage2& aMessage); |
|
208 |
|
209 /** |
|
210 * Get the latest memory card's media ID |
|
211 * |
|
212 * @param aMessage Message from client where first argument is returned |
|
213 * Media ID |
|
214 * @leave KErrNotFound Not memory cards exist at all |
|
215 */ |
|
216 void GetMemoryCardL(const RMessage2& aMessage); |
|
217 |
|
218 /** |
|
219 * Check if the memory card's media ID exist in DB |
|
220 * @param aMessage Message from client where first argument is media ID |
|
221 * and second is exists boolean value |
|
222 */ |
|
223 void CheckMemoryCardL(const RMessage2& aMessage); |
|
224 |
|
225 /** |
|
226 * Set media's media ID, drive and present state to DB. |
|
227 * |
|
228 * @param aMessage Message from client where first argument is media ID |
|
229 * and second is drive and third is present state |
|
230 */ |
|
231 void SetMediaL(const RMessage2& aMessage); |
|
232 |
|
233 /** |
|
234 * Check if the media's with given media ID exist in DB and return |
|
235 * drive and present state. |
|
236 * |
|
237 * @param aMessage Message from client where first argument is media |
|
238 * ID, second is media ID, third is drive and fourth |
|
239 * is exists boolean value |
|
240 */ |
|
241 void GetMediaL(const RMessage2& aMessage); |
|
242 |
|
243 /** |
|
244 * Get present medias' media IDs and drives. |
|
245 * |
|
246 * @param aMessage Message from client where first argument is media |
|
247 * count and second is media infos |
|
248 */ |
|
249 void GetPresentMediasL(const RMessage2& aMessage); |
|
250 |
|
251 /** |
|
252 * Sets files object to present state. |
|
253 * @param aMessage Message from client where first argument is media ID |
|
254 * and file count, second argument is URIs, third |
|
255 * argument is TMdSFileInfos and fourth argument is |
|
256 * result buffer, which are sent back to client |
|
257 */ |
|
258 void SetFilesToPresentL(const RMessage2& aMessage); |
|
259 |
|
260 /** |
|
261 * Sets all file objects which has given media ID to not present state. |
|
262 * |
|
263 * @param aMessage Message from client where first argument is media ID |
|
264 */ |
|
265 void SetFilesToNotPresentL(const RMessage2& aMessage); |
|
266 |
|
267 /** |
|
268 * Removes all file objects which has given media ID and are in not |
|
269 * present. |
|
270 * |
|
271 * @param aMessage Message from client where first argument is media ID |
|
272 */ |
|
273 void RemoveFilesNotPresentL(const RMessage2& aMessage); |
|
274 |
|
275 /** |
|
276 * Gets schema version. |
|
277 * |
|
278 * @param aMessage message from client where first argument is major |
|
279 * version number and second is minor version number |
|
280 */ |
|
281 void GetSchemaVersionL(const RMessage2& aMessage); |
|
282 |
|
283 /** |
|
284 * Set object to "present" state by GUID. |
|
285 * |
|
286 * @param aMessage message from client where first argument is GUID |
|
287 * high and second is GUID low |
|
288 * |
|
289 * @leave KErrNotFound MdE can't find object in "not present" state |
|
290 * with matching GUID |
|
291 */ |
|
292 void SetObjectToPresentByGuidL(const RMessage2& aMessage); |
|
293 |
|
294 /** |
|
295 * Change path of objects, which match to the old path, to the new |
|
296 * path. |
|
297 * |
|
298 * @param aMessage message from client where first argument is the old |
|
299 * path and second is the new path |
|
300 */ |
|
301 void ChangePathL(const RMessage2& aMessage); |
|
302 |
|
303 /** |
|
304 * Change C-drive media id to MdS_Medias table and update all objects that have the old id. |
|
305 */ |
|
306 void ChangeMediaIdL( const RMessage2& aMessage ); |
|
307 |
|
308 /** |
|
309 * Set "binary composing to file" pending flag to objects. |
|
310 * |
|
311 * @param aMessage message from client where first argument is |
|
312 * serialized array of object IDs |
|
313 */ |
|
314 void SetPendingL(const RMessage2& aMessage); |
|
315 |
|
316 /** |
|
317 * Reset "binary composing to file" pending flag to objects. |
|
318 * |
|
319 * @param aMessage message from client where first argument is |
|
320 * serialized array of object IDs |
|
321 */ |
|
322 void ResetPendingL(const RMessage2& aMessage); |
|
323 |
|
324 /** |
|
325 * Get count of objects with "binary composing to file" pending flag |
|
326 * |
|
327 * @param aMessage message from client where first argument is |
|
328 * serialized object def ID |
|
329 * |
|
330 * @return if >= 0, object count is returned, otherwise error code is |
|
331 * returned |
|
332 */ |
|
333 TInt GetPendingCountL(const RMessage2& aMessage); |
|
334 |
|
335 /** |
|
336 * Get IDs from objects with "binary composing to file" pending flag |
|
337 * |
|
338 * @param aMessage message from client where first argument is |
|
339 * serialized object def ID and second argument is |
|
340 * returned object ID count and third is serialized |
|
341 * array for object IDs |
|
342 * |
|
343 * @return if > 0, buffer is not large enough for objects ID from DB, |
|
344 * otherwise error code is returned |
|
345 */ |
|
346 TInt GetPendingL(const RMessage2& aMessage); |
|
347 |
|
348 public: // Functions from base classes |
|
349 |
|
350 /** |
|
351 * From CSession2, ServiceL. |
|
352 * Service request from client. |
|
353 * @param aMessage Message from client |
|
354 * (containing requested operation and any data). |
|
355 */ |
|
356 void ServiceL( const RMessage2& aMessage ); |
|
357 |
|
358 /** |
|
359 * SizeToRemoteL. |
|
360 * Writes size to slave process. |
|
361 * @param aMessage Message from client |
|
362 * @param aRemote, pointer to client's variable. |
|
363 * @param aHierarchy hierarchy that's size is to be transmitted |
|
364 */ |
|
365 static void SizeToRemoteL( const RMessage2& aMsg, TInt aMessageSlot, TInt aSize); |
|
366 |
|
367 private: // Constructors and destructors |
|
368 |
|
369 /** |
|
370 * CMdSServerSession. |
|
371 * C++ default constructor. |
|
372 * @param aClient The Client's thread. |
|
373 * @param aServer The server. |
|
374 */ |
|
375 CMdSServerSession( CMdSServer& aServer ); |
|
376 |
|
377 /** |
|
378 * ConstructL. |
|
379 * 2nd phase constructor. |
|
380 */ |
|
381 void ConstructL(); |
|
382 |
|
383 /** |
|
384 * Internal function to handle service request from client. |
|
385 * @param aMessage Message from client |
|
386 * (containing requested operation and any data). |
|
387 */ |
|
388 void ServiceFunctionL( const RMessage2& aMessage ); |
|
389 |
|
390 CMdCSerializationBuffer* CombineBuffersL( |
|
391 CMdCSerializationBuffer& aLeftBuffer, CMdCSerializationBuffer& aRightBuffer ); |
|
392 |
|
393 CMdCSerializationBuffer* CombineItemBuffersL( |
|
394 CMdCSerializationBuffer& aLeftBuffer, CMdCSerializationBuffer& aRightBuffer ); |
|
395 |
|
396 private: // Data |
|
397 |
|
398 /** |
|
399 * iServer, reference to the server. |
|
400 */ |
|
401 CMdSServer& iServer; |
|
402 |
|
403 /** |
|
404 * Find engine |
|
405 */ |
|
406 RPointerArray<CMdSFindEngine> iFindEngines; |
|
407 |
|
408 class CNotificationCacheItem : public CBase |
|
409 { |
|
410 public: |
|
411 CNotificationCacheItem( TInt aId, TUint32 aCode, |
|
412 CMdCSerializationBuffer* aData ) : |
|
413 iId( aId ), |
|
414 iCode( aCode ), |
|
415 iData( aData ) |
|
416 { |
|
417 } |
|
418 |
|
419 ~CNotificationCacheItem() |
|
420 { |
|
421 delete iData; |
|
422 } |
|
423 |
|
424 public: |
|
425 const TInt iId; |
|
426 const TUint32 iCode; |
|
427 CMdCSerializationBuffer* iData; |
|
428 }; |
|
429 |
|
430 /** |
|
431 * Cache of notification events |
|
432 */ |
|
433 RPointerArray<CNotificationCacheItem> iNotificationCache; |
|
434 }; |
|
435 |
|
436 #endif // __MDESERVERSESSION_H__ |