To perform a conversion you must first get a converter that handles the relevant source and target data types. A converter can handle files or streams or both, so its capabilities must also be checked.
To obtain a suitable converter:
create a CCnaConverterList
object and use it to
get the UID of the converter(s) that convert from/to a particular data type
use CCnaConverterList::NewConverterL()
to create
the converter (a CConverterBase2
-based object). The
converter architecture loads the converter DLL and instantiates the converter
object from it
use CConverterBase2::Capabilities()
to check
whether the converter supports file or stream conversion.
The following code fragment 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
When use of the converter is complete, delete the converter and the converter list. The converter architecture unloads the converter DLLs that were loaded.