blob: ac801e046a8617c3070fe07b2f929e9635dca7fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
/**
@file
@internalComponent
@released
*/
#ifndef CCNTEVENTQUEUE_H
#define CCNTEVENTQUEUE_H
#include <e32base.h>
#include <cntdb.h>
#include <cntdbobs.h> // for tcontactdbobserverevent.
#define KMaxNumberOfEventsInEventQueue 1000
#if defined(_DEBUG) // For OOM testing set granularity to 1
const TInt KCntEventGranularity = 1;
#else
const TInt KCntEventGranularity = 10;
#endif
/**
The CEventQueue class is used to queue database events on the Server for later
consumption by Client-side objects which make IPC calls to read events from the
queue. An instance of this class is owned by each CCntSession object.
When a Contacts database is openend, created or replaced in the method
CCntSession::FileOpenCreateReplaceL() then the CCntSession object is registered
as a database event observer of the associated CCntDbManager.
Then when a database event occurs the database event callback interface
implemented by CCntSession (i.e. the MContactDbObserver::HandleDatabaseEventL()
method) is called and the event placed in this queue.
*/
class CEventQueue : public CBase
{
public:
CEventQueue();
~CEventQueue();
void QueueEvent(const TContactDbObserverEventV2 &aEvent);
void RequestEvent(const RMessage2& aMessage);
void CancelEventRequest();
private:
enum TFlag
{
EQueueError=0x0001,
EValidEventMsg=0x0002
};
private:
void Flush();
void SendEvent(const TContactDbObserverEventV2 &aEvent, const CContactIdArray* aAdditionalContactIds);
void SetFlag(TFlag aFlag);
void ClearFlag(TFlag aFlag);
TBool Flag(TFlag aFlag);
TInt Append(const TContactDbObserverEventV2 &aEvent);
private:
RArray<TContactDbObserverEventV2> iEvents;
RPointerArray<CContactIdArray> iIds;
RMessage2 iEventMsg;
TInt iFlags;
TInt iEventsInQueue;
};
#endif
|