|
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: Initial state for MT event. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <sipcontenttypeheader.h> |
|
23 #include <sipdialogassocbase.h> |
|
24 #include "mceeventsubscribemtidlestate.h" |
|
25 #include "mcesipeventhelper.h" |
|
26 #include "mcesip.h" |
|
27 #include "mceeventslogs.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CMceEventSubscribeMtIdleState::CMceEventSubscribeMtIdleState |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CMceEventSubscribeMtIdleState::CMceEventSubscribeMtIdleState() |
|
38 { |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CMceEventSubscribeMtIdleState::~CMceEventSubscribeMtIdleState |
|
43 // Destructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CMceEventSubscribeMtIdleState::~CMceEventSubscribeMtIdleState() |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMceEventSubscribeMtIdleState::ProcessSubscribeStateL |
|
52 // For sending out subscribe, update |
|
53 // Be noticed that it will be also update, unsubscribe |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CMceEventSubscribeMtIdleState::HandleL( CMceComEvent& /*aEvent*/ ) |
|
57 { |
|
58 User::Leave( KMceEventStateError ); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceEventSubscribeMtIdleState::HandleReceiveRequestL |
|
63 // Ápply concrete state. |
|
64 // Be noticed that it is receiving notify and subscribe in the terminated state |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CMceEventSubscribeMtIdleState::HandleReceiveRequestL( |
|
68 CMceComEvent& aEvent ) |
|
69 { |
|
70 MCEEVENTS_DEBUG("CMceEventSubscribeMtIdleState::HandleReceiveRequestL, Entry"); |
|
71 User::LeaveIfError( aEvent.SIPEvent().Dialog() ? |
|
72 KErrNone : KMceEventStateError ); |
|
73 |
|
74 CSIPServerTransaction& serverTran = aEvent.SIPEvent().Request(); |
|
75 CSIPServerTransaction* serverTranCheck = &serverTran; |
|
76 User::LeaveIfError( serverTranCheck ? KErrNone : KMceEventStateError ); |
|
77 User::LeaveIfError( serverTran.RequestElements() ? |
|
78 KErrNone : KMceEventStateError ); |
|
79 |
|
80 const CSIPMessageElements& msgElem = |
|
81 serverTran.RequestElements()->MessageElements(); |
|
82 |
|
83 CDesC8Array* headers = MceSip::UserHeadersToTextArrayL( |
|
84 serverTran, |
|
85 aEvent.SIPEvent().Dialog()->Dialog() ); |
|
86 |
|
87 CleanupStack::PushL( headers ); |
|
88 |
|
89 HBufC8* contenttype= NULL; |
|
90 if( msgElem.ContentType() ) |
|
91 { |
|
92 contenttype = msgElem.ContentType()->ToTextValueL(); |
|
93 } |
|
94 |
|
95 CleanupStack::PushL( contenttype ); |
|
96 HBufC8* content = msgElem.Content().AllocLC(); |
|
97 aEvent.SIPEvent().IncomingSubscribeL( headers, |
|
98 contenttype, |
|
99 content ); |
|
100 CleanupStack::Pop( content ); |
|
101 CleanupStack::Pop( contenttype ); |
|
102 CleanupStack::Pop( headers ); |
|
103 |
|
104 CSIPResponseElements* response = |
|
105 MCESIPEventHelper::SubscribeRequestReceivedLC( aEvent, msgElem ); |
|
106 if ( response->StatusCode() == KMceSipOK ) |
|
107 { |
|
108 TBool terminated = EFalse; |
|
109 |
|
110 MCESIPEventHelper::HandleExpireHeaderL( msgElem,terminated ); |
|
111 if ( terminated ) |
|
112 { |
|
113 //send 200 OK, and turn to Terminated |
|
114 //SendResponse |
|
115 serverTran.SendResponseL( response ); |
|
116 CleanupStack::Pop( response ); |
|
117 aEvent.EventContext().SetCurrentStateL( |
|
118 aEvent, |
|
119 KMceTerminatedEventStateIndex ); |
|
120 //Tell client state has terminated |
|
121 aEvent.SIPEvent().ClientStateChangedL( |
|
122 CMceEvent::ETerminated, |
|
123 EFalse ); |
|
124 } |
|
125 else |
|
126 { |
|
127 //to Estalishing state |
|
128 //delete the response |
|
129 CleanupStack::PopAndDestroy( response ); |
|
130 aEvent.EventContext().SetCurrentStateL( |
|
131 aEvent, |
|
132 KMceEstablishingEventStateIndex ); |
|
133 } |
|
134 } |
|
135 else |
|
136 { |
|
137 //when the subscribe request is bad, sendresponse |
|
138 //state terminated |
|
139 serverTran.SendResponseL( response ); |
|
140 CleanupStack::Pop( response ); |
|
141 User::Leave( KErrArgument ); |
|
142 //Should inform the subsession to delete the session |
|
143 } |
|
144 MCEEVENTS_DEBUG("CMceEventSubscribeMtIdleState::HandleReceiveRequestL, Exit"); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CMceEventSubscribeMtIdleState::HandleResponseReceivedL |
|
149 // Ápply concrete state. |
|
150 // Be noticed that it will be also update, unsubscribe |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMceEventSubscribeMtIdleState::HandleResponseReceivedL( |
|
154 CMceComEvent& /*aEvent*/ ) |
|
155 { |
|
156 User::Leave( KMceEventStateError ); |
|
157 } |
|
158 |
|
159 // End of File |