messagingfw/biomsgfw/BIUTSRC/CBioAsyncWaiter.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <cbioasyncwaiter.h>
       
    17 
       
    18 /**
       
    19 Standard 2-phase contruction.
       
    20 
       
    21 Allocates and initialises the object.
       
    22 
       
    23 @return A pointer to the created object.
       
    24 */
       
    25 EXPORT_C CBioAsyncWaiter* CBioAsyncWaiter::NewLC()
       
    26 	{
       
    27 	CBioAsyncWaiter* self = new(ELeave) CBioAsyncWaiter();
       
    28 	CleanupStack::PushL(self);
       
    29 	return self;
       
    30 	}
       
    31 
       
    32 CBioAsyncWaiter::CBioAsyncWaiter()
       
    33 	: CActive(EPriorityStandard)
       
    34 	{
       
    35 	CActiveScheduler::Add(this);
       
    36 	}	
       
    37 
       
    38 /**
       
    39 Destructor.
       
    40 
       
    41 Also cancels any outstanding requests.
       
    42 */
       
    43 EXPORT_C CBioAsyncWaiter::~CBioAsyncWaiter()
       
    44 	{
       
    45 	Cancel();
       
    46 	}
       
    47 	
       
    48 /**
       
    49 Starts the asynchronous request.
       
    50 
       
    51 Starts the active scheduler and waits for the asynchronous request
       
    52 to complete.
       
    53 */
       
    54 EXPORT_C void CBioAsyncWaiter::StartAndWait()
       
    55 	{
       
    56 	SetActive();
       
    57 	CActiveScheduler::Start();
       
    58 	}
       
    59 
       
    60 /**
       
    61 Obtains the result of the asynchronous request.
       
    62 
       
    63 Returns the error code of the last asynchronous request that
       
    64 was made.
       
    65 
       
    66 @return KErrNone is request was successful, otherwise the error
       
    67 		code that the request completed with.
       
    68 */
       
    69 EXPORT_C TInt CBioAsyncWaiter::Result() const
       
    70 	{
       
    71 	return iError;
       
    72 	}
       
    73 	
       
    74 void CBioAsyncWaiter::RunL()
       
    75 	{
       
    76 	iError = iStatus.Int();
       
    77 	CActiveScheduler::Stop();
       
    78 	}
       
    79 	
       
    80 void CBioAsyncWaiter::DoCancel()
       
    81 	{
       
    82 	iError = KErrCancel;
       
    83 	CActiveScheduler::Stop();
       
    84 	}
       
    85