|
1 /* |
|
2 * Copyright (c) 2009-2010 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 * Client side IPC handling for Connection Method Manager server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <cmmanagerdef.h> |
|
21 |
|
22 #include "cmmserverdefs.h" |
|
23 #include "cmmanagerapi.h" |
|
24 #include "cmdestinationwrapper.h" |
|
25 #include "cmconnectionmethodwrapper.h" |
|
26 #include "cmmclistatic.h" |
|
27 |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "cmmanagerapiTraces.h" |
|
31 #endif |
|
32 |
|
33 |
|
34 RCmManagerApi::RCmManagerApi() : RSessionBase() |
|
35 { |
|
36 OstTraceFunctionEntry0( RCMMANAGERAPI_RCMMANAGERAPI_ENTRY ); |
|
37 |
|
38 iConnected = EFalse; |
|
39 iSmallBufsForDestinations = ETrue; |
|
40 iSmallBufsForConnMethods = ETrue; |
|
41 |
|
42 OstTraceFunctionExit0( RCMMANAGERAPI_RCMMANAGERAPI_EXIT ); |
|
43 } |
|
44 |
|
45 //----------------------------------------------------------------------------- |
|
46 // RCmManagerApi::Connect() |
|
47 //----------------------------------------------------------------------------- |
|
48 // |
|
49 TInt RCmManagerApi::Connect() |
|
50 { |
|
51 OstTraceFunctionEntry0( RCMMANAGERAPI_CONNECT_ENTRY ); |
|
52 |
|
53 if ( !iConnected ) |
|
54 { |
|
55 TInt retry = 2; |
|
56 for (;;) |
|
57 { |
|
58 TInt err = CreateSession( KCmmServer, TVersion( 0, 0, 0 ), KCmmDefaultMessageSlots ); |
|
59 |
|
60 if ( err != KErrNotFound && err != KErrServerTerminated ) |
|
61 { |
|
62 if ( !err ) |
|
63 { |
|
64 iConnected = ETrue; |
|
65 } |
|
66 OstTraceFunctionExit0( RCMMANAGERAPI_CONNECT_EXIT ); |
|
67 return err; |
|
68 } |
|
69 // KErrNotFound and KErrServerTerminated will go through. |
|
70 if ( --retry <= 0 ) |
|
71 { |
|
72 OstTraceFunctionExit0( DUP1_RCMMANAGERAPI_CONNECT_EXIT ); |
|
73 return err; |
|
74 } |
|
75 err = TCmManagerLauncher::LaunchServer( |
|
76 KCmmServer, |
|
77 KCmmServerFile, |
|
78 KCmmUid3, |
|
79 KCmmServerInitHeapSize, |
|
80 KCmmServerMaxHeapSize, |
|
81 KCmmServerStackSize ); |
|
82 |
|
83 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
84 { |
|
85 // Failed to launch server, and it wasn't already running. |
|
86 OstTraceFunctionExit0( DUP2_RCMMANAGERAPI_CONNECT_EXIT ); |
|
87 return err; |
|
88 } |
|
89 } |
|
90 } |
|
91 |
|
92 OstTraceFunctionExit0( DUP3_RCMMANAGERAPI_CONNECT_EXIT ); |
|
93 return KErrNone; |
|
94 } |
|
95 |
|
96 //----------------------------------------------------------------------------- |
|
97 // RCmManagerApi::Close() |
|
98 //----------------------------------------------------------------------------- |
|
99 // |
|
100 void RCmManagerApi::Close() |
|
101 { |
|
102 OstTraceFunctionEntry0( RCMMANAGERAPI_CLOSE_ENTRY ); |
|
103 |
|
104 if ( iConnected ) |
|
105 { |
|
106 // Close all subsessions first. |
|
107 // |
|
108 // Don't call subsession destructors (wrappers), since they will try to |
|
109 // remove themselves from these pointer arrays. Here we can just close |
|
110 // the arrays at the end. |
|
111 for ( TInt i = 0; i < iConnMethods.Count(); i++ ) |
|
112 { |
|
113 iConnMethods[i]->CloseSession(); |
|
114 } |
|
115 iConnMethods.Close(); |
|
116 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
117 { |
|
118 iDestinations[i]->CloseSession(); |
|
119 } |
|
120 iDestinations.Close(); |
|
121 |
|
122 RSessionBase::Close(); |
|
123 iConnected = EFalse; |
|
124 } |
|
125 |
|
126 OstTraceFunctionExit0( RCMMANAGERAPI_CLOSE_EXIT ); |
|
127 } |
|
128 |
|
129 //----------------------------------------------------------------------------- |
|
130 // RCmManagerApi::StoreDestinationWrapper() |
|
131 //----------------------------------------------------------------------------- |
|
132 // |
|
133 TInt RCmManagerApi::StoreDestinationWrapper( |
|
134 CCmDestinationWrapper* aDestinationWrapper ) |
|
135 { |
|
136 OstTraceFunctionEntry0( RCMMANAGERAPI_STOREDESTINATIONWRAPPER_ENTRY ); |
|
137 |
|
138 TInt err = iDestinations.InsertInAddressOrder( aDestinationWrapper ); |
|
139 |
|
140 OstTraceFunctionExit0( RCMMANAGERAPI_STOREDESTINATIONWRAPPER_EXIT ); |
|
141 return err; |
|
142 } |
|
143 |
|
144 //----------------------------------------------------------------------------- |
|
145 // RCmManagerApi::RemoveDestinationWrapper() |
|
146 //----------------------------------------------------------------------------- |
|
147 // |
|
148 TInt RCmManagerApi::RemoveDestinationWrapper( |
|
149 CCmDestinationWrapper* aDestinationWrapper ) |
|
150 { |
|
151 OstTraceFunctionEntry0( RCMMANAGERAPI_REMOVEDESTINATIONPOINTER_ENTRY ); |
|
152 |
|
153 TInt index = iDestinations.FindInAddressOrder( aDestinationWrapper ); |
|
154 if ( index >= 0 ) |
|
155 { |
|
156 iDestinations.Remove( index ); |
|
157 index = KErrNone; |
|
158 } |
|
159 |
|
160 OstTraceFunctionExit0( RCMMANAGERAPI_REMOVEDESTINATIONPOINTER_EXIT ); |
|
161 return index; |
|
162 } |
|
163 |
|
164 //----------------------------------------------------------------------------- |
|
165 // RCmManagerApi::GetDestinationWrapperL() |
|
166 //----------------------------------------------------------------------------- |
|
167 // |
|
168 CCmDestinationWrapper* RCmManagerApi::GetDestinationWrapperL( const TInt& aHandle ) |
|
169 { |
|
170 OstTraceFunctionEntry0( RCMMANAGERAPI_GETDESTINATIONWRAPPER_ENTRY ); |
|
171 |
|
172 CCmDestinationWrapper* result( NULL ); |
|
173 if ( aHandle ) |
|
174 { |
|
175 for ( TInt i = 0; i < iDestinations.Count(); i++ ) |
|
176 { |
|
177 if ( iDestinations[i]->GetHandle() == aHandle ) |
|
178 { |
|
179 result = iDestinations[i]; |
|
180 break; |
|
181 } |
|
182 } |
|
183 } |
|
184 if ( !result ) |
|
185 { |
|
186 User::Leave( KErrCorrupt ); |
|
187 } |
|
188 |
|
189 OstTraceFunctionExit0( RCMMANAGERAPI_GETDESTINATIONWRAPPER_EXIT ); |
|
190 return result; |
|
191 } |
|
192 |
|
193 //----------------------------------------------------------------------------- |
|
194 // RCmManagerApi::StoreConnMethodWrapper() |
|
195 //----------------------------------------------------------------------------- |
|
196 // |
|
197 TInt RCmManagerApi::StoreConnMethodWrapper( |
|
198 CCmConnectionMethodWrapper* aConnMethodWrapper ) |
|
199 { |
|
200 OstTraceFunctionEntry0( RCMMANAGERAPI_STORECONNMETHODWRAPPER_ENTRY ); |
|
201 |
|
202 TInt err = iConnMethods.InsertInAddressOrder( aConnMethodWrapper ); |
|
203 |
|
204 OstTraceFunctionExit0( RCMMANAGERAPI_STORECONNMETHODWRAPPER_EXIT ); |
|
205 return err; |
|
206 } |
|
207 |
|
208 //----------------------------------------------------------------------------- |
|
209 // RCmManagerApi::RemoveConnMethodWrapper() |
|
210 //----------------------------------------------------------------------------- |
|
211 // |
|
212 TInt RCmManagerApi::RemoveConnMethodWrapper( |
|
213 CCmConnectionMethodWrapper* aConnMethodWrapper ) |
|
214 { |
|
215 OstTraceFunctionEntry0( RCMMANAGERAPI_REMOVECONNMETHODPOINTER_ENTRY ); |
|
216 |
|
217 TInt index = iConnMethods.FindInAddressOrder( aConnMethodWrapper ); |
|
218 if ( index >= 0 ) |
|
219 { |
|
220 iConnMethods.Remove( index ); |
|
221 index = KErrNone; |
|
222 } |
|
223 |
|
224 OstTraceFunctionExit0( RCMMANAGERAPI_REMOVECONNMETHODPOINTER_EXIT ); |
|
225 return index; |
|
226 } |
|
227 |
|
228 //----------------------------------------------------------------------------- |
|
229 // RCmManagerApi::GetConnMethodWrapperL() |
|
230 //----------------------------------------------------------------------------- |
|
231 // |
|
232 CCmConnectionMethodWrapper* RCmManagerApi::GetConnMethodWrapperL( const TInt& aHandle ) |
|
233 { |
|
234 OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNMETHODWRAPPER_ENTRY ); |
|
235 |
|
236 CCmConnectionMethodWrapper* result( NULL ); |
|
237 if ( aHandle ) |
|
238 { |
|
239 for ( TInt i = 0; i < iConnMethods.Count(); i++ ) |
|
240 { |
|
241 if ( iConnMethods[i]->GetHandle() == aHandle ) |
|
242 { |
|
243 result = iConnMethods[i]; |
|
244 break; |
|
245 } |
|
246 } |
|
247 } |
|
248 if ( !result ) |
|
249 { |
|
250 User::Leave( KErrCorrupt ); |
|
251 } |
|
252 |
|
253 OstTraceFunctionExit0( RCMMANAGERAPI_GETCONNMETHODWRAPPER_EXIT ); |
|
254 return result; |
|
255 } |
|
256 |
|
257 //----------------------------------------------------------------------------- |
|
258 // RCmManagerApi::GetBearerInfoInt() |
|
259 //----------------------------------------------------------------------------- |
|
260 // |
|
261 TInt RCmManagerApi::GetBearerInfoInt( |
|
262 const TUint32 aBearerType, |
|
263 const TUint32 aAttribute, |
|
264 TUint32& aValue ) |
|
265 { |
|
266 OstTraceFunctionEntry0( RCMMANAGERAPI_GETBEARERINFOINT_ENTRY ); |
|
267 |
|
268 TPckg<TUint32> pckg( aValue ); |
|
269 TIpcArgs args( aBearerType, aAttribute, &pckg ); |
|
270 TInt err = SendReceive( ECmmGetBearerInfoInt, args ); |
|
271 |
|
272 OstTraceFunctionExit0( RCMMANAGERAPI_GETBEARERINFOINT_EXIT ); |
|
273 return err; |
|
274 } |
|
275 |
|
276 //----------------------------------------------------------------------------- |
|
277 // RCmManagerApi::GetBearerInfoBool() |
|
278 //----------------------------------------------------------------------------- |
|
279 // |
|
280 TInt RCmManagerApi::GetBearerInfoBool( |
|
281 const TUint32 aBearerType, |
|
282 const TUint32 aAttribute, |
|
283 TBool& aValue ) |
|
284 { |
|
285 OstTraceFunctionEntry0( RCMMANAGERAPI_GETBEARERINFOBOOL_ENTRY ); |
|
286 |
|
287 TPckg<TBool> pckg( aValue ); |
|
288 TIpcArgs args( aBearerType, aAttribute, &pckg ); |
|
289 TInt err = SendReceive( ECmmGetBearerInfoBool, args ); |
|
290 |
|
291 OstTraceFunctionExit0( RCMMANAGERAPI_GETBEARERINFOBOOL_EXIT ); |
|
292 return err; |
|
293 } |
|
294 |
|
295 //----------------------------------------------------------------------------- |
|
296 // RCmManagerApi::GetBearerInfoString() |
|
297 //----------------------------------------------------------------------------- |
|
298 // |
|
299 TInt RCmManagerApi::GetBearerInfoString( |
|
300 const TUint32 aBearerType, |
|
301 const TUint32 aAttribute, |
|
302 HBufC* aBuffer ) |
|
303 { |
|
304 OstTraceFunctionEntry0( RCMMANAGERAPI_GETBEARERINFOSTRING_ENTRY ); |
|
305 |
|
306 TPtr descriptor( aBuffer->Des() ); |
|
307 TIpcArgs args( aBearerType, aAttribute, &descriptor ); |
|
308 TInt err = SendReceive( ECmmGetBearerInfoString, args ); |
|
309 |
|
310 OstTraceFunctionExit0( RCMMANAGERAPI_GETBEARERINFOSTRING_EXIT ); |
|
311 return err; |
|
312 } |
|
313 |
|
314 //----------------------------------------------------------------------------- |
|
315 // RCmManagerApi::GetBearerInfoString8() |
|
316 //----------------------------------------------------------------------------- |
|
317 // |
|
318 TInt RCmManagerApi::GetBearerInfoString8( |
|
319 const TUint32 aBearerType, |
|
320 const TUint32 aAttribute, |
|
321 HBufC8* aBuffer8 ) |
|
322 { |
|
323 OstTraceFunctionEntry0( RCMMANAGERAPI_GETBEARERINFOSTRING8_ENTRY ); |
|
324 |
|
325 TPtr8 descriptor( aBuffer8->Des() ); |
|
326 TIpcArgs args( aBearerType, aAttribute, &descriptor ); |
|
327 TInt err = SendReceive( ECmmGetBearerInfoString8, args ); |
|
328 |
|
329 OstTraceFunctionExit0( RCMMANAGERAPI_GETBEARERINFOSTRING8_EXIT ); |
|
330 return err; |
|
331 } |
|
332 |
|
333 //----------------------------------------------------------------------------- |
|
334 // RCmManagerApi::GetConnectionMethodInfoInt() |
|
335 //----------------------------------------------------------------------------- |
|
336 // |
|
337 TInt RCmManagerApi::GetConnectionMethodInfoInt( |
|
338 const TUint32 aIapId, |
|
339 const TUint32 aAttribute, |
|
340 TUint32& aValue ) |
|
341 { |
|
342 OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOINT_ENTRY ); |
|
343 |
|
344 TPckg<TUint32> pckg( aValue ); |
|
345 TIpcArgs args( aIapId, aAttribute, &pckg ); |
|
346 TInt err = SendReceive( ECmmGetConnMethodInfoInt, args ); |
|
347 |
|
348 OstTraceFunctionExit0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOINT_EXIT ); |
|
349 return err; |
|
350 } |
|
351 |
|
352 //----------------------------------------------------------------------------- |
|
353 // RCmManagerApi::GetConnectionMethodInfoBool() |
|
354 //----------------------------------------------------------------------------- |
|
355 // |
|
356 TInt RCmManagerApi::GetConnectionMethodInfoBool( |
|
357 const TUint32 aIapId, |
|
358 const TUint32 aAttribute, |
|
359 TBool& aValue ) |
|
360 { |
|
361 OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOBOOL_ENTRY ); |
|
362 |
|
363 TPckg<TUint32> pckg( aValue ); |
|
364 TIpcArgs args( aIapId, aAttribute, &pckg ); |
|
365 TInt err = SendReceive( ECmmGetConnMethodInfoBool, args ); |
|
366 |
|
367 OstTraceFunctionExit0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOBOOL_EXIT ); |
|
368 return err; |
|
369 } |
|
370 |
|
371 //----------------------------------------------------------------------------- |
|
372 // RCmManagerApi::GetConnectionMethodInfoString() |
|
373 //----------------------------------------------------------------------------- |
|
374 // |
|
375 TInt RCmManagerApi::GetConnectionMethodInfoString( |
|
376 const TUint32 aIapId, |
|
377 const TUint32 aAttribute, |
|
378 HBufC* aBuffer ) |
|
379 { |
|
380 OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOSTRING_ENTRY ); |
|
381 |
|
382 TPtr descriptor( aBuffer->Des() ); |
|
383 TIpcArgs args( aIapId, aAttribute, &descriptor ); |
|
384 TInt err = SendReceive( ECmmGetConnMethodInfoString, args ); |
|
385 |
|
386 OstTraceFunctionExit0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOSTRING_EXIT ); |
|
387 return err; |
|
388 } |
|
389 |
|
390 //----------------------------------------------------------------------------- |
|
391 // RCmManagerApi::GetConnectionMethodInfoString8() |
|
392 //----------------------------------------------------------------------------- |
|
393 // |
|
394 TInt RCmManagerApi::GetConnectionMethodInfoString8( |
|
395 const TUint32 aIapId, |
|
396 const TUint32 aAttribute, |
|
397 HBufC8* aBuffer8 ) |
|
398 { |
|
399 OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOSTRING8_ENTRY ); |
|
400 |
|
401 TPtr8 descriptor( aBuffer8->Des() ); |
|
402 TIpcArgs args( aIapId, aAttribute, &descriptor ); |
|
403 TInt err = SendReceive( ECmmGetConnMethodInfoString8, args ); |
|
404 |
|
405 OstTraceFunctionExit0( RCMMANAGERAPI_GETCONNECTIONMETHODINFOSTRING8_EXIT ); |
|
406 return err; |
|
407 } |
|
408 |
|
409 //----------------------------------------------------------------------------- |
|
410 // RCmManagerApi::GetConnMethodsL( |
|
411 //----------------------------------------------------------------------------- |
|
412 // |
|
413 void RCmManagerApi::GetConnMethodsL( |
|
414 const TCmmIpcStructGetConnMethods& aParameters, |
|
415 RArray<TUint32>& aCmArray ) |
|
416 { |
|
417 OstTraceFunctionEntry0( RCMMANAGERAPI_GETCONNMETHODSL_ENTRY ); |
|
418 |
|
419 TInt err( KErrNone ); |
|
420 TInt count( KMaxTInt ); |
|
421 TPckg<TInt> countPckg( count ); |
|
422 TPckgBuf<TCmmIpcStructGetConnMethods> parametersPckg( aParameters ); |
|
423 |
|
424 HBufC8* smallBuf( NULL ); |
|
425 HBufC8* bigBuf( NULL ); |
|
426 |
|
427 if ( iSmallBufsForConnMethods ) |
|
428 { |
|
429 smallBuf = HBufC8::NewLC( KCmmConnMethodAmountNormal ); |
|
430 TPtr8 smallBufPtr( smallBuf->Des() ); |
|
431 |
|
432 TIpcArgs args( ¶metersPckg, &countPckg, &smallBufPtr ); |
|
433 err = SendReceive( ECmmGetConnMethodArray, args ); |
|
434 User::LeaveIfError( err ); |
|
435 } |
|
436 |
|
437 if ( countPckg() <= KCmmConnMethodAmountNormal ) |
|
438 { |
|
439 aCmArray.Reset(); |
|
440 aCmArray.ReserveL( countPckg() ); |
|
441 for ( TInt i = 0; i < countPckg(); i++ ) |
|
442 { |
|
443 aCmArray.AppendL( (TUint32)(*smallBuf)[i] ); |
|
444 } |
|
445 } |
|
446 else if ( countPckg() == KMaxTInt ) |
|
447 { |
|
448 // All connection methods didn't fit into small array, ask again with big array. |
|
449 iSmallBufsForConnMethods = EFalse; // Switch small buffer mode off. |
|
450 if ( smallBuf ) |
|
451 { |
|
452 CleanupStack::PopAndDestroy( smallBuf ); |
|
453 smallBuf = NULL; |
|
454 } |
|
455 |
|
456 bigBuf = HBufC8::NewLC( KCmmConnMethodAmountMax ); |
|
457 TPtr8 bigBufPtr( bigBuf->Des() ); |
|
458 |
|
459 TIpcArgs args( ¶metersPckg, &countPckg, &bigBufPtr ); |
|
460 err = SendReceive( ECmmGetConnMethodArray, args ); |
|
461 User::LeaveIfError( err ); |
|
462 |
|
463 if ( countPckg() <= KCmmConnMethodAmountMax ) |
|
464 { |
|
465 // Don't switch back to small buffer mode if client was only asking |
|
466 // for legacy connection methods (likely a small list). |
|
467 if ( countPckg() < KCmmConnMethodAmountNormal && aParameters.iLegacyOnly == EFalse ) |
|
468 { |
|
469 iSmallBufsForConnMethods = ETrue; // Switch small buffer mode back on. |
|
470 } |
|
471 |
|
472 aCmArray.Reset(); |
|
473 aCmArray.ReserveL( countPckg() ); |
|
474 for ( TInt i = 0; i < countPckg(); i++ ) |
|
475 { |
|
476 aCmArray.AppendL( (TUint32)(*smallBuf)[i] ); |
|
477 } |
|
478 } |
|
479 else |
|
480 { |
|
481 User::Leave( KErrUnknown ); |
|
482 } |
|
483 CleanupStack::PopAndDestroy( bigBuf ); |
|
484 } |
|
485 else |
|
486 { |
|
487 User::Leave( KErrUnknown ); |
|
488 } |
|
489 |
|
490 if ( smallBuf ) |
|
491 { |
|
492 CleanupStack::PopAndDestroy( smallBuf ); |
|
493 } |
|
494 |
|
495 OstTraceFunctionExit0( RCMMANAGERAPI_GETCONNMETHODSL_EXIT ); |
|
496 } |
|
497 |
|
498 //----------------------------------------------------------------------------- |
|
499 // RCmManagerApi::GetAllDestinationsL() |
|
500 //----------------------------------------------------------------------------- |
|
501 // |
|
502 void RCmManagerApi::GetAllDestinationsL( RArray<TUint32>& aDestArray ) |
|
503 { |
|
504 OstTraceFunctionEntry0( RCMMANAGERAPI_GETALLDESTINATIONSL_ENTRY ); |
|
505 |
|
506 TInt err( KErrNone ); |
|
507 TInt count( KMaxTInt ); |
|
508 TPckg<TInt> countPckg( count ); |
|
509 |
|
510 HBufC16* smallBuf( NULL ); |
|
511 HBufC16* bigBuf( NULL ); |
|
512 |
|
513 if ( iSmallBufsForDestinations ) |
|
514 { |
|
515 smallBuf = HBufC16::NewLC( KCmmDestAmountNormal ); |
|
516 TPtr16 smallBufPtr( smallBuf->Des() ); |
|
517 |
|
518 TIpcArgs args( &countPckg, &smallBufPtr ); |
|
519 err = SendReceive( ECmmGetAllDestinations, args ); |
|
520 User::LeaveIfError( err ); |
|
521 } |
|
522 |
|
523 if ( countPckg() <= KCmmDestAmountNormal ) |
|
524 { |
|
525 aDestArray.Reset(); |
|
526 aDestArray.ReserveL( countPckg() ); |
|
527 for ( TInt i = 0; i < countPckg(); i++ ) |
|
528 { |
|
529 aDestArray.AppendL( (TUint32)(*smallBuf)[i] ); |
|
530 } |
|
531 } |
|
532 else if ( countPckg() == KMaxTInt ) |
|
533 { |
|
534 // All destinations didn't fit into small array, ask again with big array. |
|
535 iSmallBufsForDestinations = EFalse; // Switch small buffer mode off. |
|
536 if ( smallBuf ) |
|
537 { |
|
538 CleanupStack::PopAndDestroy( smallBuf ); |
|
539 smallBuf = NULL; |
|
540 } |
|
541 |
|
542 bigBuf = HBufC16::NewLC( KCmmDestAmountMax ); |
|
543 TPtr16 bigBufPtr( bigBuf->Des() ); |
|
544 |
|
545 TIpcArgs args( &countPckg, &bigBufPtr ); |
|
546 err = SendReceive( ECmmGetAllDestinations, args ); |
|
547 User::LeaveIfError( err ); |
|
548 |
|
549 if ( countPckg() <= KCmmDestAmountMax ) |
|
550 { |
|
551 if ( countPckg() < KCmmDestAmountNormal ) |
|
552 { |
|
553 iSmallBufsForDestinations = ETrue; // Switch small buffer mode back on. |
|
554 } |
|
555 |
|
556 aDestArray.Reset(); |
|
557 aDestArray.ReserveL( countPckg() ); |
|
558 for ( TInt i = 0; i < countPckg(); i++ ) |
|
559 { |
|
560 aDestArray.AppendL( (TUint32)(*smallBuf)[i] ); |
|
561 } |
|
562 } |
|
563 else |
|
564 { |
|
565 User::Leave( KErrUnknown ); |
|
566 } |
|
567 CleanupStack::PopAndDestroy( bigBuf ); |
|
568 } |
|
569 else |
|
570 { |
|
571 User::Leave( KErrUnknown ); |
|
572 } |
|
573 |
|
574 if ( smallBuf ) |
|
575 { |
|
576 CleanupStack::PopAndDestroy( smallBuf ); |
|
577 } |
|
578 |
|
579 OstTraceFunctionExit0( RCMMANAGERAPI_GETALLDESTINATIONSL_EXIT ); |
|
580 } |
|
581 |
|
582 //----------------------------------------------------------------------------- |
|
583 // RCmManagerApi::GetBearerPriorityArrayL() |
|
584 //----------------------------------------------------------------------------- |
|
585 // |
|
586 void RCmManagerApi::GetBearerPriorityArrayL( RArray<TBearerPriority>& aArray ) |
|
587 { |
|
588 OstTraceFunctionEntry0( RCMMANAGERAPI_GETBEARERPRIORITYARRAYL_ENTRY ); |
|
589 |
|
590 HBufC* buffer = HBufC::NewLC( KCmmDefaultBearerPriorityArraySize ); |
|
591 TPtr bufferPtr( buffer->Des() ); |
|
592 |
|
593 TIpcArgs args( &bufferPtr ); |
|
594 TInt err = SendReceive( ECmmGetBearerPriorityArray, args ); |
|
595 User::LeaveIfError( err ); |
|
596 |
|
597 // bufferPtr[1] should now contain the needed buffer length. |
|
598 if ( bufferPtr[1] > bufferPtr.Length() ) |
|
599 { |
|
600 // First buffer wasn't big enough. Try again with correct size buffer. |
|
601 CleanupStack::PopAndDestroy( buffer ); |
|
602 buffer = HBufC::NewLC( bufferPtr[1] ); |
|
603 bufferPtr.Set( buffer->Des() ); |
|
604 |
|
605 TIpcArgs args2( &bufferPtr ); |
|
606 err = SendReceive( ECmmGetBearerPriorityArray, args2 ); |
|
607 User::LeaveIfError( err ); |
|
608 |
|
609 if ( bufferPtr[1] > bufferPtr.Length() ) |
|
610 { |
|
611 User::Leave( KErrAbort ); |
|
612 } |
|
613 } |
|
614 |
|
615 const TInt bearerCount = bufferPtr[0]; |
|
616 |
|
617 // Cleanup old array. There's a pointer in that T-class... |
|
618 for ( TInt i = 0; i < aArray.Count(); i++ ) |
|
619 { |
|
620 if ( aArray[i].iServiceType ) |
|
621 { |
|
622 delete aArray[i].iServiceType; |
|
623 aArray[i].iServiceType = NULL; |
|
624 } |
|
625 } |
|
626 aArray.Reset(); |
|
627 aArray.ReserveL( bearerCount ); |
|
628 |
|
629 TInt position( 2 ); // Start of first priority item |
|
630 for ( TInt i = 0; i < bearerCount; i++ ) |
|
631 { |
|
632 TBearerPriority bearerPriority; |
|
633 bearerPriority.iPriority = bufferPtr[position++] << KBitsInTwoBytes; |
|
634 bearerPriority.iPriority += bufferPtr[position++]; |
|
635 bearerPriority.iUIPriority = bufferPtr[position++] << KBitsInTwoBytes; |
|
636 bearerPriority.iUIPriority += bufferPtr[position++]; |
|
637 bearerPriority.iServiceType = NULL; |
|
638 |
|
639 const TInt stringLength = bufferPtr[position++]; |
|
640 if ( stringLength ) |
|
641 { |
|
642 HBufC* serviceName = HBufC::NewL( stringLength ); |
|
643 serviceName->Des().Append( &(bufferPtr[position]), stringLength ); |
|
644 position += stringLength; |
|
645 bearerPriority.iServiceType = serviceName; |
|
646 // Ownership moved into array. |
|
647 } |
|
648 aArray.AppendL( bearerPriority ); |
|
649 } |
|
650 |
|
651 CleanupStack::PopAndDestroy( buffer ); |
|
652 |
|
653 OstTraceFunctionExit0( RCMMANAGERAPI_GETBEARERPRIORITYARRAYL_EXIT ); |
|
654 } |
|
655 |
|
656 //----------------------------------------------------------------------------- |
|
657 // RCmManagerApi::SetBearerPriorityArrayL() |
|
658 //----------------------------------------------------------------------------- |
|
659 // |
|
660 void RCmManagerApi::SetBearerPriorityArrayL( const RArray<TBearerPriority>& aArray ) |
|
661 { |
|
662 OstTraceFunctionEntry0( RCMMANAGERAPI_SETBEARERPRIORITYARRAYL_ENTRY ); |
|
663 |
|
664 // iPriority: 2 16-bit values, |
|
665 // iUIPriority: 2 16-bit values, |
|
666 // iServiceType length: 1 16-bit value. |
|
667 const TInt KCmmBearerPriorityHeaderLength = 5; |
|
668 |
|
669 // Buffer starts with legth of 2, to contain both the total amount of |
|
670 // TBearerPriority objects, and the size of the buffer (number of 16-bit |
|
671 // values) needed to contain the whole structure including all headers. |
|
672 TInt bufferLength( 2 ); |
|
673 |
|
674 const TInt bearerCount = aArray.Count(); |
|
675 for ( TInt i = 0; i < bearerCount; i++ ) |
|
676 { |
|
677 bufferLength += KCmmBearerPriorityHeaderLength; |
|
678 const TBearerPriority& bearerPriority = aArray[i]; |
|
679 if ( !bearerPriority.iServiceType ) |
|
680 { |
|
681 User::Leave( KErrArgument ); |
|
682 } |
|
683 // Get length of service type name and add it to needed buffer length. |
|
684 bufferLength += bearerPriority.iServiceType->Length(); |
|
685 } |
|
686 |
|
687 HBufC* buffer = HBufC::NewLC( bufferLength ); |
|
688 TPtr bufferPtr( buffer->Des() ); |
|
689 |
|
690 bufferPtr.Append( bearerCount ); |
|
691 bufferPtr.Append( bufferLength ); |
|
692 |
|
693 TInt position = bufferPtr.Length(); |
|
694 for ( TInt i = 0; i < bearerCount; i++ ) |
|
695 { |
|
696 const TBearerPriority& bearerPriority = aArray[i]; |
|
697 |
|
698 bufferPtr.Append( ( bearerPriority.iPriority & 0xFFFF0000 ) >> KBitsInTwoBytes ); |
|
699 bufferPtr.Append( ( bearerPriority.iPriority & 0x0000FFFF ) ); |
|
700 bufferPtr.Append( ( bearerPriority.iUIPriority & 0xFFFF0000 ) >> KBitsInTwoBytes ); |
|
701 bufferPtr.Append( ( bearerPriority.iUIPriority & 0x0000FFFF ) ); |
|
702 |
|
703 position += KCmmBearerPriorityHeaderLength; |
|
704 if ( !bearerPriority.iServiceType ) |
|
705 { |
|
706 User::Leave( KErrArgument ); |
|
707 } |
|
708 const TInt stringLength = bearerPriority.iServiceType->Length(); |
|
709 bufferPtr.Append( stringLength ); |
|
710 bufferPtr.Insert( position, *(bearerPriority.iServiceType) ); |
|
711 position += stringLength; |
|
712 } |
|
713 |
|
714 TIpcArgs args( &bufferPtr ); |
|
715 TInt err = SendReceive( ECmmUpdateBearerPriorityArray, args ); |
|
716 User::LeaveIfError( err ); |
|
717 CleanupStack::PopAndDestroy( buffer ); |
|
718 |
|
719 OstTraceFunctionExit0( RCMMANAGERAPI_SETBEARERPRIORITYARRAYL_EXIT ); |
|
720 } |
|
721 |
|
722 //----------------------------------------------------------------------------- |
|
723 // RCmManagerApi::GetSupportedBearersL() |
|
724 //----------------------------------------------------------------------------- |
|
725 // |
|
726 void RCmManagerApi::GetSupportedBearersL( RArray<TUint32>& aArray ) |
|
727 { |
|
728 OstTraceFunctionEntry0( RCMMANAGERAPI_GETSUPPORTEDBEARERSL_ENTRY ); |
|
729 |
|
730 TInt err( KErrNone ); |
|
731 TInt count( KMaxTInt ); |
|
732 TPckg<TInt> countPckg( count ); |
|
733 |
|
734 HBufC8* smallBuf( NULL ); |
|
735 HBufC8* bigBuf( NULL ); |
|
736 |
|
737 smallBuf = HBufC8::NewLC( KCmmBearerAmountNormal * sizeof( TUint32 ) ); |
|
738 TPtr8 smallBufPtr( smallBuf->Des() ); |
|
739 |
|
740 TIpcArgs args( &countPckg, &smallBufPtr ); |
|
741 err = SendReceive( ECmmGetSupportedBearers, args ); |
|
742 User::LeaveIfError( err ); |
|
743 |
|
744 if ( countPckg() <= KCmmBearerAmountNormal ) |
|
745 { |
|
746 aArray.Reset(); |
|
747 aArray.ReserveL( countPckg() ); |
|
748 |
|
749 TUint32 a( 0 ); |
|
750 TPtr8 ptr = smallBuf->Des(); |
|
751 for ( TInt i = 0; i < countPckg(); i++ ) |
|
752 { |
|
753 a = 0; |
|
754 a += (TUint32)ptr[0 + ( i * sizeof( TUint32 ) )]; |
|
755 a += (TUint32)ptr[1 + ( i * sizeof( TUint32 ) )] << KBitsInOneByte; |
|
756 a += (TUint32)ptr[2 + ( i * sizeof( TUint32 ) )] << KBitsInTwoBytes; |
|
757 a += (TUint32)ptr[3 + ( i * sizeof( TUint32 ) )] << KBitsInThreeBytes; |
|
758 aArray.AppendL( a ); |
|
759 } |
|
760 } |
|
761 else |
|
762 { |
|
763 TInt storedCount = countPckg(); |
|
764 |
|
765 bigBuf = HBufC8::NewLC( countPckg() * sizeof( TUint32 ) ); |
|
766 TPtr8 bigBufPtr( bigBuf->Des() ); |
|
767 |
|
768 TIpcArgs args( &countPckg, &bigBufPtr ); |
|
769 err = SendReceive( ECmmGetSupportedBearers, args ); |
|
770 User::LeaveIfError( err ); |
|
771 |
|
772 if ( countPckg() <= storedCount ) |
|
773 { |
|
774 aArray.Reset(); |
|
775 aArray.ReserveL( countPckg() ); |
|
776 |
|
777 TUint32 a( 0 ); |
|
778 TPtr8 ptr = bigBuf->Des(); |
|
779 for ( TInt i = 0; i < countPckg(); i++ ) |
|
780 { |
|
781 a = 0; |
|
782 a += (TUint32)ptr[0 + ( i * sizeof( TUint32 ) )]; |
|
783 a += (TUint32)ptr[1 + ( i * sizeof( TUint32 ) )] << KBitsInOneByte; |
|
784 a += (TUint32)ptr[2 + ( i * sizeof( TUint32 ) )] << KBitsInTwoBytes; |
|
785 a += (TUint32)ptr[3 + ( i * sizeof( TUint32 ) )] << KBitsInThreeBytes; |
|
786 aArray.AppendL( a ); |
|
787 } |
|
788 } |
|
789 else |
|
790 { |
|
791 User::Leave( KErrUnknown ); |
|
792 } |
|
793 |
|
794 CleanupStack::PopAndDestroy( bigBuf ); |
|
795 } |
|
796 CleanupStack::PopAndDestroy( smallBuf ); |
|
797 |
|
798 OstTraceFunctionExit0( RCMMANAGERAPI_GETSUPPORTEDBEARERSL_EXIT ); |
|
799 } |
|
800 |
|
801 //----------------------------------------------------------------------------- |
|
802 // RCmManagerApi::GetEasyWlanId() |
|
803 //----------------------------------------------------------------------------- |
|
804 // |
|
805 TInt RCmManagerApi::GetEasyWlanId( TUint32& aValue ) |
|
806 { |
|
807 OstTraceFunctionEntry0( RCMMANAGERAPI_GETEASYWLANID_ENTRY ); |
|
808 |
|
809 TPckg<TUint32> pckg( aValue ); |
|
810 TIpcArgs args( &pckg ); |
|
811 TInt err = SendReceive( ECmmGetEasyWlanId, args ); |
|
812 |
|
813 OstTraceFunctionExit0( RCMMANAGERAPI_GETEASYWLANID_EXIT ); |
|
814 return err; |
|
815 } |
|
816 |
|
817 //----------------------------------------------------------------------------- |
|
818 // RCmManagerApi::ReadDefaultConnection() |
|
819 //----------------------------------------------------------------------------- |
|
820 // |
|
821 TInt RCmManagerApi::ReadDefaultConnection( |
|
822 TCmDefConnValue& aDefConnSetting ) |
|
823 { |
|
824 OstTraceFunctionEntry0( RCMMANAGERAPI_READDEFAULTCONNECTION_ENTRY ); |
|
825 |
|
826 TPckgBuf<TCmDefConnValue> pkg( aDefConnSetting ); |
|
827 TIpcArgs args( &pkg ); |
|
828 TInt err = SendReceive( ECmmReadDefaultConnection, args ); |
|
829 aDefConnSetting = pkg(); |
|
830 |
|
831 OstTraceFunctionExit0( RCMMANAGERAPI_READDEFAULTCONNECTION_EXIT ); |
|
832 return err; |
|
833 } |
|
834 |
|
835 //----------------------------------------------------------------------------- |
|
836 // RCmManagerApi::WriteDefaultConnection() |
|
837 //----------------------------------------------------------------------------- |
|
838 // |
|
839 TInt RCmManagerApi::WriteDefaultConnection( |
|
840 const TCmDefConnValue& aDefConnSetting ) |
|
841 { |
|
842 OstTraceFunctionEntry0( RCMMANAGERAPI_WRITEDEFAULTCONNECTION_ENTRY ); |
|
843 |
|
844 TPckgBuf<TCmDefConnValue> pkg( aDefConnSetting ); |
|
845 TIpcArgs args( &pkg ); |
|
846 TInt err = SendReceive( ECmmWriteDefaultConnection, args ); |
|
847 |
|
848 OstTraceFunctionExit0( RCMMANAGERAPI_WRITEDEFAULTCONNECTION_EXIT ); |
|
849 return err; |
|
850 } |
|
851 |
|
852 //----------------------------------------------------------------------------- |
|
853 // RCmManagerApi::ReadGeneralConnectionSettings() |
|
854 //----------------------------------------------------------------------------- |
|
855 // |
|
856 TInt RCmManagerApi::ReadGeneralConnectionSettings( |
|
857 TCmGenConnSettings& aGenConnSettings ) |
|
858 { |
|
859 OstTraceFunctionEntry0( RCMMANAGERAPI_READGENERALCONNECTIONSETTINGS_ENTRY ); |
|
860 |
|
861 TPckgBuf<TCmGenConnSettings> pkg( aGenConnSettings ); |
|
862 TIpcArgs args( &pkg ); |
|
863 TInt err = SendReceive( ECmmReadGeneralConnectionSettings, args ); |
|
864 aGenConnSettings = pkg(); |
|
865 |
|
866 OstTraceFunctionExit0( RCMMANAGERAPI_READGENERALCONNECTIONSETTINGS_EXIT ); |
|
867 return err; |
|
868 } |
|
869 |
|
870 //----------------------------------------------------------------------------- |
|
871 // RCmManagerApi::WriteGeneralConnectionSettings() |
|
872 //----------------------------------------------------------------------------- |
|
873 // |
|
874 TInt RCmManagerApi::WriteGeneralConnectionSettings( |
|
875 const TCmGenConnSettings& aGenConnSettings ) |
|
876 { |
|
877 OstTraceFunctionEntry0( RCMMANAGERAPI_WRITEGENERALCONNECTIONSETTINGS_ENTRY ); |
|
878 |
|
879 TPckgBuf<TCmGenConnSettings> pkg( aGenConnSettings ); |
|
880 TIpcArgs args( &pkg ); |
|
881 TInt err = SendReceive( ECmmWriteGeneralConnectionSettings, args ); |
|
882 |
|
883 OstTraceFunctionExit0( RCMMANAGERAPI_WRITEGENERALCONNECTIONSETTINGS_EXIT ); |
|
884 return err; |
|
885 } |
|
886 |
|
887 //----------------------------------------------------------------------------- |
|
888 // RCmManagerApi::CopyConnectionMethod() |
|
889 //----------------------------------------------------------------------------- |
|
890 // |
|
891 TInt RCmManagerApi::CopyConnectionMethod( |
|
892 const TInt aTargetDestHandle, |
|
893 const TInt aConnMethodHandle, |
|
894 TInt& aIndex ) |
|
895 { |
|
896 OstTraceFunctionEntry0( RCMMANAGERAPI_COPYCONNECTIONMETHOD_ENTRY ); |
|
897 |
|
898 TPckg<TInt> pkg( aIndex ); |
|
899 TIpcArgs args( aTargetDestHandle, aConnMethodHandle, &pkg ); |
|
900 TInt err = SendReceive( ECmmCopyConnMethod, args ); |
|
901 |
|
902 OstTraceFunctionExit0( RCMMANAGERAPI_COPYCONNECTIONMETHOD_EXIT ); |
|
903 return err; |
|
904 } |
|
905 |
|
906 //----------------------------------------------------------------------------- |
|
907 // RCmManagerApi::MoveConnectionMethod() |
|
908 //----------------------------------------------------------------------------- |
|
909 // |
|
910 TInt RCmManagerApi::MoveConnectionMethod( |
|
911 TCmmIpcStructMoveConnMethod& aPkgData ) |
|
912 { |
|
913 OstTraceFunctionEntry0( RCMMANAGERAPI_MOVECONNECTIONMETHOD_ENTRY ); |
|
914 |
|
915 TPckgBuf<TCmmIpcStructMoveConnMethod> pkg( aPkgData ); |
|
916 TIpcArgs args( &pkg ); |
|
917 TInt err = SendReceive( ECmmMoveConnMethod, args ); |
|
918 aPkgData = pkg(); |
|
919 |
|
920 OstTraceFunctionExit0( RCMMANAGERAPI_MOVECONNECTIONMETHOD_EXIT ); |
|
921 return err; |
|
922 } |
|
923 |
|
924 //----------------------------------------------------------------------------- |
|
925 // RCmManagerApi::RemoveConnectionMethod() |
|
926 //----------------------------------------------------------------------------- |
|
927 // |
|
928 TInt RCmManagerApi::RemoveConnectionMethod( |
|
929 const TInt aTargetDestHandle, |
|
930 const TInt aConnMethodHandle ) |
|
931 { |
|
932 OstTraceFunctionEntry0( RCMMANAGERAPI_REMOVECONNECTIONMETHOD_ENTRY ); |
|
933 |
|
934 TIpcArgs args( aTargetDestHandle, aConnMethodHandle ); |
|
935 TInt err = SendReceive( ECmmRemoveConnMethod, args ); |
|
936 |
|
937 OstTraceFunctionExit0( RCMMANAGERAPI_REMOVECONNECTIONMETHOD_EXIT ); |
|
938 return err; |
|
939 } |
|
940 |
|
941 //----------------------------------------------------------------------------- |
|
942 // RCmManagerApi::RemoveAllReferences() |
|
943 //----------------------------------------------------------------------------- |
|
944 // |
|
945 TInt RCmManagerApi::RemoveAllReferences( |
|
946 const TInt aConnMethodHandle ) |
|
947 { |
|
948 OstTraceFunctionEntry0( RCMMANAGERAPI_REMOVEALLREFERENCES_ENTRY ); |
|
949 |
|
950 TIpcArgs args( aConnMethodHandle ); |
|
951 TInt err = SendReceive( ECmmRemoveAllReferences, args ); |
|
952 |
|
953 OstTraceFunctionExit0( RCMMANAGERAPI_REMOVEALLREFERENCES_EXIT ); |
|
954 return err; |
|
955 } |
|
956 |
|
957 // End of file |