Exemple #1
0
EXPORT_C void CEnvironment::SetL(const TDesC& aKey, const TDesC& aValue)
	{
	WaitLC();

	HBufC** valPtr = iVars.Find(aKey);
	HBufC* currentValue = NULL;
	if (valPtr) currentValue = *valPtr;

	if (valPtr == NULL && iParentEnv)
		{
		// If we don't have it, and we have a parent env, we should pass the request through to it.
		iParentEnv->SetL(aKey, aValue);
		}
	else
		{
		if (currentValue)
			{
			// If we already have a value in the hash, just update it if possible
			TPtr ptr = currentValue->Des();
			if (ptr.MaxLength() >= aValue.Length())
				{
				ptr.Copy(aValue);
				CleanupStack::PopAndDestroy(); // Release lock
				return;
				}
			}
		}
	
	HBufC* newVal = aValue.AllocLC();
	iVars.InsertL(aKey, newVal);
	delete currentValue;
	CleanupStack::Pop(newVal);
	CleanupStack::PopAndDestroy(); // Release lock
	}
EXPORT_C TBool AknPhoneNumberTextUtils::WrapPhoneNumberToArrayL( 
    const TDesC& aPhoneNumberToWrap,
    TInt aLineWidthInPixels,
    TInt aMaxLines,
    const CFont& aFont,
    CArrayFix<TPtrC>& aWrappedArray )
    {
    TBool retVal( EFalse ); // Not truncated
 
    HBufC* reversedText = aPhoneNumberToWrap.AllocLC();
    TPtr revPtr = reversedText->Des();

    ReverseDescriptor( revPtr );

    CArrayFix<TInt>* lineWidthArray = new (ELeave) CArrayFixFlat<TInt>(KLineArrayGranularity);
    CleanupStack::PushL( lineWidthArray );

    lineWidthArray->AppendL( aLineWidthInPixels, aMaxLines );

    // Perform the wrap on the reversed text
    AknTextUtils::WrapToArrayL( revPtr, *lineWidthArray, aFont, aWrappedArray );

    // Now rearrange the TPtrCs to point to the original array
    TInt totalLen = reversedText->Length();
    TInt count = aWrappedArray.Count();
    TInt usedLen = 0; // Accumulates the length actually used
    for ( TInt index = 0; index < count; index++)
        {
        TPtrC& currentPtr = aWrappedArray.At(index);
        // The TPtrCs have to be moved. The reversing is taken into effect, but not purely reversed
        // because their otherwise they would have negative lengths.  That is, {a,b} does not go to
        // { final - a, final - b }, but rather to {final - b, final - a}; they are flipped, to get
        // their start points before the end points
        //
        // Now, representing the start position by pos, and the end by pos+len-1 we have the TPtrC at
        // {pos, pos+len-1} inclusive, in reversed array. 
        // The TPtrC must be modified to point to {total_len-1 - (pos+len-1), total_len-1 - pos} 
        // in the unreversed array:
        TInt len = currentPtr.Length();
        usedLen += len;
        TInt pos = currentPtr.Ptr() - reversedText->Ptr(); // pointer arithmetic
        TInt newPos = totalLen - pos - len;
        // If the TPtr is zero length then it must get special treatment, as the normal
        // calculations give an end point before the start point! i.e. {pos, pos-1}
        // We handle this by NOT flipping in this case.
        // { pos, pos-1 } -> {totalLen-1-pos, totalLen-1 - (pos-1)}
        // Note that a zero length wrapped line is completely possible amoung a bunch of other 
        // lines with characters on them, as the line lengths may be of wildly different lengths.
        if ( len == 0 ) 
            newPos--;
        currentPtr.Set( aPhoneNumberToWrap.Mid(newPos, len) );
        }

    // If the accumulated length is less than that in the entire input descriptor, then text does not fit
    if ( usedLen < totalLen )
        retVal = ETrue;

    CleanupStack::PopAndDestroy(2); // lineWidthArray first, and then reversedText
    return retVal;
    }
