epoc32/include/mw/aiwservicehandler.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:     Declares an API for the consumer applications to access the 
williamr@2
    15
*                Application Interworking Framework. 
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
williamr@2
    23
#ifndef AIW_SERVICE_HANDLER_H
williamr@2
    24
#define AIW_SERVICE_HANDLER_H
williamr@2
    25
williamr@2
    26
// INCLUDES
williamr@2
    27
#include <barsread.h> 
williamr@2
    28
#include <aiwcommon.h>
williamr@2
    29
williamr@2
    30
// CONSTANTS
williamr@2
    31
williamr@2
    32
// MACROS
williamr@2
    33
williamr@2
    34
// FUNCTION PROTOTYPES
williamr@2
    35
williamr@2
    36
// FORWARD DECLARATIONS
williamr@2
    37
class CAiwServiceHandlerImpl;
williamr@2
    38
williamr@2
    39
// CLASS DECLARATION
williamr@2
    40
williamr@2
    41
/**
williamr@2
    42
* CAiwServiceHandler is the main class of the Application Interworking
williamr@2
    43
* Framework. The Service Handler implements support for dynamically
williamr@2
    44
* loadable service providers which offer services to consumer applications. 
williamr@2
    45
* The Service Handler maps consumers and service providers together via 
williamr@2
    46
* interests and data agreements and hides the consumers from the providers. 
williamr@2
    47
*
williamr@2
    48
* SERVICE is any command or functionality offered by a provider to 
williamr@2
    49
* consumer. The service includes typically menu item UI elements,
williamr@2
    50
* but it can also just an engine type of command which executes specific 
williamr@2
    51
* functionality and reports status back to the consumer.
williamr@2
    52
*
williamr@2
    53
* CONSUMER application accesses interesting services offered by
williamr@2
    54
* service provider(s). The consumer uses only those services in which
williamr@2
    55
* it is interested in. The interest is expressed using a set of criteria
williamr@2
    56
* items.
williamr@2
    57
*
williamr@2
    58
* INTEREST is a list of criteria items.
williamr@2
    59
*
williamr@2
    60
* CRITERIA consists of set of attributes which guide the AIW Framework to use
williamr@2
    61
* only those providers in which the consumer is interested in.
williamr@2
    62
* The criteria consists of following attributes:
williamr@2
    63
*   - Criteria UID (we can allocate pre-defined criteria items).
williamr@2
    64
*   - Service command UID (we can allocate pre-defined commands).
williamr@2
    65
*   - Content MIME type (string).
williamr@2
    66
*   - Additional options (variant data type just in case).
williamr@2
    67
*
williamr@2
    68
* PROVIDER produces those services for a consumer that match the given criteria 
williamr@2
    69
* specified by the consumer. A provider can offer menu items and their command
williamr@2
    70
* handling logic to the consumer applications. A provider can also offer base
williamr@2
    71
* services that don't require any UI elements.
williamr@2
    72
*
williamr@2
    73
* DATA AGREEMENT is an agreement between consumer and provider about parameters 
williamr@2
    74
* needed to be passed in a use case.
williamr@2
    75
*
williamr@2
    76
* @lib ServiceHandler.lib
williamr@2
    77
* @since S60 2.6
williamr@2
    78
*/
williamr@2
    79
