64 RemCon server construction. |
67 RemCon server construction. |
65 @return Ownership of a new RemCon server object |
68 @return Ownership of a new RemCon server object |
66 */ |
69 */ |
67 static CRemConServer* NewLC(); |
70 static CRemConServer* NewLC(); |
68 |
71 |
69 /** Destructor. */ |
|
70 ~CRemConServer(); |
72 ~CRemConServer(); |
71 |
73 |
72 public: // called by session objects |
74 public: // called by controller session objects |
73 /** Called by a session when a client session is created. Cancels the |
75 |
|
76 /** Called by a controller session when created. Cancels the |
74 shutdown timer in accordance with transient server design. */ |
77 shutdown timer in accordance with transient server design. */ |
75 TInt ClientOpened(CRemConSession& aSession); |
78 TInt ControllerClientOpened(CRemConControllerSession& aSession); |
76 |
79 |
77 /** Called by a session when it has had its client type set (i.e. becomes |
|
78 a controller or a target). Uses the bearer manager to inform bearers as appropriate. |
|
79 */ |
|
80 void ClientTypeSet(CRemConSession& aSession); |
|
81 |
|
82 /** Called by a target session when it has had its features registered. */ |
|
83 void TargetClientAvailable(CRemConSession& aSession); |
|
84 |
|
85 /** Called by a controller session when it has had its features registered. */ |
80 /** Called by a controller session when it has had its features registered. */ |
86 void ControllerClientAvailable(); |
81 void ControllerClientAvailable(); |
87 |
82 |
88 /** Called by a session when it has had its client goes connection oriented |
83 /** Called by a controller session when it has had its client go connection oriented |
89 Uses the bearer manager to inform bearers as appropriate |
84 Uses the bearer manager to inform bearers as appropriate |
90 aUid is the uid of the bearer we are going connection oriented on. |
85 aUid is the uid of the bearer we are going connection oriented on. |
91 */ |
86 */ |
92 void ClientGoConnectionOriented(CRemConSession& aSession, TUid aUid); |
87 void ClientGoConnectionOriented(CRemConControllerSession& aSession, TUid aUid); |
93 |
88 |
94 /** Called by a session when it has had its client go connection less. |
89 /** Called by a controller session when it has had its client go connection less. |
95 Uses the bearer manager to inform bearers as appropriate. |
90 Uses the bearer manager to inform bearers as appropriate. |
96 aUid is the uid of the bearer we were connection oriented on, |
91 aUid is the uid of the bearer we were connection oriented on, |
97 */ |
92 */ |
98 void ClientGoConnectionless(CRemConSession& aSession, TUid aUid); |
93 void ClientGoConnectionless(CRemConControllerSession& aSession, TUid aUid); |
99 |
94 |
100 /** Called by a session when a client session is destroyed. Starts the |
95 /** Called by a controller session it is destroyed. Starts the |
101 shutdown timer if necessary in accordance with transient server design. |
96 shutdown timer if necessary in accordance with transient server design. |
102 Does not assume that the session successfully registered itself with the |
97 Does not assume that the session successfully registered itself with the |
103 server to begin with. |
98 server to begin with. |
104 aUid is the bearer uid the session was on for connection oriented sessions, |
99 aUid is the bearer uid the session was on for connection oriented sessions, |
105 if KNullUid the session was connectionless, |
100 if KNullUid the session was connectionless, |
106 */ |
101 */ |
107 void ClientClosed(CRemConSession& aSession, TUid aUid); |
102 void ControllerClientClosed(CRemConControllerSession& aSession, TUid aUid); |
108 |
103 |
109 /** |
104 /** |
110 @return ETrue if there's already a session of target type with process ID |
105 Sends a command. |
111 aProcId, EFalse otherwise. |
106 Puts the command on the 'pending TSP' queue so the TSP can either address |
112 */ |
107 it or give it permission to send. |
113 TBool TargetClientWithSameProcessId(TProcessId aProcId) const; |
108 Always takes ownership of aMsg. |
|
109 */ |
|
110 void SendCommand(CRemConMessage& aMsg); |
|
111 |
|
112 /** |
|
113 Removes any current message from this controller session from the 'outgoing pending |
|
114 TSP' queue. If the message is that currently being dealt with by the TSP, |
|
115 then cancels the TSP's operation. |
|
116 */ |
|
117 void SendCancel(CRemConControllerSession& aSess); |
|
118 |
|
119 /** |
|
120 Tries to complete a Receive request for a controller session. |
|
121 Called by controller sessions when a Receive request is posted. The 'incoming pending |
|
122 delivery' queue is checked for commands waiting to be delivered to |
|
123 aSession. The controller session's request is completed with the first such found. |
|
124 */ |
|
125 void ReceiveRequest(CRemConControllerSession& aSession); |
|
126 |
|
127 public: // Called by target client objects (either CRemConTargetClientProcess or CRemConTargetSession) |
|
128 |
|
129 /** |
|
130 Called by CRemConTargetClientProcess to cancel the servers shutdown timer when a new |
|
131 target session has been opened. |
|
132 */ |
|
133 void CancelShutdownTimer(); |
|
134 |
|
135 /** Called by CRemConTargetClientProcess to notify the server that it is available. |
|
136 This is done when the client has registered one or more interfaces. */ |
|
137 void TargetClientAvailable(const CRemConTargetClientProcess& aClient); |
|
138 |
|
139 /** Called by CRemConTargetClientProcess to notify the server that it has registered |
|
140 additional intefaces. */ |
|
141 void TargetFeaturesUpdated(CRemConTargetClientProcess& aClient); |
|
142 |
|
143 /** Called by CRemConTargetClientProcess to notify the server that a target session |
|
144 has closed. */ |
|
145 void TargetSessionClosed(CRemConTargetClientProcess& aClient, CRemConTargetSession& aSession); |
|
146 |
|
147 /** Called by CRemConTargetClientProcess to notify the server that a client session is closing. |
|
148 Starts the shutdown timer if necessary in accordance with transient server design. |
|
149 Does not assume that the session successfully registered itself with the |
|
150 server to begin with. |
|
151 */ |
|
152 void TargetClientClosed(CRemConTargetClientProcess& aClient); |
|
153 |
|
154 /** Called by a client instance when a session is created. Makes an item |
|
155 for the session in the record of which points in the connection history |
|
156 sessions are interested in. */ |
|
157 TInt RegisterTargetSessionPointerToConnHistory(const CRemConTargetSession& aSession); |
|
158 |
|
159 /** |
|
160 Starts the process of sending a response, via the TSP |
|
161 Completes the client's send message with a bearer-level error. |
|
162 Always takes ownership of aMsg. |
|
163 */ |
|
164 void SendResponse(CRemConMessage& aMsg, CRemConTargetClientProcess& aClient); |
|
165 |
|
166 /** Finishes the process of sending a response, after the TSP |
|
167 has permitted the response |
|
168 Always takes onwership of aMsg. |
|
169 */ |
|
170 void CompleteSendResponse(CRemConMessage& aMsg, CRemConTargetClientProcess& aClient); |
|
171 |
|
172 /** |
|
173 Sends a reject back to the bearer. |
|
174 */ |
|
175 void SendReject (TRemConAddress aAddr, TUid aInterfaceUid, TUint aOperationId, TUint aTransactionId); |
|
176 |
|
177 /** |
|
178 Tries to complete a Receive request for a target client. |
|
179 Called by clients when a Receive request is posted. The 'incoming pending |
|
180 delivery' queue is checked for commands waiting to be delivered to |
|
181 the client. A delivery attempt is made for each pending message. |
|
182 */ |
|
183 void ReceiveRequest(CRemConTargetClientProcess& aClient); |
|
184 |
|
185 public: // called by controller and target sessions |
114 |
186 |
115 /** Returns the current bearer-level connection state of the system. */ |
187 /** Returns the current bearer-level connection state of the system. */ |
116 CConnections& Connections(); |
188 CConnections& Connections(); |
117 |
189 |
118 /** Each session has a pointer into the connection history- pointing at |
190 /** Each session has a pointer into the connection history- pointing at |
129 history record is the 'Last' connection history record, i.e. the current |
201 history record is the 'Last' connection history record, i.e. the current |
130 connection set. Returns EFalse otherwise. */ |
202 connection set. Returns EFalse otherwise. */ |
131 TBool ConnectionHistoryPointerAtLatest(TUint aSessionId) const; |
203 TBool ConnectionHistoryPointerAtLatest(TUint aSessionId) const; |
132 |
204 |
133 /** |
205 /** |
134 Sends a command. |
|
135 Puts the command on the 'pending TSP' queue so the TSP can either address |
|
136 it or give it permission to send. |
|
137 Always takes ownership of aMsg. |
|
138 */ |
|
139 void SendCommand(CRemConMessage& aMsg); |
|
140 |
|
141 /** |
|
142 Starts the process of sending a response, via the TSP |
|
143 Completes the client's send message with a bearer-level error. |
|
144 Always takes ownership of aMsg. |
|
145 */ |
|
146 void SendResponse(CRemConMessage& aMsg, CRemConSession& aSess); |
|
147 |
|
148 /** Finishes the process of sending a response, after the TSP |
|
149 has permitted the response |
|
150 Always takes onwership of aMsg. |
|
151 */ |
|
152 void CompleteSendResponse(CRemConMessage& aMsg, CRemConSession& aSess); |
|
153 |
|
154 /** |
|
155 Sends a reject back to the bearer. |
|
156 */ |
|
157 void SendReject (TRemConAddress aAddr, TUid aInterfaceUid, TUint aOperationId, TUint aTransactionId); |
|
158 |
|
159 /** |
|
160 Removes any current message from this session from the 'outgoing pending |
|
161 TSP' queue. If the message is that currently being dealt with by the TSP, |
|
162 then cancels the TSP's operation. |
|
163 */ |
|
164 void SendCancel(CRemConSession& aSess); |
|
165 |
|
166 /** |
|
167 Tries to complete a Receive request. |
|
168 Called by sessions when a Receive request is posted. The 'incoming pending |
|
169 delivery' queue is checked for commands waiting to be delivered to |
|
170 aSession. The session's request is completed with the first such found. |
|
171 */ |
|
172 void ReceiveRequest(CRemConSession& aSession); |
|
173 |
|
174 /** |
|
175 Determines a state of a connection to the given remote address. |
206 Determines a state of a connection to the given remote address. |
176 @param - aAddr, remote address of a connection |
207 @param - aAddr, remote address of a connection |
177 @return - connection state |
208 @return - connection state |
178 */ |
209 */ |
179 TConnectionState ConnectionState(const TRemConAddress& aAddr); |
210 TConnectionState ConnectionState(const TRemConAddress& aAddr); |
180 |
211 |
181 /** |
212 /** |
182 Informs RemCon server that one of the interfaces being used by the calling |
213 Informs RemCon server that one of the interfaces being used by the calling |
183 session requires the use of the bulk server. |
214 session requires the use of the bulk server. |
184 */ |
215 */ |
185 TInt BulkServerRequired(); |
216 TInt BulkServerRequired(); |
186 |
217 |
187 public: // called by the bearer manager |
218 public: // called by the bearer manager |
188 inline RPointerArray<CRemConSession>& Sessions(); |
|
189 |
219 |
190 /** This function is called when a ConnectIndicate is handled by the |
220 /** This function is called when a ConnectIndicate is handled by the |
191 bearer manager (in which case aError will be KErrNone) and when |
221 bearer manager (in which case aError will be KErrNone) and when |
192 ConnectConfirm is handled by the bearer manager (in which case aError will |
222 ConnectConfirm is handled by the bearer manager (in which case aError will |
193 be the connection error). |
223 be the connection error). |
293 void MrctspoDoIncomingCommandPermitted(TBool aIsPermitted); |
323 void MrctspoDoIncomingCommandPermitted(TBool aIsPermitted); |
294 void MrctspoDoIncomingNotifyPermitted(TBool aIsPermitted); |
324 void MrctspoDoIncomingNotifyPermitted(TBool aIsPermitted); |
295 TInt MrctspoSetLocalAddressedClient(const TUid& aBearerUid, const TClientInfo& aClientInfo); |
325 TInt MrctspoSetLocalAddressedClient(const TUid& aBearerUid, const TClientInfo& aClientInfo); |
296 |
326 |
297 private: // utility |
327 private: // utility |
|
328 CRemConControllerSession* CreateControllerSessionL(const RMessage2& aMessage); |
|
329 CRemConTargetSession* CreateTargetSessionL(const RMessage2& aMessage); |
|
330 |
|
331 /** Extracts a client's process ID and secure ID from a given RMessage2 and stores |
|
332 in a given TClientInfo. */ |
|
333 void ClientProcessAndSecureIdL(TClientInfo& aClientInfo, const RMessage2& aMessage) const; |
|
334 |
|
335 void RemoveSessionFromConnHistory(const CRemConSession& aSession); |
|
336 |
298 /** Removes connection history records which are no longer interesting and |
337 /** Removes connection history records which are no longer interesting and |
299 updates the indices in iSession2ConnHistory accordingly. */ |
338 updates the indices in iSession2ConnHistory accordingly. */ |
300 void UpdateConnectionHistoryAndPointers(); |
339 void UpdateConnectionHistoryAndPointers(); |
301 |
340 |
302 CRemConSession* Session(TUint aSessionId) const; |
341 CRemConControllerSession* ControllerSession(TUint aSessionId) const; |
303 |
342 CRemConTargetClientProcess* TargetClient(TUint aClientId) const; |
304 void StartShutdownTimerIfNoSessionsOrBulkThread(); |
343 CRemConTargetClientProcess* TargetClient(TProcessId aProcessId) const; |
|
344 |
|
345 void StartShutdownTimerIfNoClientsOrBulkThread(); |
|
346 void TryToDropClientProcess(TUint aClientIndex); |
305 void LoadTspL(); |
347 void LoadTspL(); |
306 |
348 |
307 TBool FindDuplicateNotify(CRemConMessage& aMsg); |
349 TBool FindDuplicateNotify(CRemConMessage& aMsg); |
308 |
350 |
309 #ifdef __FLOG_ACTIVE |
351 #ifdef __FLOG_ACTIVE |
310 void LogSessions() const; |
352 void LogControllerSessions() const; |
|
353 void LogTargetSessions() const; |
311 void LogRemotes() const; |
354 void LogRemotes() const; |
312 void LogConnectionHistoryAndInterest() const; |
355 void LogConnectionHistoryAndInterest() const; |
313 void LogOutgoingCmdPendingTsp() const; |
356 void LogOutgoingCmdPendingTsp() const; |
314 void LogOutgoingNotifyCmdPendingTsp() const; |
357 void LogOutgoingNotifyCmdPendingTsp() const; |
315 void LogOutgoingRspPendingTsp() const; |
358 void LogOutgoingRspPendingTsp() const; |
358 Utility for delivering a single incoming command to a client session. |
401 Utility for delivering a single incoming command to a client session. |
359 Takes a copy of aMsg, sets its SessionId, and delivers it to aSess, |
402 Takes a copy of aMsg, sets its SessionId, and delivers it to aSess, |
360 putting it on the correct queue. |
403 putting it on the correct queue. |
361 Does not take ownership of aMsg. |
404 Does not take ownership of aMsg. |
362 */ |
405 */ |
363 void DeliverCmdToClientL(const CRemConMessage& aMsg, CRemConSession& aSess); |
406 void DeliverCmdToClientL(const CRemConMessage& aMsg, CRemConTargetClientProcess& aClient); |
364 |
407 |
365 /** |
408 /** |
366 Utility for delivering a single message to a client session. |
409 Utility for delivering a single message to a controller client session. |
367 If the session aSess has an outstanding Receive request, completes the |
410 If the session aSess has an outstanding Receive request, completes the |
368 request with aMsg and (if aMsg is a command) puts aMsg the 'incoming |
411 request with aMsg. Otherwise, puts aMsg in the 'incoming pending delivery' |
369 delivered' queue. Otherwise, puts aMsg in the 'incoming pending delivery' |
|
370 queue. |
412 queue. |
371 Always takes ownership of aMsg. |
413 Always takes ownership of aMsg. |
372 @return KErrNone if the message was successfully delivered or put on the |
414 @return KErrNone if the message was successfully delivered or put on the |
373 incoming pending delivered queue, otherwise one of the system wide error codes |
415 incoming pending delivered queue, otherwise one of the system wide error codes |
374 Ownership of aMsg will be taken regardless of the error. |
416 Ownership of aMsg will be taken regardless of the error. |
375 */ |
417 */ |
376 TInt DeliverMessageToClient(CRemConMessage& aMsg, CRemConSession& aSess); |
418 TInt DeliverMessageToClient(CRemConMessage& aMsg, CRemConControllerSession& aSess); |
|
419 |
|
420 /** |
|
421 Utility for delivering a single message to a target client. |
|
422 If the client aClient has an outstanding Receive request, completes the |
|
423 request with aMsg and puts aMsg the 'incoming delivered' queue (since it |
|
424 shall be a command). Otherwise, puts aMsg in the 'incoming pending delivery' |
|
425 queue. |
|
426 Always takes ownership of aMsg. |
|
427 @return KErrNone if the message was successfully delivered or put on the |
|
428 incoming pending delivered queue, otherwise one of the system wide error codes |
|
429 Ownership of aMsg will be taken regardless of the error. |
|
430 */ |
|
431 TInt DeliverMessageToClient(CRemConMessage& aMsg, CRemConTargetClientProcess& aClient); |
377 |
432 |
378 /** Gives the head outgoing command to the TSP for (a) addressing to |
433 /** Gives the head outgoing command to the TSP for (a) addressing to |
379 remote target(s), if its address is null, or (b) permission to send, if it |
434 remote target(s), if its address is null, or (b) permission to send, if it |
380 has a remote address. */ |
435 has a remote address. */ |
381 void TspOutgoingCommand(); |
436 void TspOutgoingCommand(); |