Example #1
0
// ---------------------------------------------------------------------------
// Check whether an error code is severe error or not
// ---------------------------------------------------------------------------
//
TInt CDunStream::ProcessErrorCondition( TInt aError, TBool& aIsError )
    {
    FTRACE(FPrint( _L("CDunStream::ProcessErrorCondition() (Dir=%d)" ), iDirection));
    aIsError = EFalse;
    if ( aError != KErrNone )
        {
        aIsError = ETrue;
        RArray<TInt>* okErrors = NULL;
        if ( iOperationType == EDunOperationTypeRead )
            {
            okErrors = &iOkErrorsR;
            }
        else // iOperationType == EDunOperationTypeWrite
            {
            okErrors = &iOkErrorsW;
            }
        TInt retTemp = okErrors->Find( aError );
        if ( retTemp == KErrNotFound )
            {
            FTRACE(FPrint( _L("CDunStream::ProcessErrorCondition() (Dir=%d) (%d=ETrue) complete" ), iDirection, aError));
            return ETrue;
            }
        }
    FTRACE(FPrint( _L("CDunStream::ProcessErrorCondition() (Dir=%d) (%d=EFalse) complete" ), iDirection, aError));
    return EFalse;
    }
// ---------------------------------------------------------------------------
// CSisxSifPluginUiHandler::DisplayDriveL()
// ---------------------------------------------------------------------------
//
TInt CSisxSifPluginUiHandler::DisplayDriveL( const Swi::CAppInfo& /*aAppInfo*/,
        TInt64 /*aSize*/, const RArray<TChar>& aDriveLetters,
        const RArray<TInt64>& /*aDriveSpaces*/ )
    {
    FLOG( _L("CSisxSifPluginUiHandler::DisplayDriveL") );

    TInt driveNumber = EDriveC;
    TInt err = iSifUi->SelectedDrive( driveNumber );
    if( err )
        {
        FLOG_1( _L("CSisxSifPluginUiHandler::DisplayDriveL; SelectedDrive err=%d"), err );
        }

    TChar driveLetter = 'C';
    err = RFs::DriveToChar( driveNumber, driveLetter );
    if( err )
        {
        FLOG_1( _L("CSisxSifPluginUiHandler::DisplayDriveL; DriveToChar err=%d"), err );
        }

    TInt index = aDriveLetters.Find( driveLetter );
    if( index >= 0 && index < aDriveLetters.Count() )
        {
        return index;
        }
    return 0;
    }
Example #3
0
void CMemoryView::HandleDeletedChunk(TUint32 aAddress)
{
    TChunkInfo chunkInfo(aAddress);
    TInt pos = iChunkList.Find(chunkInfo, TChunkInfo::Match);
    if (pos < 0)
    {
        PrintWarning(_L("Couldn't handle deletion of chunk 0x%08x: %d"), aAddress, pos);
    }
    else
    {
        TChunkInfo& c = iChunkList[pos];

        // Rejuvenate chunks that haven't been updated since this one last was.
        const TInt numChunks = iChunkList.Count();
        for (TInt i = 0; i < numChunks; ++i)
        {
            TChunkInfo& d = iChunkList[i];
            if (d.iUpdateCount > c.iUpdateCount)
            {
                --d.iUpdateCount;
            }
        }

        iChunkList.Remove(pos);
        if (iChunkList.Count() <= iNumConsoleLines)
        {
            iVerticalOffset = 0;
        }
    }
}
// ---------------------------------------------------------------------------
// CJavaRegistry::SuiteEntryExistsL
// ---------------------------------------------------------------------------
//
TBool CJavaRegistry::SuiteEntryExistsL(TUid aSuiteUid) const
{
    JELOG2(EJavaStorage);

    if (aSuiteUid == TUid::Null())
    {
        User::Leave(KErrArgument);
    }

    RArray<TUid> suiteUids;

    // New registry filters non-present applictions.
    iRegistry->GetRegistryEntryUidsL(Java::EMidp2MidletSuite, suiteUids);
    int result = suiteUids.Find(aSuiteUid);

    suiteUids.Close();

    TBool exists = EFalse;

    if (KErrNotFound != result)
    {
        exists = ETrue;
    }
    return exists;
}
// ---------------------------------------------------------------------------
// CSisxSifPluginUiHandler::DisplayOptionsL()
// ---------------------------------------------------------------------------
//
TBool CSisxSifPluginUiHandler::DisplayOptionsL( const Swi::CAppInfo& /*aAppInfo*/,
        const RPointerArray<TDesC>& aOptions, RArray<TBool>& aSelections )
    {
    FLOG( _L("CSisxSifPluginUiHandler::DisplayOptionsL") );
    TInt optionCount = aOptions.Count();
    CPtrCArray* selectableItems = new( ELeave ) CPtrC16Array( optionCount );
    CleanupStack::PushL( selectableItems );
    for( TInt index = 0; index < optionCount; index++ )
        {
        selectableItems->AppendL( *aOptions[ index ] );
        }

    RArray<TInt> selectedIndexes;
    TBool isSelected = iSifUi->ShowSelectOptionsL( *selectableItems, selectedIndexes );
    if( isSelected && selectedIndexes.Count() )
        {
        TInt selectionsCount = aSelections.Count();
        __ASSERT_DEBUG( selectionsCount == optionCount, User::Invariant() );
        for( TInt index = 0; index < selectionsCount; index++ )
            {
            aSelections[ index ] = ( selectedIndexes.Find( index ) != KErrNotFound );
            }
        }
    return isSelected;
    }
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void PosLmLandmarkHandler::RemoveNonExistingCategoriesL(
    CPosLmLocalDbAccess& aDbAccess,
    RArray<TPosLmItemId>& aCategoryIdArray)
    {
    RArray<TPosLmItemId> categoriesInDatabase;
    CleanupClosePushL(categoriesInDatabase);

    PosLmCategoryHandler::GetAllCategoryIdsL(aDbAccess,
        CPosLmCategoryManager::ECategorySortOrderNone, categoriesInDatabase);

    if (categoriesInDatabase.Count() == 0)
        {
        aCategoryIdArray.Reset();
        }

    for (TInt i = 0; i < aCategoryIdArray.Count();)
        {
        if (categoriesInDatabase.Find(aCategoryIdArray[i]) == KErrNotFound)
            {
            aCategoryIdArray.Remove(i);
            }
        else
            {
            i++;
            }
        }

    CleanupStack::PopAndDestroy(&categoriesInDatabase);
    }
