|
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 "mcesession.h" |
|
22 #include "mceitcsender.h" |
|
23 #include "mceitc.h" |
|
24 #include "mcecomsession.h" |
|
25 #include "mceserial.h" |
|
26 #include "mceclilogs.h" |
|
27 |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMceItcSender::NewL |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CMceItcSender* CMceItcSender::NewL ( MMceItc& aITC ) |
|
34 { |
|
35 CMceItcSender* self = CMceItcSender::NewLC( aITC ); |
|
36 CleanupStack::Pop (self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CMceItcSender::NewLC |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CMceItcSender* CMceItcSender::NewLC ( MMceItc& aITC ) |
|
45 { |
|
46 CMceItcSender* self = new (ELeave) CMceItcSender( aITC ); |
|
47 CleanupStack::PushL( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CMceItcSender::CMceItcSender |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CMceItcSender::CMceItcSender ( MMceItc& aITC ) |
|
57 : iITC ( aITC ), |
|
58 iEmptyBody ( KNullDesC8 ) |
|
59 { |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CMceItcSender::~CMceItcSender |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CMceItcSender::~CMceItcSender () |
|
67 { |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CMceItcSender::Send |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 TInt CMceItcSender::Send(TMceIds& aIds, TMceItcFunctions aITCFunction) |
|
76 { |
|
77 |
|
78 TPckgBuf<TMceIds> mceIdsPckg( aIds ); |
|
79 iITCMsgArgs.Set( EMceItcArgIds, &mceIdsPckg ); |
|
80 |
|
81 TInt err = iITC.Send( aITCFunction, iITCMsgArgs ); |
|
82 aIds = mceIdsPckg(); |
|
83 return err; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMceItcSender::SendL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CMceItcSender::SendL( TMceIds& aIds, TMceItcFunctions aITCFunction ) |
|
91 { |
|
92 MCECLI_DEBUG("CMceItcSender::SendL, Entry"); |
|
93 MCECLI_DEBUG_ITC( "ITC", aITCFunction ); |
|
94 MCECLI_DEBUG_IDS( "IDS", aIds ); |
|
95 |
|
96 TInt err = Send( aIds, aITCFunction ); |
|
97 if ( err != KErrNone ) |
|
98 { |
|
99 MCECLI_DEBUG_DVALUE("CMceItcSender::SendL, Exit. error", err ); |
|
100 User::Leave( err ); |
|
101 } |
|
102 |
|
103 MCECLI_DEBUG("CMceItcSender::SendL, Exit"); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMceItcSender::SendL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CMceItcSender::SendL( TMceIds& aIds, |
|
111 TMceItcFunctions aITCFunction, |
|
112 CMceMsgBase& aMessage, |
|
113 HBufC8* aBody, |
|
114 TBool aTakeOwnershipOfBody ) |
|
115 { |
|
116 MCECLI_DEBUG("CMceItcSender::SendL(message,body), Entry"); |
|
117 |
|
118 aMessage.EncodeL(); |
|
119 TPtr8 externalizedMessage = aMessage.EncodeBuffer().Ptr(0); |
|
120 |
|
121 Mem::FillZ( &iITCMsgArgs, sizeof( iITCMsgArgs ) ); |
|
122 aIds.iMsgType = aMessage.Type(); |
|
123 |
|
124 iITCMsgArgs.Set( EMceItcArgContext, &externalizedMessage ); |
|
125 |
|
126 if ( aBody ) |
|
127 { |
|
128 iITCMsgArgs.Set( EMceItcArgMessageContent, aBody ); |
|
129 } |
|
130 else |
|
131 { |
|
132 iITCMsgArgs.Set( EMceItcArgMessageContent, &iEmptyBody ); |
|
133 } |
|
134 SendL( aIds, aITCFunction ); |
|
135 if ( aTakeOwnershipOfBody ) |
|
136 { |
|
137 delete aBody; |
|
138 } |
|
139 |
|
140 MCECLI_DEBUG("CMceItcSender::SendL(message,body), Exit"); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CMceItcSender::SendL |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CMceItcSender::SendL( TMceIds& aIds, |
|
148 TMceItcFunctions aITCFunction, |
|
149 TUint32& aData ) |
|
150 { |
|
151 MCECLI_DEBUG("CMceItcSender::SendL(TUin32), Entry"); |
|
152 |
|
153 Mem::FillZ( &iITCMsgArgs, sizeof( iITCMsgArgs ) ); |
|
154 TPckgBuf<TUint32> mceDataPckg( aData ); |
|
155 |
|
156 iITCMsgArgs.Set( EMceItcArgId, &mceDataPckg ); |
|
157 |
|
158 SendL( aIds, aITCFunction ); |
|
159 |
|
160 MCECLI_DEBUG("CMceItcSender::SendL(TUin32), Exit"); |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CMceItcSender::WriteL |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void CMceItcSender::WriteL( TMceIds& aIds, |
|
168 TMceItcFunctions aITCFunction, |
|
169 const TDesC8& aData ) |
|
170 { |
|
171 MCECLI_DEBUG("CMceItcSender::WriteL, Entry"); |
|
172 |
|
173 Mem::FillZ( &iITCMsgArgs, sizeof( iITCMsgArgs ) ); |
|
174 aIds.iMsgType = EMceItcMsgTypeWriteString; |
|
175 |
|
176 iITCMsgArgs.Set( EMceItcArgContext, &aData ); |
|
177 |
|
178 SendL( aIds, aITCFunction ); |
|
179 |
|
180 MCECLI_DEBUG("CMceItcSender::WriteL, Exit"); |
|
181 } |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CMceItcSender::ReadL |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CMceItcSender::ReadL( TMceIds& aIds, |
|
189 TMceItcFunctions aITCFunction, |
|
190 TDes8& aData ) |
|
191 { |
|
192 MCECLI_DEBUG("CMceItcSender::ReadL, Entry"); |
|
193 Mem::FillZ( &iITCMsgArgs, sizeof( iITCMsgArgs ) ); |
|
194 aIds.iMsgType = EMceItcMsgTypeReadString; |
|
195 |
|
196 iITCMsgArgs.Set( EMceItcArgContext, &aData ); |
|
197 |
|
198 SendL( aIds, aITCFunction ); |
|
199 |
|
200 MCECLI_DEBUG("CMceItcSender::ReadL, Exit"); |
|
201 } |
|
202 |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CMceItcSender::ReadArrayL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 CDesC8Array* CMceItcSender::ReadArrayL(TMceIds& aIds, |
|
209 TMceItcFunctions aITCFunction ) |
|
210 { |
|
211 MCECLI_DEBUG("CMceItcSender::ReadArrayL, Entry"); |
|
212 |
|
213 Mem::FillZ(&iITCMsgArgs, sizeof(iITCMsgArgs)); |
|
214 aIds.iMsgType = KMceNotAssigned; |
|
215 |
|
216 CMceMsgTextArray* textArray = new (ELeave) CMceMsgTextArray(); |
|
217 CleanupStack::PushL( textArray ); |
|
218 |
|
219 HBufC8* arrayBuf = HBufC8::NewLC( KMceMaxSizeInReadStream ); |
|
220 TPtr8 arrayBufPtr = arrayBuf->Des(); |
|
221 iITCMsgArgs.Set (EMceItcArgContext, &arrayBufPtr); |
|
222 SendL (aIds,aITCFunction); |
|
223 |
|
224 textArray->DecodeL( *arrayBuf ); |
|
225 |
|
226 CDesC8Array* array = textArray->iArray; |
|
227 |
|
228 CleanupStack::PopAndDestroy(arrayBuf);//arrayBuf |
|
229 CleanupStack::PopAndDestroy( textArray );//textArray |
|
230 |
|
231 MCECLI_DEBUG("CMceItcSender::ReadArrayL, Exit"); |
|
232 return array; |
|
233 |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CMceItcSender::ReadArrayL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 CDesC8Array* CMceItcSender::ReadArrayL( TMceIds& aIds, |
|
241 TMceItcFunctions aITCFunction, |
|
242 const TDesC8& aData ) |
|
243 { |
|
244 MCECLI_DEBUG("CMceItcSender::ReadArrayL(inout), Entry"); |
|
245 |
|
246 Mem::FillZ( &iITCMsgArgs, sizeof( iITCMsgArgs ) ); |
|
247 aIds.iMsgType = KMceNotAssigned; |
|
248 |
|
249 CMceMsgTextArray* textArray = new (ELeave) CMceMsgTextArray(); |
|
250 CleanupStack::PushL( textArray ); |
|
251 |
|
252 HBufC8* arrayBuf = HBufC8::NewLC( KMceMaxSizeInReadStream ); |
|
253 TPtr8 arrayBufPtr = arrayBuf->Des(); |
|
254 arrayBufPtr.Copy( aData ); |
|
255 iITCMsgArgs.Set ( EMceItcArgContext, &arrayBufPtr ); |
|
256 SendL ( aIds, aITCFunction ); |
|
257 |
|
258 textArray->DecodeL( *arrayBuf ); |
|
259 |
|
260 CDesC8Array* array = textArray->iArray; |
|
261 |
|
262 CleanupStack::PopAndDestroy( arrayBuf );//arrayBuf |
|
263 CleanupStack::PopAndDestroy( textArray );//textArray |
|
264 |
|
265 MCECLI_DEBUG("CMceItcSender::ReadArrayL(inout), Exit"); |
|
266 return array; |
|
267 |
|
268 } |
|
269 |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CMceItcSender::ReadStringL |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 HBufC8* CMceItcSender::ReadStringL(TMceIds& aIds, |
|
276 TMceItcFunctions aITCFunction ) |
|
277 { |
|
278 |
|
279 MCECLI_DEBUG("CMceItcSender::ReadStringL, Entry"); |
|
280 |
|
281 Mem::FillZ(&iITCMsgArgs, sizeof(iITCMsgArgs)); |
|
282 aIds.iMsgType = KMceNotAssigned; |
|
283 |
|
284 |
|
285 HBufC8* string = HBufC8::NewLC( KMceMaxSizeInSessionAsDesc ); |
|
286 TPtr8 stringPtr = string->Des(); |
|
287 iITCMsgArgs.Set (EMceItcArgContext, &stringPtr); |
|
288 SendL (aIds,aITCFunction); |
|
289 |
|
290 CleanupStack::Pop( string ); |
|
291 |
|
292 MCECLI_DEBUG("CMceItcSender::ReadStringL, Exit"); |
|
293 return string; |
|
294 |
|
295 } |
|
296 |
|
297 |
|
298 |