NONSHARABLE_CLASS(CAiwServiceHandler) : public CBase
williamr@2
    80
    {
williamr@2
    81
    public:  // Construction & destruction
williamr@2
    82
williamr@2
    83
        /**
williamr@2
    84
        * Constructs a Service Handler instance.
williamr@2
    85
        */
williamr@2
    86
        IMPORT_C static CAiwServiceHandler* NewL();
williamr@2
    87
        
williamr@2
    88
        /**
williamr@2
    89
        * Constructs a Service Handler instance.
williamr@2
    90
        */
williamr@2
    91
        IMPORT_C static CAiwServiceHandler* NewLC();  
williamr@2
    92
williamr@2
    93
        /** 
williamr@2
    94
        * Destructor.
williamr@2
    95
        */
williamr@2
    96
        IMPORT_C virtual ~CAiwServiceHandler();
williamr@2
    97
        
williamr@2
    98
    public:  // Management
williamr@2
    99
williamr@2
   100
        /**
williamr@2
   101
        * Resets the Service Handler, discards existing interest and unloads 
williamr@2
   102
        * corresponding service providers.
williamr@2
   103
        */
williamr@2
   104
        IMPORT_C void Reset();
williamr@2
   105
williamr@2
   106
        /**
williamr@2
   107
        * Returns the amount of providers that fulfil the given criteria.
williamr@2
   108
        *
williamr@2
   109
        * @param aCriteria Criteria to match.
williamr@2
   110
        * @return Number of providers matching the criteria.
williamr@2
   111
        */
williamr@2
   112
        IMPORT_C TInt NbrOfProviders(const CAiwCriteriaItem* aCriteria);
williamr@2
   113
        
williamr@2
   114
    public:  // Interest handling
williamr@2
   115
        
williamr@2
   116
        /**
williamr@2
   117
        * Adds the given interest to the Service Handler from a resource and updates 
williamr@2
   118
        * possibly existing old interest. Corresponding service providers are loaded.
williamr@2
   119
        * If a provider leaves during initialization, it is trapped by the Service Handler.
williamr@2
   120
        *
williamr@2
   121
        * @param aInterestResourceId ID of the resource containing criteria items.
williamr@2
   122
        * @leave KErrNotSupported CCoeEnv is not accessible.
williamr@2
   123
        * @see Reset
williamr@2
   124
        */
williamr@2
   125
        IMPORT_C void AttachL(TInt aInterestResourceId);
williamr@2
   126
williamr@2
   127
        /**
williamr@2
   128
        * Adds given interest to the Service Handler from an array of criteria items.
williamr@2
   129
        * If a provider leaves during initialization, it is trapped by the Service Handler.
williamr@2
   130
        *
williamr@2
   131
        * @param aInterest Array of criteria items. Ownership is not transferred.
williamr@2
   132
        */
williamr@2
   133
        IMPORT_C void AttachL(const RCriteriaArray& aInterest);
williamr@2
   134
williamr@2
   135
        /**
williamr@2
   136
        * Gets the currently valid interest in use by the Service Handler.
williamr@2
   137
        *
williamr@2
   138
        * @param aInterest An array of returned criteria items, may be empty.
williamr@2
   139
        *                  Ownership is not transferred, i.e. the objects in the 
williamr@2
   140
        *                  array must not be deleted.
williamr@2
   141
        */
williamr@2
   142
        IMPORT_C void GetInterest(RCriteriaArray& aInterest);
williamr@2
   143
williamr@2
   144
        /**
williamr@2
   145
        * Removes given interest from the Service Handler. Corresponding service 
williamr@2
   146
        * providers are unloaded.
williamr@2
   147
        * 
williamr@2
   148
        * @param aInterest Array of returned criteria items, may be empty.
williamr@2
   149
        */
williamr@2
   150
        IMPORT_C void DetachL(const RCriteriaArray& aInterest);
williamr@2
   151
williamr@2
   152
        /**
williamr@2
   153
        * Removes given interest from the Service Handler. Corresponding service 
williamr@2
   154
        * providers are unloaded.
williamr@2
   155
        * 
williamr@2
   156
        * @param aInterestResourceId ID of the resource containing criteria items.
williamr@2
   157
        * @leave KErrNotSupported CCoeEnv is not accessible.
williamr@2
   158
        */
williamr@2
   159
        IMPORT_C void DetachL(TInt aInterestResourceId);
williamr@2
   160
        
williamr@2
   161
        /**
williamr@2
   162
        * Returns criteria by ID.
williamr@2
   163
        *
williamr@2
   164
        * @param aId Criteria ID.
williamr@2
   165
        * @return Criteria item pointer matching the ID. Ownership is not transferred.
williamr@2
   166
        */
williamr@2
   167
        IMPORT_C const CAiwCriteriaItem* GetCriteria(TInt aId);
williamr@2
   168
williamr@2
   169
        /**
williamr@2
   170
        * Returns an empty instance of CAiwGenericParamList class. It can be
williamr@2
   171
        * used for example as an input parameter list for the Service Handler's
williamr@2
   172
        * API methods. This is just a convenience method and doesn't have
williamr@2
   173
        * to be used. If consumer wants to create input list by itself
williamr@2
   174
        * it is ok. If this method is used, the Service Handler takes care
williamr@2
   175
        * of deleting returned generic parameter list.
williamr@2
   176
        *
williamr@2
   177
        * @return  An empty instance of CAiwGenericParameter list.
williamr@2
   178
        */
williamr@2
   179
        IMPORT_C CAiwGenericParamList& InParamListL();
williamr@2
   180
williamr@2
   181
        /**
williamr@2
   182
        * Returns an empty instance of CAiwGenericParamList class. The instance can be
williamr@2
   183
        * used for example as an output parameter list for Service Handler
williamr@2
   184
        * API methods. This is just a convenience method and doesn't have
williamr@2
   185
        * to be used. If consumer wants to create output list by itself
williamr@2
   186
        * it is ok. If this method is used, Service Handler takes care
williamr@2
   187
        * of deleting returned generic parameter list.
williamr@2
   188
        *
williamr@2
   189
        * @return  An empty instance of CAiwGenericParameter list.
williamr@2
   190
        */
williamr@2
   191
        IMPORT_C CAiwGenericParamList& OutParamListL();
williamr@2
   192
        
williamr@2
   193
    public:  // Menu handling
williamr@2
   194
williamr@2
   195
        /**
williamr@2
   196
        * Initialises menu pane with service commands from a provider.
williamr@2
   197
        * This method must be called upon DynInitMenuPaneL of consumer
williamr@2
   198
        * application in order to let the provider to hook its menu items.
williamr@2
   199
        *
williamr@2
   200
        * @param aMenuPane Handle of the menu pane to initialise.
williamr@2
   201
        * @param aMenuResourceId The menu to be attached.
williamr@2
   202
        * @param aBaseMenuCmdId Base ID for the Service Handler to generate 
williamr@2
   203
        *                       menu IDs for placeholders.
williamr@2
   204
        * @param aInParamList Input parameter list for provider's parameters checking.
williamr@2
   205
        * @leave KErrNotSupported CCoeEnv is not accessible.
williamr@2
   206
        * @leave KErrOverflow Consumer application has too many AIW placeholders in its menu. 
williamr@2
   207
        *                     Currently, maximum 16 is supported.
williamr@2
   208
        */
williamr@2
   209
        IMPORT_C void InitializeMenuPaneL(
williamr@2
   210
            CEikMenuPane& aMenuPane,
williamr@2
   211
            TInt aMenuResourceId,
williamr@2
   212
            TInt aBaseMenuCmdId,
williamr@2
   213
            const CAiwGenericParamList& aInParamList);
williamr@2
   214
            
williamr@2
   215
        /**
williamr@2
   216
        * Initialises menu pane with service commands from a provider.
williamr@2
   217
        * This method must be called upon DynInitMenuPaneL of consumer
williamr@2
   218
        * application in order to let the provider to hook its menu items.
williamr@2
   219
        * In normal circumstances, the other variant of this method should be used.
williamr@2
   220
        *
williamr@2
   221
        * @since S60 3.1
williamr@2
   222
        * @param aMenuPane Handle of the menu pane to initialise.
williamr@2
   223
        * @param aMenuResourceId The menu to be attached.
williamr@2
   224
        * @param aBaseMenuCmdId Base ID for the Service Handler to generate 
williamr@2
   225
        *                       menu IDs for placeholders.
williamr@2
   226
        * @param aInParamList Input parameter list for provider's parameters checking.
williamr@2
   227
        * @param aUseSubmenuTextsIfAvailable If the provider has specified alternative submenu
williamr@2
   228
        *                       texts for its menu items, those can be taken into use if this 
williamr@2
   229
        *                       parameter is set to ETrue. This should be used only for manually 
williamr@2
   230
        *                       created submenus. If using AIW_CASCADE_ID or 
williamr@2
   231
        *                       AIW_INTELLIGENT_CASCADE_ID, the AIW framework can automatically 
williamr@2
   232
        *                       decide whether to use the submenu texts or not, and this parameter 
williamr@2
   233
        *                       has no effect.
williamr@2
   234
        * @leave KErrNotSupported CCoeEnv is not accessible.
williamr@2
   235
        * @leave KErrOverflow Consumer application has too many AIW placeholders in its menu. 
williamr@2
   236
        *                     Currently, maximum 16 is supported.
williamr@2
   237
        */
williamr@2
   238
        IMPORT_C void InitializeMenuPaneL(
williamr@2
   239
            CEikMenuPane& aMenuPane,
williamr@2
   240
            TInt aMenuResourceId,
williamr@2
   241
            TInt aBaseMenuCmdId,
williamr@2
   242
            const CAiwGenericParamList& aInParamList,
williamr@2
   243
            TBool aUseSubmenuTextsIfAvailable);            
williamr@2
   244
        
williamr@2
   245
        /**
williamr@2
   246
        * Returns the service command ID associated to the menu command. If found, it means 
williamr@2
   247
        * that there is a provider which can handle the menu command. Thus the command 
williamr@2
   248
        * handling needs to be routed to the provider via ExecuteMenuCmdL.
williamr@2
   249
        *
williamr@2
   250
        * @param aMenuCmdId Menu command ID to be mapped to service cmd.
williamr@2
   251
        * @return Service command ID, KAiwCmdNone if no ID is found.
williamr@2
   252
        * @see ExecuteMenuCmdL
williamr@2
   253
        */
williamr@2
   254
        IMPORT_C TInt ServiceCmdByMenuCmd(TInt aMenuCmdId) const;
williamr@2
   255
williamr@2
   256
        /**
williamr@2
   257
        * Tells the provider to execute a menu command invoked by the consumer.
williamr@2
   258
        * Not supported if calling outside UI framework. Use ServiceCmdByMenuCmd to 
williamr@2
   259
        * check if there is any provider for the menu command.
williamr@2
   260
        *
williamr@2
   261
        * @param aMenuCmdId The menu command to be executed.
williamr@2
   262
        * @param aInParamList Input data parameters, can be an empty list.
williamr@2
   263
        * @param aOutParamList Output data parameters, can be an empty list.
williamr@2
   264
        * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in AiwCommon.hrh.
williamr@2
   265
        * @param aCallback Callback for asynchronous command handling, parameter checking, etc.
williamr@2
   266
        * @leave KErrArgument Callback is missing when required.
williamr@2
   267
        * @leave KErrNotSupported No cmd matches given menu command or CCoeEnv is not accessible.
williamr@2
   268
        * @see ServiceCmdByMenuCmd
williamr@2
   269
        */
williamr@2
   270
        IMPORT_C void ExecuteMenuCmdL(
williamr@2
   271
            TInt aMenuCmdId,
williamr@2
   272
            const CAiwGenericParamList& aInParamList,
williamr@2
   273
            CAiwGenericParamList& aOutParamList,
williamr@2
   274
            TUint aCmdOptions = 0,
williamr@2
   275
            MAiwNotifyCallback* aCallback= NULL);
williamr@2
   276
williamr@2
   277
        /**
williamr@2
   278
        * Attach menu related criteria items to the given menu.
williamr@2
   279
        * If a provider leaves during initialization, it is trapped by the Service Handler. 
williamr@2
   280
        *
williamr@2
   281
        * @param aMenuResourceId      Menu to be attached.
williamr@2
   282
        * @param aInterestResourceId  Resource id for the interest list.
williamr@2
   283
        * @leave KErrNotSupported     CCoeEnv is not accessible.
williamr@2
   284
        */
williamr@2
   285
        IMPORT_C void AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId);