// -----------------------------------------------------------------------------
void CPresenceCacheBuddyInfo::DoSet16BitValueL( 
    const TDesC& aKey,    
    const TDesC& aValue )
    {   
      
    // Remove old values first
    RemoveField( aKey );
    
    //Convert Unicode to Utf-8
    HBufC8* convertBuffer =  CnvUtfConverter::ConvertFromUnicodeToUtf8L( aValue );
    CleanupStack::PushL( convertBuffer );
    HBufC* keyBuffer = aKey.AllocLC();    
    
    TInt insertPos = iIds.Find(0);
    if ( insertPos < 0 )
        {
        insertPos = iIds.Count();
        iIds.Append( keyBuffer );
        iValues.Append( convertBuffer );
        }
    else
        {
        iIds[insertPos] = keyBuffer;
        iValues[insertPos] = convertBuffer;
        }
    
    iHashMap.InsertL( keyBuffer, insertPos  );
        
    CleanupStack::Pop( keyBuffer );
    CleanupStack::Pop( convertBuffer );       
    }
// -----------------------------------------------------------------------------
// Implements checking if a given MIME type is supported or not
// -----------------------------------------------------------------------------
//
TBool CAknsWallpaperPlugin::IsMimeTypeSupportedL(const TDesC& aMimeTypeString)
    {
    // Check for a type separator in the string
    TInt pos = aMimeTypeString.Find(KAknsWallpaperPluginSeparator);

    // Leave if no separator was found.. the MIME
    // standard requires it
    if (pos == KErrNotFound)
        {
        User::Leave(KErrArgument);
        }

    // Copy the full Mime type string (needed for uppercase)
    HBufC* fullBuf = aMimeTypeString.AllocLC();
    TPtr fullString = fullBuf->Des();
    fullString.UpperCase();

    // Construct the compare string
    TPtrC compareString(aMimeTypeString.Left(pos));

    // Perform the comparison
    TBool ret = EFalse;

    // Mime type case:  IMAGE/* except IMAGE/X-OTA-BITMAP
    if (compareString.CompareF(KAknsWallpaperPluginMimeTypeImage) == 0 &&
        !(fullString.CompareF(KAknsWallpaperPluginMimeTypeOTABitmap) == 0))
        {
        ret = ETrue;
        }
    CleanupStack::PopAndDestroy(fullBuf);

    return ret;
    }
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
void CPosModulesSettings::SetVersionL( const TDesC& aVersion )
	{
	HBufC* version = aVersion.AllocLC();
	delete iVersion;
	iVersion = version;
	CleanupStack::Pop( version );
	}
