130 /** |
111 /** |
131 Accessor for the currently outstanding client Receive message. |
112 Accessor for the currently outstanding client Receive message. |
132 @return Handle to client's receive message. |
113 @return Handle to client's receive message. |
133 */ |
114 */ |
134 inline const RMessage2& CurrentReceiveMessage() const; |
115 inline const RMessage2& CurrentReceiveMessage() const; |
135 |
|
136 inline const TPlayerType& PlayerType() const; |
|
137 inline const TPlayerSubType& PlayerSubType() const; |
|
138 |
|
139 inline const TDesC8& Name() const; |
|
140 |
116 |
141 TInt SupportedInterfaces(RArray<TUid>& aUids); |
117 TInt SupportedInterfaces(RArray<TUid>& aUids); |
|
118 TInt AppendSupportedInterfaces(RArray<TUid>& aUids); |
142 TInt SupportedBulkInterfaces(RArray<TUid>& aUids); |
119 TInt SupportedBulkInterfaces(RArray<TUid>& aUids); |
|
120 TInt AppendSupportedBulkInterfaces(RArray<TUid>& aUids); |
143 TInt SupportedOperations(TUid aInterfaceUid, RArray<TUint>& aOperations); |
121 TInt SupportedOperations(TUid aInterfaceUid, RArray<TUint>& aOperations); |
144 |
122 |
145 /** |
123 /** |
146 Panics the client's current Send message with the given code. |
124 Panics the client's current Send message with the given code. |
147 */ |
125 */ |
148 void PanicSend(TRemConClientPanic aCode); |
126 void PanicSend(TRemConClientPanic aCode); |
149 |
127 |
150 public: // called by the bearer manager |
128 /** |
151 /** |
129 Checks whether this session is fully initialised and available for use |
152 Indicates that a connect request has been completed. The request was not |
130 by bearers. |
153 necessarily from this session- the session must check that the connected |
131 @return ETrue if session can be used by bearers, EFalse otherwise |
154 address is one it has asked to be connected. If it is, and we have a |
132 */ |
155 connect request outstanding, the connect request should be completed. |
133 inline TBool ClientAvailable() const; |
156 @param aAddr The connected address. |
|
157 @param aError The error with which the connection attempt was completed. |
|
158 */ |
|
159 void CompleteConnect(const TRemConAddress& aAddr, TInt aError); |
|
160 |
|
161 /** |
|
162 Indicates that a disconnect request has been completed. The request was |
|
163 not necessarily from this session- the session must check that the |
|
164 disconnected address is one it has asked to be disconnected. If it is, and |
|
165 we have a disconnect request outstanding, the disconnect request should be |
|
166 completed. |
|
167 @param aAddr The disconnected address. |
|
168 @param aError The error with which the disconnection attempt was |
|
169 completed. |
|
170 */ |
|
171 void CompleteDisconnect(const TRemConAddress& aAddr, TInt aError); |
|
172 |
134 |
173 /** |
135 /** |
174 Indicates that a connection has come up or down. If the session has a |
136 Indicates that a connection has come up or down. If the session has a |
175 'connections notification' outstanding, it should be completed. Note that, |
137 'connections notification' outstanding, it should be completed. Note that, |
176 when a connection comes up or down, ConnectionsChanged is called before |
138 when a connection comes up or down, ConnectionsChanged is called before |
177 CompleteConnect or DisconnectComplete. These functions are called |
139 CompleteConnect or DisconnectComplete. These functions are called |
178 synchronously by the connection-handling code. |
140 synchronously by the connection-handling code. |
179 */ |
141 */ |
180 void ConnectionsChanged(); |
142 void ConnectionsChanged(); |
181 |
143 |
182 public: // called by the active helper |
144 protected: |
183 /** |
145 /** |
184 Process pending messages. |
146 Constructor. |
185 */ |
147 @param aServer The server. |
186 void ProcessPendingMsgL(); |
148 @param aBearerManager The bearer manager. |
187 |
149 @param aId The unique ID of the new session. |
188 private: |
150 */ |
189 /** |
151 CRemConSession(CRemConServer& aServer, |
190 Constructor. |
152 CBearerManager& aBearerManager, |
191 @param aServer The server. |
153 TUint aId); |
192 @param aBearerManager The bearer manager. |
154 |
193 @param aId The unique ID of the new session. |
155 /** |
194 */ |
156 2nd-phase construction. |
195 CRemConSession(CRemConServer& aServer, |
157 @param aMessage The message received from the client. |
196 CBearerManager& aBearerManager, |
158 */ |
197 TUint aId); |
159 void BaseConstructL(const TClientInfo& aClientInfo); |
198 |
160 |
199 /** |
161 |
200 2nd-phase construction. |
162 protected: |
201 @param aMessage The message received from the client. |
163 |
202 */ |
|
203 void ConstructL(const RMessage2& aMessage); |
|
204 |
|
205 private: // from CSession2 |
|
206 /** |
|
207 Called when a message is received from the client. |
|
208 @param aMessage Message received from the client. |
|
209 */ |
|
210 void ServiceL(const RMessage2& aMessage); |
|
211 |
|
212 private: // utility- IPC command handlers |
|
213 void SetClientType(const RMessage2& aMessage); |
|
214 void GoConnectionOriented(const RMessage2& aMessage); |
|
215 void GoConnectionless(const RMessage2& aMessage); |
|
216 void ConnectBearer(const RMessage2& aMessage); |
|
217 void ConnectBearerCancel(const RMessage2& aMessage); |
|
218 void DisconnectBearer(const RMessage2& aMessage); |
|
219 void DisconnectBearerCancel(const RMessage2& aMessage); |
|
220 void Send(const RMessage2& aMessage); |
|
221 void SendNotify(const RMessage2& aMessage); |
|
222 void SendUnreliable(const RMessage2& aMessage); |
|
223 void SendCancel(const RMessage2& aMessage); |
|
224 void Receive(const RMessage2& aMessage); |
|
225 void ReceiveCancel(const RMessage2& aMessage); |
|
226 void GetConnectionCount(const RMessage2& aMessage); |
|
227 void GetConnections(const RMessage2& aMessage); |
|
228 void NotifyConnectionsChange(const RMessage2& aMessage); |
|
229 void NotifyConnectionsChangeCancel(const RMessage2& aMessage); |
|
230 void RegisterInterestedAPIs(const RMessage2& aMessage); |
|
231 |
|
232 private: // utility |
|
233 /** |
164 /** |
234 Utility to complete the given message with the given error code. |
165 Utility to complete the given message with the given error code. |
235 @param aMessage Message to complete. |
166 @param aMessage Message to complete. |
236 @param aError Error to complete with. |
167 @param aError Error to complete with. |
237 */ |
168 */ |
238 void CompleteClient(const RMessage2& aMessage, TInt aError); |
169 void CompleteClient(const RMessage2& aMessage, TInt aError); |
239 |
170 |
|
171 CRemConInterfaceDetailsArray* ExtractInterestedAPIsL(const RMessage2& aMessage); |
|
172 |
|
173 /** |
|
174 Gets the information needed to send from the RMessage. |
|
175 |
|
176 @param aMessage The message containing the info. |
|
177 @param aInterfaceUid The uid of the interface to send on |
|
178 @param aOperationId The operation id to send |
|
179 @param aMessageSubType The sub type of hte message |
|
180 @param aSendDes The operation data to send. Ownership is passed |
|
181 to the caller and aSendDes is placed on the cleanup |
|
182 stack when this function completes successfully. |
|
183 @leave If the data was not successfully read. Note: if the message is invalid |
|
184 this function will not leave, but rather panic the message and return |
|
185 EFalse. This function will only leave if there's a system error, such |
|
186 as out of memory. |
|
187 @return ETrue if the message information was successfully retrieved, |
|
188 or EFalse if the message is invalid, in which case it got panicked. |
|
189 If this function returns EFalse, aSendDes is not left on the cleanup stack. |
|
190 */ |
|
191 TBool DoGetSendInfoLC(const RMessage2& aMessage, |
|
192 TUid& aInterfaceUid, |
|
193 TUint& aOperationId, |
|
194 TRemConMessageSubType& aMessageSubType, |
|
195 RBuf8& aSendDes); |
|
196 |
|
197 |
|
198 protected: // from CSession2 |
|
199 /** |
|
200 Called when a message is received from the client. |
|
201 |
|
202 Also used from the session, where a session has stored |
|
203 a message for later processing. |
|
204 |
|
205 @param aMessage Message received from the client. |
|
206 */ |
|
207 void ServiceL(const RMessage2& aMessage); |
|
208 |
|
209 private: // utility- IPC command handlers |
|
210 virtual void SetPlayerType(const RMessage2& aMessage)=0; |
|
211 virtual void SendUnreliable(const RMessage2& aMessage) = 0; |
|
212 virtual void SendCancel(const RMessage2& aMessage); |
|
213 virtual void Receive(const RMessage2& aMessage); |
|
214 virtual void ReceiveCancel(const RMessage2& aMessage); |
|
215 virtual void GetConnectionCount(const RMessage2& aMessage); |
|
216 virtual void GetConnections(const RMessage2& aMessage); |
|
217 virtual void NotifyConnectionsChange(const RMessage2& aMessage); |
|
218 virtual void NotifyConnectionsChangeCancel(const RMessage2& aMessage); |
|
219 virtual void RegisterInterestedAPIs(const RMessage2& aMessage) = 0; |
|
220 virtual void GoConnectionOriented(const RMessage2& aMessage); |
|
221 virtual void GoConnectionless(const RMessage2& aMessage); |
|
222 virtual void ConnectBearer(const RMessage2& aMessage); |
|
223 virtual void ConnectBearerCancel(const RMessage2& aMessage); |
|
224 virtual void DisconnectBearer(const RMessage2& aMessage); |
|
225 virtual void DisconnectBearerCancel(const RMessage2& aMessage); |
|
226 virtual void SendNotify(const RMessage2& aMessage); |
|
227 void Send(const RMessage2& aMessage); |
|
228 |
|
229 private: // utility |
|
230 virtual CRemConMessage* DoPrepareSendMessageL(const RMessage2& aMessage)=0; |
|
231 virtual void DoSendCancel()=0; |
|
232 virtual void DoReceive()=0; |
|
233 void WriteMessageToClientL(const CRemConMessage& aMsg); |
|
234 virtual void SendToServer(CRemConMessage& aMsg)=0; |
|
235 static TInt SendNextCb(TAny* aThis); |
|
236 void DoSendNext(); |
|
237 |
|
238 protected: |
240 void DoSendL(const RMessage2& aMessage); |
239 void DoSendL(const RMessage2& aMessage); |
241 void DoSendNotifyL(const RMessage2& aMessage); |
240 void GetPlayerTypeAndNameL(const RMessage2& aMessage, TPlayerTypeInformation& aPlayerType, RBuf8& aPlayerName); |
242 CRemConMessage* DoCreateUnreliableMessageL(const RMessage2& aMessage); |
|
243 void DoRegisterInterestedAPIsL(const RMessage2& aMessage); |
|
244 void DoSetClientTypeL(const RMessage2& aMessage); |
|
245 void DoSendCancel(); |
|
246 |
|
247 CRemConInterfaceDetails* FindInterfaceByUid(TUid aUid) const; |
241 CRemConInterfaceDetails* FindInterfaceByUid(TUid aUid) const; |
248 |
242 |
249 void SendToServer(CRemConMessage& aMsg); |
243 protected: // unowned |
250 |
|
251 void CheckForPendingMsg() const; |
|
252 |
|
253 static TInt SendNextCb(TAny* aThis); |
|
254 |
|
255 void DoSendNext(); |
|
256 |
|
257 void EmptySendQueue(); |
|
258 |
|
259 void WriteMessageToClientL(const CRemConMessage& aMsg); |
|
260 |
|
261 private: // unowned |
|
262 CRemConServer& iServer; |
244 CRemConServer& iServer; |
263 CBearerManager& iBearerManager; |
245 CBearerManager& iBearerManager; |
264 |
246 |
265 private: // message handles for asynchronous IPC requests |
247 protected: // message handles for asynchronous IPC requests |
266 RMessage2 iConnectBearerMsg; |
|
267 RMessage2 iDisconnectBearerMsg; |
|
268 RMessage2 iSendMsg; |
248 RMessage2 iSendMsg; |
269 RMessage2 iReceiveMsg; |
249 RMessage2 iReceiveMsg; |
270 RMessage2 iNotifyConnectionsChangeMsg; |
250 RMessage2 iNotifyConnectionsChangeMsg; |
271 // Stores pending connect/disconnect request |
251 |
272 // There can be only one pending request at any time |
|
273 RMessage2 iPendingMsg; |
|
274 |
|
275 CMessageQueue* iSendQueue; |
252 CMessageQueue* iSendQueue; |
276 |
253 |
277 private: // owned |
254 protected: // owned |
278 // Address of remote device associated with this session (only relevant |
|
279 // for controllers). A null remote address indicates a connectionless |
|
280 // controller; a non-null UID indicates a connection-oriented controller. |
|
281 TRemConAddress iRemoteAddress; |
|
282 |
|
283 TRemConClientType iType; |
|
284 |
|
285 // The client's process ID, secure ID and caps. |
255 // The client's process ID, secure ID and caps. |
286 TClientInfo iClientInfo; |
256 TClientInfo iClientInfo; |
287 |
257 |
288 // Unique session identifier. |
258 // Unique session identifier. |
289 const TUint iId; |
259 const TUint iId; |