Get a converter

To obtain a suitable converter, complete the following steps:

  1. Create a CCnaConverterList object and use it to get the UID of the converter that convert from a particular data type to another.

  2. Create the converter (a CConverterBase2-based object) using CCnaConverterList::NewConverterL(). The converter architecture loads the converter DLL and instantiates the converter object from it.

  3. Check whether the converter supports file or stream conversion using CConverterBase2::Capabilities().

The following code snippet creates a converter that can convert files of data type text/abc to type text/xyz.

_LIT( KFromType, "text/abc" );
_LIT( KToType, "text/xyz" );
CCnaConverterList* list = CCnaConverterList::NewLC();
TUid uid = list->ConverterL( TDataType( KFromType ), TDataType( KToType ) );
CConverterBase* converter = list->NewConverterL( uid );
User::LeaveIfNull( converter );
if( !( converter->Capabilities() & CConverterBase::EConvertsFiles ) )
    {
    delete converter;
    converter = NULL;
    }
CleanupStack::PushL( converter );
...
CleanupStack::PopAndDestroy( 2 ); // list, converter