15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // System includes |
19 // System includes |
20 |
|
21 // User includes |
|
22 #include <debug.h> |
|
23 #include <liwservicehandler.h> |
20 #include <liwservicehandler.h> |
24 #include <liwvariant.h> |
21 #include <liwvariant.h> |
25 #include <liwgenericparam.h> |
22 #include <liwgenericparam.h> |
26 |
23 |
|
24 // User includes |
27 #include "caicpscommandbuffer.h" |
25 #include "caicpscommandbuffer.h" |
28 #include "aicpsexecuteparam.h" |
26 #include "aicpsexecuteparam.h" |
|
27 #include <debug.h> |
29 |
28 |
30 // Constants |
29 // Constants |
31 _LIT8( KCPSConfigurationIf, "IContentPublishing" ); |
30 _LIT8( KCPSConfigurationIf, "IContentPublishing" ); |
32 _LIT8( KCPS, "Service.ContentPublishing" ); |
31 _LIT8( KCPS, "Service.ContentPublishing" ); |
33 _LIT8( KExecuteAction, "ExecuteAction" ); |
32 _LIT8( KExecuteAction, "ExecuteAction" ); |
34 _LIT8( KExecuteMultipleActions, "ExecuteMultipleActions" ); |
33 _LIT8( KExecuteMultipleActions, "ExecuteMultipleActions" ); |
35 _LIT8( KFilters, "filters" ); |
34 _LIT8( KFilters, "filters" ); |
|
35 |
36 // ======== LOCAL FUNCTIONS ======== |
36 // ======== LOCAL FUNCTIONS ======== |
37 |
37 |
38 // ======== MEMBER FUNCTIONS ======== |
38 // ======== MEMBER FUNCTIONS ======== |
39 // --------------------------------------------------------------------------- |
39 // --------------------------------------------------------------------------- |
40 // CAiCpsCommandBuffer::CAiCpsCommandBuffer |
40 // CAiCpsCommandBuffer::CAiCpsCommandBuffer |
86 // |
86 // |
87 CAiCpsCommandBuffer::~CAiCpsCommandBuffer() |
87 CAiCpsCommandBuffer::~CAiCpsCommandBuffer() |
88 { |
88 { |
89 // Flush any pending commands |
89 // Flush any pending commands |
90 Flush(); |
90 Flush(); |
|
91 |
91 if ( iCpsInterface ) |
92 if ( iCpsInterface ) |
92 { |
93 { |
93 // Close interface |
94 // Close interface |
94 iCpsInterface->Close(); |
95 iCpsInterface->Close(); |
95 } |
96 } |
96 |
97 |
|
98 TRAP_IGNORE( DetachL() ); |
|
99 |
|
100 delete iCpsService; |
|
101 delete iServiceHandler; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CAiCpsCommandBuffer::DetachL |
|
106 // |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CAiCpsCommandBuffer::DetachL() |
|
110 { |
97 if ( iServiceHandler && iCpsService ) |
111 if ( iServiceHandler && iCpsService ) |
98 { |
112 { |
99 // Detach services from the handler |
113 // Detach services from the handler |
100 RCriteriaArray interestList; |
114 RCriteriaArray list; |
101 |
115 CleanupClosePushL( list ); |
102 TRAP_IGNORE( interestList.AppendL( iCpsService ); |
116 |
103 iServiceHandler->DetachL( interestList ); ); |
117 list.AppendL( iCpsService ); |
104 |
118 |
105 interestList.Reset(); |
119 iServiceHandler->DetachL( list ); |
106 } |
120 |
107 |
121 CleanupStack::PopAndDestroy( &list ); |
108 delete iCpsService; |
122 } |
109 delete iServiceHandler; |
|
110 |
|
111 } |
123 } |
112 |
124 |
113 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
114 // CAiCpsCommandBuffer::GetCPSInterfaceL |
126 // CAiCpsCommandBuffer::GetCPSInterfaceL |
115 // |
127 // |
116 // --------------------------------------------------------------------------- |
128 // --------------------------------------------------------------------------- |
117 // |
129 // |
118 void CAiCpsCommandBuffer::GetCPSInterfaceL() |
130 void CAiCpsCommandBuffer::GetCPSInterfaceL() |
119 { |
131 { |
120 iServiceHandler = CLiwServiceHandler::NewL(); |
132 if ( iCpsInterface ) |
|
133 { |
|
134 return; |
|
135 } |
121 |
136 |
122 RCriteriaArray interestList; |
137 RCriteriaArray interestList; |
123 |
138 CleanupClosePushL( interestList ); |
124 // Attach to CPS: |
139 |
125 iCpsService = CLiwCriteriaItem::NewL( 1, KCPSConfigurationIf, KCPS ); |
140 CLiwServiceHandler* serviceHandler = CLiwServiceHandler::NewL(); |
126 iCpsService->SetServiceClass( TUid::Uid( KLiwClassBase ) ); |
141 CleanupStack::PushL( serviceHandler ); |
127 |
142 |
128 interestList.AppendL( iCpsService ); |
143 // Attach to CPS: |
129 iServiceHandler->AttachL( interestList ); |
144 CLiwCriteriaItem* cpsService = CLiwCriteriaItem::NewL( 1, KCPSConfigurationIf, KCPS ); |
130 interestList.Reset(); |
145 CleanupStack::PushL( cpsService ); |
131 |
146 |
132 CLiwGenericParamList& inParamList( iServiceHandler->InParamListL() ); |
147 cpsService->SetServiceClass( TUid::Uid( KLiwClassBase ) ); |
133 CLiwGenericParamList& outParamList( iServiceHandler->OutParamListL() ); |
148 |
134 |
149 interestList.AppendL( cpsService ); |
135 iServiceHandler->ExecuteServiceCmdL( |
150 serviceHandler->AttachL( interestList ); |
136 *iCpsService, |
151 |
|
152 CLiwGenericParamList& inParamList( serviceHandler->InParamListL() ); |
|
153 CLiwGenericParamList& outParamList( serviceHandler->OutParamListL() ); |
|
154 |
|
155 serviceHandler->ExecuteServiceCmdL( |
|
156 *cpsService, |
137 inParamList, |
157 inParamList, |
138 outParamList ); |
158 outParamList ); |
139 |
159 |
140 TInt pos( 0 ); |
160 TInt pos( 0 ); |
141 |
161 |
142 outParamList.FindFirst( pos, KCPSConfigurationIf ); |
162 outParamList.FindFirst( pos, KCPSConfigurationIf ); |
143 |
163 |
144 if ( pos != KErrNotFound ) |
164 if ( pos != KErrNotFound ) |
145 { |
165 { |
146 iCpsInterface = (outParamList)[pos].Value().AsInterface(); |
166 iCpsInterface = (outParamList)[pos].Value().AsInterface(); |
147 inParamList.Reset(); |
167 inParamList.Reset(); |
148 outParamList.Reset(); |
168 outParamList.Reset(); |
149 } |
169 } |
150 else |
170 else |
151 { |
171 { |
152 inParamList.Reset(); |
172 inParamList.Reset(); |
153 outParamList.Reset(); |
173 outParamList.Reset(); |
154 User::Leave( KErrNotFound ); |
174 User::Leave( KErrNotFound ); |
155 } |
175 } |
|
176 |
|
177 CleanupStack::Pop( cpsService ); |
|
178 iCpsService = cpsService; |
|
179 |
|
180 CleanupStack::Pop( serviceHandler ); |
|
181 iServiceHandler = serviceHandler; |
|
182 |
|
183 CleanupStack::PopAndDestroy( &interestList ); |
156 } |
184 } |
157 |
185 |
158 // --------------------------------------------------------------------------- |
186 // --------------------------------------------------------------------------- |
159 // CAiCpsCommandBuffer::AddCommand |
187 // CAiCpsCommandBuffer::AddCommand |
160 // |
188 // |
170 |
198 |
171 __PRINTS( "CAiCpsCommandBuffer::AddCommand - done" ); |
199 __PRINTS( "CAiCpsCommandBuffer::AddCommand - done" ); |
172 } |
200 } |
173 |
201 |
174 // --------------------------------------------------------------------------- |
202 // --------------------------------------------------------------------------- |
|
203 // CAiCpsCommandBuffer::ServiceHandler |
|
204 // |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 CLiwServiceHandler* CAiCpsCommandBuffer::ServiceHandler() const |
|
208 { |
|
209 return iServiceHandler; |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // CAiCpsCommandBuffer::CpsInterface |
|
214 // |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 MLiwInterface* CAiCpsCommandBuffer::CpsInterface() const |
|
218 { |
|
219 return iCpsInterface; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
175 // CAiCpsCommandBuffer::DoAddCommandL |
223 // CAiCpsCommandBuffer::DoAddCommandL |
176 // |
224 // |
177 // --------------------------------------------------------------------------- |
225 // --------------------------------------------------------------------------- |
178 // |
226 // |
179 void CAiCpsCommandBuffer::DoAddCommandL( const TDesC& aPluginId, |
227 void CAiCpsCommandBuffer::DoAddCommandL( const TDesC& aPluginId, |
180 const TDesC& aType, CLiwDefaultMap* aFilter, |
228 const TDesC& aType, CLiwDefaultMap* aFilter, |
181 const TDesC8& aAction ) |
229 const TDesC8& aAction ) |
182 { |
230 { |
183 TInt found = KErrNotFound; |
231 TInt found( KErrNotFound ); |
184 for (TInt i=0; i< iPlugins.Count(); i++) |
232 |
|
233 for ( TInt i = 0; i < iPlugins.Count(); i++ ) |
185 { |
234 { |
186 if ( aPluginId == iPlugins[i]->PluginId() ) |
235 if ( aPluginId == iPlugins[i]->PluginId() ) |
187 { |
236 { |
188 found = i; |
237 found = i; |
189 break; |
238 break; |
201 param->SetRegistryTypeL( aType ); |
250 param->SetRegistryTypeL( aType ); |
202 param->SetFilterL( aFilter ); |
251 param->SetFilterL( aFilter ); |
203 param->AddActionL( aAction ); |
252 param->AddActionL( aAction ); |
204 iPlugins.AppendL( param ); |
253 iPlugins.AppendL( param ); |
205 CleanupStack::Pop( param ); |
254 CleanupStack::Pop( param ); |
206 } |
255 } |
207 |
|
208 } |
256 } |
209 |
257 |
210 // --------------------------------------------------------------------------- |
258 // --------------------------------------------------------------------------- |
211 // CAiCpsCommandBuffer::Flush |
259 // CAiCpsCommandBuffer::Flush |
212 // |
260 // |
213 // --------------------------------------------------------------------------- |
261 // --------------------------------------------------------------------------- |
214 // |
262 // |
215 void CAiCpsCommandBuffer::Flush() |
263 void CAiCpsCommandBuffer::Flush() |
216 { |
264 { |
217 __PRINTS( "CAiCpsCommandBuffer::Flush, start" ); |
265 __PRINTS( "CAiCpsCommandBuffer::Flush, start" ); |
|
266 |
218 if ( iPlugins.Count() > 0 ) |
267 if ( iPlugins.Count() > 0 ) |
219 { |
268 { |
220 TRAP_IGNORE( DoFlushL() ); |
269 TRAP_IGNORE( DoFlushL() ); |
221 } |
270 } |
|
271 |
222 __PRINTS( "CAiCpsCommandBuffer::Flush - done" ); |
272 __PRINTS( "CAiCpsCommandBuffer::Flush - done" ); |
223 } |
273 } |
224 |
274 |
225 // --------------------------------------------------------------------------- |
275 // --------------------------------------------------------------------------- |
226 // CAiCpsCommandBuffer::DoFlushL |
276 // CAiCpsCommandBuffer::DoFlushL |
227 // |
277 // |
228 // --------------------------------------------------------------------------- |
278 // --------------------------------------------------------------------------- |
229 // |
279 // |
230 void CAiCpsCommandBuffer::DoFlushL() |
280 void CAiCpsCommandBuffer::DoFlushL() |
231 { |
281 { |
232 if ( !iCpsInterface ) |
282 if ( !iCpsInterface ) |
233 { |
283 { |
234 GetCPSInterfaceL(); |
284 GetCPSInterfaceL(); |
235 } |
285 } |
236 |
286 |
237 if(iCpsInterface) |
287 if ( iCpsInterface ) |
238 { |
288 { |
239 __PRINTS( "CAiCpsCommandBuffer::DoFlush : Execute" ); |
289 __PRINTS( "CAiCpsCommandBuffer::DoFlush : Execute" ); |
240 TInt pluginCount = iPlugins.Count(); |
290 |
|
291 TInt pluginCount( iPlugins.Count() ); |
|
292 |
241 CLiwDefaultList* pluginCmdList = CLiwDefaultList::NewLC(); |
293 CLiwDefaultList* pluginCmdList = CLiwDefaultList::NewLC(); |
242 |
294 |
243 for (TInt i=0; i < pluginCount; i++ ) |
295 for ( TInt i = 0; i < pluginCount; i++ ) |
244 { |
296 { |
245 CLiwDefaultMap* inParamMap = iPlugins[i]->InParamMapLC(); |
297 CLiwDefaultMap* inParamMap = iPlugins[i]->InParamMapLC(); |
246 pluginCmdList->AppendL( inParamMap ); |
298 pluginCmdList->AppendL( inParamMap ); |
247 CleanupStack::PopAndDestroy( inParamMap ); |
299 CleanupStack::PopAndDestroy( inParamMap ); |
248 } |
300 } |
|
301 |
249 CLiwGenericParamList* inParamList = CLiwGenericParamList::NewLC(); |
302 CLiwGenericParamList* inParamList = CLiwGenericParamList::NewLC(); |
250 CLiwGenericParamList* outParamList = CLiwGenericParamList::NewLC(); |
303 CLiwGenericParamList* outParamList = CLiwGenericParamList::NewLC(); |
251 |
304 |
252 TLiwGenericParam item( KFilters, TLiwVariant ( pluginCmdList)); |
305 TLiwGenericParam item( KFilters, TLiwVariant ( pluginCmdList ) ); |
253 inParamList->AppendL( item ); |
306 inParamList->AppendL( item ); |
254 |
307 |
255 iCpsInterface->ExecuteCmdL( KExecuteMultipleActions, *inParamList, *outParamList); |
308 iCpsInterface->ExecuteCmdL( KExecuteMultipleActions, *inParamList, *outParamList); |
256 |
309 |
257 CleanupStack::PopAndDestroy( outParamList ); |
310 CleanupStack::PopAndDestroy( 3, pluginCmdList ); // outparamList, inParamList |
258 CleanupStack::PopAndDestroy( inParamList ); |
311 |
259 CleanupStack::PopAndDestroy( pluginCmdList ); |
312 iPlugins.ResetAndDestroy(); |
260 } |
313 } |
261 else |
|
262 { |
|
263 User::Leave( KErrNotSupported ); |
|
264 } |
|
265 iPlugins.ResetAndDestroy(); |
|
266 } |
314 } |
267 |
315 |
268 // End of file |
316 // End of file |