2 * Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Declares an API for the consumer applications to access the
15 * Application Interworking Framework.
23 #ifndef AIW_SERVICE_HANDLER_H
24 #define AIW_SERVICE_HANDLER_H
28 #include <aiwcommon.h>
34 // FUNCTION PROTOTYPES
36 // FORWARD DECLARATIONS
37 class CAiwServiceHandlerImpl;
42 * CAiwServiceHandler is the main class of the Application Interworking
43 * Framework. The Service Handler implements support for dynamically
44 * loadable service providers which offer services to consumer applications.
45 * The Service Handler maps consumers and service providers together via
46 * interests and data agreements and hides the consumers from the providers.
48 * SERVICE is any command or functionality offered by a provider to
49 * consumer. The service includes typically menu item UI elements,
50 * but it can also just an engine type of command which executes specific
51 * functionality and reports status back to the consumer.
53 * CONSUMER application accesses interesting services offered by
54 * service provider(s). The consumer uses only those services in which
55 * it is interested in. The interest is expressed using a set of criteria
58 * INTEREST is a list of criteria items.
60 * CRITERIA consists of set of attributes which guide the AIW Framework to use
61 * only those providers in which the consumer is interested in.
62 * The criteria consists of following attributes:
63 * - Criteria UID (we can allocate pre-defined criteria items).
64 * - Service command UID (we can allocate pre-defined commands).
65 * - Content MIME type (string).
66 * - Additional options (variant data type just in case).
68 * PROVIDER produces those services for a consumer that match the given criteria
69 * specified by the consumer. A provider can offer menu items and their command
70 * handling logic to the consumer applications. A provider can also offer base
71 * services that don't require any UI elements.
73 * DATA AGREEMENT is an agreement between consumer and provider about parameters
74 * needed to be passed in a use case.
76 * @lib ServiceHandler.lib
79 NONSHARABLE_CLASS(CAiwServiceHandler) : public CBase
81 public: // Construction & destruction
84 * Constructs a Service Handler instance.
86 IMPORT_C static CAiwServiceHandler* NewL();
89 * Constructs a Service Handler instance.
91 IMPORT_C static CAiwServiceHandler* NewLC();
96 IMPORT_C virtual ~CAiwServiceHandler();
101 * Resets the Service Handler, discards existing interest and unloads
102 * corresponding service providers.
104 IMPORT_C void Reset();
107 * Returns the amount of providers that fulfil the given criteria.
109 * @param aCriteria Criteria to match.
110 * @return Number of providers matching the criteria.
112 IMPORT_C TInt NbrOfProviders(const CAiwCriteriaItem* aCriteria);
114 public: // Interest handling
117 * Adds the given interest to the Service Handler from a resource and updates
118 * possibly existing old interest. Corresponding service providers are loaded.
119 * If a provider leaves during initialization, it is trapped by the Service Handler.
121 * @param aInterestResourceId ID of the resource containing criteria items.
122 * @leave KErrNotSupported CCoeEnv is not accessible.
125 IMPORT_C void AttachL(TInt aInterestResourceId);
128 * Adds given interest to the Service Handler from an array of criteria items.
129 * If a provider leaves during initialization, it is trapped by the Service Handler.
131 * @param aInterest Array of criteria items. Ownership is not transferred.
133 IMPORT_C void AttachL(const RCriteriaArray& aInterest);
136 * Gets the currently valid interest in use by the Service Handler.
138 * @param aInterest An array of returned criteria items, may be empty.
139 * Ownership is not transferred, i.e. the objects in the
140 * array must not be deleted.
142 IMPORT_C void GetInterest(RCriteriaArray& aInterest);
145 * Removes given interest from the Service Handler. Corresponding service
146 * providers are unloaded.
148 * @param aInterest Array of returned criteria items, may be empty.
150 IMPORT_C void DetachL(const RCriteriaArray& aInterest);
153 * Removes given interest from the Service Handler. Corresponding service
154 * providers are unloaded.
156 * @param aInterestResourceId ID of the resource containing criteria items.
157 * @leave KErrNotSupported CCoeEnv is not accessible.
159 IMPORT_C void DetachL(TInt aInterestResourceId);
162 * Returns criteria by ID.
164 * @param aId Criteria ID.
165 * @return Criteria item pointer matching the ID. Ownership is not transferred.
167 IMPORT_C const CAiwCriteriaItem* GetCriteria(TInt aId);
170 * Returns an empty instance of CAiwGenericParamList class. It can be
171 * used for example as an input parameter list for the Service Handler's
172 * API methods. This is just a convenience method and doesn't have
173 * to be used. If consumer wants to create input list by itself
174 * it is ok. If this method is used, the Service Handler takes care
175 * of deleting returned generic parameter list.
177 * @return An empty instance of CAiwGenericParameter list.
179 IMPORT_C CAiwGenericParamList& InParamListL();
182 * Returns an empty instance of CAiwGenericParamList class. The instance can be
183 * used for example as an output parameter list for Service Handler
184 * API methods. This is just a convenience method and doesn't have
185 * to be used. If consumer wants to create output list by itself
186 * it is ok. If this method is used, Service Handler takes care
187 * of deleting returned generic parameter list.
189 * @return An empty instance of CAiwGenericParameter list.
191 IMPORT_C CAiwGenericParamList& OutParamListL();
193 public: // Menu handling
196 * Initialises menu pane with service commands from a provider.
197 * This method must be called upon DynInitMenuPaneL of consumer
198 * application in order to let the provider to hook its menu items.
200 * @param aMenuPane Handle of the menu pane to initialise.
201 * @param aMenuResourceId The menu to be attached.
202 * @param aBaseMenuCmdId Base ID for the Service Handler to generate
203 * menu IDs for placeholders.
204 * @param aInParamList Input parameter list for provider's parameters checking.
205 * @leave KErrNotSupported CCoeEnv is not accessible.
206 * @leave KErrOverflow Consumer application has too many AIW placeholders in its menu.
207 * Currently, maximum 16 is supported.
209 IMPORT_C void InitializeMenuPaneL(
210 CEikMenuPane& aMenuPane,
211 TInt aMenuResourceId,
213 const CAiwGenericParamList& aInParamList);
216 * Initialises menu pane with service commands from a provider.
217 * This method must be called upon DynInitMenuPaneL of consumer
218 * application in order to let the provider to hook its menu items.
219 * In normal circumstances, the other variant of this method should be used.
222 * @param aMenuPane Handle of the menu pane to initialise.
223 * @param aMenuResourceId The menu to be attached.
224 * @param aBaseMenuCmdId Base ID for the Service Handler to generate
225 * menu IDs for placeholders.
226 * @param aInParamList Input parameter list for provider's parameters checking.
227 * @param aUseSubmenuTextsIfAvailable If the provider has specified alternative submenu
228 * texts for its menu items, those can be taken into use if this
229 * parameter is set to ETrue. This should be used only for manually
230 * created submenus. If using AIW_CASCADE_ID or
231 * AIW_INTELLIGENT_CASCADE_ID, the AIW framework can automatically
232 * decide whether to use the submenu texts or not, and this parameter
234 * @leave KErrNotSupported CCoeEnv is not accessible.
235 * @leave KErrOverflow Consumer application has too many AIW placeholders in its menu.
236 * Currently, maximum 16 is supported.
238 IMPORT_C void InitializeMenuPaneL(
239 CEikMenuPane& aMenuPane,
240 TInt aMenuResourceId,
242 const CAiwGenericParamList& aInParamList,
243 TBool aUseSubmenuTextsIfAvailable);
246 * Returns the service command ID associated to the menu command. If found, it means
247 * that there is a provider which can handle the menu command. Thus the command
248 * handling needs to be routed to the provider via ExecuteMenuCmdL.
250 * @param aMenuCmdId Menu command ID to be mapped to service cmd.
251 * @return Service command ID, KAiwCmdNone if no ID is found.
252 * @see ExecuteMenuCmdL
254 IMPORT_C TInt ServiceCmdByMenuCmd(TInt aMenuCmdId) const;
257 * Tells the provider to execute a menu command invoked by the consumer.
258 * Not supported if calling outside UI framework. Use ServiceCmdByMenuCmd to
259 * check if there is any provider for the menu command.
261 * @param aMenuCmdId The menu command to be executed.
262 * @param aInParamList Input data parameters, can be an empty list.
263 * @param aOutParamList Output data parameters, can be an empty list.
264 * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in AiwCommon.hrh.
265 * @param aCallback Callback for asynchronous command handling, parameter checking, etc.
266 * @leave KErrArgument Callback is missing when required.
267 * @leave KErrNotSupported No cmd matches given menu command or CCoeEnv is not accessible.
268 * @see ServiceCmdByMenuCmd
270 IMPORT_C void ExecuteMenuCmdL(
272 const CAiwGenericParamList& aInParamList,
273 CAiwGenericParamList& aOutParamList,
274 TUint aCmdOptions = 0,
275 MAiwNotifyCallback* aCallback= NULL);
278 * Attach menu related criteria items to the given menu.
279 * If a provider leaves during initialization, it is trapped by the Service Handler.
281 * @param aMenuResourceId Menu to be attached.
282 * @param aInterestResourceId Resource id for the interest list.
283 * @leave KErrNotSupported CCoeEnv is not accessible.
285 IMPORT_C void AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId);
288 * Attach menu related criteria items to the given menu.
289 * If a provider leaves during initialization, it is trapped by the Service Handler.
291 * @param aMenuResourceId Menu to be attached.
292 * @param aReader Resource reader for the interest list.
293 * @leave KErrNotSupported CCoeEnv is not accessible.
295 IMPORT_C void AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader);
298 * Attach menu related criteria items to the given menu.
301 * @param aMenuResourceId Menu to be attached.
302 * @param aInterest Array of criteria items. Ownership is not transferred.
303 * @leave KErrNotSupported CCoeEnv is not accessible.
305 IMPORT_C void AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest);
308 * Detach menu related criteria items from the given menu.
309 * In following cases this method just returns without doing anything:
310 * 1. If interest resource id is non-zero and CCoeEnv is not accessible.
311 * 2. If interest resource id is non-zero and there occurs an error when reading
312 * the interest (e.g. not enough memory).
314 * @param aMenuResourceId Menu to be detached.
315 * @param aInterestResourceId Resource id for the interest list. If NULL, all
316 * criteria items are detached from the given menu.
318 IMPORT_C void DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId);
321 * Checks if there are menu providers attached to given menu id. Consumer
322 * application can use this information to decide whether a sub menu
323 * containing only AIW items should be hidden or not.
325 * @param aSubMenuId The menu id to be checked.
326 * @return ETrue if there isn't any menu providers attached to this menu.
329 IMPORT_C TBool IsSubMenuEmpty(TInt aSubMenuId);
332 * Returns boolean value indicating whether the given menu contains
333 * currently attached placeholders.
335 * @param aMenuResourceId Resource id of the menu to be queried.
336 * @return ETrue if aMenuResource contains currently attached placeholders.
339 IMPORT_C TBool IsAiwMenu(TInt aMenuResourceId);
342 * Handles AIW submenus. This method should be called from consumer application's
345 * @param aPane Menu pane to be handled.
346 * @return ETrue if aPane was an AIW submenu and it was handled.
347 * Consumer's DynInitMenuPaneL pane may now return.
348 * EFalse if aPane was not an AIW submenu and DynInitMenuPaneL should
351 IMPORT_C TBool HandleSubmenuL(CEikMenuPane& aPane);
354 * CEikMenuPane uses this method to inform AIF framework that a menu is launched.
355 * This method does not need to be called by any other component.
359 IMPORT_C static void ReportMenuLaunch();
361 public: // Generic Service Command handling
364 * Executes a service command for all providers. Otherwise similar to ExecuteMenuCmdL.
366 * @param aCmdId The command to be executed.
367 * @param aInParamList Input data parameters, can be an empty list.
368 * @param aOutParamList Output data parameters, can be an empty list.
369 * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in AiwCommon.hrh.
370 * @param aCallback Callback for asynchronous command handling, parameter checking, etc.
371 * @leave KErrArgument Callback is missing when required.
372 * @leave KErrNotSupported No provider supports the service.
374 IMPORT_C void ExecuteServiceCmdL(
376 const CAiwGenericParamList& aInParamList,
377 CAiwGenericParamList& aOutParamList,
378 TUint aCmdOptions = 0,
379 MAiwNotifyCallback* aCallback = 0);
383 CAiwServiceHandler();
386 CAiwServiceHandlerImpl* iImpl;
389 #endif // AIW_SERVICE_HANDLER_H