williamr@2
   286
williamr@2
   287
        /**
williamr@2
   288
        * Attach menu related criteria items to the given menu.
williamr@2
   289
        * If a provider leaves during initialization, it is trapped by the Service Handler. 
williamr@2
   290
        *
williamr@2
   291
        * @param aMenuResourceId  Menu to be attached.
williamr@2
   292
        * @param aReader          Resource reader for the interest list.
williamr@2
   293
        * @leave KErrNotSupported CCoeEnv is not accessible.
williamr@2
   294
        */
williamr@2
   295
        IMPORT_C void AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader);
williamr@2
   296
        
williamr@2
   297
        /**
williamr@2
   298
        * Attach menu related criteria items to the given menu. 
williamr@2
   299
        *
williamr@2
   300
        * @since S60 3.2
williamr@2
   301
        * @param aMenuResourceId  Menu to be attached.
williamr@2
   302
        * @param aInterest        Array of criteria items. Ownership is not transferred.
williamr@2
   303
        * @leave KErrNotSupported CCoeEnv is not accessible.
williamr@2
   304
        */
williamr@2
   305
        IMPORT_C void AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest);   
williamr@2
   306
williamr@2
   307
        /**
williamr@2
   308
        * Detach menu related criteria items from the given menu.
williamr@2
   309
        * In following cases this method just returns without doing anything:
williamr@2
   310
        *   1. If interest resource id is non-zero and CCoeEnv is not accessible.
williamr@2
   311
        *   2. If interest resource id is non-zero and there occurs an error when reading
williamr@2
   312
        *      the interest (e.g. not enough memory). 
williamr@2
   313
        * 
williamr@2
   314
        * @param aMenuResourceId      Menu to be detached.
williamr@2
   315
        * @param aInterestResourceId  Resource id for the interest list. If NULL, all 
williamr@2
   316
        *                             criteria items are detached from the given menu.
williamr@2
   317
        */
