sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Definition of the CEComServerSession class
sl@0: // 
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @internalComponent
sl@0:  @file
sl@0: */
sl@0: 
sl@0: #ifndef __ECOMSERVERSESSION_H__
sl@0: #define __ECOMSERVERSESSION_H__
sl@0: 
sl@0: #include <s32mem.h>
sl@0: #include "EComServer.h"
sl@0: 
sl@0: #include "clientrequest.h"
sl@0: 
sl@0: // __________________________________________________________________________
sl@0: //
sl@0: /**
sl@0: 	@internalComponent
sl@0: 	@since 7.0
sl@0: 	Provides the server side session which
sl@0: 	handles the messages from REComSession, unpacking the input
sl@0: 	message parameters, calling the server and packaging the 
sl@0: 	the returned data as output message parameters.
sl@0: 	Warning : The implementation of the ListImplementations
sl@0: 	method for returning an arbitrary sized data set
sl@0: 	uses a 2 phase collection method that
sl@0: 	will not work IF the session is shared and two 
sl@0: 	client calls on this method are interleaved.
sl@0: 	It leads to incorrect results for one of them,
sl@0: 	with potentially fatal results. so...
sl@0: 	DO NOT SHARE SERVER SIDE SESSIONS BETWEEN CLIENTS
sl@0:  */
sl@0: 
sl@0: class CEComServerSession : public CSession2
sl@0: 	{
sl@0: public:
sl@0: 	
sl@0: 	CEComServerSession();
sl@0: 
sl@0: 	
sl@0: 	void CreateL();
sl@0: /**
sl@0: 	@fn				void CompleteNotifications(TInt aCompletionCode)
sl@0: 	Intended Usage	: Completes all the outstanding notification requests with the
sl@0: 					supplied error code.
sl@0: 	@since			7.0
sl@0: 	@param			aCompletionCode The code with which to complete the notifications.
sl@0: 	@pre 			REComServerSession is fully constructed.
sl@0: 	@post			The notifications contained on the iNotificationRequests array
sl@0: 					have been completed with aCompletionCode, and the array has 
sl@0: 					been cleared.
sl@0:  */
sl@0: 	
sl@0: 	void CompleteNotifications(TInt aCompletionCode);
sl@0: 
sl@0: private:
sl@0: 	
sl@0: 	inline CEComServer& Server();
sl@0: 
sl@0: 	
sl@0: 	~CEComServerSession();
sl@0: 
sl@0: 	
sl@0: 	void ServiceL(const RMessage2& aMessage);
sl@0: 
sl@0: 	void ServiceL(const TClientRequest& aMessage);
sl@0: 
sl@0: 	
sl@0: 	inline TBool ReceivePending() const;
sl@0: 
sl@0: 	
sl@0: 	void DoListImplementationsL(const TClientRequest& aMessage);
sl@0: 
sl@0: 	
sl@0: 	TBool DoCollectListL(const TClientRequest& aMessage);
sl@0: 	
sl@0: 	void DoListExtendedInterfacesL(const TClientRequest& aMessage);
sl@0: 	
sl@0: 	void DoGetResolvedImplementationL(const TClientRequest& aMessage);
sl@0: 	void UnpackMatchStrAndExtendedInterfacesFromClientL(const TClientRequest& aMessage,
sl@0: 														RExtendedInterfacesArray& aExtendedInterfaces,
sl@0: 														RBuf8& aMatchStr);
sl@0: 	
sl@0: 	void DoSetGetParametersL(const TClientRequest& aMessage);
sl@0: /**
sl@0: 	@fn				CleanupInternalList()
sl@0: 	Intended Usage	: Releases the list of CImplementationInformation pointers
sl@0: 					 that are stored within the iList variable after a successful 
sl@0: 					 call to the DoListImplementations service.
sl@0: 	@since			7.0
sl@0: 	@pre 			REComServerSession is fully constructed.
sl@0: 	@post			The resources held by iList are released, and iList is NULL.
sl@0:  */
sl@0: 	
sl@0: 	void CleanupInternalList();
sl@0: 
sl@0: private:
sl@0: 	/** 
sl@0: 		The externalised data from a ListImplementations service call
sl@0: 		held for return, pending the collection service call.
sl@0: 	 */
sl@0: 	
sl@0: 	CBufFlat* iMemoryStore;
sl@0: 	
sl@0: 	/** The last ListImplementations service request */
sl@0: 	
sl@0: 	TInt iListContext;
sl@0: 
sl@0: 	/** 
sl@0: 		A successful ListImplementations service request 
sl@0: 		generates a list of CImplementationInformation pointers
sl@0: 		that are stored within this list.
sl@0: 	 */
sl@0: 	
sl@0: 	RImplInfoArray* iList;
sl@0: 
sl@0: 	/** The array of client notification requests outstanding */
sl@0: 	
sl@0: 	struct SEComNotification    
sl@0: 		{
sl@0: 			/** Notification status object */
sl@0: 			TInt iRequestStatusHandle; 
sl@0: 			/** Client identity */
sl@0: 			TClientRequest iMessage;     
sl@0: 		};
sl@0: 
sl@0: 	RArray<SEComNotification> iNotificationRequests;
sl@0: 
sl@0: 	/** A friend class for testing purposes */
sl@0: 	friend class TEComServer_StateAccessor;
sl@0: 	/** A friend class for testing purposes */
sl@0: 	friend class TEComServerSession_StateAccessor;
sl@0: 	};
sl@0: 
sl@0: /**
sl@0: @fn				PanicClient(const RMessage& aMessage,TInt aPanicCode)
sl@0: Intended Usage	: A global function to complete aMessage with the supplied panic code.
sl@0: @since			7.0
sl@0: @param			aPanicCode The error code with which to complete the message.
sl@0: @pre 			None.
sl@0: @post			aMessage has been completed.
sl@0: @internalComponent
sl@0: */
sl@0: extern void PanicClient(const TClientRequest& aMessage,TInt aPanicCode);
sl@0: 
sl@0: #include "EComServerSession.inl"
sl@0: 
sl@0: #endif	// __ECOMSERVERSESSION_H__
sl@0: 
sl@0: