1 /* |
|
2 * Copyright (c) 2002-2005 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: Feature Manager stub plugin |
|
15 * implementation. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "featmgrplugin.h" |
|
21 #include <featureinfoplugin.h> |
|
22 #include "trace.h" |
|
23 |
|
24 CFeatMgrPlugin* CFeatMgrPlugin::NewL() |
|
25 { |
|
26 CFeatMgrPlugin* self = new(ELeave) CFeatMgrPlugin(); |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 CleanupStack::Pop(); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CFeatMgrPlugin::~CFeatMgrPlugin() |
|
34 { |
|
35 if ( iTimer ) |
|
36 { |
|
37 delete iTimer; |
|
38 iTimer = NULL; |
|
39 } |
|
40 } |
|
41 |
|
42 CFeatMgrPlugin::CFeatMgrPlugin() |
|
43 { |
|
44 } |
|
45 |
|
46 void CFeatMgrPlugin::ConstructL() |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 void CFeatMgrPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId, |
|
52 const TUint8 aTransId, |
|
53 TDesC8& /*aData*/ ) |
|
54 { |
|
55 COMPONENT_TRACE((_L("FeatMgrPlugin: Processing command: 0x%x, TransId: 0x%x"), |
|
56 aCommandId, aTransId)); |
|
57 |
|
58 switch ( aCommandId ) |
|
59 { |
|
60 case FeatureInfoCommand::ELoadFeatureInfoCmdId: |
|
61 { |
|
62 COMPONENT_TRACE(_L("FeatMgrPlugin: Processed ELoadFeatureInfoCmdId")); |
|
63 // Load feature info |
|
64 } |
|
65 break; |
|
66 default : |
|
67 { |
|
68 COMPONENT_TRACE((_L("FeatMgrPlugin: Unknown Command: 0x%x"), aCommandId)); |
|
69 } |
|
70 break; |
|
71 } |
|
72 |
|
73 TInt retval(KErrNone); |
|
74 TInt timeout( 1000 ); // microseconds |
|
75 |
|
76 // create new timer |
|
77 |
|
78 |
|
79 iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this); |
|
80 } |
|
81 |
|
82 void CFeatMgrPlugin::GenericTimerFiredL( |
|
83 MFeatureInfoPluginCallback& aService, |
|
84 FeatureInfoCommand::TFeatureInfoCmd aCommandId, |
|
85 TUint8 aTransId, |
|
86 TInt /*aRetVal*/) |
|
87 { |
|
88 COMPONENT_TRACE((_L("FeatMgr Plugin: GenericTimerFiredL (0x%x, 0x%x)"), |
|
89 aCommandId, aTransId)); |
|
90 |
|
91 //__ASSERT_ALWAYS(!(&aService), User::Invariant() ); |
|
92 |
|
93 RArray<FeatureInfoCommand::TFeature>* list = |
|
94 new(ELeave) RArray<FeatureInfoCommand::TFeature>(1); |
|
95 |
|
96 FeatureInfoCommand::TFeatureInfo featureList; |
|
97 TInt err( KErrNone ); |
|
98 |
|
99 // |
|
100 // TEST CASES |
|
101 // |
|
102 |
|
103 /***/ |
|
104 // For testing, case 1. |
|
105 // Returns empty list and KErrNone. |
|
106 |
|
107 featureList.iErrorCode = KErrNone; |
|
108 featureList.iList = *list; |
|
109 |
|
110 FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList); |
|
111 |
|
112 TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage)); |
|
113 /***/ |
|
114 |
|
115 /*** |
|
116 // For testing, case 2. |
|
117 // Returns one feature and KErrNone. |
|
118 |
|
119 FeatureInfoCommand::TFeature feature1; |
|
120 feature1.iFeatureID = KFeatureIdBt; |
|
121 feature1.iValue = ETrue; |
|
122 |
|
123 list->Append(feature1); |
|
124 |
|
125 featureList.iErrorCode = KErrNone; |
|
126 featureList.iList = *list; |
|
127 |
|
128 FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList); |
|
129 |
|
130 TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage)); |
|
131 ***/ |
|
132 |
|
133 /*** |
|
134 // For testing, case 3. |
|
135 // Returns three features and KErrNone |
|
136 |
|
137 FeatureInfoCommand::TFeature feature1; |
|
138 FeatureInfoCommand::TFeature feature2; |
|
139 FeatureInfoCommand::TFeature feature3; |
|
140 |
|
141 feature1.iFeatureID = KFeatureIdBt; |
|
142 feature1.iValue = EFalse; |
|
143 |
|
144 feature1.iFeatureID = KFeatureIdIrda; |
|
145 feature1.iValue = ETrue; |
|
146 |
|
147 feature1.iFeatureID = KFeatureIdProtocolWlan; |
|
148 feature1.iValue = EFalse; |
|
149 |
|
150 list->Append(feature1); |
|
151 list->Append(feature2); |
|
152 list->Append(feature3); |
|
153 |
|
154 featureList.iErrorCode = KErrNone; |
|
155 featureList.iList = *list; |
|
156 |
|
157 FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList); |
|
158 |
|
159 TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage)); |
|
160 ***/ |
|
161 |
|
162 /*** |
|
163 // For testing, case 4. |
|
164 // Returns empty list and KErrArgument. |
|
165 |
|
166 featureList.iErrorCode = KErrArgument; |
|
167 featureList.iList = *list; |
|
168 |
|
169 FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList); |
|
170 |
|
171 TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage)); |
|
172 ***/ |
|
173 |
|
174 /*** |
|
175 // For testing, case 5. |
|
176 // ProcessResponseL never called. |
|
177 ***/ |
|
178 |
|
179 list->Reset(); |
|
180 delete list; |
|
181 |
|
182 // TEST CASES END |
|
183 |
|
184 if ( err != KErrNone ) |
|
185 { |
|
186 COMPONENT_TRACE((_L("FeatMgr Plugin: Error in ProcessResponseL: %d"), err)); |
|
187 } |
|
188 |
|
189 if ( iTimer && !iTimer->IsActive() ) |
|
190 { |
|
191 delete iTimer; |
|
192 iTimer = NULL; |
|
193 COMPONENT_TRACE((_L("FeatMgr Plugin: GenericTimerFiredL - Removed obsolete timer"))); |
|
194 } |
|
195 } |
|
196 |
|