143 } |
145 } |
144 return element; |
146 return element; |
145 } |
147 } |
146 |
148 |
147 template <class T> |
149 template <class T> |
|
150 T* CQueue<T>::FindElement( T* aMatch ) |
|
151 { |
|
152 if( !iList.IsEmpty() ) |
|
153 { |
|
154 TSglQueIter<T> iterator(CQueue<T>::iList); |
|
155 iterator.SetToFirst(); |
|
156 T* matchingOwner; |
|
157 |
|
158 while( ( matchingOwner = iterator++ ) ) |
|
159 { |
|
160 if( matchingOwner == aMatch ) |
|
161 { |
|
162 return matchingOwner; |
|
163 } |
|
164 } |
|
165 } |
|
166 return NULL; |
|
167 } |
|
168 |
|
169 template <class T> |
|
170 T* CQueue<T>::FindElement( TDesC8& aMessageId ) |
|
171 { |
|
172 if( !iList.IsEmpty() ) |
|
173 { |
|
174 TSglQueIter<T> iterator(CQueue<T>::iList); |
|
175 iterator.SetToFirst(); |
|
176 T* currentElement; |
|
177 |
|
178 while( ( currentElement = iterator++ ) ) |
|
179 { |
|
180 HBufC8* messageId = currentElement->MessageIdLC(); |
|
181 if ( *messageId == aMessageId ) |
|
182 { |
|
183 CleanupStack::PopAndDestroy( ); // messageId |
|
184 return currentElement; |
|
185 } |
|
186 CleanupStack::PopAndDestroy( ); // messageId |
|
187 } |
|
188 } |
|
189 |
|
190 return NULL; |
|
191 } |
|
192 |
|
193 template <class T> |
148 T* CQueue<T>::getMatch(T* aMatch) |
194 T* CQueue<T>::getMatch(T* aMatch) |
149 { |
195 { |
150 aMatch; |
196 aMatch; |
151 return NULL; |
197 return NULL; |
152 } |
198 } |
217 public: |
266 public: |
218 |
267 |
219 enum TQueueType |
268 enum TQueueType |
220 { |
269 { |
221 TClientQueue, |
270 TClientQueue, |
222 TInCommingMsgQueue |
271 TInCommingMsgQueue, |
|
272 TCompletedSendQueue, |
|
273 TCompletedIncQueue, |
|
274 TReceiveProgressQueue, |
|
275 TSendProgressQueue |
223 }; |
276 }; |
224 |
277 |
225 static CMSRPServerSubSession* NewL( CMSRPServerSession& aServerSession, CStateFactory& aStateFactory ); |
278 static CMSRPServerSubSession* NewL( |
|
279 CMSRPServerSession& aServerSession, CStateFactory& aStateFactory, const TDesC8& aSessionId ); |
226 |
280 |
227 static CMSRPServerSubSession* NewLC( CMSRPServerSession& aServerSession, CStateFactory& aStateFactory ); |
281 static CMSRPServerSubSession* NewLC( |
|
282 CMSRPServerSession& aServerSession, CStateFactory& aStateFactory, const TDesC8& aSessionId ); |
228 |
283 |
229 virtual ~CMSRPServerSubSession( ); |
284 virtual ~CMSRPServerSubSession( ); |
230 |
285 |
231 TBool ServiceL( const RMessage2& aMessage ); |
286 void ServiceL( const RMessage2& aMessage ); |
232 |
287 |
233 // From MMSRPConnectionObserver |
288 // From MMSRPConnectionObserver |
234 void ConnectionStateL( TInt aNewState, TInt aStatus ); |
289 void ConnectionStateL( TInt aNewState, TInt aStatus ); |
235 |
290 |
236 TBool MessageReceivedL( CMSRPMessageHandler* aMsg ); |
291 TBool MessageReceivedL( CMSRPMessageHandler* aMsg ); |
237 |
292 |
238 void UnclaimedMessageL( CMSRPMessageHandler* aMsg ); |
293 void UnclaimedMessageL( CMSRPMessageHandler* aMsg ); |
239 |
294 |
240 // From MMSRPMsgObserver |
295 // From MMSRPMsgObserver |
241 void MessageSendCompleteL(); |
296 void MessageSendCompleteL( CMSRPMessageHandler* aMessageHandler ); |
242 |
297 |
243 void MessageResponseSendCompleteL(CMSRPMessageHandler& aMsg); |
298 void MessageResponseSendCompleteL(CMSRPMessageHandler& aMsg); |
244 |
299 |
245 virtual void MessageSendProgressL(TInt aBytesSent, TInt aTotalBytes); |
300 void MessageReportSendCompleteL( CMSRPMessageHandler& aMsg ); |
246 |
301 |
247 virtual void MessageReceiveProgressL(TInt aBytesSent, TInt aTotalBytes); |
302 void MessageSendProgressL( CMSRPMessageHandler* aMessageHandler ); |
|
303 |
|
304 void MessageReceiveProgressL( CMSRPMessageHandler* aMessageHandler ); |
|
305 |
|
306 void MessageCancelledL( ); |
248 |
307 |
249 void WriterError(); |
308 void WriterError(); |
250 |
|
251 CMSRPMessageHandler* ReceiveFileMsgHandler(); |
|
252 |
|
253 void NotifyFileReceiveResultToClientL(CMSRPMessageHandler *msgHandler); |
|
254 |
|
255 void NotifyFileSendResultToClientL(CMSRPMessageHandler *msgHandler); |
|
256 |
309 |
257 private: |
310 private: |
258 CMSRPServerSession& iServerSession; |
311 CMSRPServerSession& iServerSession; |
259 CMSRPServerSubSession( CMSRPServerSession& aServerSession, CStateFactory &aStateFactory); |
312 CMSRPServerSubSession( CMSRPServerSession& aServerSession, CStateFactory &aStateFactory); |
260 void ConstructL(); |
313 void ConstructL( const TDesC8& aSessionId ); |
261 |
314 |
262 // ProcessEventL shall only take a event. The data associated with the event can be a |
315 // ProcessEventL shall only take a event. The data associated with the event can be a |
263 // RMessage(Client to Server events), CSendBuffer(buffer being send out by connection manager), |
316 // RMessage(Client to Server events), CSendBuffer(buffer being send out by connection manager), |
264 // CMSRPMessage(received message) or other such data. |
317 // CMSRPMessage(received message) or other such data. |
265 // The associated data is stored in the context and retrieved by the relevant state when needed. |
318 // The associated data is stored in the context and retrieved by the relevant state when needed. |
266 |
319 |
267 TBool CMSRPServerSubSession::ProcessEventL( TMSRPFSMEvent aEvent); |
320 void CMSRPServerSubSession::ProcessEventL( TMSRPFSMEvent aEvent); |
268 |
321 |
269 HBufC8* CreateSubSessionIDL( ); |
322 //HBufC8* CreateSubSessionIDL( ); |
270 |
323 |
271 void HandleLocalPathRequestL( const RMessage2& aMessage ); |
324 void HandleLocalPathRequestL( const RMessage2& aMessage ); |
272 |
325 |
273 void HandleConnectRequestL( const RMessage2& aMessage ); |
326 void HandleConnectRequestL( const RMessage2& aMessage ); |
274 |
327 |
294 |
347 |
295 TBool QueueReceivedMessages(); |
348 TBool QueueReceivedMessages(); |
296 |
349 |
297 // Utility functions. |
350 // Utility functions. |
298 |
351 |
299 TBool sendResultToClientL(CMSRPMessageHandler *incommingMsgHandler); |
352 void sendResultToClientL(CMSRPMessageHandler *incommingMsgHandler); |
300 TBool sendMsgToClientL(CMSRPMessageHandler *incommingMsgHandler); |
353 TBool sendMsgToClientL(CMSRPMessageHandler *incommingMsgHandler); |
301 TBool SendProgressToClientL(CMSRPMessageHandler *msgHandler); |
354 TBool sendReportToClientL( CMSRPMessageHandler *incommingMsgHandler ); |
302 TBool ReceiveProgressToClientL(CMSRPMessageHandler *msgHandler); |
355 void SendProgressToClientL( CMSRPMessageHandler* aMessageHandler ); |
|
356 void ReceiveProgressToClientL( CMSRPMessageHandler* aMessageHandler ); |
303 |
357 |
304 void ReadSendDataPckgL(); |
358 void ReadSendDataPckgL(); |
305 |
359 |
306 TBool listnerSetupComplete(); |
360 TBool listnerSetupComplete(); |
307 |
361 |
310 TBool QueuesEmpty(); |
364 TBool QueuesEmpty(); |
311 TBool informConnectionReadyToClient(); |
365 TBool informConnectionReadyToClient(); |
312 |
366 |
313 void QueueLog(); |
367 void QueueLog(); |
314 |
368 |
315 TBool checkMessageForSelfL(CMSRPMessageHandler *aMsgHandler); |
369 /** |
|
370 * Checks that incoming messages session id is a correct one for |
|
371 * this session |
|
372 * @param aMsgHandler message handler containing the incoming message |
|
373 * @return true if message belongs to this session, false if not |
|
374 */ |
|
375 TBool CheckMessageSessionIdL( CMSRPMessageHandler *aMsgHandler ); |
316 TBool matchSessionIDL(const CMSRPHeaderBase *aPathHeader, TBool local = TRUE); |
376 TBool matchSessionIDL(const CMSRPHeaderBase *aPathHeader, TBool local = TRUE); |
317 TPtrC8 extractSessionID(const TDesC8& aPathBuffer); |
377 TPtrC8 extractSessionID(const TDesC8& aPathBuffer); |
318 |
378 |
319 CStateFactory& StateFactory(); |
379 CStateFactory& StateFactory(); |
320 |
380 |
349 |
409 |
350 // Temorary Event Data. |
410 // Temorary Event Data. |
351 const RMessage2* iClientMessage; |
411 const RMessage2* iClientMessage; |
352 CMSRPMessageHandler* iReceivedMsg; |
412 CMSRPMessageHandler* iReceivedMsg; |
353 CMSRPMessageHandler* iReceivedResp; |
413 CMSRPMessageHandler* iReceivedResp; |
|
414 CMSRPMessageHandler* iReceivedReport; |
354 CMSRPMessageHandler* iReceiveFileMsgHdler; |
415 CMSRPMessageHandler* iReceiveFileMsgHdler; |
355 TBool iFileShare; //is previous state file share |
|
356 TBool iSendCompleteNotify; // |
416 TBool iSendCompleteNotify; // |
357 TBool iReceiveCompleteNotify; |
417 TBool iReceiveCompleteNotify; |
358 TInt iBytesTransferred; |
418 TBool iFileShareCancelled; |
359 TInt iTotalBytes; |
419 |
|
420 // used for progress reports, temporary, not owned |
|
421 CMSRPMessageHandler* iReceiveProgressMsg; |
|
422 |
|
423 // used for progress reports, temporary, not owned |
|
424 CMSRPMessageHandler* iSendProgressMsg; |
360 |
425 |
361 // Client Listners waiting to be completed. |
426 // Client Listners waiting to be completed. |
362 |
427 |
363 // Listner for response of Connect request. |
428 // Listner for response of Connect request. |
364 CRMessageContainer iConnectionListner; |
429 CRMessageContainer iConnectionListner; |
375 // for which the subsession has still not rerceived a sendmessagecomplete event. |
440 // for which the subsession has still not rerceived a sendmessagecomplete event. |
376 // Once the sendmessage completed is received the message handler is put on the |
441 // Once the sendmessage completed is received the message handler is put on the |
377 // OutGoingMessage queue where it waits for a response to arrive. |
442 // OutGoingMessage queue where it waits for a response to arrive. |
378 CMSRPMessageHandler *iCurrentMsgHandler; |
443 CMSRPMessageHandler *iCurrentMsgHandler; |
379 |
444 |
380 // Queues. |
445 // Message queues |
381 CQueueMsgHandlers<CMSRPMessageHandler> iOutMsgQ; |
446 CQueueMsgHandlers<CMSRPMessageHandler> iOutMsgQ; |
382 CQueueMsgHandlers<CMSRPMessageHandler> iInCommingMsgQ; |
447 CQueueMsgHandlers<CMSRPMessageHandler> iInCommingMsgQ; |
383 CQueueMsgHandlers<CMSRPMessageHandler> iPendingSendMsgQ; |
448 CQueueMsgHandlers<CMSRPMessageHandler> iPendingSendMsgQ; |
384 CQueueMsgHandlers<CMSRPMessageHandler> iPendingForDeletionQ; |
449 CQueueMsgHandlers<CMSRPMessageHandler> iPendingForDeletionQ; |
385 |
450 CQueueMsgHandlers< CMSRPMessageHandler > iPendingDataSendCompleteQ; |
|
451 CQueueMsgHandlers< CMSRPMessageHandler > iPendingDataIncCompleteQ; |
|
452 |
|
453 // progress report queues |
|
454 CQueueMsgHandlers< CMSRPMessageHandler > iPendingSendProgressQ; |
|
455 CQueueMsgHandlers< CMSRPMessageHandler > iPendingReceiveProgressQ; |
|
456 |
|
457 // This queue holds the instance of messages currently being received |
|
458 CQueueMsgHandlers< CMSRPMessageHandler > iCurrentlyReceivingMsgQ; |
|
459 |
|
460 TBool iSendProgressReports; |
|
461 |
386 friend class TStateBase; |
462 friend class TStateBase; |
387 friend class TStateIdle; |
463 friend class TStateIdle; |
388 friend class TStateConnecting; |
464 friend class TStateConnecting; |
389 friend class TStateActive; |
465 friend class TStateActive; |
390 friend class TStateActiveSend; |
|
391 friend class TStateWaitForClient; |
466 friend class TStateWaitForClient; |
392 friend class TStateFileShare; |
|
393 friend class TStateError; // Not a very good thing !! Need change. |
467 friend class TStateError; // Not a very good thing !! Need change. |
394 |
468 |
395 #ifdef __UT_TSTATEFACTORY_H__ |
469 #ifdef __UT_TSTATEFACTORY_H__ |
396 friend class UT_TStateFactory; |
470 friend class UT_TStateFactory; |
397 #endif |
471 #endif |