|
1 /* |
|
2 * Copyright (c) 2007 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 |
|
19 #include "BTUIActive.h" |
|
20 |
|
21 |
|
22 // ======== MEMBER FUNCTIONS ======== |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // C++ default constructor |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CBTUIActive::CBTUIActive( MBTUIActiveObserver* aObserver, TInt aId, |
|
29 TInt aPriority ) |
|
30 : CActive( aPriority ), |
|
31 iRequestId( aId ), |
|
32 iObserver( aObserver ) |
|
33 { |
|
34 CActiveScheduler::Add( this ); |
|
35 } |
|
36 |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Symbian 2nd-phase constructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 void CBTUIActive::ConstructL() |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // NewL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CBTUIActive* CBTUIActive::NewL( MBTUIActiveObserver* aObserver, |
|
52 TInt aId, TInt aPriority ) |
|
53 { |
|
54 CBTUIActive* self = new( ELeave ) CBTUIActive( aObserver, aId, aPriority ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Destructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CBTUIActive::~CBTUIActive() |
|
67 { |
|
68 Cancel(); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // RequestId() |
|
73 // Return the request ID of this active object. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CBTUIActive::RequestId() |
|
77 { |
|
78 return iRequestId; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // SetRequestId() |
|
83 // Set a new request ID for this active object. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CBTUIActive::SetRequestId( TInt aId ) |
|
87 { |
|
88 iRequestId = aId; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // GoActive() |
|
93 // Set active. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CBTUIActive::GoActive() |
|
97 { |
|
98 SetActive(); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CancelRequest() |
|
103 // Cancel an outstanding request. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CBTUIActive::CancelRequest() |
|
107 { |
|
108 Cancel(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // RequestStatus() |
|
113 // Get a reference to the active object request status. |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 TRequestStatus& CBTUIActive::RequestStatus() |
|
117 { |
|
118 return iStatus; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // From class CActive. |
|
123 // Called by the active scheduler when the request has been cancelled. |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CBTUIActive::DoCancel() |
|
127 { |
|
128 } |
|
129 |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // From class CActive. |
|
133 // Called by the active scheduler when the request has been completed. |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CBTUIActive::RunL() |
|
137 { |
|
138 iObserver->RequestCompletedL( this, iRequestId, iStatus.Int() ); |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // From class CActive. |
|
144 // Called by the active scheduler when an error in RunL has occurred. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CBTUIActive::RunError( TInt aError ) |
|
148 { |
|
149 iObserver->HandleError( this, iRequestId, aError ); |
|
150 return KErrNone; |
|
151 } |