|
1 /* |
|
2 * Copyright (c) 2004 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 "mceinsessionobserver.h" |
|
22 #include "mcemanager.h" |
|
23 #include "mceinsession.h" |
|
24 #include "mcetransactiondatacontainer.h" |
|
25 #include "mcemanagerreceiver.h" |
|
26 #include "mce.h" |
|
27 #include "mcecomsession.h" |
|
28 #include "mceserial.h" |
|
29 #include "mceclilogs.h" |
|
30 #include "mcesecureinsession.h" |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CMceManagerReceiver::CMceManagerReceiver |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CMceManagerReceiver::CMceManagerReceiver( RMce& aMce, |
|
37 CMceManager& aManager ) |
|
38 : CMceItcReceiverBase ( aMce ), |
|
39 iManager( aManager ) |
|
40 { |
|
41 iIdsPckg().iAppUID = aManager.AppUid().iUid; |
|
42 iIdsPckg().iManagerType = KMceCSSIPSession; |
|
43 |
|
44 Init(); |
|
45 |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMceManagerReceiver::~CMceManagerReceiver |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMceManagerReceiver::~CMceManagerReceiver () |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CMceManagerReceiver::IncomingEventL |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CMceManagerReceiver::IncomingEventL( TMceItcCallBack aEvent, |
|
61 TMceIds& aIds, |
|
62 const TDesC8& aContext ) |
|
63 { |
|
64 |
|
65 MCECLI_DEBUG("CMceManagerReceiver::IncomingEventL, Entry"); |
|
66 MCECLI_DEBUG_DVALUE("context size", aContext.Length() ); |
|
67 |
|
68 __ASSERT_ALWAYS( aEvent == EMceItcObjectAdded , |
|
69 User::Leave( KErrNotSupported ) ); |
|
70 __ASSERT_ALWAYS( aIds.iMsgType == EMceItcMsgTypeSession , |
|
71 User::Leave( KErrNotSupported ) ); |
|
72 |
|
73 HandleIncomingSessionL( aContext, NULL, aIds ); |
|
74 |
|
75 MCECLI_DEBUG("CMceManagerReceiver::IncomingEventL, Exit"); |
|
76 |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CMceManagerReceiver::IncomingEventL |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CMceManagerReceiver::IncomingEventL( TMceItcCallBack aEvent, |
|
85 TMceIds& aIds, |
|
86 const TDesC8& aContext, |
|
87 HBufC8* aContent ) |
|
88 { |
|
89 MCECLI_DEBUG("CMceManagerReceiver::IncomingEventL, Entry"); |
|
90 MCECLI_DEBUG_DVALUE("context size", aContext.Length() ); |
|
91 MCECLI_DEBUG_DVALUE("content size", aContent ? aContent->Length() : 0 ); |
|
92 |
|
93 __ASSERT_ALWAYS( aEvent == EMceItcObjectAdded , |
|
94 User::Leave( KErrNotSupported ) ); |
|
95 __ASSERT_ALWAYS( aIds.iMsgType == EMceItcMsgTypeSession , |
|
96 User::Leave( KErrNotSupported ) ); |
|
97 |
|
98 HandleIncomingSessionL( aContext, aContent, aIds ); |
|
99 |
|
100 MCECLI_DEBUG("CMceManagerReceiver::IncomingEventL, Exit"); |
|
101 |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CMceManagerReceiver::IncomingEventL |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CMceManagerReceiver::IncomingEventL( TMceItcCallBack /*aEvent*/, |
|
109 TMceIds& aIds ) |
|
110 { |
|
111 MCECLI_DEBUG("CMceManagerReceiver::IncomingEventL, Entry"); |
|
112 iManager.HandleIncomingEventL( aIds ); |
|
113 MCECLI_DEBUG("CMceManagerReceiver::IncomingEventL, Exit"); |
|
114 } |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CMceManagerReceiver::ErrorOccuredL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CMceManagerReceiver::ErrorOccuredL (TMceIds& /*aIds*/, TInt aError ) |
|
122 { |
|
123 MCECLI_DEBUG_DVALUE("CMceManagerReceiver::ErrorOccuredL, error", aError ); |
|
124 User::Leave( aError ); |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CMceManagerReceiver::HandleIncomingSessionL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CMceManagerReceiver::HandleIncomingSessionL ( const TDesC8& aContext, |
|
133 HBufC8* aContent, |
|
134 TMceIds& aIds ) |
|
135 { |
|
136 MCECLI_DEBUG("CMceManagerReceiver::HandleIncomingSessionL, Entry"); |
|
137 |
|
138 if ( iManager.InSessionObserver() ) |
|
139 { |
|
140 CMceInSession* session = NULL; |
|
141 |
|
142 RDesReadStream readStream( aContext ); |
|
143 CleanupClosePushL( readStream ); |
|
144 |
|
145 MCECLI_DEBUG("CMceManagerReceiver::HandleIncomingSessionL, creating new session"); |
|
146 |
|
147 if (aIds.iSecureFlag) |
|
148 { |
|
149 session = CMceSecureInSession::NewL( readStream, iManager, aIds.iProfileID ); |
|
150 } |
|
151 else |
|
152 { |
|
153 session = CMceInSession::NewL( readStream, iManager, aIds.iProfileID ); |
|
154 } |
|
155 |
|
156 |
|
157 CleanupStack::PopAndDestroy();//readStream |
|
158 CleanupStack::PushL( session ); |
|
159 CDesC8Array* headers = NULL; |
|
160 HBufC8* contentType = NULL; |
|
161 CDesC8Array* contentHeaders = NULL; |
|
162 session->GetSIPParams( headers, contentType, contentHeaders ); |
|
163 |
|
164 TInt pushs = 0; |
|
165 |
|
166 if ( headers ) |
|
167 { |
|
168 CleanupStack::PushL( headers );++pushs; |
|
169 } |
|
170 if ( contentType ) |
|
171 { |
|
172 CleanupStack::PushL( contentType );++pushs; |
|
173 } |
|
174 if ( contentHeaders ) |
|
175 { |
|
176 CleanupStack::PushL( contentHeaders );++pushs; |
|
177 } |
|
178 |
|
179 |
|
180 TMceTransactionDataContainer* container = |
|
181 iManager.TransactionContainer(); |
|
182 |
|
183 if ( container ) |
|
184 { |
|
185 container->SetHeaders( headers ); |
|
186 container->SetContentType( contentType ); |
|
187 container->SetContent( aContent ); |
|
188 container->SetContentHeaders( contentHeaders ); |
|
189 iManager.InSessionObserver()->IncomingSession( session, |
|
190 container ); |
|
191 CleanupStack::Pop( pushs ); |
|
192 } |
|
193 else |
|
194 { |
|
195 CleanupStack::PopAndDestroy( pushs ); |
|
196 iManager.InSessionObserver()->IncomingSession( session, |
|
197 container ); |
|
198 } |
|
199 |
|
200 CleanupStack::Pop( session ); |
|
201 |
|
202 if (container) |
|
203 { |
|
204 container->Clear(); |
|
205 } |
|
206 } |
|
207 else |
|
208 { |
|
209 delete aContent; |
|
210 } |
|
211 |
|
212 MCECLI_DEBUG("CMceManagerReceiver::HandleIncomingSessionL, Exit"); |
|
213 |
|
214 } |
|
215 |