void CMemSpyEngineHelperChunk::GetChunkHandlesL( RArray<TAny*>& aHandles, TType aType, TUint aId )
    {
	TAny* handles[ KMemSpyEngineMaxChunkCount ];
	TInt count = KMemSpyEngineMaxChunkCount;

    TInt r = 0;
    //
    switch( aType )
        {
    case EThread:
        r = iEngine.Driver().GetChunkHandlesForThread( aId, handles, count );
        break;
    case EProcess:
        r = iEngine.Driver().GetChunkHandlesForProcess( aId, handles, count );
        break;
    default:
    case EAll:
        r = iEngine.Driver().GetChunkHandles( handles, count );
        break;
        }
    //
    if  ( r == KErrNone )
    	{
        count = Min( count, KMemSpyEngineMaxChunkCount );
        for( TInt index = 0; index < count; index++ )
            {
            TAny* handle = handles[ index ];

            if  ( aHandles.Find( handle ) == KErrNotFound )
                {
                aHandles.AppendL( handle );
                }
            }
        }
    }
Example #8
0
TInt CSCPParamDB :: GetApplicationIDListL(RArray <TUid>& aIDArray) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry  = HBufC :: NewLC(KSelectAll().Length());
    lSelectQry->Des().Append(KSelectAll);
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TBool lStatus(EFalse);
    TInt lRet(KErrNone);
    
    TRAP(lRet, lStatus = lDBView.FirstL());
    
    if(lRet == KErrNone && lStatus) {
        do {
            lDBView.GetL();
            TUid lAppUID = TUid :: Uid(lDBView.ColInt(iColSet->ColNo(KColAppId)));
            
            if(aIDArray.Find(lAppUID) == KErrNotFound) {
                aIDArray.AppendL(lAppUID);
            }
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
    CleanupStack :: PopAndDestroy(2);
    return KErrNone;
}
Example #9
0
void CMemoryView::HandleChangedChunk(TUint32 aAddress, TInt aSize, TInt aHighWaterMark)
{
    TChunkInfo chunkInfo(aAddress);
    TInt pos = iChunkList.Find(chunkInfo, TChunkInfo::Match);
    if (pos < 0)
    {
        PrintWarning(_L("Couldn't handle updated to chunk 0x%08x: %d"), aAddress, pos);
    }
    else
    {
        TChunkInfo& c = iChunkList[pos];
        // Age all the chunks that have been updated more recently than this one.
        const TInt numChunks = iChunkList.Count();
        for (TInt i = 0; i < numChunks; ++i)
        {
            TChunkInfo& d = iChunkList[i];
            if (d.iUpdateCount < c.iUpdateCount)
            {
                ++d.iUpdateCount;
            }
        }

        c.iUpdateCount = 0;
        c.iCurrentSize = aSize;
        c.iHighWaterMark = aHighWaterMark;
        Sort();
    }
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void PosLmLandmarkHandler::UpdateCategoriesL(
    CPosLmLocalDbAccess& aDbAccess,
    const CPosLandmark& aLandmark,
    const CPosLandmark& aOldLandmark)
    {
    RArray<TPosLmItemId> categoryArray;
    CleanupClosePushL(categoryArray);
    aLandmark.GetCategoriesL(categoryArray);

    RArray<TPosLmItemId> oldCategoryArray;
    CleanupClosePushL(oldCategoryArray);
    aOldLandmark.GetCategoriesL(oldCategoryArray);

    RemoveNonExistingCategoriesL(aDbAccess, categoryArray);

    RArray<TPosLmItemId> toBeAdded;
    CleanupClosePushL(toBeAdded);

    TInt i;
    for (i = 0; i < categoryArray.Count(); i++)
        {
        if (oldCategoryArray.Find(categoryArray[i]) == KErrNotFound)
            {
            User::LeaveIfError(toBeAdded.Append(categoryArray[i]));
            }
        }

    AddCategoriesToLandmarkL(aDbAccess, toBeAdded, aLandmark.LandmarkId());
    CleanupStack::PopAndDestroy(&toBeAdded);

    RArray<TPosLmItemId> toBeRemoved;
    CleanupClosePushL(toBeRemoved);

    for (i = 0; i < oldCategoryArray.Count(); i++)
        {
        if (categoryArray.Find(oldCategoryArray[i]) == KErrNotFound)
            {
            User::LeaveIfError(toBeRemoved.Append(oldCategoryArray[i]));
            }
        }

    RemoveCategoriesFromLandmarkL(aDbAccess, toBeRemoved,
        aLandmark.LandmarkId());

    CleanupStack::PopAndDestroy(3, &categoryArray); //&oldCategoryArray
    // &toBeRemoved
    }
// ---------------------------------------------------------------------------
// CMediaMtpDataProvider::Insert
//
// ---------------------------------------------------------------------------
//
void CMediaMtpDataProvider::InsertL( RArray<TUint>& aArray, const TUint aProperCode ) const
    {
    TInt err = KErrNone;
    err = aArray.Find( aProperCode );
    if ( err == KErrNotFound )
        err = aArray.Append( aProperCode );

    User::LeaveIfError( err );
    }
// -----------------------------------------------------------------------------
// Delete all attributes from a media object except those specified
// -----------------------------------------------------------------------------
//
void CGlxGarbageCollector::DeleteOtherAttributes( CGlxCache& /*aCache*/, CGlxMedia& aMedia, 
        const RArray<TMPXAttribute>& aAttributesToKeep ) const
    {
    TRACER("CGlxGarbageCollector::DeleteOtherAttributes");
    
    // loop backwards so can delete attributes during the loop
    for ( TInt attrIndex = aMedia.Count() - 1; attrIndex >= 0; attrIndex-- )
        {
        // delete the attribute if it is not in use
        if ( KErrNotFound == aAttributesToKeep.Find( aMedia.Attribute( attrIndex ), TMPXAttribute::Match ) )
            {
            GLX_LOG_INFO( "CGlxGarbageCollector::CleanupMediaL - Deleted attribute" );
            aMedia.DeleteAttribute( attrIndex );
            }
        }
    }
bool S60CameraSettings::isSharpeningSupported() const
{
#ifdef POST_31_PLATFORM
    if (m_imageProcessingSettings) {
        RArray<TUid> suppTransforms;
        TRAPD(err, m_imageProcessingSettings->GetSupportedTransformationsL(suppTransforms));
        if (err)
            return false;

        if (suppTransforms.Find(KUidECamEventImageProcessingAdjustSharpness))
            return true;
    }
    return false;
#else // S60 3.1 Platform
    return false;
#endif // POST_31_PLATFORM
}
Example #14
0
TInt CSCPParamDB :: ListParamsUsedByAppL(RArray <TInt>& aParamIds, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry(NULL);
    
    if(aApp == -1) {
        lSelectQry = HBufC :: NewLC(KSelectAllAscParamID().Length());
        lSelectQry->Des().Append(KSelectAllAscParamID);
    }
    else {
        lSelectQry = HBufC :: NewLC(KSelectWhereAppIdByAscParamID().Length() + 15);
        lSelectQry->Des().Format(KSelectWhereAppIdByAscParamID, aApp);
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> SQL Query: %S"), &lSelectQry->Des());
    _SCPDB_LOG(_L("[CSCPParamDB]-> Executing the query..."));
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(lSelectQry->Des())));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TInt lErr(KErrNone);
    TInt lStatus(KErrNone);    
    
    TRAP(lErr, lStatus = lDBView.FirstL());
    _SCPDB_LOG(_L("[CSCPParamDB]-> Fetching values for the column KColParamId"));
    
    if(lErr == KErrNone && lStatus) {
        do {
            lDBView.GetL();
            TInt lPID = lDBView.ColInt(iColSet->ColNo(KColParamId));
            
            if(aParamIds.Find(lPID) == KErrNotFound) {
                aParamIds.AppendL(lPID);
            }
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> Query execution complete..."));
    CleanupStack :: PopAndDestroy(2);
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListParamsUsedByApp() <<<"));
    return KErrNone;
}
int S60CameraSettings::saturation()
{
#ifdef POST_31_PLATFORM
    if (m_imageProcessingSettings) {
        RArray<TUid> suppTransforms;
        TRAPD(err, m_imageProcessingSettings->GetSupportedTransformationsL(suppTransforms));
        if (err)
            if (err != KErrNotSupported)
                emit error(QCamera::CameraError, QString("Failure while querying supported transformations."));

        if (suppTransforms.Find(KUidECamEventtImageProcessingAdjustSaturation))
            return m_imageProcessingSettings->TransformationValue(KUidECamEventtImageProcessingAdjustSaturation);
    }
    return 0;
#else // S60 3.1 Platform
    return 0;
#endif // POST_31_PLATFORM
}
Example #16
0
// ---------------------------------------------------------
// CPosTp164::CheckLandmarkL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp164::CheckLandmarkL(TPosLmItemId aLandmarkId, RArray<TPosLmItemId> aCategoriesList)
    {
    iLog->Log(_L("CheckLandmarkL"));
    
    // Get landmark
    CPosLandmark* lm1 = iDatabase->ReadLandmarkLC(aLandmarkId);
    TPtrC name1;
    lm1->GetLandmarkName(name1);
    iLog->Log(name1);
    
    RArray<TPosLmItemId> categories;
    CleanupClosePushL(categories);
    // Get all categories attached to this landmark
    lm1->GetCategoriesL(categories);
   
    CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase);
    CleanupStack::PushL(categoryManager);
    
    if ( aCategoriesList.Count() != categories.Count() )
        {
        iLog->Log(_L("ERROR: Wrong number of categories, actual %d, expected %d"),
            categories.Count(), aCategoriesList.Count() );
        iErrorsFound++;
        }
    
    for (TInt i=0;i<categories.Count();i++)
        {
        if (aCategoriesList.Find(categories[i]) != KErrNotFound)
            {
            iLog->Log(_L("Found"));
            }
        else 
            {
            iLog->Log(_L("ERROR: Category '%S' was not found"));
            iErrorsFound++;
            }
        }
    
    CleanupStack::PopAndDestroy(categoryManager);

    CleanupStack::PopAndDestroy(&categories);
    CleanupStack::PopAndDestroy(lm1);
    }
// ---------------------------------------------------------------------------
// CWriteableJavaRegistry::AddUids
// ---------------------------------------------------------------------------
//
void CWriteableJavaRegistry::AddUids(
    const JavaStorageApplicationList_t& aApps,
    const JavaStorageEntry& aEntry,
    RArray<TUid>& aUids) const
{
    JavaStorageApplicationList_t::const_iterator iter;

    for (iter = aApps.begin(); iter != aApps.end(); iter++)
    {
        JavaStorageApplicationEntry_t::const_iterator finder
        = (*iter).find(aEntry);

        if (finder != (*iter).end())
        {
            Uid appUid((*finder).entryValue());
            TUid uid;
            TInt err = uidToTUid(appUid, uid);

            if (KErrNone == err)
            {
                err = aUids.Find(uid);

                if (KErrNotFound == err)
                {
                    // reset the error flag
                    err = KErrNone;
                    if (IsPresent((*iter)))
                    {
                        err = aUids.Append(uid);
                    }
                    if (err)
                    {
                        ELOG1(EJavaStorage, "Failed to add Uid to container. "
                              "( error code = %d )", err);

                    }
                }
            }
        }
    }
}
/** Function from defect raiser for testing
* Sets a new exception date and updates the entry in the agenda model.
@param aNewAgnEntry Agenda entry containing the exception date
@param aExistingAgnEntry Agenda entry that will be updated.
@return True if aExistingAgnEntry was updated. EFalse if the
exception date already existed.*/
TBool CTestCalInterimApiDEF064928Step::CreateExceptionDateL(const CCalEntry* aNewAgnEntry, CCalEntry* aExistingAgnEntry)
{
	RArray<TCalTime> exceptions;
	CleanupClosePushL(exceptions);
	aExistingAgnEntry->GetExceptionDatesL(exceptions);
	TInt ret=exceptions.Find(aNewAgnEntry->RecurrenceIdL());
	if(ret==KErrNotFound)
		{
		exceptions.Append(aNewAgnEntry->RecurrenceIdL());
		aExistingAgnEntry->SetExceptionDatesL(exceptions);
		SaveToAgendaL(aExistingAgnEntry,ETrue);
		}
	else
		{
		SetTestStepResult(EFail);
		}
		
	CleanupStack::PopAndDestroy(1);//close exceptions

	return (ret==KErrNotFound);
}
void S60CameraSettings::setSaturation(int value)
{
#ifdef POST_31_PLATFORM
    if (m_imageProcessingSettings) {
        RArray<TUid> suppTransforms;
        TRAPD(err, m_imageProcessingSettings->GetSupportedTransformationsL(suppTransforms));
        if (err)
            if (err != KErrNotSupported)
                emit error(QCamera::CameraError, QString("Failure while querying supported transformations."));

        if (suppTransforms.Find(KUidECamEventtImageProcessingAdjustSaturation))
            m_imageProcessingSettings->SetTransformationValue(KUidECamEventtImageProcessingAdjustSaturation, value == -1 ? 0 : value*2-100);
        else
            emit error(QCamera::NotSupportedFeatureError, QString("Setting saturation is not supported."));
    }
    else
        emit error(QCamera::NotSupportedFeatureError, QString("Setting saturation is not supported."));
#else // S60 3.1
    Q_UNUSED(value);
    emit error(QCamera::NotSupportedFeatureError, QString("Setting saturation is not supported."));
#endif // POST_31_PLATFORM
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void PosLmLandmarkHandler::ReadFieldsL(
    CPosLmLocalDbAccess& aDbAccess,
    CPosLandmark& aLandmark,
    TBool aHasRequestedFields,
    const RArray<TUint>& aRequestedFields)
    {
    if (!aHasRequestedFields || aRequestedFields.Count() > 0)
        {
        HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen);
        sql->Des().Format(KPosLmSqlFindUint, &KPosLmSqlAll,
            &KPosLmLandmarkFieldTable, &KPosLmLandmarkIdCol,
            aLandmark.LandmarkId());

        RDbView view;
        aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation,
            view, *sql);

        HBufC* textFieldBuffer = HBufC::NewLC(KPosLmMaxTextFieldLength);

        while (view.NextL())
            {
            view.GetL();

            TUint16 fieldType = view.ColUint16(EPosLmLfcFieldTypeCol);

            if (!aHasRequestedFields ||
                aRequestedFields.Find(fieldType) != KErrNotFound)
                {
                TPtr buffer = textFieldBuffer->Des();
                PosLmLongTextColHandler::ReadFromLongTextColumnL(
                    buffer, view, EPosLmLfcFieldStringCol);

                aLandmark.SetPositionFieldL(fieldType, *textFieldBuffer);
                }
            }

        CleanupStack::PopAndDestroy(3, sql); //&view, textFieldBuffer
        }
    }
Example #21
0
// ----------------------------------------------------------------------------
// Group attributes belonging to one content into an item in the array
// ----------------------------------------------------------------------------
//
EXPORT_C void MPXUser::MergeAttributeL(
    const TArray<TMPXAttribute>& aSrc,
    RArray<TMPXAttribute>& aDest)
    {
    CleanupClosePushL(aDest);
    aDest.Reset();
    for (TInt i = 0; i < aSrc.Count(); i++)
        {
        const TMPXAttribute& s = aSrc[i];
        TInt index = aDest.Find(s, TMPXAttribute::MatchContentId);
        if ( KErrNotFound == index )
            {
            aDest.AppendL(s);
            }
        else
            {
            TMPXAttribute& d = aDest[index];
            d = TMPXAttribute(d.ContentId(), d.AttributeId() | s.AttributeId());
            }
        }
    CleanupStack::Pop();
    }
Example #22
0
// ---------------------------------------------------------------------------
// Adds error code to consider as "no error" to either endpoint
// ---------------------------------------------------------------------------
//
TInt CDunStream::AddSkippedError( TInt aError,
                                  TDunOperationType aOperationType )
    {
    FTRACE(FPrint( _L("CDunStream::AddSkippedError()" ) ));
    RArray<TInt>* okErrors = NULL;
    if ( aOperationType == EDunOperationTypeRead )
        {
        okErrors = &iOkErrorsR;
        }
    else if ( aOperationType == EDunOperationTypeWrite )
        {
        okErrors = &iOkErrorsW;
        }
    else
        {
        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (ERROR) complete" ) ));
        return KErrGeneral;
        }
    if ( aError >= 0 )  // errors can't be >= 0
        {
        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (ERROR) complete" ) ));
        return KErrGeneral;
        }
    TInt retTemp = okErrors->Find( aError );
    if ( retTemp != KErrNotFound )
        {
        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (already exists) complete" ) ));
        return KErrAlreadyExists;
        }
    retTemp = okErrors->Append( aError );
    if ( retTemp != KErrNone )
        {
        FTRACE(FPrint( _L("CDunStream::AddSkippedError() (append failed!) complete" ) ));
        return retTemp;
        }
    FTRACE(FPrint( _L("CDunStream::AddSkippedError() complete" ) ));
    return KErrNone;
    }
TVerdict CSyncTestStep::doTestStepPreambleL()
	{
	__UHEAP_MARK;

	iScheduler = new(ELeave) CActiveScheduler;
	CActiveScheduler::Install(iScheduler);
	
	iSecureBackupEngine = CSBEClient::NewL();

	//
	// Connect to PhBkSync...
	//
	TInt  ret = iSession.Connect();
	TESTCHECKL(ret, KErrNone);

	//
	// Perform a sync to start the tests in a clean state. We also wait for the
	// slower TSYs to get ready!
	//
	RPhoneBookSession::TSyncState  syncState(RPhoneBookSession::EUnsynchronised);
	
	ret = iSession.GetPhoneBookCacheState(syncState);

	if (ret != KErrNone  ||  syncState != RPhoneBookSession::ECacheValid)
		{
		TRequestStatus  status(KErrUnknown);

		while (status.Int() != KErrNone)
			{
			iSession.DoSynchronisation(status);
			User::WaitForRequest(status);

			if (status.Int() == KErrServerTerminated)
				{
				INFO_PRINTF1(_L("PhBkSync has terminated, restarting..."));

				iSession.Close();
				ret = iSession.Connect();
				TESTCHECKL(ret, KErrNone);

				User::After(5*1000000);
				}
			else if (status.Int() != KErrNone)
				{
				INFO_PRINTF2(_L("Preamble sync result was %d so retrying..."), status.Int());
				User::After(5*1000000);
				}
			}
		TESTCHECKL(status.Int(), KErrNone);
	
		//
		// For MMTSY testing to pass, ensure that the equivilant entries
		// from SIMTSY are on the SIM (slots 1 to 20 excluding 18 and 19)...
		//
		RArray<TInt>  freeSlotArray;
		CleanupClosePushL(freeSlotArray);
		
		iSession.GetFreeSlotsL(freeSlotArray);

		for (TInt count = 1;  count <= 20;  count++)
			{
			if (freeSlotArray.Find(count) != KErrNotFound  &&
			    count != 18  &&  count != 19)
				{
				TBuf<20>  telName;
				TBuf<20>  telNumber;

				telName.AppendFormat(_L("Friend %d"), count);
				telNumber.AppendFormat(_L("12345000%03d"), count);

				INFO_PRINTF4(_L("Preamble filling contact {\"%S\", \"%S\"} to slot %d..."),
				             &telName, &telNumber, count);
				
				TContactICCEntry  iccEntry;
				TRequestStatus  status;

				iccEntry.iName.Copy(telName);
				iccEntry.iNumber.Copy(telNumber);
				iccEntry.iSlotNum    = count;
				iccEntry.iContactUID = KNullContactId;
				iccEntry.iTON        = RMobilePhone::EUnknownNumber;

				WriteContactToICCL(iccEntry, status);
				TESTCHECKL(status.Int(), KErrNone);
				TESTCHECKCONDITION(iccEntry.iSlotNum != KSyncIndexNotSupplied);
				}
			}

		CleanupStack::PopAndDestroy(&freeSlotArray);
		}

	return TestStepResult();
	} // CSyncTestStep::doTestStepPreambleL
/**
Removes comm addresses from the 3 lists that are already in the database and have been updated.
It takes the 3 lists in as parameters and modifies them accordingly. It also populates the list
of comm address ids that are free to be recycled during updating.
*/
void CPplCommAddrTable::RemoveNonUpdatedAddrsL(RArray<TMatch>& aNewPhones, RArray<TPtrC>& aNewEmails, RArray<TPtrC>& aNewSips,
					  RArray<TInt>& aFreeCommAddrIds, const TInt aItemId,CPplCommAddrTable::TCommAddrExtraInfoType 
                      aExtraInfoType )
	{
	// build the RSqlStatement
	RSqlStatement stmnt;
	CleanupClosePushL(stmnt);
	stmnt.PrepareL(iDatabase, iWholeSelectStmnt->SqlStringL() );
	const TInt KContactIdParamIndex(KFirstIndex); // first and only parameter in the query
	User::LeaveIfError(stmnt.BindInt(KContactIdParamIndex, aItemId) ) ;

	// fetch the results from the query and compare them with the new comm_addrs we have
	TInt err(KErrNone);
	while ((err = stmnt.Next() ) == KSqlAtRow)
		{
		const TInt KType(stmnt.ColumnInt(iWholeSelectStmnt->ParameterIndex(KCommAddrType() ) ) );
		if (KType == EPhoneNumber)
			{
			TMatch phoneNumber;
			TPtrC valString    = stmnt.ColumnTextL(iWholeSelectStmnt->ParameterIndex(KCommAddrValue() ) );
			TPtrC extValString = stmnt.ColumnTextL(iWholeSelectStmnt->ParameterIndex(KCommAddrExtraValue() ) );
			TInt extTypeInfoString = stmnt.ColumnInt(iWholeSelectStmnt->ParameterIndex(KCommAddrExtraTypeInfo() ) );
			User::LeaveIfError(TLex(valString).Val(phoneNumber.iLowerSevenDigits) );
			User::LeaveIfError(TLex(extValString).Val(phoneNumber.iUpperDigits) );

			TInt matchIndex(aNewPhones.Find(phoneNumber, TIdentityRelation<TMatch>(&TMatch::Equals) ) );
			// remove any phone numbers from the new list if we already
			// have them in the db and they haven't changed...
			if (matchIndex != KErrNotFound  && (extTypeInfoString == aExtraInfoType))
				{
				aNewPhones.Remove(matchIndex);
				}
			// ...and add any spare ids to the recycle list
			else
				{
				aFreeCommAddrIds.AppendL(
					stmnt.ColumnInt(iWholeSelectStmnt->ParameterIndex(KCommAddrId() ) ) );
				}
			}
		else // is Email or SIP
			{
			TPtrC valString = stmnt.ColumnTextL(iWholeSelectStmnt->ParameterIndex(KCommAddrValue() ) );
			TInt matchIndex(0);

			// remove any email and sip addresses from the new list if
			// we already have them in the db and they haven't changed...
			if (KType == EEmailAddress)
				{
				matchIndex = aNewEmails.Find(valString);
				if (matchIndex != KErrNotFound)
					{
					aNewEmails.Remove(matchIndex);
					}
				}
			else // SIP
				{
				matchIndex = aNewSips.Find(valString);
				if (matchIndex != KErrNotFound)
					{
					aNewSips.Remove(matchIndex);
					}
				}

			// ...and add any spare ids to the recycle list
			if (matchIndex == KErrNotFound)
				{
				aFreeCommAddrIds.AppendL(
					stmnt.ColumnInt(iWholeSelectStmnt->ParameterIndex(KCommAddrId() ) ) );
				}
			}
		}
	// leave if we didn't complete going through the results properly
	if(err != KSqlAtEnd)
		{
		User::Leave(err);
		}
	CleanupStack::PopAndDestroy(&stmnt);
	}
/**
Updates communication addresses in the database.

If there are the same number of items to be updated as are already in the database, the
existing records are overwritten using the update statement. However, if there is a
different number of addresses to be updated, records in the database (if there are any)
are deleted (using DeleteL() ) and the new data is inserted (using CreateInDbL() ).

@param aItem A contact item whose communication addresses are to be updated in the contacts database.
*/
void CPplCommAddrTable::UpdateL(const CContactItem& aItem)
	{
	// Check that the contact item is a card, own card or ICC entry.
	const TUid type(aItem.Type() );
	if (type != KUidContactCard && type != KUidContactOwnCard && type != KUidContactICCEntry && type != KUidContactGroup)
		{
		return;
		}

	const TContactItemId KItemId(aItem.Id() );

	// create lists for comm_addrs and go through contact item to populate them with any new ones we find
	RArray<TMatch> newPhones;
	RArray<TPtrC>  newEmails;
	RArray<TPtrC>  newSips;
	CleanupClosePushL(newPhones);
	CleanupClosePushL(newEmails);
	CleanupClosePushL(newSips);
	
	CPplCommAddrTable::TCommAddrExtraInfoType extraInfoType = ENonMobileNumber;

	for (TInt fieldNum = aItem.CardFields().Count() - 1; fieldNum >= 0; --fieldNum)
		{
		CContactItemField& currField = aItem.CardFields()[fieldNum];
		const CContentType& contType = currField.ContentType();
		TBool isPhone(contType.ContainsFieldType(KUidContactFieldPhoneNumber) ||
					  contType.ContainsFieldType(KUidContactFieldFax)		  ||
					  contType.ContainsFieldType(KUidContactFieldSms)		  );
		TBool isEmail(contType.ContainsFieldType(KUidContactFieldEMail) );
		TBool isSip(contType.ContainsFieldType(KUidContactFieldSIPID) );

		// check it's a field we want and that it's not empty
		// store a new address if we haven't already seen it -- no point storing the same one twice.
		if ((isPhone || isEmail || isSip) && currField.StorageType() == KStorageTypeText
				&& currField.TextStorage()->IsFull() )
			{
			// get phone numbers
			if (isPhone)
				{
				TMatch phoneNumber;
				phoneNumber = CreatePaddedPhoneDigitsL(currField.TextStorage()->Text(), KLowerSevenDigits,
													   KMaxPhoneMatchLength - KLowerSevenDigits);
				if (newPhones.Find(phoneNumber, TIdentityRelation<TMatch>(&TMatch::Equals) ) == KErrNotFound)
					{
					newPhones.AppendL(phoneNumber);
					}
				if(contType.ContainsFieldType(KUidContactFieldVCardMapCELL))
                    {
                    extraInfoType = EMobileNumber;
                    }
				}
			// get email addresses
			else if (isEmail && newEmails.Find(currField.TextStorage()->Text() ) == KErrNotFound)
				{
				newEmails.AppendL(currField.TextStorage()->Text() );
				}
			// get SIP addresses
			else if (newSips.Find(currField.TextStorage()->Text() ) == KErrNotFound)
				{
				newSips.AppendL(currField.TextStorage()->Text() );
				}
			}
		}

	// if there are no comm addresses in the contact item, delete any from the database
	if (!(newPhones.Count() + newEmails.Count() + newSips.Count() ) )
		{
		TBool lowDiskErr(EFalse);
		DeleteL(aItem, lowDiskErr);
		CleanupStack::PopAndDestroy(3, &newPhones); // and newSips, newEmails
		if (lowDiskErr)
			{
			User::Leave(KErrDiskFull);
			}
		return;
		}

	// create from the database a list of comm_addr_ids that can be recycled as their
	// comm_addrs are in the database but not in the new version of the contact item
	RArray<TInt> freeCommAddrIds;
	CleanupClosePushL(freeCommAddrIds);

	// weed out addresses from the list that are already in the db but haven't changed
	// and populate the freeCommAddrIds list
	RemoveNonUpdatedAddrsL(newPhones, newEmails, newSips, freeCommAddrIds, KItemId, extraInfoType);

	// do the actual updating on an address-by-address basis

	DoUpdateCommAddrsL(newPhones, newEmails, newSips, freeCommAddrIds, KItemId,extraInfoType);

	CleanupStack::PopAndDestroy(4, &newPhones); // and freeCommAddrIds, newSips, newEmails
	}
/**
Insert new communication addresses into the comm_addr table.
@param aItem A contact item whose communication addresses are to be added to the contacts database.
*/
void CPplCommAddrTable::CreateInDbL(CContactItem& aItem)
	{
	// Check that the contact item is a card, own card or ICC entry.
	const TUid KType = aItem.Type();
	if (KType != KUidContactCard && KType != KUidContactOwnCard && KType != KUidContactICCEntry && KType != KUidContactGroup)
		{
		return;
		}

	// create lists for comm_addrs to keep track of what we have already seen so as to avoid duplicates
	RArray<TMatch> newPhones;
	RArray<TPtrC>  newEmails;
	RArray<TPtrC>  newSips;
	CleanupClosePushL(newPhones);
	CleanupClosePushL(newEmails);
	CleanupClosePushL(newSips);

	for (TInt fieldNum = aItem.CardFields().Count() - 1; fieldNum >= 0; --fieldNum)
		{
		CContactItemField& currField = aItem.CardFields()[fieldNum];
		const CContentType& contType = currField.ContentType();
		TBool isPhone(contType.ContainsFieldType(KUidContactFieldPhoneNumber) ||
					  contType.ContainsFieldType(KUidContactFieldFax)		  ||
					  contType.ContainsFieldType(KUidContactFieldSms)		  );
		TBool isEmail(contType.ContainsFieldType(KUidContactFieldEMail) );
		TBool isSip(contType.ContainsFieldType(KUidContactFieldSIPID) );

		// check it's a field we want and that it's not empty
		// insert a new address only if we haven't already seen it -- no point storing the same one twice.
		if ((isPhone || isEmail || isSip) && currField.StorageType() == KStorageTypeText
				&& currField.TextStorage()->IsFull() )
			{
			const TContactItemId KItemId(aItem.Id());

			// get phone numbers
			if (isPhone)
				{
				TMatch phoneNumber;
				phoneNumber = CreatePaddedPhoneDigitsL(currField.TextStorage()->Text(), KLowerSevenDigits,
													   KMaxPhoneMatchLength - KLowerSevenDigits);
				if (newPhones.Find(phoneNumber, TIdentityRelation<TMatch>(&TMatch::Equals) ) == KErrNotFound)
					{
					if(contType.ContainsFieldType(KUidContactFieldVCardMapCELL))
                        {
                        DoPhoneNumWriteOpL(phoneNumber, EInsert, KItemId,EPhoneNumber,EMobileNumber);
                        }
					else
					    {
					    DoPhoneNumWriteOpL(phoneNumber, EInsert, KItemId);
					    }
					
					newPhones.AppendL(phoneNumber);
					}
				}
			// get email addresses
			else if (isEmail && newEmails.Find(currField.TextStorage()->Text() ) == KErrNotFound)
				{
				DoNonPhoneWriteOpL(currField.TextStorage()->Text(), EInsert, KItemId, EEmailAddress);
				newEmails.AppendL(currField.TextStorage()->Text() );
				}
			// get SIP addresses
			else if (newSips.Find(currField.TextStorage()->Text() ) == KErrNotFound)
				{
				DoNonPhoneWriteOpL(currField.TextStorage()->Text(), EInsert, KItemId, ESipAddress);
				newSips.AppendL(currField.TextStorage()->Text() );
				}
			}
		}

	CleanupStack::PopAndDestroy(3, &newPhones); // and newSips, newEmails
	}
// ---------------------------------------------------------------------------
// CTestStartupListUpdater::RemoveL()
// ---------------------------------------------------------------------------
//
TInt CTestStartupListUpdater::RemoveL( CStifItemParser& aItem )
    {
    _LIT( KTestName, "Remove" );
    Print( 0, KTestStartFormat, &KTestName );
    TInt testResult = KErrNone;

    RSoftwareComponentRegistry registry;
    User::LeaveIfError( registry.Connect() );
    CleanupClosePushL( registry );

    // Get installed application TComponentIds and TUids
    RArray<TUid> uidList;
    CleanupClosePushL( uidList );
    RArray<TComponentId> componentIdList;
    CleanupClosePushL( componentIdList );

    registry.GetComponentIdsL( componentIdList );
    for( TInt i = 0; i < componentIdList.Count(); ++i ) {
        TComponentId compId = componentIdList[ i ];
        CComponentEntry *compEntry = CComponentEntry::NewLC();
        if( registry.GetComponentL( compId, *compEntry ) ) {
            if( compEntry->IsRemovable() && compEntry->SoftwareType() == KSoftwareTypeNative )
                {
                _LIT(KCompUid, "CompUid");
                CPropertyEntry *property = registry.GetComponentPropertyL( compId, KCompUid );
                CleanupStack::PushL( property );
                CIntPropertyEntry* intProperty = dynamic_cast<CIntPropertyEntry*>( property );
                uidList.AppendL( TUid::Uid( intProperty->IntValue() ) );
                CleanupStack::PopAndDestroy( property );
            } else {
                uidList.AppendL( KNullUid );
            }

        }
        CleanupStack::PopAndDestroy( compEntry );
    }
    if( uidList.Count() != componentIdList.Count() )
        {
        _LIT( KFailedToGetIds, "Failed to get IDs" );
        Print( 0, KTestStartFormat, &KFailedToGetIds );
        testResult = KErrGeneral;
        }

    // Uninstall TUid apps listed in parameters
    TPtrC param;
    while( aItem.GetNextString ( param ) == KErrNone && testResult == KErrNone )
        {
        const TUint KMaxLimit = 0xFFFFFFFF;
        TLex lex( param );
        TUint32 intVal = 0;

        _LIT( KHexPrefix, "0x" );
        if( param.Left( KHexPrefix().Length() ) == KHexPrefix )
            {
            lex.Inc( KHexPrefix().Length() );
            testResult = lex.BoundedVal( intVal, EHex, KMaxLimit );
            }
        else
            {
            testResult = lex.BoundedVal( intVal, EDecimal, KMaxLimit );
            }

        if( testResult == KErrNone )
            {
            TUid uid( TUid::Uid( intVal ) );
            if( uid != KNullUid )
                {
                TInt index = uidList.Find( uid );
                if( index >= 0 && index < componentIdList.Count() )
                    {
                    TComponentId componentId = componentIdList[ index ];

                    RSoftwareInstall installer;
                    User::LeaveIfError( installer.Connect() );
                    CleanupClosePushL( installer );

                    TRequestStatus status;
                    installer.Uninstall( componentId, status );
                    User::WaitForRequest( status );
                    testResult = status.Int();

                    CleanupStack::PopAndDestroy( &installer );
                    }
                else
                    {
                    testResult = KErrNotFound;
                    }
                }
            else
                {
                testResult = KErrUnknown;
                }
            }
        Print( 1, KTestParamFormatArg, &KTestName, &param, testResult );
        }

    CleanupStack::PopAndDestroy( 3, &registry );    // componentIdList, uidList, registry
    Print( 0, KTestDoneFormat, &KTestName );
    return testResult;
    }
// ---------------------------------------------------------------------------
// CAppMngr2SisxRuntime::GetInstallationFilesL()
// ---------------------------------------------------------------------------
//
void CAppMngr2SisxRuntime::GetInstallationFilesL(
        RPointerArray<CAppMngr2PackageInfo>& aPackageInfos,
        const RPointerArray<CAppMngr2RecognizedFile>& aFileList,
        RFs& aFsSession, TRequestStatus& aStatus )
    {
    TInt fileCount = aFileList.Count();
    FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: fileCount = %d", fileCount );
    if( fileCount )
        {
        // Check if this is the memory card installer daemon private folder.
        // All files are from the same directory, 
        CAppMngr2RecognizedFile* firstFile = aFileList[ 0 ];
        if( firstFile->FileName().Find( KAppMngr2DaemonPrivateFolder ) == KErrNotFound )
            {
            // No, it isn't. Process all files in aFileList and create package info objects.
            FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: normal folder" );
            for( TInt index = 0; index < fileCount; index++ )
                {
                CAppMngr2RecognizedFile* file = aFileList[ index ];
                
                TPtrC fileName = file->FileName();
                FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: file %S", &fileName );
                CreateNewPackageL( fileName, aPackageInfos, aFsSession );
                }
            }
        else
            {
            // It is. Process only those files that are not installed.
            FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: swidaemon private folder" );
            RArray<TUid> uids;
            CleanupClosePushL( uids );
            iSisRegistrySession.InstalledUidsL( uids );
            
            for( TInt index = 0; index < fileCount; index++ )
                {
                CAppMngr2RecognizedFile* recFile = aFileList[ index ];
                
                TPtrC fileName = recFile->FileName();
                FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: file %S", &fileName );
                
                // extract UID name from full path name
                TParsePtrC parse( fileName );
                TPtrC uidName = parse.Name().Left( KUidLength );
                FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: uidName %S", &uidName );
                
                // convert UID name to numerical form
                TLex lex( uidName );
                TUint32 uidValue;
                TInt lexError = lex.Val( uidValue, EHex );
                if( lexError == KErrNone )
                    {
                    // It's an UID name, try to display package name instead
                    FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: value %08x", uidValue );
                    
                    // check if this UID is already installed
                    TUid fileUid;
                    fileUid.iUid = uidValue;
                    if( uids.Find( fileUid ) == KErrNotFound )
                        {
                        FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: not installed" );
                        // Not installed, must be displayed. 
                        CreateNewPackageL( fileName, aPackageInfos, aFsSession );
                        }
                    else
                        {
                        FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: is installed" );
                        // Installed, two possible cases here. The package is in the
                        // SWI daemon private folder in memory card because:
                        // 1) memory card application is installed in use normally, or
                        // 2) the same application is already in ROM/internal drive.
                        // In case 1) this item MAY NOT be displayed here as it is already
                        // displayed in "Installed apps" side. In case of 2) it MUST be
                        // displayed, so that user can remove it from memory card. Cases
                        // 1) and 2) can be identified by checking the memory card's
                        // "unknown" list. If the sis package is unknown, it is case 2),
                        // as applications that are installed in use, are always known.
                        TChar driveLetter = parse.Drive()[ 0 ];
                        TInt driveNumber = 0;
                        User::LeaveIfError( RFs::CharToDrive( driveLetter, driveNumber ) );
                        CAppMngr2SisxUnknownList* unknownSisx = CAppMngr2SisxUnknownList::NewLC(
                                driveNumber );
                        TInt unknownIndex = unknownSisx->FindPkgWithUID( fileUid );
                        FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: unknownIndex %d",
                                unknownIndex );
                        if( unknownIndex >= 0 && unknownIndex < unknownSisx->PkgCount() )
                            {
                            // It is unknown package after all, add it to the list.
                            CreateNewPackageL( fileName, aPackageInfos, aFsSession );
                            }
                        CleanupStack::PopAndDestroy( unknownSisx );
                        }
                    }
                else
                    {
                    // Not an UID name, must be displayed.
                    FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: not UID name (lexErr %d)",
                            lexError );
                    CreateNewPackageL( fileName, aPackageInfos, aFsSession );
                    }
                }

            CleanupStack::PopAndDestroy( &uids );
            }
        }
    TRequestStatus* status = &aStatus;
    User::RequestComplete( status, KErrNone );
    }
