|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 |
|
27 #ifndef CCNTEVENTQUEUE_H |
|
28 #define CCNTEVENTQUEUE_H |
|
29 |
|
30 #include <e32base.h> |
|
31 #include <cntdb.h> |
|
32 |
|
33 #include <cntdbobs.h> // for tcontactdbobserverevent. |
|
34 |
|
35 |
|
36 #define KMaxNumberOfEventsInEventQueue 1000 |
|
37 |
|
38 #if defined(_DEBUG) // For OOM testing set granularity to 1 |
|
39 const TInt KCntEventGranularity = 1; |
|
40 #else |
|
41 const TInt KCntEventGranularity = 10; |
|
42 #endif |
|
43 |
|
44 |
|
45 /** |
|
46 The CEventQueue class is used to queue database events on the Server for later |
|
47 consumption by Client-side objects which make IPC calls to read events from the |
|
48 queue. An instance of this class is owned by each CCntSession object. |
|
49 |
|
50 When a Contacts database is openend, created or replaced in the method |
|
51 CCntSession::FileOpenCreateReplaceL() then the CCntSession object is registered |
|
52 as a database event observer of the associated CCntDbManager. |
|
53 |
|
54 Then when a database event occurs the database event callback interface |
|
55 implemented by CCntSession (i.e. the MContactDbObserver::HandleDatabaseEventL() |
|
56 method) is called and the event placed in this queue. |
|
57 */ |
|
58 class CEventQueue : public CBase |
|
59 { |
|
60 public: |
|
61 CEventQueue(); |
|
62 ~CEventQueue(); |
|
63 void QueueEvent(const TContactDbObserverEvent &aEvent); |
|
64 void RequestEvent(const RMessage2& aMessage); |
|
65 void CancelEventRequest(); |
|
66 |
|
67 private: |
|
68 enum TFlag |
|
69 { |
|
70 EQueueError=0x0001, |
|
71 EValidEventMsg=0x0002 |
|
72 }; |
|
73 |
|
74 private: |
|
75 void Flush(); |
|
76 void SendEvent(const TContactDbObserverEvent &aEvent); |
|
77 void SetFlag(TFlag aFlag); |
|
78 void ClearFlag(TFlag aFlag); |
|
79 TBool Flag(TFlag aFlag); |
|
80 |
|
81 private: |
|
82 RArray<TContactDbObserverEvent> iEvents; |
|
83 RMessage2 iEventMsg; |
|
84 TInt iFlags; |
|
85 TInt iEventsInQueue; |
|
86 }; |
|
87 |
|
88 |
|
89 #endif |