103 MSRPLOG("TStateBase::processPendingMessagesL Entered!"); |
78 MSRPLOG("TStateBase::processPendingMessagesL Entered!"); |
104 CMSRPMessageHandler *msgHandler; |
79 CMSRPMessageHandler *msgHandler; |
105 |
80 |
106 msgHandler = aContext->iPendingSendMsgQ.DeQueue(); |
81 msgHandler = aContext->iPendingSendMsgQ.DeQueue(); |
107 msgHandler->SendMessageL(*aContext->iConnection); |
82 msgHandler->SendMessageL(*aContext->iConnection); |
108 |
83 aContext->iOutMsgQ.Queue( *msgHandler ); |
109 // Shift this to Outgoing Queue. |
84 return aContext->StateFactory().getStateL( EActive ); |
110 aContext->iCurrentMsgHandler = msgHandler; |
85 } |
111 return aContext->StateFactory().getStateL(EActiveSend); |
86 |
112 } |
87 TStateBase* TStateBase::processCompletedMessageL( CMSRPServerSubSession *aContext ) |
113 |
88 { |
|
89 MSRPLOG("TStateBase::processCompletedMessageL Entered!"); |
|
90 CMSRPMessageHandler* msgHandler = aContext->iPendingDataSendCompleteQ.DeQueue(); |
|
91 |
|
92 if ( msgHandler->IsTransmissionTerminated() ) |
|
93 { |
|
94 MSRPLOG("TStateBase::processCompletedMessageL transmission terminated"); |
|
95 if( aContext->iResponseListner.Check() ) |
|
96 { |
|
97 MSRPLOG("TStateBase::processCompletedMessageL complete with KErrCancel"); |
|
98 aContext->iResponseListner.Complete( KErrCancel ); |
|
99 } |
|
100 } |
|
101 else |
|
102 { |
|
103 aContext->sendResultToClientL( msgHandler ); |
|
104 } |
|
105 |
|
106 delete msgHandler; |
|
107 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
108 } |
|
109 |
|
110 TStateBase* TStateBase::processCompletedIncomingMessageL( CMSRPServerSubSession *aContext ) |
|
111 { |
|
112 MSRPLOG("TStateBase::processCompletedIncomingMessageL Entered!"); |
|
113 CMSRPMessageHandler* msgHandler = aContext->iPendingDataIncCompleteQ.DeQueue(); |
|
114 |
|
115 if ( msgHandler->IsTransmissionTerminated() ) |
|
116 { |
|
117 MSRPLOG("TStateBase::processCompletedIncomingMessageL transmission terminated"); |
|
118 if( aContext->iIncommingMessageListner.Check() ) |
|
119 { |
|
120 MSRPLOG("TStateBase::processCompletedIncomingMessageL complete with KErrCancel"); |
|
121 aContext->iIncommingMessageListner.Complete( KErrCancel ); |
|
122 } |
|
123 } |
|
124 else |
|
125 { |
|
126 aContext->sendMsgToClientL( msgHandler ); |
|
127 delete msgHandler; |
|
128 } |
|
129 |
|
130 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
131 } |
|
132 |
|
133 TStateBase* TStateBase::processReceiveReportL( CMSRPServerSubSession *aContext ) |
|
134 { |
|
135 MSRPLOG("TStateBase::processReceiveReportL Entered!"); |
|
136 CMSRPMessageHandler* msgHandler = aContext->iPendingReceiveProgressQ.DeQueue(); |
|
137 |
|
138 aContext->ReceiveProgressToClientL( msgHandler ); |
|
139 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
140 } |
|
141 |
|
142 TStateBase* TStateBase::processSendReportL( CMSRPServerSubSession *aContext ) |
|
143 { |
|
144 MSRPLOG("TStateBase::processSendReportL Entered!"); |
|
145 CMSRPMessageHandler* msgHandler = aContext->iPendingSendProgressQ.DeQueue(); |
|
146 |
|
147 aContext->SendProgressToClientL( msgHandler ); |
|
148 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
149 } |
|
150 |
114 TStateBase* TStateBase::handlesResponseL(CMSRPServerSubSession *aContext, |
151 TStateBase* TStateBase::handlesResponseL(CMSRPServerSubSession *aContext, |
115 CMSRPMessageHandler *incommingMsgHandler) |
152 CMSRPMessageHandler *incommingMsgHandler) |
116 { |
153 { |
117 TStateBase *nextState; |
154 TStateBase *nextState; |
118 MSRPLOG("TStateBase::handlesResponseL Entered!"); |
155 MSRPLOG("TStateBase::handlesResponseL Entered!"); |
163 } |
196 } |
164 |
197 |
165 TStateBase* TStateBase::handleRequestsL(CMSRPServerSubSession *aContext, |
198 TStateBase* TStateBase::handleRequestsL(CMSRPServerSubSession *aContext, |
166 CMSRPMessageHandler *incommingMsgHandler) |
199 CMSRPMessageHandler *incommingMsgHandler) |
167 { |
200 { |
|
201 MSRPLOG("-> TStateBase::handleRequestsL"); |
168 MMSRPIncomingMessage::TMSRPMessageType msgType = incommingMsgHandler->MessageType(); |
202 MMSRPIncomingMessage::TMSRPMessageType msgType = incommingMsgHandler->MessageType(); |
169 |
203 |
170 if(MMSRPIncomingMessage::EMSRPMessage == msgType) // SEND request |
204 if(MMSRPIncomingMessage::EMSRPMessage == msgType) // SEND request |
171 { |
205 { |
172 MSRPLOG("SEND request received"); |
206 MSRPLOG("SEND request received"); |
173 TBool sendToClient = incommingMsgHandler->SendResponseL(aContext, |
207 incommingMsgHandler->SendResponseL(aContext, *aContext->iConnection, EAllOk ); |
174 *aContext->iConnection, 0); |
208 incommingMsgHandler->SendReportL(aContext, *aContext->iConnection, EAllOk ); |
175 if(sendToClient) |
209 if( incommingMsgHandler->IsMessageComplete() ) |
176 { |
210 { |
|
211 MSRPLOG("-> TStateBase::handleRequestsL complete"); |
177 aContext->sendMsgToClientL(incommingMsgHandler); |
212 aContext->sendMsgToClientL(incommingMsgHandler); |
178 } |
213 delete incommingMsgHandler; |
|
214 //aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); |
|
215 return aContext->StateFactory().getStateL(EWaitForClient); |
|
216 } |
|
217 return aContext->StateFactory().getStateL( EActive ); |
|
218 } |
|
219 else if(MMSRPIncomingMessage::EMSRPReport == msgType) // Drop Reports |
|
220 { |
|
221 aContext->sendMsgToClientL( incommingMsgHandler ); |
|
222 delete incommingMsgHandler; |
|
223 //aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); |
|
224 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
225 } |
|
226 else // It is an unrecognized request eg. AUTH |
|
227 { |
|
228 MSRPLOG("Unrecognized request received"); |
|
229 incommingMsgHandler->SendResponseL(aContext, *aContext->iConnection, EUnknownRequestMethod ); |
179 aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); |
230 aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); |
180 return aContext->StateFactory().getStateL(EWaitForClient); |
231 return aContext->StateFactory().getStateL(EWaitForClient); |
181 } |
232 } |
182 else if(MMSRPIncomingMessage::EMSRPReport == msgType) // Drop Reports |
|
183 { |
|
184 MSRPLOG("Reports not supported!!"); |
|
185 delete incommingMsgHandler; |
|
186 return this; |
|
187 } |
|
188 else // It is an unrecognized request eg. AUTH |
|
189 { |
|
190 MSRPLOG("Unrecognized request received"); |
|
191 TBool sendToClient = incommingMsgHandler->SendResponseL(aContext, |
|
192 *aContext->iConnection, CMSRPResponse::EUnknownRequestMethod); |
|
193 aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); |
|
194 return aContext->StateFactory().getStateL(EWaitForClient); |
|
195 } |
|
196 } |
233 } |
197 |
234 |
198 TStateBase* TStateBase::handleClientListnerCancelL(CMSRPServerSubSession * aContext, |
235 TStateBase* TStateBase::handleClientListnerCancelL( CMSRPServerSubSession* aContext, |
199 TMSRPFSMEvent aEvent) |
236 TMSRPFSMEvent aEvent) |
200 { |
237 { |
|
238 MSRPLOG("-> TStateBase::handleClientListnerCancelL"); |
201 if(aEvent == EMSRPCancelReceivingEvent) |
239 if(aEvent == EMSRPCancelReceivingEvent) |
202 { |
240 { |
|
241 // let's find the correct listener first |
|
242 TBuf8< KMaxLengthOfTransactionIdString > messageId; |
|
243 aContext->iClientMessage->ReadL( 0, messageId ); |
|
244 // going through all incoming instances |
|
245 CMSRPMessageHandler* owner = aContext->iCurrentlyReceivingMsgQ.FindElement( messageId ); |
|
246 if ( owner ) |
|
247 { |
|
248 MSRPLOG2("TStateBase::handleClientListnerCancelL terminating %d", owner ); |
|
249 owner->TerminateReceiving( aContext, *aContext->iConnection ); |
|
250 } |
|
251 else |
|
252 { |
|
253 if( aContext->iIncommingMessageListner.Check() ) |
|
254 { |
|
255 aContext->iIncommingMessageListner.Complete( KErrNone ); |
|
256 } |
|
257 } |
|
258 |
203 // Confirm completion of the Cancel Request. |
259 // Confirm completion of the Cancel Request. |
204 aContext->CompleteClient(KErrNone); |
260 aContext->CompleteClient( KErrNone ); |
205 |
|
206 // Complete the Listner if that is active. |
|
207 if(aContext->iIncommingMessageListner.Check()) |
|
208 aContext->iIncommingMessageListner.Complete(KErrNone); |
|
209 } |
261 } |
210 |
262 |
211 if(aEvent == EMSRPCancelSendRespListeningEvent) |
263 if(aEvent == EMSRPCancelSendRespListeningEvent) |
212 { |
264 { |
213 // Confirm completion of the Cancel Request. |
265 // Confirm completion of the Cancel Request. |
214 aContext->CompleteClient(KErrNone); |
266 aContext->CompleteClient( KErrNone ); |
215 |
267 |
216 // Complete the Listner if that is active. |
268 // Complete the Listner if that is active. |
217 if(aContext->iResponseListner.Check()) |
269 if(aContext->iResponseListner.Check()) |
218 aContext->iResponseListner.Complete(KErrNone); |
270 aContext->iResponseListner.Complete( KErrNone ); |
219 } |
271 } |
220 |
272 |
221 return aContext->StateFactory().getStateL(EWaitForClient); |
273 return aContext->StateFactory().getStateL(EWaitForClient); |
|
274 } |
|
275 |
|
276 TStateBase* TStateBase::HandleClientCancelSendingL( CMSRPServerSubSession* aContext ) |
|
277 { |
|
278 MSRPLOG("-> TStateBase::HandleClientCancelSendingL"); |
|
279 // let's find the correct listener first |
|
280 TBuf8< KMaxLengthOfTransactionIdString > messageId; |
|
281 aContext->iClientMessage->ReadL( 0, messageId ); |
|
282 |
|
283 // going through all incoming instances |
|
284 CMSRPMessageHandler* owner = aContext->iOutMsgQ.FindElement( messageId ); |
|
285 if ( owner ) |
|
286 { |
|
287 MSRPLOG2("TStateBase::HandleClientCancelSendingL terminating %d", owner ); |
|
288 owner->TerminateSending( ); |
|
289 } |
|
290 |
|
291 // Confirm completion of the Cancel Request. |
|
292 aContext->CompleteClient( KErrNone ); |
|
293 return this; |
222 } |
294 } |
223 |
295 |
224 TStateBase* TStateBase::handleConnectionStateChangedL(CMSRPServerSubSession *aContext) |
296 TStateBase* TStateBase::handleConnectionStateChangedL(CMSRPServerSubSession *aContext) |
225 { |
297 { |
226 TStateBase* state = NULL; |
298 TStateBase* state = NULL; |
319 { |
391 { |
320 state = aContext->StateFactory().getStateL( EActive ); |
392 state = aContext->StateFactory().getStateL( EActive ); |
321 } |
393 } |
322 else |
394 else |
323 { |
395 { |
324 if( CMSRPServerSubSession::TInCommingMsgQueue == |
396 CMSRPServerSubSession::TQueueType type = aContext->getQToProcess(); |
325 aContext->getQToProcess() ) |
397 if ( type == CMSRPServerSubSession::TReceiveProgressQueue ) |
326 state = processIncommingMessageL( aContext ); |
398 { |
|
399 state = processReceiveReportL( aContext ); |
|
400 } |
|
401 else if ( type == CMSRPServerSubSession::TSendProgressQueue ) |
|
402 { |
|
403 state = processSendReportL( aContext ); |
|
404 } |
|
405 else if ( type == CMSRPServerSubSession::TCompletedSendQueue ) |
|
406 { |
|
407 state = processCompletedMessageL( aContext ); |
|
408 } |
|
409 else if ( type == CMSRPServerSubSession::TCompletedIncQueue ) |
|
410 { |
|
411 state = processCompletedIncomingMessageL( aContext ); |
|
412 } |
|
413 else if( type == CMSRPServerSubSession::TInCommingMsgQueue ) |
|
414 { |
|
415 state = processIncommingMessageL( aContext ); |
|
416 } |
327 else |
417 else |
|
418 { |
328 state = processPendingMessageQL( aContext ); |
419 state = processPendingMessageQL( aContext ); |
|
420 } |
329 } |
421 } |
330 |
422 |
331 return state; |
423 return state; |
|
424 } |
|
425 |
|
426 TStateBase* TStateBase::handleInCommingMessagesL(CMSRPServerSubSession *aContext) |
|
427 { |
|
428 CMSRPMessageHandler* incommingMsg = aContext->iReceivedMsg; |
|
429 aContext->iReceivedMsg = NULL; |
|
430 |
|
431 return processIncommingMessageL(aContext, incommingMsg); |
|
432 } |
|
433 |
|
434 TStateBase* TStateBase::MessageSendCompleteL(CMSRPServerSubSession *aContext) |
|
435 { |
|
436 // Handle send message complete event. |
|
437 if( NULL == aContext->iCurrentMsgHandler) |
|
438 { |
|
439 MSRPLOG( "TStateBase::MessageSendCompleteL :: iCurrentMsgHandler is NULL \n" ); |
|
440 return this; |
|
441 } |
|
442 |
|
443 if ( aContext->iCurrentMsgHandler->IsTransmissionTerminated() ) |
|
444 { |
|
445 MSRPLOG("TStateBase::processCompletedMessageL transmission terminated"); |
|
446 if( aContext->iResponseListner.Check() ) |
|
447 { |
|
448 MSRPLOG("TStateBase::processCompletedMessageL complete with KErrCancel"); |
|
449 aContext->iResponseListner.Complete( KErrCancel ); |
|
450 } |
|
451 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
452 } |
|
453 |
|
454 if( aContext->iCurrentMsgHandler->IsMessageComplete() ) |
|
455 { |
|
456 // Messages with Failure Report set to "No" will never get a response. |
|
457 aContext->sendResultToClientL( aContext->iCurrentMsgHandler ); |
|
458 CMSRPMessageHandler* temp = aContext->iOutMsgQ.getMatch( aContext->iCurrentMsgHandler ); |
|
459 if ( temp ) |
|
460 { |
|
461 aContext->iOutMsgQ.explicitRemove( aContext->iCurrentMsgHandler ); |
|
462 } |
|
463 delete aContext->iCurrentMsgHandler; |
|
464 aContext->iCurrentMsgHandler = NULL; |
|
465 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
466 } |
|
467 else |
|
468 { |
|
469 aContext->iCurrentMsgHandler = NULL; |
|
470 // Handle any pending events in Queue. |
|
471 return handleQueuesL(aContext); |
|
472 } |
332 } |
473 } |
333 |
474 |
334 TStates TStateIdle::identity() |
475 TStates TStateIdle::identity() |
335 { |
476 { |
336 return EIdle; |
477 return EIdle; |
551 } |
699 } |
552 |
700 |
553 return state; |
701 return state; |
554 } |
702 } |
555 |
703 |
556 TStateBase* TStateWaitForClient::fileSendCompleteL(CMSRPServerSubSession *aContext) |
|
557 { |
|
558 CMSRPMessageHandler *outgoingMessageHandler = aContext->iOutMsgQ.getHead(); |
|
559 |
|
560 if( outgoingMessageHandler && outgoingMessageHandler->IsMessageComplete() ) |
|
561 { |
|
562 aContext->iOutMsgQ.explicitRemove(outgoingMessageHandler); |
|
563 delete outgoingMessageHandler; |
|
564 aContext->iSendCompleteNotify = TRUE; |
|
565 } |
|
566 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
567 } |
|
568 |
|
569 TStateBase * TStateWaitForClient::handleResponseSentL( CMSRPServerSubSession *aContext) |
|
570 { |
|
571 CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; |
|
572 oriMessageHandler->UpdateResponseStateL(aContext->iReceivedResp); |
|
573 if(oriMessageHandler->FileTransferComplete() ) |
|
574 { |
|
575 aContext->iReceiveCompleteNotify = TRUE; |
|
576 } |
|
577 |
|
578 return aContext->StateFactory().getStateL(EWaitForClient); |
|
579 } |
|
580 |
|
581 TStates TStateWaitForClient::identity() |
704 TStates TStateWaitForClient::identity() |
582 { |
705 { |
583 return EWaitForClient; |
706 return EWaitForClient; |
584 } |
707 } |
585 |
708 |
586 TStateBase* TStateBase::handleSendFileL(CMSRPServerSubSession *aContext) |
|
587 { |
|
588 MSRPLOG("TStateBase::handleSendFileL() enter"); |
|
589 aContext->ReadSendDataPckgL(); |
|
590 CMSRPMessageHandler *aMessageHandler = CMSRPMessageHandler::NewL(aContext, |
|
591 aContext->iSendMSRPdataPckg().iExtMessageBuffer); |
|
592 |
|
593 aMessageHandler->SendFileL(*aContext->iConnection); |
|
594 |
|
595 aContext->iOutMsgQ.Queue(*aMessageHandler); |
|
596 aContext->CompleteClient( KErrNone ); |
|
597 |
|
598 aContext->iFileShare = TRUE; |
|
599 MSRPLOG("TStateBase::handleSendFileL() exit"); |
|
600 if(!aContext->listnerSetupComplete()) |
|
601 { |
|
602 return aContext->StateFactory().getStateL(EWaitForClient); |
|
603 } |
|
604 |
|
605 return aContext->StateFactory().getStateL(EFileShare); |
|
606 } |
|
607 |
|
608 TStateBase* TStateBase::handleReceiveFileL(CMSRPServerSubSession *aContext) |
|
609 { |
|
610 MSRPLOG("TStateBase::handleReceiveFileL() enter"); |
|
611 |
|
612 aContext->ReadSendDataPckgL(); |
|
613 |
|
614 aContext->iReceiveFileMsgHdler = CMSRPMessageHandler::NewL(aContext, |
|
615 aContext->iSendMSRPdataPckg().iExtMessageBuffer); |
|
616 |
|
617 |
|
618 aContext->iReceiveFileMsgHdler->ReceiveFileL(); |
|
619 aContext->CompleteClient( KErrNone ); |
|
620 aContext->iFileShare = TRUE; |
|
621 MSRPLOG("TStateBase::handleReceiveFileL() exit"); |
|
622 if(!aContext->listnerSetupComplete()) |
|
623 { |
|
624 return aContext->StateFactory().getStateL(EWaitForClient); |
|
625 } |
|
626 |
|
627 return aContext->StateFactory().getStateL(EFileShare); |
|
628 } |
|
629 |
|
630 TStateBase* TStateWaitForClient::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) |
709 TStateBase* TStateWaitForClient::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) |
631 { |
710 { |
632 // In the TStateWaitForClient stat the server subsession waits for the client to setup |
711 // In the TStateWaitForClient stat the server subsession waits for the client to setup |
633 // handlers to receive requests/responses/reports from the MSRP peer. |
712 // handlers to receive requests/responses/reports from the MSRP peer. |
634 // TODO - TStateWaitForClient can be removed. Replace this with a eventQueue implementation. |
713 // TODO - TStateWaitForClient can be removed. Replace this with a eventQueue implementation. |
660 // Queue any thing that comes. |
743 // Queue any thing that comes. |
661 aContext->iInCommingMsgQ.Queue(*aContext->iReceivedMsg); |
744 aContext->iInCommingMsgQ.Queue(*aContext->iReceivedMsg); |
662 break; |
745 break; |
663 |
746 |
664 case EMSRPDataSendCompleteEvent: |
747 case EMSRPDataSendCompleteEvent: |
665 // Data Send Complete received in the TWaitForClient state is |
748 case EMSRPDataCancelledEvent: |
666 // not handeled. At Data Send Complete messae with Failure Report |
749 { |
667 // header set to "no" need to inform the client about completion. |
750 MSRPLOG("TStateWaitForClient::EventL EMSRPDataCancelledEvent"); |
668 // Currently Queuing of completion events is not supported. |
751 |
669 if(aContext->iFileShare) |
752 if( aContext->iCurrentMsgHandler->IsMessageComplete() ) |
670 { |
753 { |
671 state = fileSendCompleteL(aContext); |
754 MSRPLOG("TStateWaitForClient::EventL moving to pending data"); |
672 break; |
755 aContext->iOutMsgQ.explicitRemove( aContext->iCurrentMsgHandler ); |
|
756 aContext->iPendingDataSendCompleteQ.Queue( *aContext->iCurrentMsgHandler ); |
673 } |
757 } |
674 MSRPLOG2("TStateWaitForClient::Not supported, Please check %d",aEvent); |
758 aContext->iCurrentMsgHandler = NULL; |
675 break; |
759 break; |
|
760 } |
676 |
761 |
677 case EMSRPResponseSendCompleteEvent: |
762 case EMSRPResponseSendCompleteEvent: |
678 if(aContext->iFileShare) |
763 { |
|
764 if( aContext->iReceivedResp->IsMessageComplete() ) |
679 { |
765 { |
680 state = handleResponseSentL(aContext); |
766 aContext->iPendingDataIncCompleteQ.Queue( *aContext->iReceivedResp ); |
681 break; |
|
682 } |
767 } |
683 break; |
768 aContext->iReceivedResp = NULL; |
684 |
769 break; |
|
770 } |
|
771 |
|
772 case EMSRPReportSendCompleteEvent: |
|
773 { |
|
774 if( aContext->iReceivedReport->IsMessageComplete() ) |
|
775 { |
|
776 aContext->iPendingDataIncCompleteQ.Queue( *aContext->iReceivedReport ); |
|
777 } |
|
778 aContext->iReceivedReport = NULL; |
|
779 break; |
|
780 } |
|
781 |
685 case EMSRPDataSendMessageEvent: |
782 case EMSRPDataSendMessageEvent: |
686 aContext->QueueClientSendRequestsL(); |
783 aContext->QueueClientSendRequestsL(); |
687 break; |
784 break; |
688 |
785 |
689 case EMSRPCancelReceivingEvent: |
786 case EMSRPCancelReceivingEvent: |
690 case EMSRPCancelSendRespListeningEvent: |
787 case EMSRPCancelSendRespListeningEvent: |
691 handleClientListnerCancelL(aContext, aEvent); |
788 handleClientListnerCancelL(aContext, aEvent); |
692 break; |
789 break; |
|
790 |
|
791 case EMSRPDataSendMessageCancelEvent: |
|
792 { |
|
793 HandleClientCancelSendingL( aContext ); |
|
794 break; |
|
795 } |
693 |
796 |
694 case EConnectionStateChangedEvent: |
797 case EConnectionStateChangedEvent: |
695 state = handleConnectionStateChangedL(aContext); |
798 state = handleConnectionStateChangedL(aContext); |
696 break; |
799 break; |
697 |
800 |
698 case EMSRPSendProgressEvent: |
801 case EMSRPSendProgressEvent: |
|
802 { |
|
803 state = aContext->StateFactory().getStateL( EWaitForClient ); |
|
804 // queue only if this msghandler is not already in the queue |
|
805 if ( aContext->iPendingSendProgressQ.FindElement( aContext->iSendProgressMsg ) == NULL ) |
|
806 { |
|
807 aContext->iPendingSendProgressQ.Queue( *aContext->iSendProgressMsg ); |
|
808 } |
|
809 break; |
|
810 } |
699 case EMSRPReceiveProgressEvent: |
811 case EMSRPReceiveProgressEvent: |
700 //ignore event if no listener |
812 { |
701 MSRPLOG("TStateWaitForClient::EventL Ignoring Progress Event") |
813 // Queue any thing that comes. |
702 state = aContext->StateFactory().getStateL(EWaitForClient); |
814 state = aContext->StateFactory().getStateL( EWaitForClient ); |
703 break; |
815 // queue only if this msghandler is not already in the queue |
704 |
816 if ( aContext->iPendingReceiveProgressQ.FindElement( aContext->iReceiveProgressMsg ) == NULL ) |
705 case EMSRPSendFileEvent: |
817 { |
706 state = handleSendFileL(aContext); |
818 aContext->iPendingReceiveProgressQ.Queue( *aContext->iReceiveProgressMsg ); |
707 break; |
819 } |
708 |
820 break; |
709 case EMSRPReceiveFileEvent : |
821 } |
710 state = handleReceiveFileL(aContext); |
|
711 break; |
|
712 |
822 |
713 default: |
823 default: |
714 // Any such error usually a client/server protocol voilation or connection/subsession |
824 // Any such error usually a client/server protocol voilation or connection/subsession |
715 // protocol voilation. A bug to fix!! |
825 // protocol voilation. A bug to fix!! |
716 |
826 MSRPLOG2("TStateWaitForClient::EventL :: Err!! Invalid state was received %d",aEvent); |
717 MSRPLOG2("TStateWaitForClient::EventL :: Err!! Invalid state to have received %d",aEvent); |
|
718 state = HandleStateErrorL(aContext); |
827 state = HandleStateErrorL(aContext); |
719 break; |
828 break; |
720 }; |
829 }; |
721 |
830 |
722 if(NULL == state) |
831 if(NULL == state) |
723 { |
832 { |
724 // State not set. |
833 // State not set. |
725 if(!aContext->listnerSetupComplete()) |
834 if( !aContext->listnerSetupComplete() ) |
726 { |
835 { |
727 state = this; |
836 state = this; |
728 } |
837 } |
729 else if (aContext->iFileShare) |
838 else |
730 { |
839 { |
731 state = aContext->StateFactory().getStateL(EFileShare); |
840 state = handleQueuesL(aContext); |
732 |
|
733 if(aContext->iReceiveCompleteNotify) |
|
734 { |
|
735 aContext->NotifyFileReceiveResultToClientL(NULL); |
|
736 state = aContext->StateFactory().getStateL(EWaitForClient); |
|
737 } |
|
738 else if (aContext->iSendCompleteNotify) |
|
739 { |
|
740 aContext->NotifyFileSendResultToClientL(NULL); |
|
741 state = aContext->StateFactory().getStateL(EWaitForClient); |
|
742 } |
|
743 else if(!aContext->QueuesEmpty()) |
|
744 state = state->handleQueuesL(aContext); |
|
745 } |
841 } |
746 else |
|
747 state = handleQueuesL(aContext); |
|
748 } |
842 } |
749 return state; |
843 return state; |
750 } |
844 } |
751 |
845 |
752 TStates TStateActive::identity() |
846 TStates TStateActive::identity() |
753 { |
847 { |
754 return EActive; |
848 return EActive; |
755 } |
849 } |
756 |
850 |
770 |
864 |
771 case EMSRPIncomingMessageReceivedEvent: |
865 case EMSRPIncomingMessageReceivedEvent: |
772 state = handleInCommingMessagesL(aContext); |
866 state = handleInCommingMessagesL(aContext); |
773 break; |
867 break; |
774 |
868 |
775 case EMSRPSendFileEvent: |
|
776 state = handleSendFileL(aContext); |
|
777 break; |
|
778 |
|
779 case EMSRPReceiveFileEvent : |
|
780 state = handleReceiveFileL(aContext); |
|
781 break; |
|
782 |
|
783 case EConnectionStateChangedEvent: |
869 case EConnectionStateChangedEvent: |
784 state = handleConnectionStateChangedL(aContext); |
870 state = handleConnectionStateChangedL(aContext); |
785 break; |
871 break; |
786 |
872 |
787 case EMSRPCancelReceivingEvent: |
873 case EMSRPCancelReceivingEvent: |
788 case EMSRPCancelSendRespListeningEvent: |
874 case EMSRPCancelSendRespListeningEvent: |
789 state = handleClientListnerCancelL(aContext, aEvent); |
875 state = handleClientListnerCancelL(aContext, aEvent); |
790 break; |
876 break; |
791 |
877 |
|
878 case EMSRPDataSendMessageCancelEvent: |
|
879 { |
|
880 state = HandleClientCancelSendingL( aContext ); |
|
881 break; |
|
882 } |
|
883 |
|
884 case EMSRPDataCancelledEvent: |
|
885 case EMSRPDataSendCompleteEvent: |
|
886 state = MessageSendCompleteL(aContext); |
|
887 break; |
|
888 |
|
889 case EMSRPResponseSendCompleteEvent: |
|
890 { |
|
891 state = handleResponseSentL(aContext); |
|
892 break; |
|
893 } |
|
894 |
|
895 case EMSRPReportSendCompleteEvent: |
|
896 { |
|
897 state = handleReportSentL( aContext ); |
|
898 break; |
|
899 } |
|
900 |
|
901 case EMSRPReceiveProgressEvent: |
|
902 { |
|
903 aContext->ReceiveProgressToClientL( aContext->iReceiveProgressMsg ); |
|
904 state = aContext->StateFactory().getStateL( EWaitForClient ); |
|
905 break; |
|
906 } |
|
907 |
|
908 case EMSRPSendProgressEvent: |
|
909 { |
|
910 aContext->SendProgressToClientL( aContext->iSendProgressMsg ); |
|
911 state = aContext->StateFactory().getStateL( EWaitForClient ); |
|
912 break; |
|
913 } |
|
914 |
792 default: |
915 default: |
793 // Any such error usually a client/server protocol voilation or connection/subsession |
916 // Any such error usually a client/server protocol voilation or connection/subsession |
794 // protocol voilation. A bug to fix!! |
917 // protocol voilation. A bug to fix!! |
795 |
918 |
796 MSRPLOG2("TStateActive::EventL :: Err!! Invalid state to have received %d",aEvent); |
919 MSRPLOG2("TStateActive::EventL :: Err!! Invalid state to have received %d",aEvent); |
809 |
932 |
810 CMSRPMessageHandler *msgHandler |
933 CMSRPMessageHandler *msgHandler |
811 = CMSRPMessageHandler::NewL(aContext, |
934 = CMSRPMessageHandler::NewL(aContext, |
812 aContext->iSendMSRPdataPckg().iExtMessageBuffer); |
935 aContext->iSendMSRPdataPckg().iExtMessageBuffer); |
813 |
936 |
814 msgHandler->SendMessageL( *aContext->iConnection ); |
937 msgHandler->SendMessageL( *aContext->iConnection ); |
815 aContext->iCurrentMsgHandler = msgHandler; |
938 aContext->iOutMsgQ.Queue( *msgHandler ); |
816 |
|
817 aContext->CompleteClient( KErrNone ); |
939 aContext->CompleteClient( KErrNone ); |
818 |
940 |
819 return aContext->StateFactory().getStateL(EActiveSend); |
941 return aContext->StateFactory().getStateL( EActive ); |
820 } |
942 } |
821 |
943 |
822 TStateBase* TStateBase::handleInCommingMessagesL(CMSRPServerSubSession *aContext) |
944 TStateBase* TStateActive::handleResponseSentL( CMSRPServerSubSession* aContext ) |
823 { |
945 { |
824 CMSRPMessageHandler* incommingMsg = aContext->iReceivedMsg; |
946 MSRPLOG("-> TStateActive::handleResponseSentL"); |
825 aContext->iReceivedMsg = NULL; |
947 if( aContext->iReceivedResp->IsMessageComplete() ) |
826 |
948 { |
827 return processIncommingMessageL(aContext, incommingMsg); |
949 if ( !aContext->iReceivedResp->SendReportL(aContext, *aContext->iConnection, EAllOk ) ) |
828 } |
950 { |
829 |
951 if ( aContext->iReceivedResp->IsTransmissionTerminated() ) |
830 TStates TStateFileShare::identity() |
952 { |
831 { |
953 if( aContext->iIncommingMessageListner.Check() ) |
832 return EFileShare; |
954 { |
833 } |
955 aContext->iIncommingMessageListner.Complete( KErrCancel ); |
834 |
956 } |
835 TStateBase* TStateFileShare::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) |
957 } |
836 { |
958 else |
837 TStateBase *state = NULL; |
959 { |
838 MSRPLOG2("Entered TStateFileShare Event %d",aEvent); |
960 aContext->sendMsgToClientL( aContext->iReceivedResp ); |
839 switch(aEvent) |
961 } |
840 { |
962 return aContext->StateFactory().getStateL(EWaitForClient); |
841 case EMSRPDataSendCompleteEvent: // maps to file send complete |
963 } |
842 state = fileSendCompleteL(aContext); |
964 else |
843 break; |
965 { |
844 |
966 aContext->iReceivedResp = NULL; |
845 case EMSRPIncomingMessageReceivedEvent: // incoming responses to file chunks |
967 } |
846 state = handleInCommingMessagesL(aContext); |
|
847 break; |
|
848 |
|
849 case EMSRPResponseSendCompleteEvent: |
|
850 state = handleResponseSentL(aContext); |
|
851 break; |
|
852 |
|
853 case EMSRPSendProgressEvent: |
|
854 state = handleSendProgressL(aContext); |
|
855 break; |
|
856 |
|
857 case EMSRPReceiveProgressEvent: |
|
858 state = handleReceiveProgressL(aContext); |
|
859 break; |
|
860 |
|
861 case EConnectionStateChangedEvent : |
|
862 state = handleConnectionStateChangedL(aContext); |
|
863 break; |
|
864 |
|
865 |
|
866 case EMSRPCancelReceivingEvent: |
|
867 case EMSRPCancelSendRespListeningEvent: |
|
868 state = handleClientListnerCancelL(aContext, aEvent); |
|
869 break; |
|
870 default: |
|
871 MSRPLOG2("TStateFileShare::EventL :: Err!! Invalid state to have received %d",aEvent); |
|
872 // state = HandleStateErrorL(aContext); //handle error state |
|
873 break; |
|
874 |
|
875 } |
|
876 return state; |
|
877 } |
|
878 |
|
879 TStateBase * TStateFileShare::handleSendProgressL( CMSRPServerSubSession *aContext) |
|
880 { |
|
881 CMSRPMessageHandler *outgoingMessageHandler = aContext->iOutMsgQ.getHead(); |
|
882 aContext->SendProgressToClientL(outgoingMessageHandler); |
|
883 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
884 } |
|
885 |
|
886 TStateBase * TStateFileShare::handleReceiveProgressL( CMSRPServerSubSession *aContext) |
|
887 { |
|
888 CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; |
|
889 aContext->ReceiveProgressToClientL(oriMessageHandler); |
|
890 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
891 } |
|
892 |
|
893 TStateBase * TStateFileShare::handleResponseSentL( CMSRPServerSubSession *aContext) |
|
894 { |
|
895 CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; |
|
896 oriMessageHandler->UpdateResponseStateL(aContext->iReceivedResp); |
|
897 |
|
898 |
|
899 if(oriMessageHandler->FileTransferComplete() ) |
|
900 { |
|
901 //Notify client |
|
902 aContext->NotifyFileReceiveResultToClientL(oriMessageHandler); |
|
903 delete oriMessageHandler; |
|
904 aContext->iReceiveFileMsgHdler = NULL; |
|
905 return aContext->StateFactory().getStateL(EWaitForClient); |
|
906 } |
|
907 |
|
908 if(!aContext->listnerSetupComplete()) |
|
909 { |
|
910 return aContext->StateFactory().getStateL(EWaitForClient); |
|
911 } |
|
912 |
|
913 return aContext->StateFactory().getStateL(EFileShare); |
|
914 |
|
915 } |
|
916 |
|
917 TStateBase * TStateFileShare::handlesResponseL(CMSRPServerSubSession *aContext, |
|
918 CMSRPMessageHandler *incommingMsgHandler) |
|
919 { |
|
920 TStateBase *nextState; |
|
921 MSRPLOG("TStateFileShare::handlesFileResponseL Entered!"); |
|
922 |
|
923 // Search the outgoing Queue to find the owner of this response. |
|
924 CMSRPMessageHandler *outgoingMsgHandler = |
|
925 aContext->iOutMsgQ.getMatch(incommingMsgHandler); |
|
926 |
|
927 nextState = this; |
|
928 if(NULL != outgoingMsgHandler) |
|
929 { |
|
930 CleanupStack::PushL(incommingMsgHandler); |
|
931 outgoingMsgHandler->ConsumeFileResponseL(*incommingMsgHandler); |
|
932 |
|
933 if(outgoingMsgHandler->FileTransferComplete()) |
|
934 { |
|
935 //notify client |
|
936 aContext->NotifyFileSendResultToClientL(outgoingMsgHandler); |
|
937 aContext->iOutMsgQ.explicitRemove(outgoingMsgHandler); |
|
938 delete outgoingMsgHandler; |
|
939 nextState = aContext->StateFactory().getStateL(EWaitForClient); |
|
940 } |
|
941 |
|
942 CleanupStack::Pop(incommingMsgHandler); |
|
943 } |
|
944 delete incommingMsgHandler; |
|
945 MSRPLOG("TStateFileShare::handlesResponseL Exit!"); |
|
946 if(!aContext->listnerSetupComplete()) |
|
947 { |
|
948 return aContext->StateFactory().getStateL(EWaitForClient); |
|
949 } |
|
950 return nextState; |
|
951 } |
|
952 |
|
953 TStateBase * TStateFileShare::handleRequestsL(CMSRPServerSubSession *aContext, |
|
954 CMSRPMessageHandler *incommingMsgHandler) |
|
955 { |
|
956 if(MMSRPIncomingMessage::EMSRPMessage == incommingMsgHandler->MessageType()) |
|
957 { |
|
958 CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; |
|
959 |
|
960 if(oriMessageHandler->IsInFile()) |
|
961 { |
|
962 oriMessageHandler->WritetoFileL(incommingMsgHandler); |
|
963 incommingMsgHandler->SendResponseL(aContext, *aContext->iConnection,CMSRPResponse::EAllOk); |
|
964 if(!incommingMsgHandler->IfResponseReqL()) |
|
965 { |
|
966 delete incommingMsgHandler; |
|
967 if(oriMessageHandler->FileTransferComplete()) |
|
968 { |
|
969 aContext->NotifyFileReceiveResultToClientL(oriMessageHandler); |
|
970 delete oriMessageHandler; |
|
971 aContext->iReceiveFileMsgHdler = NULL; |
|
972 return aContext->StateFactory().getStateL(EWaitForClient); |
|
973 } |
|
974 } |
|
975 |
|
976 else |
|
977 { |
|
978 aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); |
|
979 } |
|
980 } |
|
981 } |
|
982 else |
|
983 { |
|
984 MSRPLOG("Reports not supported.!!"); |
|
985 delete incommingMsgHandler; |
|
986 } |
|
987 if(!aContext->listnerSetupComplete()) |
|
988 { |
|
989 return aContext->StateFactory().getStateL(EWaitForClient); |
|
990 } |
|
991 return this; |
|
992 } |
|
993 |
|
994 TStateBase* TStateFileShare::fileSendCompleteL(CMSRPServerSubSession *aContext) |
|
995 { |
|
996 CMSRPMessageHandler *outgoingMessageHandler = aContext->iOutMsgQ.getHead(); |
|
997 |
|
998 if( outgoingMessageHandler && outgoingMessageHandler->IsMessageComplete() ) |
|
999 { |
|
1000 //notify client |
|
1001 aContext->NotifyFileSendResultToClientL( outgoingMessageHandler ); |
|
1002 aContext->iOutMsgQ.explicitRemove(outgoingMessageHandler); |
|
1003 delete outgoingMessageHandler; |
|
1004 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
1005 } |
|
1006 // response needed keep it on the outmsg queue itself |
|
1007 return aContext->StateFactory().getStateL( EFileShare ); |
|
1008 } |
|
1009 |
|
1010 TStates TStateActiveSend::identity() |
|
1011 { |
|
1012 return EActiveSend; |
|
1013 } |
|
1014 |
|
1015 TStateBase* TStateActiveSend::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) |
|
1016 { |
|
1017 // ActiveSend state. The subsession is busy sending earlier data. Any further requests to |
|
1018 // send data from the client will be queued. Any Message received will be queued till |
|
1019 // EMSRPDataSendCompleteEvent is received. |
|
1020 // After this Message Received Queue will be processed to check for any |
|
1021 // incoming messages/responses. |
|
1022 // After that Message send queue will be processed to see if there any pending messages to |
|
1023 // trasmitt. |
|
1024 // If both the queues are empty move back to Active State. |
|
1025 |
|
1026 TStateBase *state; |
|
1027 MSRPLOG2("Entered TStateActiveSend Event %d",aEvent); |
|
1028 |
|
1029 switch(aEvent) |
|
1030 { |
|
1031 case EMSRPDataSendMessageEvent: |
|
1032 aContext->QueueClientSendRequestsL(); |
|
1033 state = this; |
|
1034 break; |
|
1035 |
|
1036 case EMSRPDataSendCompleteEvent: |
|
1037 state = MessageSendCompleteL(aContext); |
|
1038 break; |
|
1039 |
|
1040 case EMSRPIncomingMessageReceivedEvent: |
|
1041 // Queue any thing that comes. |
|
1042 aContext->iInCommingMsgQ.Queue(*aContext->iReceivedMsg); |
|
1043 state = this; |
|
1044 break; |
|
1045 |
|
1046 case EConnectionStateChangedEvent: |
|
1047 state = handleConnectionStateChangedL(aContext); |
|
1048 break; |
|
1049 |
|
1050 case EMSRPCancelReceivingEvent: |
|
1051 case EMSRPCancelSendRespListeningEvent: |
|
1052 state = handleClientListnerCancelL(aContext, aEvent); |
|
1053 break; |
|
1054 |
|
1055 default: |
|
1056 // Any such error usually a client/server protocol voilation or connection/subsession |
|
1057 // protocol voilation. A bug to fix!! |
|
1058 |
|
1059 MSRPLOG2("TStateActiveSend::EventL :: Err!! Invalid state to have received %d",aEvent); |
|
1060 state = HandleStateErrorL(aContext); |
|
1061 break; |
|
1062 } |
|
1063 return state; |
|
1064 } |
|
1065 |
|
1066 TStateBase * TStateActiveSend::MessageSendCompleteL(CMSRPServerSubSession *aContext) |
|
1067 { |
|
1068 // Handle send message complete event. |
|
1069 if( NULL == aContext->iCurrentMsgHandler) |
|
1070 { |
|
1071 MSRPLOG( "TStateActiveSend::MessageSendCompleteL :: iCurrentMsgHandler is NULL \n" ); |
|
1072 return this; |
|
1073 } |
|
1074 |
|
1075 if( aContext->iCurrentMsgHandler->IsMessageComplete() ) |
|
1076 { |
|
1077 // Messages with Failure Report set to "No" will never get a response. |
|
1078 TBool error = aContext->sendResultToClientL( aContext->iCurrentMsgHandler ); |
|
1079 delete aContext->iCurrentMsgHandler; |
|
1080 aContext->iCurrentMsgHandler = NULL; |
|
1081 |
|
1082 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
1083 } |
968 } |
1084 else |
969 else |
1085 { |
970 { |
1086 // Message expects a response to come. Put this out the OutGoing Queue. |
971 aContext->iReceivedResp->ResponseHandled(); |
1087 aContext->iOutMsgQ.Queue( *(aContext->iCurrentMsgHandler) ); |
972 aContext->iReceivedResp = NULL; |
1088 aContext->iCurrentMsgHandler = NULL; |
973 } |
1089 |
974 MSRPLOG("<- TStateBase::handleRequestsL"); |
1090 // Handle any pending events in Queue. |
975 return aContext->StateFactory().getStateL( EActive ); |
1091 return handleQueuesL(aContext); |
976 } |
1092 } |
977 |
1093 } |
978 TStateBase* TStateActive::handleReportSentL( CMSRPServerSubSession* aContext) |
1094 |
979 { |
|
980 MSRPLOG("-> TStateActive::handleReportSentL"); |
|
981 aContext->sendReportToClientL( aContext->iReceivedReport ); |
|
982 aContext->iPendingDataIncCompleteQ.Queue( *aContext->iReceivedReport ); |
|
983 aContext->iReceivedReport = NULL; |
|
984 return aContext->StateFactory().getStateL( EWaitForClient ); |
|
985 } |
1095 |
986 |
1096 TStates TStateError::identity() |
987 TStates TStateError::identity() |
1097 { |
988 { |
1098 return EError; |
989 return EError; |
1099 } |
990 } |