/**
GetObjectHandles request handler
*/	
void CMTPGetObjectHandles::ServiceL()
	{
    OstTraceFunctionEntry0( CMTPGETOBJECTHANDLES_SERVICEL_ENTRY );
    
    if(iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted)
        {
        TUint storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
        TUint handle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
        TUint enumerateState = iSingletons.DpController().StorageEnumerateState(storageId);
        if ( (enumerateState < CMTPDataProviderController::EEnumeratingPhaseOneDone)
            || (enumerateState != CMTPDataProviderController::EEnumeratedFulllyCompleted && handle != KMTPHandleAll))
            {
            if (iTimeoutCount++ >= KMTPGetObjectHandlesTimeOut)
                {
                OstTrace0( TRACE_NORMAL, CMTPGETOBJECTHANDLES_SERVICEL, 
                        "Wait for enumeration time out, return busy." );
                SendResponseL(EMTPRespCodeDeviceBusy);
                iTimeoutCount = 0;
                OstTraceFunctionExit0( CMTPGETOBJECTHANDLES_SERVICEL_EXIT );
                return;
                }
            else
                {
                OstTrace0( TRACE_NORMAL, DUP1_CMTPGETOBJECTHANDLES_SERVICEL, 
                        "Enumeration not completed, suspend request." );
                RegisterPendingRequest(20);
                OstTraceFunctionExit0( DUP1_CMTPGETOBJECTHANDLES_SERVICEL_EXIT );
                return; 
                }
            }
        }
    
    iTimeoutCount = 0;
    
	delete iHandles;
	iHandles = NULL;
	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);

	OstTraceExt2( TRACE_NORMAL, DUP2_CMTPGETOBJECTHANDLES_SERVICEL, 
	        "IsConnectMac = %d; ERequestParameter2 = %d", iDevDpSingletons.DeviceDataStore().IsConnectMac(), Request().Uint32(TMTPTypeRequest::ERequestParameter2));	
    if(iDevDpSingletons.DeviceDataStore().IsConnectMac()
       &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2)))
        {
        OstTrace0( TRACE_NORMAL, DUP3_CMTPGETOBJECTHANDLES_SERVICEL, "ConnectMac and Fetch all." );
        HandleObjectHandlesUnderMacL(*iHandles);
        }
    else
        {
    	RMTPObjectMgrQueryContext   context;
    	RArray<TUint>               handles;
    	CleanupClosePushL(context);
    	CleanupClosePushL(handles);        
    	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
    	do
    	    {
        	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
			
        	TUint32 storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
        	TUint32 parentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
        	if ( storageId != KMTPStorageAll && parentHandle == KMTPHandleNoParent )
	            {
	            const CMTPStorageMetaData& storage(iFramework.StorageMgr().StorageL(storageId));
	            HBufC* StorageSuid = storage.DesC(CMTPStorageMetaData::EStorageSuid).AllocL();
            
	            RBuf suid;
	            suid.CleanupClosePushL();
	            suid.CreateL(KMaxFileName);
	            suid = *StorageSuid;
	            _LIT(WMPInfoXml,"WMPInfo.xml");
	            suid.Append(WMPInfoXml); 
	            TUint32 handle = iFramework.ObjectMgr().HandleL(suid);
	            if ( handle != KMTPHandleNone )
	                {
	                TInt index = handles.Find(handle);
	                if ( index != KErrNotFound )
	                    {
	                    handles.Remove(index);
	                    handles.InsertL(handle,0);
	                    }
	                }   
	            delete StorageSuid;
	            StorageSuid = NULL;
	            CleanupStack::PopAndDestroy();
            	}
        	iHandles->AppendL(handles);
    	    }
    	while (!context.QueryComplete()); 
    	CleanupStack::PopAndDestroy(&handles);
    	CleanupStack::PopAndDestroy(&context);        
        }        
    						
	SendDataL(*iHandles);
	OstTraceFunctionExit0( DUP2_CMTPGETOBJECTHANDLES_SERVICEL_EXIT );
	}
