diff -r 000000000000 -r e686773b3f54 phonebookengines/contactsmodel/cntsrv/inc/CCntEventQueue.h --- /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 +#include + +#include // 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 iEvents; + RMessage2 iEventMsg; + TInt iFlags; + TInt iEventsInQueue; + }; + + +#endif