williamr@2
   318
        IMPORT_C void DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId);
williamr@2
   319
williamr@2
   320
        /**
williamr@2
   321
        * Checks if there are menu providers attached to given menu id. Consumer 
williamr@2
   322
        * application can use this information to decide whether a sub menu 
williamr@2
   323
        * containing only AIW items should be hidden or not.
williamr@2
   324
        *
williamr@2
   325
        * @param  aSubMenuId The menu id to be checked.
williamr@2
   326
        * @return ETrue  if there isn't any menu providers attached to this menu.
williamr@2
   327
        *         EFalse otherwise. 
williamr@2
   328
        */
williamr@2
   329
        IMPORT_C TBool IsSubMenuEmpty(TInt aSubMenuId);
williamr@2
   330
williamr@2
   331
        /**
williamr@2
   332
        * Returns boolean value indicating whether the given menu contains
williamr@2
   333
        * currently attached placeholders.
williamr@2
   334
        *
williamr@2
   335
        * @param   aMenuResourceId  Resource id of the menu to be queried.
williamr@2
   336
        * @return  ETrue  if aMenuResource contains currently attached placeholders.
williamr@2
   337
        *          EFalse otherwise. 
williamr@2
   338
        */
williamr@2
   339
        IMPORT_C TBool IsAiwMenu(TInt aMenuResourceId);
