AIW Generic Parameter API: Using AIW Generic Parameter API

The most important use cases are creating generic parameter lists to be passed to the AIW providers. The first use case is a basic case, and the second is a more advanced one and specific to a certain AIW service provider.

Creating a generic parameter list with basic types

The example code here demonstrates how to create a generic parameter list and fill it with file name (descriptor) and error code (integer) items. This is the way how to pass the most common types of parameters to the AIW providers that do not need provider specific objects.

#include <AiwGenericParam.h>

// Create a list and put it into the cleanup stack.
CAiwGenericParamList* list = CAiwGenericParamList::NewLC();

// Set up and append file name parameter.
_LIT(KMyFileName, "c:\\data\\testfile.txt");
TFileName filename(KMyFileName);
TAiwGenericParam param(EGenericParamFile);
param.Value().Set(filename);
list->AppendL(param);

// Set up and append error code parameter.
param.Reset();	
param.SetSemanticId(EGenericParamError);
param.Value().Set(KErrNotFound); 
list->AppendL(param);

// The list can now be passed e.g. by calling Service Handler's ExecuteMenuCmdL() or 
// ExecuteServiceCmdL().

// Pop and destroy the list when it is not needed anymore.
CleanupStack::PopAndDestroy(list);

There may be as many items as required on the list with the same semantic id. The receiving application uses iterator methods in the CAiwGenericParamList class for accessing data items on the list.

The AIW framework contains convenience methods for creating input and output lists. By using the lists, the consumer application does not have to take care of allocating the list from a heap or deleting it afterwards. The only limitation is that only one input and one output list can be requested simultaneously. If more are required, the consumer application must create and delete them by itself. The methods for creating input and output lists are defined as follows:

CAiwGenericParamList& CAiwServiceHandler::InParamListL();
CAiwGenericParamList& CaiwServiceHandler::OutParamListL();

Creating a generic parameter list with provider specific objects

If a provider specific class or struct needs to be transferred between a consumer and a provider, it needs to be serialized by using e.g. a TPtrC8 or TPckg type before adding it to a generic parameter list. The variant type id EVariantTypeDesC8 should be used for these kind of parameters. It should also be noted that the AIW framework does not support passing pointers. See Map and Navigation AIW provider documentation for an example.

Error handling

Some methods may leave, for example if running out of memory. Normal Symbian OS error handling practises should be used, including e.g. using cleanup stack and TRAP harness.


Copyright © Nokia Corporation 2001-2008
Back to top