phonebookengines/contactsmodel/cntsrv/inc/CCntEventQueue.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookengines/contactsmodel/cntsrv/inc/CCntEventQueue.h	Tue Feb 02 10:12:17 2010 +0200
@@ -0,0 +1,89 @@
+/**
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* 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 TContactDbObserverEvent &aEvent);
+	void RequestEvent(const RMessage2& aMessage);
+	void CancelEventRequest();
+
+private:
+	enum TFlag
+		{
+		EQueueError=0x0001,
+		EValidEventMsg=0x0002
+		};
+
+private:
+	void Flush();
+	void SendEvent(const TContactDbObserverEvent &aEvent);
+	void SetFlag(TFlag aFlag);
+	void ClearFlag(TFlag aFlag);
+	TBool Flag(TFlag aFlag);
+
+private:
+	RArray<TContactDbObserverEvent> iEvents;
+	RMessage2 iEventMsg;
+	TInt iFlags;
+	TInt iEventsInQueue;
+	};
+
+
+#endif