bluetoothengine/btmac/src/btmac/btmactive.cpp
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2005-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:  The BTMAC base Active Object definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "btmactive.h"
       
    20 #include "btmdefs.h"
       
    21 #include "debug.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 CBtmActive* CBtmActive::NewL(MBtmActiveObserver& aObserver, 
       
    26     CActive::TPriority aPriority, TInt aRequestId)
       
    27     {
       
    28     CBtmActive* self = new (ELeave) CBtmActive(aObserver, aPriority, aRequestId);
       
    29     return self;
       
    30     }
       
    31 
       
    32 CBtmActive::~CBtmActive()
       
    33     {
       
    34     Cancel();
       
    35     TRACE_FUNC
       
    36     }
       
    37 
       
    38 void CBtmActive::GoActive()
       
    39     {
       
    40     TRACE_ASSERT(!IsActive(), EBTPanicRequestOutstanding);
       
    41     SetActive();
       
    42     TRACE_FUNC
       
    43     }
       
    44 
       
    45 TInt CBtmActive::RequestId() const
       
    46     {
       
    47     return iRequestId;
       
    48     }
       
    49 
       
    50 void CBtmActive::SetRequestId(TInt aRequestId)
       
    51     {
       
    52     iRequestId = aRequestId;
       
    53     }
       
    54 
       
    55 void CBtmActive::DoCancel()
       
    56     {
       
    57     iObserver.CancelRequest(*this);
       
    58     TRACE_INFO((_L("Service %d cancelled"), iRequestId))
       
    59     }
       
    60     
       
    61 void CBtmActive::RunL()
       
    62     {
       
    63     TRACE_FUNC_ENTRY
       
    64     TRACE_INFO((_L("Service %d completed with %d"), iRequestId, iStatus.Int()))
       
    65     iObserver.RequestCompletedL(*this);
       
    66     TRACE_FUNC_EXIT
       
    67     }
       
    68     
       
    69 TInt CBtmActive::RunError(TInt aError)
       
    70     {
       
    71     TRACE_INFO((_L("Service %d RunError with %d"), iRequestId, aError))
       
    72     (void) aError;
       
    73     return KErrNone;
       
    74     } 
       
    75 
       
    76 CBtmActive::CBtmActive(MBtmActiveObserver& aObserver, 
       
    77     CActive::TPriority aPriority, TInt aRequestId)
       
    78     : CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId)
       
    79     {
       
    80     CActiveScheduler::Add(this);
       
    81     TRACE_FUNC
       
    82     }
       
    83 
       
    84 MBtmActiveObserver& CBtmActive::Observer()
       
    85     {
       
    86     return iObserver;
       
    87     }