mmfenh/enhancedmediaclient/Client/src/Components/SourceBase/AsyncAO.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2006 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:  This file contains the implementation of asynchronous AO object.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "AsyncAO.h"
       
    21 
       
    22 using namespace multimedia;
       
    23 
       
    24 CAsyncAO::CAsyncAO( MAsyncAOObserver& aObserver )
       
    25 :CActive(CActive::EPriorityStandard),
       
    26 iObserver(aObserver)
       
    27     {
       
    28     CActiveScheduler::Add(this);
       
    29     }
       
    30 
       
    31 CAsyncAO::~CAsyncAO()
       
    32     {
       
    33     Cancel();
       
    34     }
       
    35 
       
    36 CAsyncAO* CAsyncAO::NewL( MAsyncAOObserver& aObserver )
       
    37     {
       
    38     CAsyncAO* self = new (ELeave) CAsyncAO(aObserver);
       
    39     CleanupStack::PushL(self);
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43     }
       
    44 
       
    45 void CAsyncAO::ConstructL()
       
    46     {
       
    47     // No Implementation
       
    48     }
       
    49 
       
    50 TInt CAsyncAO::SetActive()
       
    51     {
       
    52     TInt status(KErrInUse);
       
    53     if (!CActive::IsActive())
       
    54         {
       
    55         CActive::SetActive();
       
    56         status = KErrNone;
       
    57         }
       
    58     return status;
       
    59     }
       
    60 
       
    61 void CAsyncAO::RunL()
       
    62     {
       
    63     iObserver.Event(iStatus.Int());
       
    64     }
       
    65 
       
    66 void CAsyncAO::DoCancel()
       
    67     {
       
    68     if(iStatus.Int() != KErrNone)
       
    69         {
       
    70         TRequestStatus* status = &iStatus;
       
    71         User::RequestComplete(status,KErrCancel);
       
    72         }
       
    73     }
       
    74 
       
    75 TInt CAsyncAO::Error( TInt /* aError */ )
       
    76     {
       
    77     // RunL left. The client callback function left. Incorrect callback
       
    78     // implementation. So ignore the leave and continue
       
    79     return KErrNone;
       
    80     }
       
    81 
       
    82 //  End of File