|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Event is terminated. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <siprequestelements.h> |
|
24 #include <sipcontenttypeheader.h> |
|
25 #include <sipresponseelements.h> |
|
26 #include <sipdialogassocbase.h> |
|
27 #include "mcesipeventhelper.h" |
|
28 #include "mceeventsubscribeterminatedstate.h" |
|
29 #include "mcesip.h" |
|
30 #include "mceeventslogs.h" |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMceEventSubscribeTerminatedState::CMceEventSubscribeTerminatedState |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CMceEventSubscribeTerminatedState::CMceEventSubscribeTerminatedState() |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CMceEventSubscribeTerminatedState::~CMceEventSubscribeTerminatedState |
|
46 // Destructor |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CMceEventSubscribeTerminatedState::~CMceEventSubscribeTerminatedState() |
|
50 { |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CMceEventSubscribeTerminatedState::ProcessSubscribeStateL |
|
55 // Ápply concrete state. |
|
56 // Be noticed that it will be also update, unsubscribe |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void CMceEventSubscribeTerminatedState::HandleL( |
|
60 CMceComEvent& /*aEvent*/ ) |
|
61 { |
|
62 User::Leave( KMceEventStateError ); |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMceEventSubscribeTerminatedState::HandleReceiveRequestL |
|
67 // Ápply concrete state. |
|
68 // Be noticed that it will be also update, unsubscribe |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CMceEventSubscribeTerminatedState::HandleReceiveRequestL( |
|
72 CMceComEvent& aEvent ) |
|
73 { |
|
74 MCEEVENTS_DEBUG("CMceEventSubscribeTerminatedState::HandleReceiveRequestL, Entry"); |
|
75 User::LeaveIfError( aEvent.SIPEvent().Dialog() ? |
|
76 KErrNone : KMceEventStateError ); |
|
77 |
|
78 CSIPServerTransaction& serverTran = aEvent.SIPEvent().Request(); |
|
79 CSIPServerTransaction* serverTranCheck = &serverTran; |
|
80 User::LeaveIfError( serverTranCheck ? KErrNone : KMceEventStateError ); |
|
81 |
|
82 //Received Subscribe from Mo there is noaction in the previous action |
|
83 User::LeaveIfError( aEvent.PreviousAction() == KErrNotFound ? |
|
84 KErrNone : KMceEventStateError ); |
|
85 |
|
86 User::LeaveIfError( serverTran.RequestElements() ? KErrNone : KErrCorrupt ); |
|
87 |
|
88 const CSIPMessageElements& msgElem = |
|
89 serverTran.RequestElements()->MessageElements(); |
|
90 // send 200 ok after received notify |
|
91 CDesC8Array* reqheaders = MceSip::UserHeadersToTextArrayL( |
|
92 serverTran, |
|
93 aEvent.SIPEvent().Dialog()->Dialog() ); |
|
94 CleanupStack::PushL( reqheaders ); |
|
95 |
|
96 HBufC8* reqcontenttype=NULL; |
|
97 if( msgElem.ContentType() ) |
|
98 { |
|
99 reqcontenttype = msgElem.ContentType()->ToTextValueL(); |
|
100 } |
|
101 |
|
102 CleanupStack::PushL( reqcontenttype ); |
|
103 HBufC8* reqcontent = |
|
104 msgElem.Content().AllocL(); |
|
105 CleanupStack::PushL( reqcontent ); |
|
106 aEvent.SIPEvent().NotifyReceivedL( reqheaders, |
|
107 reqcontenttype, |
|
108 reqcontent ); |
|
109 CleanupStack::Pop( reqcontent ); |
|
110 CleanupStack::Pop( reqcontenttype ); |
|
111 CleanupStack::Pop( reqheaders ); |
|
112 |
|
113 CSIPResponseElements* newresponse = |
|
114 MCESIPEventHelper::NotifyRequestReceivedLC( aEvent, msgElem ); |
|
115 if ( newresponse->StatusCode() == KMceSipOK ) |
|
116 { |
|
117 |
|
118 TBool terminated = EFalse; |
|
119 MCESIPEventHelper:: |
|
120 HandleSubscriptionStateHeaderL( msgElem, terminated ); |
|
121 serverTran.SendResponseL( newresponse ); |
|
122 CleanupStack::Pop( newresponse ); |
|
123 if ( terminated ) |
|
124 { |
|
125 // when the subscription state is terminated |
|
126 //receive notify send 200 OK |
|
127 |
|
128 aEvent.SIPEvent().ClientStateChangedL( |
|
129 CMceEvent::ETerminated, |
|
130 EFalse ); |
|
131 } |
|
132 else |
|
133 { |
|
134 //the message Notify request-subscriptionstate is not corrected |
|
135 User::Leave( KErrArgument ); |
|
136 } |
|
137 } |
|
138 else |
|
139 { |
|
140 //when the notify request is bad, state doesnt change |
|
141 serverTran.SendResponseL( newresponse ); |
|
142 CleanupStack::Pop( newresponse ); |
|
143 User::Leave( KErrArgument ); |
|
144 } |
|
145 MCEEVENTS_DEBUG("CMceEventSubscribeTerminatedState::HandleReceiveRequestL, Exit"); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CMceEventSubscribeTerminatedState::HandleResponseReceivedL |
|
150 // Ápply concrete state. |
|
151 // Be noticed that it will be also update, unsubscribe |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CMceEventSubscribeTerminatedState::HandleResponseReceivedL( |
|
155 CMceComEvent& /*aEvent*/ ) |
|
156 { |
|
157 } |
|
158 |
|
159 // End of File |