|
1 /* |
|
2 * Copyright (c) 2005-2006 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: The base active class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "basrvactive.h" |
|
20 #include "debug.h" |
|
21 |
|
22 // ======== MEMBER FUNCTIONS ======== |
|
23 |
|
24 CBasrvActive* CBasrvActive::New(MBasrvActiveObserver& aObserver, |
|
25 CActive::TPriority aPriority, TInt aRequestId) |
|
26 { |
|
27 return new CBasrvActive(aObserver, aPriority, aRequestId); |
|
28 } |
|
29 |
|
30 CBasrvActive* CBasrvActive::NewL(MBasrvActiveObserver& aObserver, |
|
31 CActive::TPriority aPriority, TInt aRequestId) |
|
32 { |
|
33 CBasrvActive* self = CBasrvActive::NewLC(aObserver, aPriority, aRequestId); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CBasrvActive* CBasrvActive::NewLC(MBasrvActiveObserver& aObserver, |
|
39 CActive::TPriority aPriority, TInt aRequestId) |
|
40 { |
|
41 CBasrvActive* self = new (ELeave) CBasrvActive(aObserver, aPriority, aRequestId); |
|
42 CleanupStack::PushL(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CBasrvActive::~CBasrvActive() |
|
47 { |
|
48 Cancel(); |
|
49 TRACE_FUNC |
|
50 } |
|
51 |
|
52 void CBasrvActive::GoActive() |
|
53 { |
|
54 TRACE_ASSERT(!IsActive(), -2); |
|
55 SetActive(); |
|
56 TRACE_INFO((_L("CBasrvActive: Service %d starts"), iRequestId)) |
|
57 } |
|
58 |
|
59 TInt CBasrvActive::RequestId() const |
|
60 { |
|
61 return iRequestId; |
|
62 } |
|
63 |
|
64 void CBasrvActive::SetRequestId(TInt aRequestId) |
|
65 { |
|
66 iRequestId = aRequestId; |
|
67 } |
|
68 |
|
69 void CBasrvActive::DoCancel() |
|
70 { |
|
71 iObserver.CancelRequest(*this); |
|
72 TRACE_INFO((_L("Service %d cancelled"), iRequestId)) |
|
73 } |
|
74 |
|
75 void CBasrvActive::RunL() |
|
76 { |
|
77 TRACE_FUNC_ENTRY |
|
78 TRACE_INFO((_L("Service %d completed with %d"), iRequestId, iStatus.Int())) |
|
79 iObserver.RequestCompletedL(*this); |
|
80 TRACE_FUNC_EXIT |
|
81 } |
|
82 |
|
83 TInt CBasrvActive::RunError(TInt aError) |
|
84 { |
|
85 TRACE_INFO((_L("Service %d RunError with %d"), iRequestId, aError)) |
|
86 (void) aError; |
|
87 return KErrNone; |
|
88 } |
|
89 |
|
90 CBasrvActive::CBasrvActive(MBasrvActiveObserver& aObserver, |
|
91 CActive::TPriority aPriority, TInt aRequestId) |
|
92 : CActive(aPriority), iObserver(aObserver), iRequestId(aRequestId) |
|
93 { |
|
94 CActiveScheduler::Add(this); |
|
95 TRACE_FUNC |
|
96 } |
|
97 |
|
98 MBasrvActiveObserver& CBasrvActive::Observer() |
|
99 { |
|
100 return iObserver; |
|
101 } |