accessoryservices/remotecontrolfw/server/inc/bulksession.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef REMCONBULKSESSION_H
       
    24 #define REMCONBULKSESSION_H
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <remconserverpanic.h>
       
    28 #include <remcon/clientinfo.h>
       
    29 
       
    30 class CRemConBulkServer;
       
    31 class CRemConLogger;
       
    32 class CBearerManager;
       
    33 class CRemConMessage;
       
    34 class CActiveHelper;
       
    35 class CMessageQueue;
       
    36 
       
    37 /**
       
    38 Rem Con session.
       
    39 */
       
    40 NONSHARABLE_CLASS(CRemConBulkSession) : public CSession2
       
    41 	{
       
    42 public:
       
    43 	/**
       
    44 	Factory method.
       
    45 	@param aServer The server.
       
    46 	@param aMessage Handle on the client message triggering this session creation.
       
    47 	@return Ownership of a new session.
       
    48 	*/
       
    49 	static CRemConBulkSession* NewL(CRemConBulkServer& aServer,
       
    50 		const RMessage2& aMessage);
       
    51 
       
    52 	~CRemConBulkSession();
       
    53 
       
    54 public: // called by the server
       
    55 	/**
       
    56 	@return This session's unique identifier.
       
    57 	*/
       
    58 	inline TUint Id() const;
       
    59 	
       
    60 	inline void SetId(TUint aId);
       
    61 	
       
    62 	inline RArray<TUid>& InterestedAPIs();
       
    63 	
       
    64 	/** 
       
    65 	@return Information about the client using this session.
       
    66 	*/
       
    67 	inline const TClientInfo& ClientInfo() const;
       
    68 	
       
    69 	/**
       
    70 	Writes aMsg to the client's Receive message (NB RMessage2::Write may fail) 
       
    71 	and completes the client's Receive message with any error.
       
    72 	@return Error.
       
    73 	*/
       
    74 	TInt WriteMessageToClient(const CRemConMessage& aMsg);
       
    75 
       
    76 	/**
       
    77 	Accessor for the currently outstanding client Receive message.
       
    78 	@return Handle to client's receive message.
       
    79 	*/
       
    80 	inline const RMessage2& CurrentReceiveMessage() const;
       
    81 
       
    82 	
       
    83 private:
       
    84 	/**
       
    85 	@param aServer The server.
       
    86 	@param aLogger The logger.
       
    87 	@param aId The unique ID of the new session.
       
    88 	*/
       
    89 	CRemConBulkSession(CRemConBulkServer& aServer);
       
    90 
       
    91 	/**
       
    92 	2nd-phase construction.
       
    93 	@param aMessage The message received from the client.
       
    94 	*/
       
    95 	void ConstructL(const RMessage2& aMessage);
       
    96 		
       
    97 private: // from CSession2
       
    98 	/**
       
    99 	Called when a message is received from the client.
       
   100 	@param aMessage Message received from the client.
       
   101 	*/
       
   102 	void ServiceL(const RMessage2& aMessage);
       
   103 
       
   104 private: // utility- IPC command handlers
       
   105 	void Send(const RMessage2& aMessage);
       
   106 	void SendUnreliable(const RMessage2& aMessage);
       
   107 	void SendCancel(const RMessage2& aMessage);
       
   108 	void Receive(const RMessage2& aMessage);
       
   109 	void ReceiveCancel(const RMessage2& aMessage);
       
   110 	
       
   111 private: // utility
       
   112 	void DoSendL(const RMessage2& aMessage);
       
   113 	
       
   114 	/**
       
   115 	Utility to complete the given message with the given error code.
       
   116 	@param aMessage Message to complete.
       
   117 	@param aError Error to complete with.
       
   118 	*/
       
   119 	void CompleteClient(const RMessage2& aMessage, TInt aError);
       
   120 	
       
   121 	CRemConMessage* DoCreateMessageL(const RMessage2& aMessage, TBool aReliable);
       
   122 	TInt SendToServer(CRemConMessage& aMsg);
       
   123 
       
   124 	
       
   125 private: // unowned
       
   126 	CRemConBulkServer& iServer;
       
   127 
       
   128 private: // message handles for asynchronous IPC requests
       
   129 	RMessage2 iReceiveMsg;
       
   130 
       
   131 private: // owned
       
   132 	// The client's process ID, secure ID and caps.
       
   133 	TClientInfo iClientInfo;
       
   134 
       
   135 	// session identifier - mapped to the control session reference...
       
   136 	TUint iId;
       
   137 	
       
   138 	RArray<TUid> iInterestedAPIs; // cached from control server.
       
   139 	};
       
   140 
       
   141 // Inlines
       
   142 
       
   143 TUint CRemConBulkSession::Id() const
       
   144 	{
       
   145 	return iId;
       
   146 	}
       
   147 
       
   148 void CRemConBulkSession::SetId(TUint aId)
       
   149 	{
       
   150 	iId = aId;
       
   151 	}
       
   152 
       
   153 const RMessage2& CRemConBulkSession::CurrentReceiveMessage() const
       
   154 	{
       
   155 	return iReceiveMsg;
       
   156 	}
       
   157 
       
   158 RArray<TUid>& CRemConBulkSession::InterestedAPIs()
       
   159 	{
       
   160 	return iInterestedAPIs;
       
   161 	}
       
   162 
       
   163 const TClientInfo& CRemConBulkSession::ClientInfo() const
       
   164 	{
       
   165 	return iClientInfo;
       
   166 	}
       
   167 
       
   168 #endif // REMCONBULKSESSION_H
       
   169