|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <sipprofile.h> |
|
22 #include "mceoutsession.h" |
|
23 #include "mcemanager.h" |
|
24 #include "mceevent.h" |
|
25 #include "mcecomsession.h" |
|
26 #include "mceitcsender.h" |
|
27 #include "mceserial.h" |
|
28 #include "mceclilogs.h" |
|
29 |
|
30 |
|
31 #define _FLAT_DATA static_cast<CMceComSession*>( iFlatData ) |
|
32 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMceOutSession::NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CMceOutSession* CMceOutSession::NewL( |
|
42 CMceManager& aManager, |
|
43 CSIPProfile& aProfile, |
|
44 const TDesC8& aRecipient, |
|
45 HBufC8* aOriginator ) |
|
46 { |
|
47 MCECLI_DEBUG("CMceOutSession::NewL, Entry"); |
|
48 |
|
49 TUint32 profileId(0); |
|
50 if ( aProfile.GetParameter( KSIPProfileId, profileId ) != KErrNone ) |
|
51 { |
|
52 User::Leave(KErrNotFound); |
|
53 } |
|
54 |
|
55 CMceOutSession* self = new (ELeave) CMceOutSession( &aManager, profileId ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL( aRecipient, aOriginator ); |
|
58 CleanupStack::Pop( self ); |
|
59 MCECLI_DEBUG("CMceOutSession::NewL, Exit"); |
|
60 |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMceOutSession::NewL |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CMceOutSession* CMceOutSession::NewL( CMceManager& aManager, |
|
69 TUint32 aIAPId, |
|
70 const TDesC8& aOriginator, |
|
71 const TDesC8& aRecipient, |
|
72 CDesC8Array* aContactParameters ) |
|
73 { |
|
74 CMceOutSession* self = new (ELeave) CMceOutSession( &aManager, 0 ); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL( aRecipient, aOriginator, aIAPId, aContactParameters ); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMceOutSession::NewL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CMceOutSession* CMceOutSession::NewL( CMceEvent& aEvent ) |
|
86 { |
|
87 MCECLI_DEBUG("CMceOutSession::NewL(event), Entry"); |
|
88 CMceOutSession* self = new (ELeave) CMceOutSession( &aEvent.Manager(), |
|
89 aEvent.ProfileId() ); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL( aEvent.Recipient(), |
|
92 aEvent.Originator(), |
|
93 aEvent.DialogId() ); |
|
94 CleanupStack::Pop( self ); |
|
95 MCECLI_DEBUG("CMceOutSession::NewL(event), Exit"); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CMceOutSession::NewL |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C CMceOutSession* CMceOutSession::NewL( CMceRefer& aRefer ) |
|
104 { |
|
105 MCECLI_DEBUG("CMceOutSession::NewL(refer), Entry"); |
|
106 CMceOutSession* self = new (ELeave) CMceOutSession( &aRefer.Manager(), |
|
107 aRefer.ProfileId() ); |
|
108 CleanupStack::PushL( self ); |
|
109 self->ConstructL( aRefer.Recipient(), |
|
110 aRefer.Originator(), |
|
111 aRefer.DialogId() ); |
|
112 CleanupStack::Pop( self ); |
|
113 MCECLI_DEBUG("CMceOutSession::NewL(refer), Exit"); |
|
114 return self; |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CMceOutSession::~CMceOutSession |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C CMceOutSession::~CMceOutSession() |
|
123 { |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CMceOutSession::EstablishL |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 EXPORT_C void CMceOutSession::EstablishL( |
|
132 TUint32 aTimeout, |
|
133 CDesC8Array* aHeaders, |
|
134 HBufC8* aContentType, |
|
135 HBufC8* aContent, |
|
136 CDesC8Array* aContentHeaders ) |
|
137 { |
|
138 MCECLI_DEBUG("CMceOutSession::EstablishL, Entry"); |
|
139 TState state = State(); |
|
140 MCECLI_DEBUG_CLISTATE( "state", state ); |
|
141 |
|
142 User::LeaveIfError( State() == EIdle ? KErrNone : KErrNotReady ); |
|
143 User::LeaveIfError( |
|
144 ( aContentType && aContent ) || |
|
145 !( aContentType || aContent || aContentHeaders ) ? |
|
146 KErrNone : KErrArgument ); |
|
147 |
|
148 //set sip params |
|
149 SetSIPParams( aHeaders, aContentType, aContentHeaders ); |
|
150 TCleanupItem sipParamsCleanup( SIPParamsCleanup, this ); |
|
151 CleanupStack::PushL( sipParamsCleanup ); |
|
152 |
|
153 FLAT_DATA( iTimeout ) = aTimeout; |
|
154 |
|
155 //create com session of this |
|
156 CMceMsgObject<CMceSession>* msg = |
|
157 new (ELeave) CMceMsgObject<CMceSession>( *this, EMceItcMsgTypeSession ); |
|
158 CleanupStack::PushL( msg ); |
|
159 |
|
160 //initialize streams, discard unused codecs |
|
161 InitializeL( EFalse, ETrue ); |
|
162 |
|
163 //start establishing the session |
|
164 TMceIds ids; |
|
165 PrepareForITC( ids ); |
|
166 |
|
167 iSender->SendL( ids, EMceItcEstablishSession , *msg, aContent ); |
|
168 |
|
169 //update the state |
|
170 FLAT_DATA( iState ) = static_cast<CMceSession::TState>( ids.iState ); |
|
171 state = State(); |
|
172 MCECLI_DEBUG_CLISTATE( "CMceSession::EstablishL, after ITC, state", state ); |
|
173 |
|
174 //cleanup |
|
175 CleanupStack::PopAndDestroy( msg ); |
|
176 |
|
177 CleanupStack::Pop(); // sipParamsCleanup |
|
178 |
|
179 SetSIPParams( NULL, NULL, NULL ); |
|
180 |
|
181 MCECLI_DEBUG("CMceOutSession::EstablishL, Exit"); |
|
182 |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CMceOutSession::AddStreamL |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CMceOutSession::AddStreamL( CMceMediaStream* aMediaStream ) |
|
190 { |
|
191 __ASSERT_ALWAYS( aMediaStream != NULL, User::Leave( KErrArgument ) ); |
|
192 |
|
193 // Just call the base class implementation. |
|
194 // Don't remove CMceOutSession::AddStreamL keep BC. |
|
195 CMceSession::AddStreamL( aMediaStream ); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CMceOutSession::StreamInitializeCondition |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 TBool CMceOutSession::StreamInitializeCondition( |
|
203 CMceMediaStream& /*aMediaStream*/ ) const |
|
204 { |
|
205 return ETrue; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CMceOutSession::CancelL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C void CMceOutSession::CancelL() |
|
213 { |
|
214 MCECLI_DEBUG("CMceOutSession::CancelL, Entry"); |
|
215 TState state = State(); |
|
216 MCECLI_DEBUG_CLISTATE( "state", state ); |
|
217 |
|
218 User::LeaveIfError( IsZombie() ? KErrArgument : KErrNone ); |
|
219 User::LeaveIfError( State() != EIdle ? KErrNone : KErrNotReady ); |
|
220 |
|
221 //send cancel |
|
222 TMceIds ids; |
|
223 PrepareForITC( ids ); |
|
224 ids.iState = State(); |
|
225 iSender->SendL( ids, EMceItcCancel ); |
|
226 |
|
227 //update the state |
|
228 FLAT_DATA( iState ) = static_cast<TState>( ids.iState ); |
|
229 state = State(); |
|
230 MCECLI_DEBUG_CLISTATE( "CMceSession::CancelL, after ITC, state", state ); |
|
231 MCECLI_DEBUG("CMceOutSession::CancelL, Exit"); |
|
232 |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CMceOutSession::NewL |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 CMceOutSession* CMceOutSession::NewL() |
|
240 { |
|
241 MCECLI_DEBUG("CMceOutSession::NewL(empty), Entry"); |
|
242 |
|
243 CMceOutSession* self = new (ELeave) CMceOutSession( NULL, NULL ); |
|
244 CleanupStack::PushL( self ); |
|
245 self->ConstructL( KNullDesC8, NULL ); |
|
246 CleanupStack::Pop( self ); |
|
247 MCECLI_DEBUG("CMceOutSession::NewL(empty), Exit"); |
|
248 return self; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CMceOutSession::CMceOutSession |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 CMceOutSession::CMceOutSession( CMceManager* aManager, TUint32 aProfileId ) |
|
256 : CMceSession( aManager, aProfileId ) |
|
257 { |
|
258 //NOP |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CMceOutSession::ConstructL |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CMceOutSession::ConstructL( const TDesC8& aRecipient, HBufC8* aOriginator ) |
|
266 { |
|
267 iFlatData = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
268 |
|
269 delete FLAT_DATA( iRecipient ); |
|
270 FLAT_DATA( iRecipient ) = 0; |
|
271 FLAT_DATA( iRecipient ) = aRecipient.AllocL(); |
|
272 |
|
273 if ( aOriginator ) |
|
274 { |
|
275 delete FLAT_DATA( iOriginator ); |
|
276 FLAT_DATA( iOriginator ) = 0; |
|
277 FLAT_DATA( iOriginator ) = (*aOriginator).AllocL(); |
|
278 } |
|
279 |
|
280 CMceSession::ConstructL(); |
|
281 |
|
282 delete aOriginator; |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CMceOutSession::ConstructL |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 void CMceOutSession::ConstructL( const TDesC8& aRecipient, |
|
290 const TDesC8& aOriginator, |
|
291 TUint32 aDialogId ) |
|
292 { |
|
293 User::LeaveIfError( |
|
294 aDialogId != KMceNotAssigned ? KErrNone : KErrArgument ); |
|
295 |
|
296 iFlatData = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
297 |
|
298 FLAT_DATA( iDialogId ) = aDialogId; |
|
299 |
|
300 delete FLAT_DATA( iRecipient ); |
|
301 FLAT_DATA( iRecipient ) = 0; |
|
302 FLAT_DATA( iRecipient ) = aRecipient.AllocL(); |
|
303 |
|
304 delete FLAT_DATA( iOriginator ); |
|
305 FLAT_DATA( iOriginator ) = 0; |
|
306 FLAT_DATA( iOriginator ) = aOriginator.AllocL(); |
|
307 |
|
308 CMceSession::ConstructL(); |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CMceOutSession::ConstructL |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CMceOutSession::ConstructL( const TDesC8& aRecipient, |
|
316 const TDesC8& aOriginator, |
|
317 TUint32 aIAPId, |
|
318 CDesC8Array* aContactParameters ) |
|
319 { |
|
320 iFlatData = CMceComSession::NewL( CMceComSession::EOutSession ); |
|
321 |
|
322 delete FLAT_DATA( iRecipient ); |
|
323 FLAT_DATA( iRecipient ) = 0; |
|
324 FLAT_DATA( iRecipient ) = aRecipient.AllocL(); |
|
325 |
|
326 delete FLAT_DATA( iOriginator ); |
|
327 FLAT_DATA( iOriginator ) = 0; |
|
328 FLAT_DATA( iOriginator ) = aOriginator.AllocL(); |
|
329 |
|
330 FLAT_DATA( iIapId ) = aIAPId; |
|
331 |
|
332 CMceSession::ConstructL(); |
|
333 |
|
334 delete aContactParameters; |
|
335 } |