|
1 /* |
|
2 * Copyright (c) 2003-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 the License "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: Implementation class for CLiwServiceHandler. |
|
15 * See also LiwServiceHandler.h. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #ifndef LIW_SERVICE_HANDLER_IMPL_H |
|
26 #define LIW_SERVICE_HANDLER_IMPL_H |
|
27 |
|
28 // INCLUDES |
|
29 #include <ecom/ecom.h> |
|
30 #include <barsread.h> |
|
31 #include <liwcommon.h> |
|
32 #include "liwtlsdata.h" |
|
33 #include <eikmobs.h> |
|
34 #include <e32capability.h> |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 // MACROS |
|
39 |
|
40 // FUNCTION PROTOTYPES |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CLiwMenuBinding; |
|
44 class CLiwMenuPane; |
|
45 class CLiwServiceIfMenu; |
|
46 class CLiwServiceIfBase; |
|
47 class CLiwEcomMonitor; |
|
48 class CRTSecMgrScriptSession; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 /** |
|
53 * Internal implementation class for CLiwServiceHandler. |
|
54 * |
|
55 * Contains the actual implementation logic for Service Handler, whereas the |
|
56 * CLiwServiceHandler class provides only the public API. |
|
57 * |
|
58 * @see CLiwServiceHandler for API documentation. |
|
59 * @since Series 60 2.6 |
|
60 */ |
|
61 NONSHARABLE_CLASS(CLiwServiceHandlerImpl) : |
|
62 public CBase, |
|
63 public MLiwNotifyCallback, |
|
64 public MEikMenuObserver, |
|
65 public MLiwMenuLaunchObserver |
|
66 { |
|
67 public: // Construction & destruction |
|
68 /** |
|
69 * Constructs CLiwServiceHandlerImpl instance. |
|
70 * |
|
71 * @return Pointer to the new instance. |
|
72 */ |
|
73 static CLiwServiceHandlerImpl* NewL(); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CLiwServiceHandlerImpl(); |
|
79 |
|
80 public: // Management |
|
81 /** |
|
82 * @see CLiwServiceHandler::Reset() |
|
83 */ |
|
84 void Reset(); |
|
85 |
|
86 /** |
|
87 * @see CLiwServiceHandler::NbrOfProviders() |
|
88 */ |
|
89 TInt NbrOfProviders(const CLiwCriteriaItem* aCriteria); |
|
90 |
|
91 |
|
92 |
|
93 public: // Interest handling |
|
94 /** |
|
95 * @see CLiwServiceHandler::AttachL() |
|
96 */ |
|
97 void AttachL(TInt aInterestResourceId); |
|
98 |
|
99 /** |
|
100 * @see CLiwServiceHandler::AttachL() |
|
101 */ |
|
102 TInt AttachL(const RCriteriaArray& aInterest); |
|
103 |
|
104 TInt AttachL(const RCriteriaArray& aInterest,CRTSecMgrScriptSession* aSecMgrScriptSession); |
|
105 /** |
|
106 * @see CLiwServiceHandler::QueryImplementationL() |
|
107 */ |
|
108 void QueryImplementationL(CLiwCriteriaItem* aItem, RCriteriaArray& aProviderList); |
|
109 void GetCapabilitiesL(RArray<TCapability>& secMgrCapList,CLiwGenericParamList* pMetaData); |
|
110 |
|
111 /** |
|
112 * @see CLiwServiceHandler::GetInterest() |
|
113 */ |
|
114 void GetInterest(RCriteriaArray& aInterest); |
|
115 |
|
116 /** |
|
117 * @see CLiwServiceHandler::DetachL() |
|
118 */ |
|
119 void DetachL(const RCriteriaArray& aInterest); |
|
120 |
|
121 /** |
|
122 * @see CLiwServiceHandler::DetachL() |
|
123 */ |
|
124 void DetachL(TInt aInterestResourceId); |
|
125 |
|
126 /** |
|
127 * @see CLiwServiceHandler::GetCriteria() |
|
128 */ |
|
129 const CLiwCriteriaItem* GetCriteria(TInt aId); |
|
130 |
|
131 /** |
|
132 * @see CLiwServiceHandler::InParamListL() |
|
133 */ |
|
134 CLiwGenericParamList& InParamListL(); |
|
135 |
|
136 /** |
|
137 * @see CLiwServiceHandler::OutParamListL() |
|
138 */ |
|
139 CLiwGenericParamList& OutParamListL(); |
|
140 |
|
141 public: // Menu handling |
|
142 /** |
|
143 * @see CLiwServiceHandler::InitializeMenuPaneL() |
|
144 */ |
|
145 void InitializeMenuPaneL( |
|
146 CEikMenuPane& aMenuPane, |
|
147 TInt aMenuResourceId, |
|
148 TInt aBaseMenuCmdId, |
|
149 const CLiwGenericParamList& aInParamList); |
|
150 /** |
|
151 * @see CLiwServiceHandler::InitializeMenuPaneL() |
|
152 */ |
|
153 void InitializeMenuPaneL( |
|
154 CEikMenuPane& aMenuPane, |
|
155 TInt aMenuResourceId, |
|
156 TInt aBaseMenuCmdId, |
|
157 const CLiwGenericParamList& aInParamList, |
|
158 TBool aUseSubmenuTextsIfAvailable); |
|
159 |
|
160 /** |
|
161 * @see CLiwServiceHandler::ServiceCmdByMenuCmd() |
|
162 */ |
|
163 TInt ServiceCmdByMenuCmd(TInt aMenuCmdId) const; |
|
164 |
|
165 /** |
|
166 * @see CLiwServiceHandler::ExecuteMenuCmdL() |
|
167 */ |
|
168 void ExecuteMenuCmdL( |
|
169 TInt aMenuCmdId, |
|
170 const CLiwGenericParamList& aInParamList, |
|
171 CLiwGenericParamList& aOutParamList, |
|
172 TUint aCmdOptions = 0, |
|
173 MLiwNotifyCallback* aCallback= NULL); |
|
174 |
|
175 /** |
|
176 * @see CLiwServiceHandler::AttachMenuL() |
|
177 */ |
|
178 void AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId); |
|
179 |
|
180 /** |
|
181 * @see CLiwServiceHandler::AttachMenuL() |
|
182 */ |
|
183 void AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader); |
|
184 |
|
185 /** |
|
186 * @see CLiwServiceHandler::AttachMenuL() |
|
187 */ |
|
188 void AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest); |
|
189 |
|
190 /** |
|
191 * Attach menu related criteria items to given menu. |
|
192 * |
|
193 * @param aMenuEntries List of menu command ids. |
|
194 * @param aMenuResourceId Menu to be attached. |
|
195 * @param aInterest Interest list. |
|
196 */ |
|
197 void AttachMenuL(RArray<TInt>& aMenuEntries, TInt aMenuResourceId, RCriteriaArray& aInterest); |
|
198 |
|
199 /** |
|
200 * Attach menu related criteria items to given menu. |
|
201 * |
|
202 * @param aMenuResourceId Resource reader pointing |
|
203 * to menu to be attached. |
|
204 */ |
|
205 |
|
206 //void AttachMenuL(TResourceReader& aReader, TInt aMenuId, RCriteriaArray& aInterest); |
|
207 |
|
208 /** |
|
209 * @see CLiwServiceHandler::DetachMenu() |
|
210 */ |
|
211 void DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId); |
|
212 |
|
213 /** |
|
214 * @see CLiwServiceHandler::IsSubMenuEmpty() |
|
215 */ |
|
216 TBool IsSubMenuEmpty(TInt aSubMenuId); |
|
217 |
|
218 /** |
|
219 * @see CLiwServiceHandler::IsLiwMenu() |
|
220 */ |
|
221 TBool IsLiwMenu(TInt aMenuResourceId); |
|
222 |
|
223 /** |
|
224 * @see CLiwServiceHandler::HandleSubmenuL() |
|
225 */ |
|
226 TBool HandleSubmenuL(CEikMenuPane& aPane); |
|
227 |
|
228 public: // Generic service command handling |
|
229 /** |
|
230 * @see CLiwServiceHandler::ExecuteServiceCmdL() |
|
231 */ |
|
232 void ExecuteServiceCmdL( |
|
233 const TInt& aCmdId, |
|
234 const CLiwGenericParamList& aInParamList, |
|
235 CLiwGenericParamList& aOutParamList, |
|
236 TUint aCmdOptions = 0, |
|
237 MLiwNotifyCallback* aCallback = 0); |
|
238 |
|
239 /** |
|
240 * @see CLiwServiceHandler::ExecuteServiceCmdL() |
|
241 */ |
|
242 void ExecuteServiceCmdL( |
|
243 const CLiwCriteriaItem& aCmd, |
|
244 const CLiwGenericParamList& aInParamList, |
|
245 CLiwGenericParamList& aOutParamList, |
|
246 TUint aCmdOptions = 0, |
|
247 MLiwNotifyCallback* aCallback = 0); |
|
248 |
|
249 /** |
|
250 * @see CLiwServiceHandler::MenuCmdId() |
|
251 */ |
|
252 TInt MenuCmdId(TInt aMenuCmdId) const; |
|
253 |
|
254 public: // Other new methods |
|
255 /** |
|
256 * Called by CLiwEcomMonitor. |
|
257 * |
|
258 * @param aImpl An object representing this class. |
|
259 * @return An error code. KErrNone if successful. |
|
260 */ |
|
261 static TInt SynchronizeCallBack(TAny* aImpl); |
|
262 |
|
263 public: // From MLiwNotifyCallback |
|
264 TInt HandleNotifyL( |
|
265 TInt aCmdId, |
|
266 TInt aEventId, |
|
267 CLiwGenericParamList& aEventParamList, |
|
268 const CLiwGenericParamList& aInParamList); |
|
269 |
|
270 public: // From MEikMenuObserver |
|
271 void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis); |
|
272 |
|
273 public: // From MEikCommandObserver (via MEikMenuObserver) |
|
274 void ProcessCommandL(TInt aCommandId); |
|
275 |
|
276 void GetProviderCapability(CLiwCriteriaItem* aItem,RCriteriaArray& aOutItem); |
|
277 |
|
278 private: // From MLiwMenuLaunchObserver |
|
279 void MenuLaunched(); |
|
280 |
|
281 private: |
|
282 // Possible placeholder types. |
|
283 enum TLiwPlaceholderType |
|
284 { |
|
285 ELiwPlaceholderNormal, |
|
286 ELiwPlaceholderCascade, |
|
287 ELiwPlaceholderIntelligentCascade |
|
288 }; |
|
289 |
|
290 private: |
|
291 CLiwServiceHandlerImpl(); |
|
292 void ConstructL(); |
|
293 |
|
294 // Attach menu related criteria items to given menu. |
|
295 void DoAttachMenuL(TResourceReader& aReader, TInt aMenuId, RCriteriaArray& aInterest); |
|
296 |
|
297 TInt DoAttachL(const RCriteriaArray& aInterest,CRTSecMgrScriptSession* aScriptSession); |
|
298 void DoAttachL(const RCriteriaArray& aInterest); |
|
299 |
|
300 void ReadInterestListL(TResourceReader& aReader, RPointerArray<CLiwCriteriaItem>& aResult); |
|
301 TInt ResolveProvidersL(CLiwBinding* aBinding, CLiwCriteriaItem* aItem, CRTSecMgrScriptSession* aScriptSession); |
|
302 TInt ResolveProvidersL(CLiwBinding* aBinding, CLiwCriteriaItem* aItem); |
|
303 |
|
304 TBool IsCached(CLiwServiceIfBase* aProvider); |
|
305 |
|
306 CLiwMenuPane* CreateEmptyLiwMenuPaneL(TInt aBaseMenuCmdId, TInt aResourceId); |
|
307 void DeleteLiwMenuPane(CLiwMenuPane* aLiwPane); |
|
308 |
|
309 TInt ResourceIdForNextFreeSlot(); |
|
310 void CopyMenuItemsL(CLiwMenuPane* aSource, CEikMenuPane& aDest, TInt aStartIndex, |
|
311 TBool aIsSubmenu); |
|
312 TInt SlotItemCmd(CEikMenuPane& aPane); |
|
313 CLiwMenuPane* MenuPaneForSlotCmd(TInt aCmdId); |
|
314 TLiwPlaceholderType PlaceholderType(CEikMenuPane& aPane, TInt aCmd, TBool& aTitleLocked); |
|
315 void ConvertPlaceholderL(CEikMenuPane& aPane, TInt aCmd, CLiwMenuPane& aLiwPane, |
|
316 const TDesC& aTitle); |
|
317 void UnCascadeL(CEikMenuPane& aPane, TInt aCmd, CLiwMenuPane& aLiwPane); |
|
318 void SkipMenuFields(TResourceReader& aReader); |
|
319 TBool IsInLastInitialized(CLiwMenuPane* liwPane) const; |
|
320 TBool GetSubmenuTitle(CEikMenuPane& aPane, TDes& aResult); |
|
321 TBool IsCriteriaAlreadyInInterest(CLiwCriteriaItem& aItem, |
|
322 RPointerArray<CLiwCriteriaItem>& aInterest) const; |
|
323 CLiwCriteriaItem* ConvertCriteriaItemPointerL(CLiwCriteriaItem* aCandidate); |
|
324 void FilterInterestListL(RPointerArray<CLiwCriteriaItem>& aOrginal, |
|
325 RPointerArray<CLiwCriteriaItem>& aFiltered); |
|
326 void FilterInfoArray(RImplInfoPtrArray& aArray, RArray<TInt32>& aArrayPlugin, |
|
327 CLiwCriteriaItem* aItem); |
|
328 CLiwMenuBinding* AlreadyBound(TInt aMenuId, TInt aMenuCmd, TInt aMenuItemIndex) const; |
|
329 void SynchronizeDbL(); |
|
330 void ListProvidersForCriteriaL(RArray<TInt>& aResult, CLiwCriteriaItem& aItem); |
|
331 void HandleRemovedProviders(RArray<TInt>& aInMemory, RImplInfoPtrArray& aOnSystem); |
|
332 void HandleNewProvidersL(RArray<TInt>& aInMemory, RImplInfoPtrArray& aOnSystem, |
|
333 CLiwCriteriaItem* aItem); |
|
334 void RemoveProvider(TInt aImplUid); |
|
335 void AddProviderL(TUid aImplUid, CLiwCriteriaItem* aItem); |
|
336 inline void ClearMenuPaneArray(); |
|
337 void AttachServiceManagerPluginsL(); |
|
338 void ServiceManagerPlugin_ListImplementationsL(RArray<TInt32>& aArray, CLiwCriteriaItem* aItem); |
|
339 CLiwServiceIfBase* ServiceManagerPlugin_CreateImplementationL(TInt32 aImplUid); |
|
340 TInt NumAlreadyInitializedPaneIdsL() const; |
|
341 |
|
342 // Leaving helper method. Handler cleanupstack issues and calls ReadInterestListL(). |
|
343 void ReadInterestL(RCriteriaArray& aInterest, TInt aInterestResourceId); |
|
344 |
|
345 // Detaches all items from given menu. |
|
346 void DoDetachMenu(TInt aMenuResourceId); |
|
347 |
|
348 // Detaches only those items from a given menu, which match the given interest. |
|
349 |
|
350 |
|
351 void DoDetachMenu(TInt aMenuResourceId, RCriteriaArray& aInterest); |
|
352 |
|
353 // Removes unnecessary criteria items from Service Handler. |
|
354 void RemoveObsoleteCriteriaItems(); |
|
355 |
|
356 // Removes unnecessary providers from Service Handler. |
|
357 void RemoveObsoleteProviders(); |
|
358 |
|
359 /* Parses the metadata information stored in the opaque_data field |
|
360 * of service provider registration information \c REGISTRY_INFO. |
|
361 * |
|
362 * The metadata information is seprated from the service command definition |
|
363 * in the opaque_data field using a separator "::". |
|
364 * |
|
365 * @param aOpaque the opaque_data values specified in the registration information |
|
366 * @param aMetaData the parsed metadata entries will be stored in this variable |
|
367 * |
|
368 */ |
|
369 void ParseMetaData(const TDesC8& aOpaque, TDes8& aMetaData); |
|
370 |
|
371 //To fetch the infoArray |
|
372 void QueryImplementationL(CLiwCriteriaItem* aItem, RImplInfoPtrArray& aInfoArray); |
|
373 |
|
374 TCapability GetServiceCapability(const TDesC& aCapName); |
|
375 |
|
376 //To fetch the version range specified by the consumer while creating Criteria |
|
377 TBool GetVersionRange(CLiwCriteriaItem* aItem,TReal& aMinVersion, TReal& aMaxVersion); |
|
378 |
|
379 //To fetch the version range specified by the consumer while creating Criteria |
|
380 TBool GetVersion (CLiwCriteriaItem* aItem,TReal& aVersion); |
|
381 |
|
382 //To fetch the implementation version specified in provider metadata |
|
383 void ComputeIntfVersion(CLiwServiceData* pProvMetaData,TReal& aIntfVersion); |
|
384 |
|
385 private: |
|
386 // Pointer to the control environment. |
|
387 CCoeEnv* iCoeEnv; |
|
388 |
|
389 // Owns all the attached criteria items. |
|
390 RPointerArray<CLiwCriteriaItem> iInterestList; |
|
391 |
|
392 // Criteria -> provider bindings for base service providers. |
|
393 RPointerArray<CLiwBinding> iBaseBindings; |
|
394 |
|
395 // Criteria -> provider bindings for menu service providers. |
|
396 RPointerArray<CLiwMenuBinding> iMenuBindings; |
|
397 |
|
398 // Contains the LIW menu panes. |
|
399 RPointerArray<CLiwMenuPane> iMenuPanes; |
|
400 |
|
401 // Input parameter list which can be given to the consumer application. |
|
402 CLiwGenericParamList* iInParams; |
|
403 |
|
404 // Output parameter list which can be given to the consumer application. |
|
405 CLiwGenericParamList* iOutParams; |
|
406 |
|
407 // Resource offset for LiwServiceHandler.rsc. |
|
408 TInt iResourceOffset; |
|
409 |
|
410 // Owns all the providers currently in memory. |
|
411 RPointerArray<CLiwServiceIfBase> iProviders; |
|
412 |
|
413 TInt iNextFreeSlot; |
|
414 RPointerArray<CLiwMenuPane> iLastInitialized; |
|
415 CLiwMenuPane* iSubmenu; |
|
416 TInt iSubmenuCmd; |
|
417 CLiwEcomMonitor* iEcomMonitor; |
|
418 TBool iTlsDataOpened; |
|
419 }; |
|
420 |
|
421 |
|
422 inline void CLiwServiceHandlerImpl::ClearMenuPaneArray() |
|
423 { |
|
424 iMenuPanes.ResetAndDestroy(); |
|
425 } |
|
426 |
|
427 #endif // LIW_SERVICE_HANDLER_IMPL_H |
|
428 |
|
429 // END of File |
|
430 |
|
431 |