|
1 /* |
|
2 * Copyright (c) 2009 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 "btrccActive.h" |
|
20 #include "debug.h" |
|
21 |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CBTRCCActive::NewL |
|
25 // ----------------------------------------------------------------------------- |
|
26 CBTRCCActive* CBTRCCActive::NewL(MBTRCCActiveObserver& aObserver, |
|
27 TInt aServiceId, CActive::TPriority aPriority) |
|
28 { |
|
29 CBTRCCActive* self = CBTRCCActive::NewLC(aObserver, aServiceId, aPriority); |
|
30 CleanupStack::Pop(self); |
|
31 return self; |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CBTRCCActive::NewLC |
|
36 // ----------------------------------------------------------------------------- |
|
37 CBTRCCActive* CBTRCCActive::NewLC(MBTRCCActiveObserver& aObserver, |
|
38 TInt aServiceId, CActive::TPriority aPriority) |
|
39 { |
|
40 CBTRCCActive* self = new (ELeave) CBTRCCActive(aObserver, aServiceId, aPriority); |
|
41 CleanupStack::PushL(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CBTRCCActive::~CBTRCCActive |
|
47 // ----------------------------------------------------------------------------- |
|
48 CBTRCCActive::~CBTRCCActive() |
|
49 { |
|
50 Cancel(); |
|
51 TRACE_FUNC |
|
52 } |
|
53 |
|
54 // ------------------------------------------------------------------------------- |
|
55 // CBTRCCActive::GoActive |
|
56 // ------------------------------------------------------------------------------- |
|
57 void CBTRCCActive::GoActive() |
|
58 { |
|
59 TRACE_ASSERT(!IsActive(), KErrGeneral); |
|
60 SetActive(); |
|
61 TRACE_FUNC |
|
62 } |
|
63 |
|
64 TInt CBTRCCActive::ServiceId() const |
|
65 { |
|
66 return iServiceId; |
|
67 } |
|
68 |
|
69 void CBTRCCActive::SetServiceId(TInt aServiceId) |
|
70 { |
|
71 iServiceId = aServiceId; |
|
72 } |
|
73 |
|
74 // ------------------------------------------------------------------------------- |
|
75 // CBTRCCActive::RunL |
|
76 // ------------------------------------------------------------------------------- |
|
77 void CBTRCCActive::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 // CBTRCCActive::DoCancel |
|
87 // ------------------------------------------------------------------------------- |
|
88 void CBTRCCActive::DoCancel() |
|
89 { |
|
90 TRACE_INFO((_L("DoCancel service %d"), iServiceId)) |
|
91 iObserver.CancelRequest(iServiceId); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CBTRCCActive::CBTRCCActive |
|
96 // ----------------------------------------------------------------------------- |
|
97 CBTRCCActive::CBTRCCActive(MBTRCCActiveObserver& aObserver, |
|
98 TInt aServiceId, CActive::TPriority aPriority) |
|
99 : CActive(aPriority), iObserver(aObserver), iServiceId(aServiceId) |
|
100 { |
|
101 CActiveScheduler::Add(this); |
|
102 TRACE_FUNC |
|
103 } |
|
104 |
|
105 MBTRCCActiveObserver& CBTRCCActive::Observer() |
|
106 { |
|
107 return iObserver; |
|
108 } |
|
109 |
|
110 // End of File |