/**
GetDevicePropDesc request handler.
*/    
void CMTPGetDevicePropDesc::ServiceL()
    {
    OstTraceFunctionEntry0( CMTPGETDEVICEPROPDESC_SERVICEL_ENTRY );  
    iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    //before performing any operation will check the properties are supported or 
    //not if not then return EMTPRespCodeDevicePropNotSupported
    const CMTPTypeArray *mtpArray = &(iDpSingletons.DeviceDataStore().GetSupportedDeviceProperties());
    RArray <TUint> supportedArray;	    
    mtpArray->Array(supportedArray);
    OstTrace1(TRACE_NORMAL, CMTPGETDEVICEPROPDESC_SERVICEL, 
            "No of elements in supported property array = %d ", supportedArray.Count());
    if(KErrNotFound == supportedArray.Find(iPropCode))
        {
        SendResponseL(EMTPRespCodeDevicePropNotSupported);       
        OstTrace0(TRACE_NORMAL, DUP1_CMTPGETDEVICEPROPDESC_SERVICEL, "CMTPGetDevicePropDesc::EMTPRespCodeDevicePropNotSupported ");
        }
    else
        {
        switch (iPropCode)
            {
            case EMTPDevicePropCodeBatteryLevel:
            if (iDpSingletons.DeviceDataStore().RequestPending())
                {
                // BatteryLevel already pending - return busy code
                SendResponseL(EMTPRespCodeDeviceBusy);
                }
            else
                {
                iDpSingletons.DeviceDataStore().BatteryLevelL(iStatus, iBatteryLevelValue);
                SetActive();	
                }
            break;
            
            case EMTPDevicePropCodeSynchronizationPartner:
                ServiceSynchronisationPartnerL();
            break;
            
            case EMTPDevicePropCodeDeviceFriendlyName:
                ServiceDeviceFriendlyNameL();
            break;
            
            case EMTPDevicePropCodeSessionInitiatorVersionInfo:
                ServiceSessionInitiatorVersionInfoL();
            break;
            
            case EMTPDevicePropCodePerceivedDeviceType:
                ServicePerceivedDeviceTypeL();
            break;
            
            case EMTPDevicePropCodeDateTime:
                ServiceDateTimeL();
            break;
            
            case EMTPDevicePropCodeDeviceIcon:
                ServiceDeviceIconL();
            break;

            case EMTPDevicePropCodeSupportedFormatsOrdered:
            ServiceSupportedFormatsOrderedL();
            break;
            
            case EMTPDevicePropCodeFunctionalID:
            	ServiceFunctionalIDL();
            break;
            case EMTPDevicePropCodeModelID:
            	ServiceModelIDL();
            break;
            case EMTPDevicePropCodeUseDeviceStage:
            	ServiceUseDeviceStageL();
            break;
 
            default:
            if(iDpSingletons.DeviceDataStore().ExtnDevicePropDp())
                {
                HandleExtnServiceL(iPropCode, iDpSingletons.DeviceDataStore().ExtnDevicePropDp());
                }
            else 
                SendResponseL(EMTPRespCodeDevicePropNotSupported); 
            break;
            }
        }
    supportedArray.Close();
    OstTraceFunctionExit0( CMTPGETDEVICEPROPDESC_SERVICEL_EXIT );
    }