phonebookengines/contactsmodel/cntsrv/inc/CViewSubSessions.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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 CVIEWSUBSESSIONS_H
       
    28 #define CVIEWSUBSESSIONS_H
       
    29 
       
    30 
       
    31 #include <e32base.h>
       
    32 
       
    33 #include "persistencelayer.h"
       
    34 
       
    35 
       
    36 class CViewSubSessionBase;
       
    37 class CContactViewBase;
       
    38 class CViewContact;
       
    39 class RContactViewSortOrder;
       
    40 class CContactLocalView;
       
    41 class CContactNamedLocalView;
       
    42 class CPersistenceLayer;
       
    43 class CCntDbManager;
       
    44 class CContactDefaultViewDefinition;
       
    45 
       
    46 
       
    47 /**
       
    48 The CViewSubSessionQueue class is used to queue view events on the Server for
       
    49 later consumption by Client-side objects which make IPC calls to read events
       
    50 from the queue.  An instance of this class is owned by each CViewSubSessionBase
       
    51 object.
       
    52 */
       
    53 class CViewSubSessionQueue : public CBase
       
    54 	{
       
    55 public:
       
    56 	CViewSubSessionQueue();
       
    57 	~CViewSubSessionQueue();
       
    58 	void QueueEvent(const TContactViewEvent& aEvent);
       
    59 	void RequestEvent(const RMessage2& aMessage);
       
    60 	void CancelEventRequest();
       
    61 
       
    62 private:
       
    63 	void SendEventL(const TContactViewEvent& aEvent);
       
    64 
       
    65 private:
       
    66 	RArray<TContactViewEvent> iEvents;
       
    67 	RMessage2 iMessage;
       
    68 	TBool iRequestPending;
       
    69 	TInt iQueueError;
       
    70 	};
       
    71 
       
    72 
       
    73 /**
       
    74 The CViewManager class is responsible for managing Server-side local view
       
    75 objects which are associated with Client-side remote view objects.
       
    76 
       
    77 Each CCntSession object creates a CViewManager instance.
       
    78 
       
    79 The CViewManager class constructs and manages one or more CContactLocalView or
       
    80 CContactNamedLocalView instances and supplies them to CViewSubSession.
       
    81 */
       
    82 class CViewManager : public CBase
       
    83 	{
       
    84 public:
       
    85 	static CViewManager* NewL(MLplPersistenceLayerFactory& aFactory,CCntDbManager& aDbManager);
       
    86 	CContactLocalView& OpenViewL(const RContactViewSortOrder& aSortOrder,MContactViewObserver& aObserver,TContactViewPreferences aContactTypeToInclude, const TUid aSortPluginImplUid, const TDesC8& aSortPluginName);
       
    87 	CContactNamedLocalView& OpenNamedViewL(const TDesC& aName,const RContactViewSortOrder& aSortOrder,MContactViewObserver& aObserver,TContactViewPreferences aContactTypeToInclude, const TUid aSortPluginImplUid, const TDesC8& aSortPluginName);
       
    88 	void CloseView(const CContactLocalView& aView,MContactViewObserver& aObserver);
       
    89 	void CloseNamedView(const CContactNamedLocalView& aView,MContactViewObserver& aObserver);
       
    90 	~CViewManager();
       
    91 	void GetDefinitionsOfExistingViewsL(RPointerArray<CContactDefaultViewDefinition>& aViewDefs);
       
    92 
       
    93 private:
       
    94 	CViewManager(MLplPersistenceLayerFactory& aFactory,CCntDbManager& aManager);
       
    95 	void ConstructL();
       
    96 
       
    97 private:
       
    98 	MLplPersistenceLayerFactory& iFactory;
       
    99 	CCntDbManager&			iManager;
       
   100 	struct TViewHandle
       
   101 		{
       
   102 		CContactLocalView*	iLocalView;
       
   103 		TUid				iSortPluginImplUid;
       
   104 		};
       
   105 	RArray<TViewHandle>		iLocalViews;
       
   106 	RPointerArray<CContactNamedLocalView> iNamedLocalViews;
       
   107 	};
       
   108 
       
   109 
       
   110 /**
       
   111 The CViewSubSessionBase class is a base class for anonymous view subsessions.
       
   112 Its main purpose is to provide methods for accessing CViewContact objects held
       
   113 in the local views managed by CViewManager.
       
   114 
       
   115 Instances of CViewSubSessionBase are constructed and managed by a CCntSession
       
   116 instance using the subsession object container mechanism.  CCntSession calls the
       
   117 derived CViewSubSessionBase::ServiceL() method after extracting the
       
   118 CViewSubSessionBase handle from RMessage2 Int3()
       
   119 */
       
   120 class CViewSubSessionBase : public CObject, public MContactViewObserver
       
   121 	{
       
   122 public:
       
   123 	virtual TInt ServiceL(const RMessage2& aMessage);
       
   124 
       
   125 protected:
       
   126 	~CViewSubSessionBase();
       
   127 	CViewSubSessionBase(CViewManager& aParent);
       
   128 	void ConstructL();
       
   129 
       
   130 private:
       
   131 	virtual void HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent);
       
   132 	void CountL(const RMessage2& aMessage) const;
       
   133 	TInt AtL(const RMessage2& aMessage) const;
       
   134 	void ContactAtL(const RMessage2& aMessage) const;
       
   135 	TInt ContactAtLengthL(const RMessage2& aMessage);
       
   136 	void FindL(const RMessage2& aMessage) const;
       
   137 	TInt GetAllFieldsLengthL(const RMessage2& aMessage);
       
   138 	void GetAllFieldsTextL(const RMessage2& aMessage);
       
   139 	void ContactMatchingCriteriaExternalizedSizeL(const RMessage2& aMessage);
       
   140 	void GetContactMatchingCriteriaL(const RMessage2& aMessage);
       
   141 	void GetIncludedTypesL(const RMessage2& aMessage);
       
   142 	void DeleteFindContacts();
       
   143 	void RequestViewEvent(const RMessage2& aMessage);
       
   144 	void CancelRequestViewEvent();
       
   145 	void GetContactIdsL(const RMessage2& aMessage);
       
   146 	void SendPluginUidToServer(const RMessage2& aMessage);
       
   147 	void GetContactsMatchingFilterL(const RMessage2& aMessage);
       
   148 	void GetSortPluginUidFromServerL(const RMessage2& aMessage);
       
   149 
       
   150 protected:
       
   151 	CViewManager& iViewManager;
       
   152 	CContactViewBase* iView;
       
   153 	HBufC* iSortableText;
       
   154 	RPointerArray<CViewContact> iContacts;
       
   155 	CViewContact* iContact;
       
   156 	CViewSubSessionQueue* iQueue;
       
   157 	};
       
   158 
       
   159 
       
   160 /**
       
   161 The CViewSubSession class implements anonymous view subsessions.
       
   162 */
       
   163 class CViewSubSession : public CViewSubSessionBase
       
   164 	{
       
   165 public:
       
   166 	static CViewSubSession* NewL(CViewManager& aParent,const RMessage2& aMessage);
       
   167 
       
   168 protected:
       
   169 	~CViewSubSession();
       
   170 	CViewSubSession(CViewManager& aParent);
       
   171 	void UnpackageSortOrderL(const RMessage2& aMessage,RContactViewSortOrder& aSortOrder,TContactViewPreferences& aContactTypes) const;
       
   172 	HBufC8* UnpackageSortOrderAndPluginDetailsLC(const RMessage2& aMessage,RContactViewSortOrder& aSortOrder,TContactViewPreferences& aContactTypes,TUid& aSortPluginImplUid) const;
       
   173 
       
   174 protected: 
       
   175 	// From CViewSubSessionBase.
       
   176 	TInt ServiceL(const RMessage2& aMessage);
       
   177 
       
   178 private:
       
   179 	void ConstructL(const RMessage2& aMessage);
       
   180 	inline CContactLocalView& View() const;
       
   181 	void ExternalizedSortOrderSizeL(const RMessage2& aMessage) const;
       
   182 	void GetSortOrderL(const RMessage2& aMessage) const;
       
   183 	};
       
   184 
       
   185 
       
   186 /**
       
   187 The CNamedViewSubSession class implements named view subsessions.
       
   188 */
       
   189 class CNamedViewSubSession : public CViewSubSession
       
   190 	{
       
   191 public:
       
   192 	static CNamedViewSubSession* NewL(CViewManager& aParent,const RMessage2& aMessage);
       
   193 
       
   194 private:
       
   195 	// From CViewSubSessionBase.
       
   196 	TInt ServiceL(const RMessage2& aMessage);
       
   197 
       
   198 private:
       
   199 	~CNamedViewSubSession();
       
   200 	CNamedViewSubSession(CViewManager& aParent);
       
   201 	void ConstructL(const RMessage2& aMessage);
       
   202 	void ChangeSortOrderL(const RMessage2& aMessage);
       
   203 	inline CContactNamedLocalView& View() const;
       
   204 	};
       
   205 
       
   206 	
       
   207 #endif