50 // Startup Nokia Stack Related Objects |
50 // Startup Nokia Stack Related Objects |
51 iConnState = CSIPConnection::EInactive; |
51 iConnState = CSIPConnection::EInactive; |
52 |
52 |
53 __FLOG_1(_L("CSIPTransitionEngine %08x:\tInstantiating CSIPProfileRegistry - may leave"), this); |
53 __FLOG_1(_L("CSIPTransitionEngine %08x:\tInstantiating CSIPProfileRegistry - may leave"), this); |
54 iProfileRegistry = CSIPProfileRegistry::NewL(iSIP, *this); |
54 iProfileRegistry = CSIPProfileRegistry::NewL(iSIP, *this); |
55 CleanupStack::PushL(iProfileRegistry); |
|
56 __FLOG_1(_L("CSIPTransitionEngine %08x:\tInstantiating CSIPHttpDigest - may leave"), this); |
55 __FLOG_1(_L("CSIPTransitionEngine %08x:\tInstantiating CSIPHttpDigest - may leave"), this); |
57 iDigest = CSIPHttpDigest::NewL(iSIP, *this ); |
56 iDigest = CSIPHttpDigest::NewL(iSIP, *this ); |
58 CleanupStack::PushL(iDigest); |
|
59 __FLOG_1(_L("CSIPTransitionEngine %08x:\tInstantiating CSIPConnection - may leave"), this); |
57 __FLOG_1(_L("CSIPTransitionEngine %08x:\tInstantiating CSIPConnection - may leave"), this); |
60 iConnection = CSIPConnection::NewL(iSIP, iIapId, *this ); |
58 iConnection = CSIPConnection::NewL(iSIP, iIapId, *this ); |
61 |
59 |
62 // Wait for the connectio to become Active |
60 // Wait for the connectio to become Active |
63 if( iConnection->State() == CSIPConnection::EInit ) |
61 if( iConnection->State() == CSIPConnection::EInit ) |
64 { |
62 { |
65 iActiveWait.Start(); |
63 iActiveWait.Start(); |
66 } |
64 } |
67 |
65 |
68 __FLOG_1(_L("CSIPTransitionEngine %08x:\tConstructL successful"), this); |
66 __FLOG_1(_L("CSIPTransitionEngine %08x:\tConstructL successful"), this); |
69 CleanupStack::Pop(2); |
|
70 } |
67 } |
71 |
68 |
72 CSIPTransitionEngine::CSIPTransitionEngine(CSIP& aSip, TInt aIapId) |
69 CSIPTransitionEngine::CSIPTransitionEngine(CSIP& aSip, TInt aIapId) |
73 :iIapId(aIapId), |
70 :iIapId(aIapId), |
74 iSIP(aSip) |
71 iSIP(aSip) |
146 /** |
143 /** |
147 Incoming request recieved outside a dialog |
144 Incoming request recieved outside a dialog |
148 */ |
145 */ |
149 { |
146 { |
150 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<Recieved Outside of a Dialog>>"),this); |
147 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<Recieved Outside of a Dialog>>"),this); |
151 CleanupStack::PushL(aTransaction); //we're take over the ownership. |
148 TRAPD(err,IncomingRequestHandlerL(aTransaction)); |
152 |
149 if(err != KErrNone) |
153 RStringF method = aTransaction->RequestElements()->Method(); |
150 { |
154 if(method == SIPStrings::StringF(SipStrConsts::EInvite)) |
151 return; |
155 { |
152 } |
156 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<Received Request Invite>>"),this); |
|
157 TSipMsgBundle msgBundle; |
|
158 // Create a dialog Association and set server transaction |
|
159 CSIPInviteDialogAssoc* dialogassoc = CSIPInviteDialogAssoc::NewL(*aTransaction); |
|
160 CleanupStack::PushL(dialogassoc); |
|
161 msgBundle.iRequest = TSipHLConsts::ERequestInvite; |
|
162 msgBundle.iDialog = dialogassoc; |
|
163 msgBundle.iServTransaction = aTransaction; |
|
164 // Look For the state machine which is responsible for handling |
|
165 // this particular request |
|
166 CSipStateMachine* smPtr = FindSMForIncomingCall(); |
|
167 if(smPtr) |
|
168 { |
|
169 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<Found State Machine to Handle the Request>>"),this); |
|
170 smPtr->IncomingRequestOutsideDialog(msgBundle); |
|
171 CleanupStack::Pop(dialogassoc); |
|
172 CleanupStack::Pop(aTransaction); |
|
173 } |
|
174 else |
|
175 {// return NotFound |
|
176 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<No State Machine found to Handle the Request>>"),this); |
|
177 __FLOG_0(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<sending 404>>")); |
|
178 CSIPResponseElements *ResElem = CSIPResponseElements::NewLC( |
|
179 404, SIPStrings::StringF(SipStrConsts::EPhraseNotFound)); |
|
180 aTransaction->SendResponseL(ResElem); |
|
181 CleanupStack::Pop(ResElem); |
|
182 CleanupStack::PopAndDestroy(aTransaction); |
|
183 CleanupStack::PopAndDestroy(dialogassoc); |
|
184 } |
|
185 } |
|
186 else |
|
187 { // bad request , not supported here |
|
188 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<Received Request other than Invite>>"),this); |
|
189 __FLOG_0(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequest() <<sending 404>>")); |
|
190 CSIPResponseElements *ResElem = CSIPResponseElements::NewLC( |
|
191 400, SIPStrings::StringF(SipStrConsts::EPhraseBadRequest)); |
|
192 aTransaction->SendResponseL(ResElem); |
|
193 CleanupStack::Pop(ResElem); |
|
194 CleanupStack::PopAndDestroy(aTransaction); |
|
195 } |
|
196 } |
153 } |
197 |
154 |
198 void CSIPTransitionEngine::IncomingRequest( CSIPServerTransaction* aTransaction, CSIPDialog& aDialog ) |
155 void CSIPTransitionEngine::IncomingRequest( CSIPServerTransaction* aTransaction, CSIPDialog& aDialog ) |
199 /** |
156 /** |
200 Incoming request recieved on an established dialog |
157 Incoming request recieved on an established dialog |
1088 } |
1045 } |
1089 } |
1046 } |
1090 } |
1047 } |
1091 return EFalse; |
1048 return EFalse; |
1092 } |
1049 } |
|
1050 |
|
1051 void CSIPTransitionEngine::IncomingRequestHandlerL(CSIPServerTransaction* aTransaction) |
|
1052 { |
|
1053 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<Recieved Outside of a Dialog>>"),this); |
|
1054 CleanupStack::PushL(aTransaction); //we're take over the ownership. |
|
1055 |
|
1056 RStringF method = aTransaction->RequestElements()->Method(); |
|
1057 if(method == SIPStrings::StringF(SipStrConsts::EInvite)) |
|
1058 { |
|
1059 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<Received Request Invite>>"),this); |
|
1060 TSipMsgBundle msgBundle; |
|
1061 // Create a dialog Association and set server transaction |
|
1062 CSIPInviteDialogAssoc* dialogassoc = CSIPInviteDialogAssoc::NewL(*aTransaction); |
|
1063 CleanupStack::PushL(dialogassoc); |
|
1064 msgBundle.iRequest = TSipHLConsts::ERequestInvite; |
|
1065 msgBundle.iDialog = dialogassoc; |
|
1066 msgBundle.iServTransaction = aTransaction; |
|
1067 // Look For the state machine which is responsible for handling |
|
1068 // this particular request |
|
1069 CSipStateMachine* smPtr = FindSMForIncomingCall(); |
|
1070 if(smPtr) |
|
1071 { |
|
1072 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<Found State Machine to Handle the Request>>"),this); |
|
1073 smPtr->IncomingRequestOutsideDialog(msgBundle); |
|
1074 CleanupStack::Pop(dialogassoc); |
|
1075 CleanupStack::Pop(aTransaction); |
|
1076 } |
|
1077 else |
|
1078 {// return NotFound |
|
1079 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<No State Machine found to Handle the Request>>"),this); |
|
1080 __FLOG_0(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<sending 404>>")); |
|
1081 CSIPResponseElements *ResElem = CSIPResponseElements::NewLC( |
|
1082 404, SIPStrings::StringF(SipStrConsts::EPhraseNotFound)); |
|
1083 aTransaction->SendResponseL(ResElem); |
|
1084 CleanupStack::Pop(ResElem); |
|
1085 CleanupStack::PopAndDestroy(aTransaction); |
|
1086 CleanupStack::PopAndDestroy(dialogassoc); |
|
1087 } |
|
1088 } |
|
1089 else |
|
1090 { // bad request , not supported here |
|
1091 __FLOG_1(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<Received Request other than Invite>>"),this); |
|
1092 __FLOG_0(_L("[TransitionEngine]: CSIPTransitionEngine[%x]::IncomingRequestL() <<sending 404>>")); |
|
1093 CSIPResponseElements *ResElem = CSIPResponseElements::NewLC( |
|
1094 400, SIPStrings::StringF(SipStrConsts::EPhraseBadRequest)); |
|
1095 aTransaction->SendResponseL(ResElem); |
|
1096 CleanupStack::Pop(ResElem); |
|
1097 CleanupStack::PopAndDestroy(aTransaction); |
|
1098 } |
|
1099 } |