remotecontrol/remotecontrolfw/server/inc/controllersession.h
changeset 51 20ac952a623c
equal deleted inserted replaced
48:22de2e391156 51:20ac952a623c
       
     1 // Copyright (c) 2010 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 #ifndef CONTROLLERSESSION_H
       
    17 #define CONTROLLERSESSION_H
       
    18 
       
    19 #include "session.h"
       
    20 #include "messagesendobserver.h"
       
    21 
       
    22 class CActiveHelper;
       
    23 NONSHARABLE_CLASS(CRemConControllerSession) : public CRemConSession, public MRemConMessageSendObserver
       
    24 	{
       
    25 public:
       
    26 	/**
       
    27 	Factory method.
       
    28 	@param aServer The server.
       
    29 	@param aBearerManager The bearer manager.
       
    30 	@param aClientInfo Information about the client using this session.
       
    31 	@param aId The unique ID of the new session.
       
    32 	@return Ownership of a new session.
       
    33 	*/
       
    34 	static CRemConControllerSession* NewL(CRemConServer& aServer,
       
    35 		CBearerManager& aBearerManager,
       
    36 		const TClientInfo& aClientInfo,
       
    37 		TUint aId);
       
    38 
       
    39 	~CRemConControllerSession();
       
    40 
       
    41 	/** 
       
    42 	Checks if this message is supported by the session
       
    43 	@param aMsg The message to check
       
    44 	@return ETrue if it is, EFalse otherwise
       
    45 	*/
       
    46 	TBool SupportedMessage(const CRemConMessage& aMsg) const;
       
    47 
       
    48 	inline const TPlayerType& PlayerType() const;
       
    49 	inline const TPlayerSubType& PlayerSubType() const;
       
    50 	inline const TDesC8& Name() const;
       
    51 	
       
    52 public: // called by the bearer manager
       
    53 	/**
       
    54 	Indicates that a connect request has been completed. The request was not 
       
    55 	necessarily from this session- the session must check that the connected 
       
    56 	address is one it has asked to be connected. If it is, and we have a 
       
    57 	connect request outstanding, the connect request should be completed.
       
    58 	@param aAddr The connected address.
       
    59 	@param aError The error with which the connection attempt was completed.
       
    60 	*/
       
    61 	void CompleteConnect(const TRemConAddress& aAddr, TInt aError);
       
    62 
       
    63 	/**
       
    64 	Indicates that a disconnect request has been completed. The request was 
       
    65 	not necessarily from this session- the session must check that the 
       
    66 	disconnected address is one it has asked to be disconnected. If it is, and 
       
    67 	we have a disconnect request outstanding, the disconnect request should be 
       
    68 	completed.
       
    69 	@param aAddr The disconnected address.
       
    70 	@param aError The error with which the disconnection attempt was 
       
    71 	completed.
       
    72 	*/
       
    73 	void CompleteDisconnect(const TRemConAddress& aAddr, TInt aError);
       
    74 	
       
    75 public: // called by the active helper
       
    76 	void ProcessPendingMsgL();
       
    77 	
       
    78 private:
       
    79 	/**
       
    80 	Constructor.
       
    81 	@param aServer The server.
       
    82 	@param aBearerManager The bearer manager.
       
    83 	@param aId The unique ID of the new session.
       
    84 	*/
       
    85 	CRemConControllerSession(CRemConServer& aServer, 
       
    86 		CBearerManager& aBearerManager,
       
    87 		TUint aId);
       
    88 
       
    89 	/**
       
    90 	2nd-phase construction.
       
    91 	@param aClientInfo Information about the client using this session.
       
    92 	*/
       
    93 	void ConstructL(const TClientInfo& aClientInfo);
       
    94 	
       
    95 private: // From CRemConSession: utility- IPC command handlers
       
    96 	void SetPlayerType(const RMessage2& aMessage);
       
    97 	void SendUnreliable(const RMessage2& aMessage);
       
    98 	void RegisterInterestedAPIs(const RMessage2& aMessage);
       
    99 	void GoConnectionOriented(const RMessage2& aMessage);
       
   100 	void GoConnectionless(const RMessage2& aMessage);
       
   101 	void ConnectBearer(const RMessage2& aMessage);
       
   102 	void ConnectBearerCancel(const RMessage2& aMessage);
       
   103 	void DisconnectBearer(const RMessage2& aMessage);
       
   104 	void DisconnectBearerCancel(const RMessage2& aMessage);
       
   105 	void SendNotify(const RMessage2& aMessage);
       
   106 
       
   107 private: // From CRemConSession: utility
       
   108 	CRemConMessage* DoPrepareSendMessageL(const RMessage2& aMessage);
       
   109 	void DoSendCancel();
       
   110 	void DoReceive();
       
   111 	
       
   112 private: // utility
       
   113 	CRemConMessage* DoCreateUnreliableMessageL(const RMessage2& aMessage);
       
   114 	void DoSendNotifyL(const RMessage2& aMessage);
       
   115 	
       
   116 	void SendToServer(CRemConMessage& aMsg);
       
   117 	
       
   118 	void CheckForPendingMsg() const; 
       
   119 	void EmptySendQueue();
       
   120 
       
   121 	void CompleteMessage(const CRemConMessage& aMessage);
       
   122 
       
   123 public: //From MRemConMessageSendObserver
       
   124 	void MrcmsoMessageSendResult(const CRemConMessage& aMessage, TInt aError);
       
   125 	void MrcmsoMessageSendOneOrMoreAttempt(const CRemConMessage& aMessage, TUint aNumRemotes);
       
   126 	void MrcmsoMessageSendOneOrMoreIncremental(const CRemConMessage& aMessage, TUint aNumRemotes);	// Not supported
       
   127 	void MrcmsoMessageSendOneOrMoreAttemptFailed(const CRemConMessage& aMessage, TInt aError);
       
   128 	void MrcmsoMessageSendOneOrMoreResult(const CRemConMessage& aMessage, TInt aError);
       
   129 	void MrcmsoMessageSendOneOrMoreAbandoned(const CRemConMessage& aMessage);	// Not supported
       
   130 
       
   131 private: // message handles for asynchronous IPC requests
       
   132 	// Address of remote device associated with this session.
       
   133 	// A null remote address indicates a connectionless 
       
   134 	// controller; a non-null UID indicates a connection-oriented controller.
       
   135 	TRemConAddress iRemoteAddress;
       
   136 
       
   137 	RMessage2 iConnectBearerMsg;
       
   138 	RMessage2 iDisconnectBearerMsg;
       
   139 	// Stores pending connect/disconnect request
       
   140 	// There can be only one pending request at any time
       
   141 	RMessage2 iPendingMsg;
       
   142 	
       
   143 	// Helps with session's async connect/disconnect requests
       
   144 	CActiveHelper *iPendingMsgProcessor;
       
   145 
       
   146 	// the player type information
       
   147 	TPlayerTypeInformation iPlayerType;
       
   148 	//the player name 
       
   149 	RBuf8 iPlayerName;
       
   150 	};
       
   151 
       
   152 #include "controllersession.inl"
       
   153 
       
   154 #endif /* CONTROLLERSESSION_H */