29
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Active object helper class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <btservices/btsimpleactive.h>
|
|
19 |
|
|
20 |
// ======== MEMBER FUNCTIONS ========
|
|
21 |
|
|
22 |
// ---------------------------------------------------------------------------
|
|
23 |
// C++ default constructor
|
|
24 |
// ---------------------------------------------------------------------------
|
|
25 |
//
|
|
26 |
CBtSimpleActive::CBtSimpleActive( MBtSimpleActiveObserver& aObserver, TInt aId,
|
|
27 |
TInt aPriority )
|
|
28 |
: CActive( aPriority ),
|
|
29 |
iRequestId( aId ),
|
|
30 |
iObserver( aObserver )
|
|
31 |
{
|
|
32 |
CActiveScheduler::Add( this );
|
|
33 |
}
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// NewL
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
EXPORT_C CBtSimpleActive* CBtSimpleActive::NewL( MBtSimpleActiveObserver& aObserver,
|
|
40 |
TInt aId, TInt aPriority )
|
|
41 |
{
|
|
42 |
CBtSimpleActive* self = new( ELeave ) CBtSimpleActive( aObserver, aId, aPriority );
|
|
43 |
return self;
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// Destructor
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
EXPORT_C CBtSimpleActive::~CBtSimpleActive()
|
|
51 |
{
|
|
52 |
Cancel();
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// Get the identifier of this instance.
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
EXPORT_C TInt CBtSimpleActive::RequestId()
|
|
60 |
{
|
|
61 |
return iRequestId;
|
|
62 |
}
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// Set the identifier of this instance.
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
EXPORT_C void CBtSimpleActive::SetRequestId( TInt aId )
|
|
69 |
{
|
|
70 |
iRequestId = aId;
|
|
71 |
}
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// Activate the active object.
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
EXPORT_C void CBtSimpleActive::GoActive()
|
|
78 |
{
|
|
79 |
SetActive();
|
|
80 |
}
|
|
81 |
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
// Get a reference to the active object request status.
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
EXPORT_C TRequestStatus& CBtSimpleActive::RequestStatus()
|
|
87 |
{
|
|
88 |
return iStatus;
|
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
// From class CActive.
|
|
93 |
// Called by the active scheduler when the request has been cancelled.
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
void CBtSimpleActive::DoCancel()
|
|
97 |
{
|
|
98 |
iObserver.CancelRequest( iRequestId );
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// From class CActive.
|
|
103 |
// Called by the active scheduler when the request has been completed.
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CBtSimpleActive::RunL()
|
|
107 |
{
|
|
108 |
iObserver.RequestCompletedL( this, iStatus.Int() );
|
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
// From class CActive.
|
|
113 |
// Called by the active scheduler when an error in RunL has occurred.
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
TInt CBtSimpleActive::RunError( TInt aError )
|
|
117 |
{
|
|
118 |
iObserver.HandleError( this, aError );
|
|
119 |
return KErrNone;
|
|
120 |
}
|