williamr@2
   340
williamr@2
   341
        /**
williamr@2
   342
        * Handles AIW submenus. This method should be called from consumer application's 
williamr@2
   343
        * DynInitMenuPaneL.
williamr@2
   344
        *
williamr@2
   345
        * @param  aPane  Menu pane to be handled.
williamr@2
   346
        * @return ETrue  if aPane was an AIW submenu and it was handled. 
williamr@2
   347
        *                Consumer's DynInitMenuPaneL pane may now return.
williamr@2
   348
        *         EFalse if aPane was not an AIW submenu and DynInitMenuPaneL should
williamr@2
   349
        *                continue normally.
williamr@2
   350
        */
williamr@2
   351
        IMPORT_C TBool HandleSubmenuL(CEikMenuPane& aPane);
williamr@2
   352
williamr@2
   353
        /**
williamr@2
   354
        * CEikMenuPane uses this method to inform AIF framework that a menu is launched.
williamr@2
   355
        * This method does not need to be called by any other component.
williamr@2
   356
        *
williamr@2
   357
        * @since S60 3.0
williamr@2
   358
        */
williamr@2
   359
        IMPORT_C static void ReportMenuLaunch();
williamr@2
   360
williamr@2
   361
    public:  // Generic Service Command handling
williamr@2
   362
        
williamr@2
   363
        /**
williamr@2
   364
        * Executes a service command for all providers. Otherwise similar to ExecuteMenuCmdL.
williamr@2
   365
        *
williamr@2
   366
        * @param aCmdId The command to be executed.
williamr@2
   367
        * @param aInParamList Input data parameters, can be an empty list.
williamr@2
   368
        * @param aOutParamList Output data parameters, can be an empty list.
williamr@2
   369
        * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in AiwCommon.hrh.    
williamr@2
   370
        * @param aCallback Callback for asynchronous command handling, parameter checking, etc.
williamr@2
   371
        * @leave KErrArgument Callback is missing when required.
williamr@2
   372
        * @leave KErrNotSupported No provider supports the service.
williamr@2
   373
        */
williamr@2
   374
        IMPORT_C void ExecuteServiceCmdL(
williamr@2
   375
            const TInt& aCmdId,
williamr@2
   376
            const CAiwGenericParamList& aInParamList,
williamr@2
   377
            CAiwGenericParamList& aOutParamList,
williamr@2
   378
            TUint aCmdOptions = 0,
williamr@2
   379
            MAiwNotifyCallback* aCallback = 0);
williamr@2
   380
            
williamr@2
   381
    private:
williamr@2
   382
        void ConstructL();
williamr@2
   383
        CAiwServiceHandler();
williamr@2
   384
williamr@2
   385
    private:
williamr@2
   386
        CAiwServiceHandlerImpl* iImpl;
williamr@2
   387
    };
williamr@2
   388
williamr@2
   389
#endif // AIW_SERVICE_HANDLER_H
williamr@2
   390
williamr@2
   391
// END of File
williamr@2
   392
williamr@2
   393