bluetoothengine/btmac/src/BTMonoCmdHandler/btmcactive.cpp
changeset 0 f63038272f30
child 1 6a1fe72036e3
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2005 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:  General Active Object offering asynchronous service
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "btmcactive.h"
       
    20 #include "debug.h"
       
    21 
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 // CBtmcActive::NewL
       
    25 // -----------------------------------------------------------------------------
       
    26 CBtmcActive* CBtmcActive::NewL(MBtmcActiveObserver& aObserver, 
       
    27     CActive::TPriority aPriority, TInt aServiceId)
       
    28     {
       
    29     CBtmcActive* self = CBtmcActive::NewLC(aObserver, aPriority, aServiceId);
       
    30     CleanupStack::Pop(self);
       
    31     return self;
       
    32     }
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CBtmcActive::NewLC
       
    36 // -----------------------------------------------------------------------------
       
    37 CBtmcActive* CBtmcActive::NewLC(MBtmcActiveObserver& aObserver, 
       
    38     CActive::TPriority aPriority, TInt aServiceId)
       
    39     {
       
    40     CBtmcActive* self = new (ELeave) CBtmcActive(aObserver, aPriority, aServiceId);
       
    41     CleanupStack::PushL(self);
       
    42     return self;
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CBtmcActive::~CBtmcActive
       
    47 // -----------------------------------------------------------------------------
       
    48 CBtmcActive::~CBtmcActive()
       
    49     {
       
    50     Cancel();
       
    51     TRACE_FUNC
       
    52     }
       
    53 
       
    54 // -------------------------------------------------------------------------------
       
    55 // CBtmcActive::GoActive
       
    56 // -------------------------------------------------------------------------------
       
    57 void CBtmcActive::GoActive()
       
    58     {
       
    59     TRACE_ASSERT(!IsActive(), KErrGeneral);
       
    60     SetActive();
       
    61     TRACE_FUNC
       
    62     }
       
    63 
       
    64 TInt CBtmcActive::ServiceId() const
       
    65     {
       
    66     return iServiceId;
       
    67     }
       
    68 
       
    69 void CBtmcActive::SetServiceId(TInt aServiceId)
       
    70     {
       
    71     iServiceId = aServiceId;
       
    72     }
       
    73 
       
    74 // -------------------------------------------------------------------------------
       
    75 // CBtmcActive::RunL
       
    76 // -------------------------------------------------------------------------------
       
    77 void CBtmcActive::RunL()
       
    78     {
       
    79     TRACE_FUNC_ENTRY
       
    80     TRACE_INFO((_L("Completed service %d, status %d"), iServiceId, iStatus.Int()))
       
    81     iObserver.RequestCompletedL(*this, iStatus.Int());
       
    82     TRACE_FUNC_EXIT
       
    83     }
       
    84     
       
    85 // -------------------------------------------------------------------------------
       
    86 // CBtmcActive::DoCancel
       
    87 // -------------------------------------------------------------------------------
       
    88 void CBtmcActive::DoCancel()
       
    89     {
       
    90     TRACE_INFO((_L("DoCancel service %d"), iServiceId))
       
    91     iObserver.CancelRequest(iServiceId);
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CBtmcActive::CBtmcActive
       
    96 // -----------------------------------------------------------------------------
       
    97 CBtmcActive::CBtmcActive(MBtmcActiveObserver& aObserver, 
       
    98     CActive::TPriority aPriority, TInt aServiceId)
       
    99     : CActive(aPriority), iObserver(aObserver), iServiceId(aServiceId)
       
   100     {
       
   101     CActiveScheduler::Add(this);
       
   102     TRACE_FUNC
       
   103     }
       
   104 
       
   105 MBtmcActiveObserver& CBtmcActive::Observer()
       
   106     {
       
   107     return iObserver;
       
   108     }
       
   109 
       
   110 // End of File