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