|
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 "mcemanager.h" |
|
22 #include "mceinsession.h" |
|
23 #include "mcemediastream.h" |
|
24 #include "mceaudiocodec.h" |
|
25 #include "mcesessionreceiver.h" |
|
26 #include "mcetransactionobserver.h" |
|
27 #include "mce.h" |
|
28 #include "mceserial.h" |
|
29 #include "mceclilogs.h" |
|
30 |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMceSessionReceiver::CMceSessionReceiver |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CMceSessionReceiver::CMceSessionReceiver( RMce& aMce, |
|
37 CMceSession& aSession ) |
|
38 : CMceItcReceiverBase( aMce ), |
|
39 iSession( &aSession ) |
|
40 { |
|
41 iIdsPckg().iAppUID = aSession.Manager().AppUid().iUid; |
|
42 iIdsPckg().iManagerType = KMceCSSIPSession; |
|
43 iIdsPckg().iSessionID = aSession.Id(); |
|
44 |
|
45 Init(); |
|
46 |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CMceSessionReceiver::~CMceSessionReceiver |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CMceSessionReceiver::~CMceSessionReceiver () |
|
54 { |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMceSessionReceiver::IncomingEventL |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CMceSessionReceiver::IncomingEventL( TMceItcCallBack aEvent, TMceIds& aIds, |
|
62 const TDesC8& aContext ) |
|
63 { |
|
64 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, Entry"); |
|
65 MCECLI_DEBUG_DVALUE("context size", aContext.Length() ); |
|
66 |
|
67 switch ( aEvent ) |
|
68 { |
|
69 case EMceItcIncomingUpdate: |
|
70 { |
|
71 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, incoming update. \ |
|
72 creating new in-session"); |
|
73 |
|
74 RDesReadStream readStream( aContext ); |
|
75 CleanupClosePushL( readStream ); |
|
76 |
|
77 CMceManager& manager = iSession->Manager(); |
|
78 CMceInSession* session = |
|
79 CMceInSession::NewL( readStream, manager, aIds.iProfileID, ETrue ); |
|
80 |
|
81 CleanupStack::PopAndDestroy();//readStream |
|
82 CleanupStack::PushL( session ); |
|
83 |
|
84 iSession->IncomingUpdateL( session, NULL ); |
|
85 |
|
86 CleanupStack::Pop( session ); |
|
87 |
|
88 break; |
|
89 } |
|
90 case EMceItcStateChanged: |
|
91 case EMceItcUpdateFailed: |
|
92 case EMceItcResponseReceived: |
|
93 case EMceItcRequestReceived : |
|
94 { |
|
95 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, incoming event. \ |
|
96 passing to session"); |
|
97 CMceMsgBase* message = DecodeMessageLC( aIds, aContext ); |
|
98 User::LeaveIfError( message ? KErrNone : KErrGeneral ); |
|
99 message->PushL(); |
|
100 |
|
101 iSession->EventReceivedL( aIds, *message ); |
|
102 |
|
103 CleanupStack::PopAndDestroy( message ); |
|
104 |
|
105 break; |
|
106 } |
|
107 case EMceItcFCMsgReceived: |
|
108 { |
|
109 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, incoming FC event. \ |
|
110 passing to FC session"); |
|
111 |
|
112 HBufC8* fcMessage = aContext.AllocL(); |
|
113 iSession->FCMessageReceived( fcMessage ); |
|
114 |
|
115 break; |
|
116 } |
|
117 //no context expected |
|
118 case EMceItcSRReceived: |
|
119 case EMceItcRRReceived: |
|
120 case EMceItcInactivityTimeout: |
|
121 case EMceItcSessionConnectionStateChanged: |
|
122 default: |
|
123 { |
|
124 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, not supported"); |
|
125 User::Leave( KErrNotSupported ); |
|
126 } |
|
127 } |
|
128 |
|
129 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, Exit"); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CMceSessionReceiver::IncomingEventL |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CMceSessionReceiver::IncomingEventL( TMceItcCallBack aEvent, TMceIds& aIds, |
|
138 const TDesC8& aContext, |
|
139 HBufC8* aContent ) |
|
140 { |
|
141 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, Entry"); |
|
142 MCECLI_DEBUG_DVALUE("context size", aContext.Length() ); |
|
143 MCECLI_DEBUG_DVALUE("content size", aContent ? aContent->Length() : 0 ); |
|
144 |
|
145 switch ( aEvent ) |
|
146 { |
|
147 case EMceItcIncomingUpdate: |
|
148 { |
|
149 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, incoming update. \ |
|
150 creating new in-session"); |
|
151 |
|
152 RDesReadStream readStream( aContext ); |
|
153 CleanupClosePushL( readStream ); |
|
154 |
|
155 CMceManager& manager = iSession->Manager(); |
|
156 CMceInSession* session = |
|
157 CMceInSession::NewL( readStream, manager, aIds.iProfileID, ETrue ); |
|
158 |
|
159 CleanupStack::PopAndDestroy();//readStream |
|
160 CleanupStack::PushL( session ); |
|
161 |
|
162 iSession->IncomingUpdateL( session, aContent ); |
|
163 |
|
164 CleanupStack::Pop( session ); |
|
165 |
|
166 break; |
|
167 } |
|
168 case EMceItcStateChanged: |
|
169 case EMceItcUpdateFailed: |
|
170 case EMceItcResponseReceived: |
|
171 case EMceItcRequestReceived: |
|
172 { |
|
173 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, incoming event. \ |
|
174 passing to session"); |
|
175 |
|
176 CMceMsgBase* message = DecodeMessageLC( aIds, aContext ); |
|
177 User::LeaveIfError( message ? KErrNone : KErrGeneral ); |
|
178 message->PushL(); |
|
179 |
|
180 iSession->EventReceivedL( aIds, *message, aContent ); |
|
181 |
|
182 CleanupStack::PopAndDestroy( message ); |
|
183 break; |
|
184 } |
|
185 //no content expected |
|
186 case EMceItcSRReceived: |
|
187 case EMceItcRRReceived: |
|
188 case EMceItcInactivityTimeout: |
|
189 case EMceItcSessionConnectionStateChanged: |
|
190 default: |
|
191 { |
|
192 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, not supported"); |
|
193 User::Leave( KErrNotSupported ); |
|
194 } |
|
195 } |
|
196 |
|
197 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, Exit"); |
|
198 |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CMceSessionReceiver::IncomingEventL |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CMceSessionReceiver::IncomingEventL( TMceItcCallBack aEvent, TMceIds& aIds ) |
|
207 { |
|
208 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, Entry"); |
|
209 |
|
210 if ( aEvent == EMceItcFCErrorReceived ) |
|
211 { |
|
212 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, FC error occured"); |
|
213 iSession->FCErrorOccurred( aIds.iStatus ); |
|
214 } |
|
215 else |
|
216 { |
|
217 MCECLI_DEBUG("CMceSessionReceiver::IncomingEventL, incoming event. \ |
|
218 passing to session"); |
|
219 iSession->EventReceivedL( aIds ); |
|
220 } |
|
221 } |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CMceSessionReceiver::ErrorOccuredL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CMceSessionReceiver::ErrorOccuredL (TMceIds& aIds, TInt aError ) |
|
229 { |
|
230 MCECLI_DEBUG("CMceSessionReceiver::ErrorOccuredL, Entry"); |
|
231 MCECLI_DEBUG_DVALUE("error", aError ); |
|
232 |
|
233 if ( aIds.iTransactionID != KMceNotAssigned ) |
|
234 |
|
235 { |
|
236 MCECLI_DEBUG("Handling Extension Requests Error"); |
|
237 |
|
238 MMceTransactionObserver* observer = iSession->Manager().TransactionObserver(); |
|
239 |
|
240 if ( observer ) |
|
241 { |
|
242 observer->TransactionFailed( *iSession, aIds.iTransactionID, aError ); |
|
243 } |
|
244 } |
|
245 |
|
246 else |
|
247 { |
|
248 iSession->ErrorOccuredL( aError ); |
|
249 } |
|
250 |
|
251 |
|
252 |
|
253 MCECLI_DEBUG("CMceSessionReceiver::ErrorOccuredL, Exit"); |
|
254 |
|
255 } |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CMceSessionReceiver::DecodeMessageL |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 CMceMsgBase* CMceSessionReceiver::DecodeMessageLC( TMceIds& aIds, |
|
265 const TDesC8& aContext ) |
|
266 { |
|
267 |
|
268 RDesReadStream readStream( aContext ); |
|
269 CleanupClosePushL( readStream ); |
|
270 |
|
271 CMceMsgBase* message = TMceFactory().CreateL( (TMceItcDataType)aIds.iMsgType, |
|
272 readStream ); |
|
273 CleanupStack::PopAndDestroy(); // readStream |
|
274 |
|
275 CleanupStack::PushL( message ); |
|
276 |
|
277 return message; |
|
278 |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CMceSessionReceiver::ReplaceSession |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 void CMceSessionReceiver::ReplaceSession( CMceSession& aNewSession ) |
|
286 { |
|
287 iSession = &aNewSession; |
|
288 } |