Exemple #6
0
void CCreGenerator::CommitChangesToCreL(RFs& aFs,TUint8 aPersistVersion,CHeapRepository& aRep,const TDesC& aTargetFilePath)
{
    HBufC* tmpFilePath=aTargetFilePath.AllocLC();
    TPtr tmpFilePathPtr(tmpFilePath->Des());
    tmpFilePathPtr.Replace(tmpFilePath->Length()-3,3,KTmpExtension());

    CDirectFileStore* store = CDirectFileStore::ReplaceLC(aFs, *tmpFilePath,(EFileWrite | EFileShareExclusive));

    const TUid uid2	 = KNullUid ;
    store->SetTypeL(TUidType(KDirectFileStoreLayoutUid, uid2, KServerUid3)) ;

    // Write the stream index/dictionary as root stream within the store
    // so we can access it when we do a restore later on
    RStoreWriteStream rootStream ;
    TStreamId rootStreamId = rootStream.CreateLC(*store) ;
    ExternalizeCre(aPersistVersion,aRep, rootStream) ;
    rootStream.CommitL() ;

    CleanupStack::PopAndDestroy(&rootStream) ;
    store->SetRootL(rootStreamId);
    store->CommitL();
    CleanupStack::PopAndDestroy(store) ;
    User::LeaveIfError(aFs.Replace(*tmpFilePath,aTargetFilePath));
    CleanupStack::PopAndDestroy();
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void CPosLmNameIndex::UpdateL( TPosLmItemId aId, const TDesC& aName )
    {
    HBufC* name = aName.AllocLC();
	CleanupStack::Pop( name );//ownership of name is transferred in the call to UpdateL
//coverity[freed_arg : FALSE]
    UpdateL( aId, name );
//coverity[pass_freed_arg : FALSE]
    }
void CMtfConfigurationType::AddConfigurationFilenameL(const TDesC& aFilename)
{
	// ISSUE: the parameter should be of type TFileName to prevent aFilename
	// being longer than the maximum length of a filename.
	HBufC* fileName = aFilename.AllocLC();
	User::LeaveIfError(iFilenames.Append(fileName));
	CleanupStack::Pop(fileName);
}
void CPresetList::AppendL(TUid aUid, const TDesC& aName)
	{
	HBufC* tempName = aName.AllocLC();
	TPresetEle ele;
	ele.iUid = aUid;
	ele.iName = tempName;
	User::LeaveIfError(iArray.Append(ele));
	CleanupStack::Pop(tempName);
	}
void CIpuTestHarness::CTestInfo::SetNameL(const TDesC& aName)
//
//	Sets iName
	{
	HBufC* temp = aName.AllocLC();
	CleanupStack::Pop();	//	temp
	delete iName;
	iName = temp;
	}
TBool
LaunchWapBrowserUtil::LaunchWapBrowser(const TDesC& aUrl)
{
#if defined NAV2_CLIENT_SERIES60_V2 || defined NAV2_CLIENT_SERIES60_V3
   TInt urlLen = aUrl.Length();
   HBufC* fixedUrl;

   if (KFourHttpString().Compare(aUrl.Left(KFourHttpString().Length()))) {
      /* Not 4 http:// at the beginning. */

      if (KHttpString().Compare(aUrl.Left(KHttpString().Length()))) {
         /* Not http:// at the beginning. */
         urlLen += KFourHttpString().Length() + 1;
         fixedUrl = HBufC::NewLC(urlLen);
         fixedUrl->Des().Copy(KFourHttpString);
      } else {
         urlLen += KFourString().Length() + 1;
         fixedUrl = HBufC::NewLC(urlLen);
         fixedUrl->Des().Copy(KFourString);
      }
      fixedUrl->Des().Append(aUrl);
   } else {
      fixedUrl = aUrl.AllocLC();
   }

   RApaLsSession aApaLsSession;

   TUid id( KPhoneUidWmlBrowser );
   TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
   TApaTask task = taskList.FindApp( id );

   if ( task.Exists() ) {
      HBufC8* param8 = HBufC8::NewLC( fixedUrl->Length() );
      param8->Des().Append( *fixedUrl );
      task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
      CleanupStack::PopAndDestroy( param8 );
   } else {
      if ( !aApaLsSession.Handle() )
      {
         User::LeaveIfError( aApaLsSession.Connect() );
      }
      TThreadId thread;
      User::LeaveIfError( aApaLsSession.StartDocument( *fixedUrl,
               KPhoneUidWmlBrowser, thread ) );
   }
   CleanupStack::PopAndDestroy(fixedUrl);

   aApaLsSession.Close();

#elif defined NAV2_CLIENT_SERIES60_V1
   return EFalse;
#else
# error This code not implemented!
#endif
   return ETrue;
}
// ---------------------------------------------------------------------------
//  Fails only on OOM case
// ---------------------------------------------------------------------------
//
void CPosModulesSettings::ParseAttributedKeyL( 
	const TDesC& aString, 
	RModuleList& aList ) const
	{
    // The sequence in the buffer is "H{8},D+,D+[,...]" 
    // which is "UID,status,cost"
    // H - hex digit, D - decimal digit, delimiter - comma
    // UID check is strict and fails with KErrCorrupt if something's wrong
    // Status and Cost checks a lazy, use default value if error
    // Status - inactive, cost - unknown
    
    // TLex uses whitespace as delimiter
    // Replace all commas with whitespace
    HBufC* string = aString.AllocLC();
    ReplaceCommasWithWhitespace( string->Des() );
    
    TLex lex( *string );
    while ( !lex.Eos() )
        {
        TPosModuleListItem item;
    
        // parse UID
        TPtrC token( lex.NextToken() );
        if ( !token.Length() )
            {
            break;  // no more items found
            }
        
        item.iUid.iUid = 0;
        TInt err = ParseModuleUid( token, (TUint32&) item.iUid.iUid );

        // parse status field
        token.Set( lex.NextToken() );
        err |= TLex( token ).Val( (TUint&) item.iAvailable, EDecimal );

        if ( item.iAvailable != EModuleAvailable && 
        	 item.iAvailable != EModuleNotAvailable )
        	 {
        	 err |= KErrCorrupt;
        	 }

        // parse cost field
        token.Set( lex.NextToken() );
        err |= TLex( token ).Val( (TUint&) item.iCost, EDecimal );

        // Avoid duplicate UIDs ( in both lists )
        TPosModuleAttributes otherItem;
        if ( !err && !ModuleExists( item.iUid ) )
            {
	        // Add module list item to the list
	        aList.AppendL( item );
            }
        }
        
	CleanupStack::PopAndDestroy( string );
	}
void CIpuTestHarness::CTestInfo::ConstructL(const TDesC& aName, TInt aNumber, TInt aErrorCode)
//
//	Non-trivial c'tor
	{
	iName = aName.AllocLC();
	CleanupStack::Pop();	//	iName

	iNumber = aNumber;
	iErrorCode = aErrorCode;
	}
Exemple #14
0
// Call this when you're starting a new test
void CTOCSPResult::NewTestL(const TDesC& aName)
{
    CheckL();

    HBufC* name = aName.AllocLC();
    User::LeaveIfError(iNames.Append(name));
    CleanupStack::Pop(name);

    iTotal++;
}
/**
 * Create and send a MR response email.
 */
EXPORT_C void CBaseMrInfoProcessor::ReplyToMeetingRequestL(
    const TFSMailMsgId& aMailBoxId,
    const TFSMailMsgId& aMessageId,
    MMRInfoObject& aMeetingRequest,
    TMRInfoResponseMode& aResponseMode,
    const TDesC& aResponseText /*= KNullDesC()*/ )

    {
    if ( MMRInfoProcessor::EMRInfoResponseSync != aResponseMode )
        {
        CFSMailMessage* reply = iPlugin.CreateMrReplyMessageL(
            aMailBoxId, aMeetingRequest, aMessageId );
        CleanupStack::PushL( reply );
        
        //body.
        if ( aResponseText != KNullDesC )
            {
            CFSMailMessagePart* body = reply->PlainTextBodyPartL();
            if ( NULL != body )
                {
                CleanupStack::PushL( body );
                
                /**@ completely unnecessary but the fw needs to accept a TDesC in
                SetContent instead.*/
                HBufC* descCopy = aResponseText.AllocLC();
                TPtr ptr = descCopy->Des();
                body->SetContent( ptr );
                
                CleanupStack::PopAndDestroy( descCopy );
                CleanupStack::PopAndDestroy( body );
                }
            }
        
        CBaseMrInfoObject* mrInfo = CBaseMrInfoObject::NewL( aMeetingRequest );
    
        if ( MMRInfoProcessor::EMRInfoRemoveFromCal == aResponseMode )
        	{
        	mrInfo->SetMethod( MMRInfoObject::EMRMethodCancel );
        	}
        else
        	{
        	mrInfo->SetMethod( MMRInfoObject::EMRMethodResponse );
        	}
    
        reply->SetMRInfo( mrInfo );
        iPlugin.SendMessageL( *reply );
    
        CleanupStack::PopAndDestroy( reply );
        }
    	
    } //ReplyToMeetingRequestL.
void CLogServBackupManager::BISetDatabaseNameL(const TDesC& aDatabaseName)
{
#ifdef LOGGING_ENABLED
    LOGTEXT3("CLogServBackupManager::BISetDatabaseNameL(%S, isActive: %d)", &aDatabaseName, IsActive());
    if	(iDatabaseName)
    {
        LOGTEXT2("CLogServBackupManager::BISetDatabaseNameL() - currently registered database filename is: %S", iDatabaseName);
    }
    else
    {
        LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - no file registered with backup interface yet");
    }
#endif

    Cancel();

    HBufC* databaseName = aDatabaseName.AllocLC();

    // If we haven't already created a backup observer, then we need
    // to kick the object back into life again.
    if	(!iBackup)
    {
        LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - no backup session created");

        // Try and create backup interface synchronously first of all, if that fails
        // then construct as an idle operation
        TRAPD(err, iBackup = CreateBackupL(*databaseName));

        LOGTEXT2("CLogServBackupManager::BISetDatabaseNameL() - backup session creation error: %d", err);
        if	(err != KErrNone)
            After(0);
    }
    else if (iDatabaseName->Compare(aDatabaseName) != KErrNone)
    {
        LOGTEXT3("CLogServBackupManager::BISetDatabaseNameL() - database filename changed from %S to %S", &iDatabaseName, &aDatabaseName);

        // De register the old, register the new
        iBackup->DeregisterFile(*iDatabaseName);
        iBackup->RegisterFileL(aDatabaseName, *this);

        LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - database re-registration complete");
    }


    delete iDatabaseName;
    iDatabaseName = databaseName;
    CleanupStack::Pop(databaseName);

    LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - end");
}
// ---------------------------------------------------------
// CWPStringPair::SetL
// ---------------------------------------------------------
//
void CWPStringPair::SetL( const TDesC& aName, const TDesC& aValue )
	{
	HBufC* name = aName.AllocLC();
	HBufC* value = aValue.AllocL();
	CleanupStack::Pop(); // name

	delete iName;
	iName = name;
	iNamePtr.Set( *iName );

	delete iValue;
	iValue = value;
	iValuePtr.Set( *iValue );
	}
void CUpsObserver::AddFilterL(CObservationFilter& aFilterList, const TDesC& aFilter) const
/**
	Inserts a new filter into the filter list.
	Sets the first character of the new filter as the current system drive.
	
	@param aFilterList A filter list object.
	@param aFilter	   A filter data which will be inserted.
 */
	{
	HBufC* filterData = aFilter.AllocLC();
	TPtr ptr(filterData->Des());
	ptr[0] = iFs->GetSystemDriveChar();
	aFilterList.AddFilterL(filterData);
	CleanupStack::Pop(filterData);
	}
void CPictureWidget::SetImage(const TDesC& aName)
{
	//if(NULL == iBitmap)
	{
		ASSERT(NULL == iBitmap);
		ASSERT(NULL == iImageReader);
		ASSERT(NULL == iImageName);

		CImage_Reader* imageReader = new (ELeave)CImage_Reader(*this);
		CleanupStack::PushL(imageReader);
		iImageName = aName.AllocLC();
		imageReader->ConstructL(*iImageName);
		CleanupStack::Pop(2);
		iImageReader = imageReader;
	}
}
Exemple #20
0
void CApaAppListServer::RegisterNonNativeApplicationTypeL(TUid aApplicationType, const TDesC& aNativeExecutable)
	{
	for (TInt i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
		{
		if (iNonNativeApplicationTypeArray[i].iTypeUid.iUid==aApplicationType.iUid)
			{
			User::Leave(KErrAlreadyExists);
			}
		}
	SNonNativeApplicationType nonNativeApplicationType;
	nonNativeApplicationType.iTypeUid.iUid=aApplicationType.iUid;
	nonNativeApplicationType.iNativeExecutable=aNativeExecutable.AllocLC();
	iNonNativeApplicationTypeArray.AppendL(nonNativeApplicationType);
	CleanupStack::Pop(nonNativeApplicationType.iNativeExecutable);
	CleanupStack::PushL(TCleanupItem(DeleteLastNonNativeApplicationType, this));
	ExternalizeNonNativeApplicationTypeArrayL();
	CleanupStack::Pop(this); // the TCleanupItem
	}
void CSecurityPolicy::AddPermissionL(CFunctionGroup& aFunctionGroup, const TDesC& aPermission)
{
    TInt permissionCount = iPermissions.Count();

    for (TInt i = 0; i < permissionCount; i++)
    {
        if ((*iPermissions[i]) == aPermission)
        {
            User::Leave(KErrAlreadyExists);
        }
    }

    HBufC* permission = aPermission.AllocLC();

    User::LeaveIfError(iPermissions.Append(permission));
    CleanupStack::Pop(permission);
    aFunctionGroup.AddPermissionL(permission);
}
/**
Symbian OS constructor
@param aText  Text that will be parsed
@param aSearchCases   Identifies what items are we looking for:
                          EFindItemSearchPhoneNumberBin
                          EFindItemSearchMailAddressBin
                          EFindItemSearchURLBin
                          EFindItemSearchScheme
                      Any combination of these flags can be given
                      as a bit mask.
@param aMinNumbers    Minimum count of numbers in a string when 
                      the string is considered as a phone number.
*/
void CTulAddressStringTokenizer::ConstructL(const TDesC& aText, TInt aSearchCases, TInt aMinNumbers)
    {
    iMinNumbers = aMinNumbers;
    HBufC* buf = NULL;
	TLanguage language = User::Language();

    if (language == ELangArabic || language == ELangHebrew || language == ELangUrdu || 
    	language == ELangFarsi || language == ELangHindi)
		{
		buf = aText.AllocLC();
        TPtr ptr = buf->Des();
        LanguageSpecificNumberConverter::ConvertToWesternNumbers( ptr );
		PerformSearchL( *buf, aSearchCases );
		}
	else
		PerformSearchL( aText, aSearchCases );

	if(buf)
		CleanupStack::PopAndDestroy(buf);
	}
/*
-------------------------------------------------------------------------------

    Class: CStifFileParser

    Method: PushFileToStack

    Description: Opens file and pushes it to stack

    Parameters: TDesc& aFileName   in: name of file to open and add to stack

    Return Values: None

    Errors/Exceptions:  None

    Status: Proposal

-------------------------------------------------------------------------------
*/
void CStifFileParser::PushFileToStackL(const TDesC& aFileName)
	{

	//First check if file is not already included
	for(TInt i = 0; i < iFileNames.Count(); i++)
		{
		if(aFileName.CompareF(iFileNames[i]->Des()) == KErrNone)
			{
			__TRACE(KError, (_L("File [%S] was already included. Ignoring"), &aFileName));
			return;
			}
		}

	//Open and add file to stack
	RFile *nf = new RFile();

	__TRACE(KInfo, (_L("Including file [%S]"), &aFileName));
	TInt r = nf->Open(iFileServer, aFileName, EFileRead | EFileShareAny);
	if(r == KErrNone)
		{
		//Add to stack
		iFileStack->PushL(nf);

		//And add to file names array
		HBufC* newFile = aFileName.AllocLC();
		User::LeaveIfError(iFileNames.Append(newFile));
		CleanupStack::Pop(newFile);

		//Set valid pointer of current file
		iCurrentFile = nf;
		}
	else
		{
		__TRACE(KError, (_L("Could not open file [%S]. Error %d. Ignoring"), &aFileName, r));
		}
	}
// -----------------------------------------------------------------------------
// CUpnpMimeMapper::AddMimeMapElL
// -----------------------------------------------------------------------------
//
void CUpnpMimeMapper::AddMimeMapElL( const TDesC8& aKey, const TDesC& aVal )
    {
    HBufC* val = aVal.AllocLC();
    iMimeToExtMap->PutL(aKey, val);
    CleanupStack::Pop(val);        
    }   
void CSsmCommandListResourceReaderImpl::CResourcePool::AppendL(const TDesC& aFileName)
	{
	HBufC* name = aFileName.AllocLC();
	iResourceFileNames.AppendL(name);
	CleanupStack::Pop(name);
	}
Exemple #26
0
EXPORT_C void CPlan::AddAppArcRegFileL(const TDesC& aFilename)
{
    HBufC* tmp = aFilename.AllocLC() ;
    iAppArcRegFiles.AppendL(tmp);
    CleanupStack::Pop(tmp);
}
void CAknFileSelectionModel::AppendIconForFileL(const TDesC& aFileName)
    {
    //TFileName absFileName( iCurrentPath.DriveAndPath() );
    HBufC *bufAbsFileName = HBufC::NewLC(KMaxPath);
    *bufAbsFileName = iCurrentPath.DriveAndPath();
    TPtr absFileName = bufAbsFileName->Des();

    absFileName.Append( aFileName );
    TUid uidIgnore;
    TDataType dataType;
    TInt err = iApaSession.AppForDocument( absFileName, uidIgnore, dataType );
    TInt iconIndex = EUnknowTypeIcon;
    CleanupStack::PopAndDestroy(); //bufAbsFileName

    if( err != KErrNone )
        {
        // Couldn't find out the data type, use generic file icon:
        iconIndex = EUnknowTypeIcon;
        }
    else
        {
        HBufC *bufDataTypeBuf = HBufC::NewLC(KMaxDataTypeLength);
        *bufDataTypeBuf = dataType.Des();
        TPtr dataTypeBuf = bufDataTypeBuf->Des();

        if( dataTypeBuf.MatchF( KCFDMimeTypeAudioVoiceRec ) == 0 ||
            dataTypeBuf.MatchF( KCFDMimeTypeAudioVoiceRec2 ) == 0 )
            {
            iconIndex = EVoiceRecFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypePlaylist ) == 0 )
            {
            iconIndex = EPlaylistFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeRam ) == 0 )
            {
            iconIndex = ELinkFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeAudio ) == 0 )
            {
            iconIndex = ESoundFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeImageGms ) == 0 )
            {
            iconIndex = EGmsFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeImage ) == 0 )
            {
            iconIndex = EImageFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeVideo ) == 0 ||
                 dataTypeBuf.MatchF( KCFDMimeTypeVideoRealMedia ) == 0 ||
                 dataTypeBuf.MatchF( KCFDMimeTypeVideoSdp ) == 0 )
            {
            iconIndex = EVideoFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeGame ) == 0 )
            {
            iconIndex = EGameFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeNote ) == 0 )
            {
            iconIndex = ENoteFileIcon;
            }
        else if( dataTypeBuf.MatchF( KCFDMimeTypeJava ) == 0 )
            {
            iconIndex = EJavaFileIcon;
            }
        else if ( dataTypeBuf.MatchF( KCFDMimeTypeFlash ) == 0 )
            {
            iconIndex = EFlashFileIcon;
            }
        else
            {
            // Check from the file name extension, if it's a SIS file:
            //TParse fileName;
            //fileName.Set( aFileName, NULL, NULL );

            HBufC * bufFileName = aFileName.AllocLC();
            TPtr ptrFileName = bufFileName->Des();
            TParsePtr fileName(ptrFileName);

            TPtrC ext( fileName.Ext() );
            if( ext.CompareF( KCFDFileExtSis ) == 0
                || ext.CompareF( KCFDFileExtSisx ) == 0 )
                {
                iconIndex = ESisFileIcon;
                }
            // RApaLsSession does not recognize .mid's:
            else if( ext.CompareF( KCFDFileExtMid ) == 0 )
                {
                iconIndex = ESoundFileIcon;
                }
            else
                {
                iconIndex = EUnknowTypeIcon;
                }
            CleanupStack::PopAndDestroy(); //bufFileName

            }

        CleanupStack::PopAndDestroy(); //bufDataTypeBuf
        }
    iImageIndexArray.Append( iconIndex );
    }
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void CPosLmNameIndex::InsertL( TPosLmItemId aLmid, const TDesC& aName )
    {
    HBufC* name = aName.AllocLC();
    CleanupStack::Pop( name );
    InsertL( aLmid, name );
    }