1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
17 |
17 |
18 #include <e32base.h> |
18 #include <e32base.h> |
19 #include <e32base_private.h> |
19 #include <e32base_private.h> |
20 #include <e32property.h> |
20 #include <e32property.h> |
21 |
21 |
22 |
|
23 #include <domainmember.h> |
22 #include <domainmember.h> |
24 #include <domainmanager.h> |
23 #include <domainmanager.h> |
25 #include "domainobserver.h" |
24 #include "domainobserver.h" |
26 #include "domainsrv.h" |
25 #include "domainsrv.h" |
27 |
26 |
379 |
378 |
380 TInt RDmManagerSession::GetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailures) |
379 TInt RDmManagerSession::GetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailures) |
381 { |
380 { |
382 __DM_ASSERT(Handle() != KNullHandle); |
381 __DM_ASSERT(Handle() != KNullHandle); |
383 |
382 |
384 |
|
385 aTransitionFailures.Reset(); |
383 aTransitionFailures.Reset(); |
386 |
384 |
387 TInt err = KErrNone; |
385 TInt err = KErrNone; |
388 |
386 |
389 TInt failureCount = GetTransitionFailureCount(); |
387 TInt failureCount = GetTransitionFailureCount(); |
390 if (failureCount <= 0) |
388 if (failureCount <= 0) |
391 return failureCount; |
389 return failureCount; |
392 |
390 |
393 // Pre-allocate array with a known size which for this case is the value in failureCount |
|
394 // in order to guarantee that future append operations to the array aTransitionFailures would |
|
395 // not fail. This is assuming that the pre-allocated size is not exceeded. |
|
396 err=aTransitionFailures.Reserve(failureCount); |
|
397 if (err != KErrNone) |
|
398 return err; |
|
399 |
|
400 TTransitionFailure* failures = new TTransitionFailure[failureCount]; |
391 TTransitionFailure* failures = new TTransitionFailure[failureCount]; |
401 if(failures == NULL) |
392 if(failures == NULL) |
402 { |
|
403 aTransitionFailures.Reset(); |
|
404 return(KErrNoMemory); |
393 return(KErrNoMemory); |
405 } |
|
406 |
|
407 TPtr8 dataPtr(reinterpret_cast<TUint8*>(failures), failureCount * sizeof(TTransitionFailure)); |
394 TPtr8 dataPtr(reinterpret_cast<TUint8*>(failures), failureCount * sizeof(TTransitionFailure)); |
408 |
395 |
409 TIpcArgs a(&dataPtr); |
396 TIpcArgs a(&dataPtr); |
410 err = RSessionBase::SendReceive(EDmGetTransitionFailures, a); |
397 err = RSessionBase::SendReceive(EDmGetTransitionFailures, a); |
411 |
398 |
412 if (err == KErrNone) |
399 if (err == KErrNone) |
413 { |
400 { |
414 for (TInt i=0; i<failureCount; i++) |
401 for (TInt i=0; i<failureCount; i++) |
415 { |
402 aTransitionFailures.Append(failures[i]); |
416 err = aTransitionFailures.Append(failures[i]); |
|
417 //The pre-allocation made above for the array aTransitionFailures should guarantee |
|
418 //that append operations complete succesfully. |
|
419 __DM_ASSERT(err == KErrNone); |
|
420 } |
|
421 } |
403 } |
422 |
404 |
423 delete [] failures; |
405 delete [] failures; |
424 |
406 |
425 return err; |
407 return err; |
455 TInt count = GetEventCount(); |
437 TInt count = GetEventCount(); |
456 // This shouldn't happen unless something gone terribly wrong |
438 // This shouldn't happen unless something gone terribly wrong |
457 if (count <= 0) |
439 if (count <= 0) |
458 return KErrGeneral; |
440 return KErrGeneral; |
459 |
441 |
460 // Pre-allocate array with a known size which for this case is the value in count |
|
461 // in order to guarantee that future append operations to the array aTransitionFailures |
|
462 // would not fail. This is assuming that the pre-allocated size is not exceeded. |
|
463 TInt ret=aTransitions.Reserve(count); |
|
464 if (ret != KErrNone) |
|
465 return ret; |
|
466 |
|
467 TTransInfo* trans = new TTransInfo[count]; |
442 TTransInfo* trans = new TTransInfo[count]; |
468 if(trans == NULL) |
443 if(trans == NULL) |
469 { |
|
470 aTransitions.Reset(); |
|
471 return(KErrNoMemory); |
444 return(KErrNoMemory); |
472 } |
|
473 |
445 |
474 TPtr8 dataPtr(reinterpret_cast<TUint8*>(trans), count * sizeof(TTransInfo)); |
446 TPtr8 dataPtr(reinterpret_cast<TUint8*>(trans), count * sizeof(TTransInfo)); |
475 |
447 |
476 TIpcArgs a(&dataPtr); |
448 TIpcArgs a(&dataPtr); |
477 ret=RSessionBase::SendReceive(EDmObserverGetEvent, a); |
449 TInt ret=RSessionBase::SendReceive(EDmObserverGetEvent, a); |
478 |
450 |
479 if(ret==KErrNone) |
451 if(ret==KErrNone) |
480 { |
452 { |
481 for (TInt i=0; i<count; i++) |
453 for (TInt i=0; i<count; i++) |
482 { |
454 aTransitions.Append(trans[i]); |
483 ret = aTransitions.Append(trans[i]); |
|
484 //The pre-allocation made above for the array aTransitions should guarantee |
|
485 //that append operations complete succesfully. |
|
486 __DM_ASSERT(ret == KErrNone); |
|
487 } |
|
488 } |
455 } |
489 |
456 |
490 delete [] trans; |
457 delete [] trans; |
491 return ret; |
458 return ret; |
492 |
459 |