|
1 /* |
|
2 * Copyright (c) 2005-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: |
|
15 * @file |
|
16 * This contains CCommandProcessor |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @prototype |
|
24 @test |
|
25 */ |
|
26 |
|
27 #include "CommandProcessor.h" |
|
28 |
|
29 EXPORT_C CCommandProcessor::~CCommandProcessor() |
|
30 /** |
|
31 * Destructor |
|
32 */ |
|
33 { |
|
34 Cancel(); |
|
35 } |
|
36 |
|
37 EXPORT_C CCommandProcessor* CCommandProcessor::NewL(MCommandProcessorCallback& aCallback, TInt aPriority) |
|
38 /** |
|
39 * Two phase constructor that allocates and constructs |
|
40 * a new Active object whos actions are performed by a callback |
|
41 * |
|
42 * @param aCallback - object to inform on RunL. |
|
43 * @param aPriority - priority of active object. |
|
44 * |
|
45 * @leave system wide error |
|
46 * |
|
47 * @see MCommandProcessorCallback |
|
48 * |
|
49 * @return New Callback active object. |
|
50 */ |
|
51 { |
|
52 CCommandProcessor* self=NewLC(aCallback, aPriority); |
|
53 CleanupStack::Pop(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 EXPORT_C CCommandProcessor* CCommandProcessor::NewLC(MCommandProcessorCallback& aCallback, TInt aPriority) |
|
58 /** |
|
59 * Two phase constructor that allocates and constructs |
|
60 * a new Active object whos actions are performed by a callback |
|
61 * |
|
62 * @param aCallback - object to inform on RunL. |
|
63 * @param aPriority - priority of active object. |
|
64 * |
|
65 * @leave system wide error |
|
66 * |
|
67 * @see MCommandProcessorCallback |
|
68 * |
|
69 * @return New Callback active object. |
|
70 */ |
|
71 { |
|
72 CCommandProcessor* self=new(ELeave) CCommandProcessor(aCallback, aPriority); |
|
73 CleanupStack::PushL(self); |
|
74 self->ConstructL(); |
|
75 return self; |
|
76 } |
|
77 |
|
78 EXPORT_C void CCommandProcessor::Activate() |
|
79 /** |
|
80 * Activate the object |
|
81 */ |
|
82 { |
|
83 SetActive(); |
|
84 } |
|
85 |
|
86 EXPORT_C void CCommandProcessor::KickState() |
|
87 /** |
|
88 * Kick Start the object |
|
89 */ |
|
90 { |
|
91 TRequestStatus* status = &iStatus; |
|
92 User::RequestComplete(status, KErrNone); |
|
93 SetActive(); |
|
94 } |
|
95 |
|
96 CCommandProcessor::CCommandProcessor(MCommandProcessorCallback& aCallback, TInt aPriority) |
|
97 /** |
|
98 * Protected constructor with timer completion callback and priority. |
|
99 * |
|
100 * Called by two phase constructor. |
|
101 * |
|
102 * @param aTestTimerCallback - object to inform on timer completion. |
|
103 * @param aPriority - priority of active object. |
|
104 * |
|
105 * @see MCommandProcessorCallback |
|
106 */ |
|
107 : CActive(aPriority) |
|
108 , iCallback(aCallback) |
|
109 { |
|
110 } |
|
111 |
|
112 void CCommandProcessor::ConstructL() |
|
113 /** |
|
114 * This is internal and not intended for use. |
|
115 * |
|
116 * Second phase of two phase constructor. |
|
117 * |
|
118 * @leave system wide error |
|
119 */ |
|
120 { |
|
121 CActiveScheduler::Add(this); |
|
122 } |
|
123 |
|
124 void CCommandProcessor::RunL() |
|
125 /** |
|
126 * Active object RunL implementation. |
|
127 * |
|
128 * Calls the MCommandProcessorCallback::NextCommandL to inform user that the RunL has been reached. |
|
129 * |
|
130 * @leave system wide error |
|
131 */ |
|
132 { |
|
133 iCallback.NextCommandL(); |
|
134 } |
|
135 |
|
136 void CCommandProcessor::DoCancel() |
|
137 /** |
|
138 * Active object DoCancel implementation. |
|
139 * |
|
140 * Calls the MCommandProcessorCallback::DoCancel to inform user that the DoCancel has been reached. |
|
141 */ |
|
142 { |
|
143 } |