//------------------------------------------------------------------------------
// CAddBuffer::Find
//------------------------------------------------------------------------------
CConnMoNodeElement* CAddBuffer::CacheFind( const TDesC8& aUri )
    {
    OstTraceExt1( TRACE_NORMAL, CADDBUFFER_CACHEFIND_ENTRY, "ENTRY: CAddBuffer::CacheFind;aUri=%s", aUri );
    
    CConnMoNodeElement* resultNode = NULL;

    for ( TInt i = 0; i < iCache.Count(); ++i )
        {
        if ( iCache[i]->iUri.Match( aUri ) != KErrNotFound )
            {
            OstTrace0( TRACE_NORMAL, CADDBUFFER_CACHEFIND_MATCH_FOUND, "CAddBuffer::CacheFind; Matching URI found.");
            resultNode = iCache[i];
            
            OstTraceExt1( TRACE_NORMAL, 
                          CADDBUFFER_CACHEFIND_RESULT_NODE, 
                          "CAddBuffer::CacheFind; resultNode=%s", 
                          resultNode->iUri );
            break;
            }
        }
    
    OstTrace0( TRACE_NORMAL, CADDBUFFER_CACHEFIND_EXIT, "EXIT: CAddBuffer::CacheFind");
    return resultNode;
    }
//------------------------------------------------------------------------------
// CAddBuffer::FindDynamicNode
//------------------------------------------------------------------------------
CConnMoNodeElement* CAddBuffer::CacheFindDynamicNode( const TDesC8& aUri )
    {
    OstTraceExt1( TRACE_NORMAL, CADDBUFFER_CACHEFINDDYNAMICNODE_ENTRY, "ENTRY: CAddBuffer::CacheFindDynamicNode;aUri=%s", aUri );
    
    CConnMoNodeElement* resultNode = NULL;

    for ( TInt i = 0; i < iCache.Count(); ++i )
        {
        if ( iCache[i]->iUri.Match( aUri ) != KErrNotFound )
            {
            // 
            TBuf8<KMaxFieldLength> dynamicNodeChildUri( aUri );
            dynamicNodeChildUri.Append( KChildNodeWildCardPattern );
            
            if ( iCache[i]->iUri.Match(dynamicNodeChildUri) == KErrNotFound )
                {
                // Correct dynamic node found.
                OstTrace0( TRACE_NORMAL, 
                           CADDBUFFER_CACHEFINDDYNAMICNODE_MATCH_FOUND, 
                           "CAddBuffer::CacheFindDynamicNode; Matching node found.");
                          
                resultNode = iCache[i];
                break;
                }
            }
        }
    if ( resultNode != NULL )
        {
        OstTraceExt1( TRACE_NORMAL, 
                  CADDBUFFER_CACHEFINDDYNAMICNODE_EXIT, 
                  "EXIT: CAddBuffer::CacheFindDynamicNode;resultNode=%s", 
                  resultNode->iUri );
        }
    
    return resultNode;
    }
void CCdcDataInterface::CancelWrite()
/**
 * Cancel an outstanding write request
 */
	{
	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELWRITE_ENTRY );
	if (!iWriter)
		{
		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELWRITE, "CCdcDataInterface::CancelWrite;iWriter=%p", iWriter );
		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
		}
	iWriter->Cancel();
	iWriteObserver = NULL;
	OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELWRITE_EXIT );
	}
/**
Set the object properties after moving
*/
void CMTPMoveObject::SetPreviousPropertiesL(const TDesC& aFileName)
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_SETPREVIOUSPROPERTIESL_ENTRY );
    LEAVEIFERROR(iFramework.Fs().SetModified(aFileName, iPreviousModifiedTime),
                 OstTraceExt1( TRACE_ERROR, CMTPMOVEOBJECT_SETPREVIOUSPROPERTIESL, "Sets the date and time for %S failed", aFileName));
    if ( iIsFolder && iIsHidden )
    {
        TEntry fileEntry;
        User::LeaveIfError(iFramework.Fs().Entry( aFileName, fileEntry ));
        fileEntry.iAtt &= ~KEntryAttHidden;
        fileEntry.iAtt |= KEntryAttHidden;
        User::LeaveIfError(iFramework.Fs().SetAtt( aFileName, fileEntry.iAtt, ~fileEntry.iAtt));
    }
    OstTraceFunctionExit0( CMTPMOVEOBJECT_SETPREVIOUSPROPERTIESL_EXIT );
}
/** Print a report at the end of a test run of all PASSED tests, Note: If a 
 test fails, the framework gets Panic'd */
void CTestEngine::Report()
	{
	TBuf<KTestCaseIdLength> aTestCaseId;
	test.Printf(_L("============================\n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_REPORT, "============================\n");
	test.Printf(_L("PASSED TESTS:\n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_REPORT_DUP01, "PASSED TESTS:\n");
	// itterate our list of tests to perform
	ResetTestCaseIndex();
	while (KErrNone == NextTestCaseId(aTestCaseId))
		{
		test.Printf(_L("%S\n"), &aTestCaseId);
		OstTraceExt1(TRACE_NORMAL, CTESTENGINE_REPORT_DUP02, "%S\n", aTestCaseId);
		}
	}
void CCdcDataInterface::CancelRead()
/**
 * Cancel an outstanding read request
 */
	{
	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELREAD_ENTRY );
	if (!iReader)
		{
		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELREAD, "CCdcDataInterface::CancelRead;iReader=%p", iReader );
		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
		}
	if (!iReadOneOrMoreReader)
		{
		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELREAD_DUP1, 
							"CCdcDataInterface::CancelRead;iReadOneOrMoreReader=%p", iReadOneOrMoreReader );
		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
		}

	iReader->Cancel();
	iReadOneOrMoreReader->Cancel();
	iReadObserver = NULL;
	iReadOneOrMoreObserver = NULL;
	OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELREAD_EXIT );
	}
// -----------------------------------------------------------------------------
// CDpPn2Rx::UpDate
// Pipe state has been changed.
// -----------------------------------------------------------------------------
//
void CDpPn2Rx::UpDate(
    CDpSubject* /*aChangedSubject*/ )
    {
    OstTrace0( TRACE_NORMAL, CDPPN2RX_UPDATE, "CDpPn2Rx::UpDate" );
    LOGM("CDpPn2Rx::UpDate");

    TInt r( KErrNone );
    // DCS PIF state changed
    switch ( iPifDcs.PipeState() )
        {
        case CDpPif::EDpPipeEnabled:
            {
            // start read but beware double read
            if ( iState == EElementWait )
                {
                r = Read();
                if ( r != KErrNone )
                    {
                    LOG("  ERROR, CDpPn2Rx::UpDate, Read() failed");
                    OstTrace0( TRACE_NORMAL, DUP1_CDPPN2RX_UPDATE, "ERROR, CDpPn2Rx::UpDate, Read() failed" );
                    }
                //no else
                }
            //no else
            break;
            }
        case CDpPif::EDpPipeDisabled: // Fall through
        case CDpPif::EDpPipeDisconnected:
            {
            if ( IsActive() )
                {
                Cancel();
                }
            //no else
            break;
            }
        default:
            {
            // Pipe is in state that is not regonized
            LOG1("  ERROR, CDpPn2Rx::UpDate, Unrecognized pipe state: %d",
                iPifDcs.PipeState() );
            OstTraceExt1( TRACE_NORMAL, DUP2_CDPPN2RX_UPDATE, "ERROR, CDpPn2Rx::UpDate, Unrecognized pipe state: %s", iPifDcs.PipeState() );

            Cancel();
            break;
            }
        }
    }
void CCdcDataInterface::CancelNotifyDataAvailable()
/**
 * Cancel notification of arrival of data.
 */
	{
	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE_ENTRY );
	if (!iDataAvailableNotifier)
		{
		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE, 
						"CCdcDataInterface::CancelNotifyDataAvailable;iDataAvailableNotifier=%p", iDataAvailableNotifier );
		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
		}
	iDataAvailableNotifier->Cancel();
	iNotifyDataAvailableObserver = NULL;	
	OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE_EXIT );
	}
//------------------------------------------------------------------------------
// CAddBuffer::AddNodeToBuffer()
//------------------------------------------------------------------------------
void CAddBuffer::AddNodeToBufferL( const TDesC8& aUri, 
                                   const TDesC8& aParentLUID,
                                   const TInt    aStatusRef )
    {
    OstTraceExt1( TRACE_NORMAL, CADDBUFFER_ADDNODETOBUFFERL_ENTRY, "ENTRY: CAddBuffer::AddNodeToBufferL;aUri=%s", aUri );
    
    CConnMoNodeElement* newNode = new (ELeave) CConnMoNodeElement();
    
    newNode->iUri.Copy( aUri );
    newNode->iParentLUID.Copy( aParentLUID );
    newNode->iStatusRef = aStatusRef;
    newNode->iProcessed = EFalse;
    newNode->iLeaf = EFalse;
    
    iBuffer.AppendL( newNode );
    OstTrace0( TRACE_NORMAL, CADDBUFFER_ADDNODETOBUFFERL_EXIT, "EXIT: CAddBuffer::AddNodeToBufferL");
    }
/*!
    This function handles urlChanged signal from QGraphicsWebView
    
    @param [in] newUrl New URL
 */
void WlanLoginView::handleUrlChanged(const QUrl& newUrl )
{
    OstTraceFunctionEntry0(WLANLOGINVIEW_HANDLEURLCHANGED_ENTRY);
 
#ifdef OST_TRACE_COMPILER_IN_USE
    QString url = newUrl.toString();
    TPtrC tmp(url.utf16(),url.length() );
    
    OstTraceExt1(
        TRACE_NORMAL,
        WLANLOGINVIEW_HANDLEURLCHANGED_URL_TRACE, 
        "WlanLoginEngine::handleUrlChanged;newUrl=%S",
        tmp);
#endif

    OstTraceFunctionExit0(WLANLOGINVIEW_HANDLEURLCHANGED_EXIT);
}
//------------------------------------------------------------------------------
// CAddBuffer::AddNodeToBuffer()
//------------------------------------------------------------------------------
TInt CAddBuffer::GetGroup( const TDesC8& aRoot, RPointerArray<CConnMoNodeElement>* aGroup )
    {
    OstTraceExt1( TRACE_NORMAL, CADDBUFFER_GETGROUP_ENTRY, "ENTRY: CAddBuffer::GetGroup;aRoot=%s", aRoot );

    iCache.Reset();
    TInt retval( KErrNotFound );
    TBool first = ETrue;
    TBuf8<KSmlMaxURISegLen> groupTag;
    groupTag.Copy( aRoot );
    groupTag.Append( KChildNodeWildCardPattern );

    for ( TInt i = 0; i < iBuffer.Count(); ++i )
        {
        if ( iBuffer[i]->iUri.Match( groupTag ) != KErrNotFound
             && !iBuffer[i]->iProcessed )
            {
            if ( first )
                {
                groupTag.Insert( aRoot.Length(), KNodeSeparator );
                groupTag.Insert( aRoot.Length() + 1, CUtils::GetSecondURISeg( iBuffer[i]->iUri ) );
                first = EFalse;
                retval = 0;
                }
            TInt err = KErrNone;
            TRAP(err,aGroup->AppendL(iBuffer[i]));
            if(err != KErrNone)
                {
				retval = err;
                break;
                }
            TRAP(err,iCache.AppendL(iBuffer[i]));
            if(err != KErrNone)
                {
                TInt indx = aGroup->Find(iBuffer[i]);
                if(indx != KErrNotFound)
                    aGroup->Remove(indx);
				retval = err;
                break;
                }
            retval++;
            }
        }
    OstTrace1( TRACE_NORMAL, CADDBUFFER_GETGROUP_EXIT, "EXIT: CAddBuffer::GetGroup;retval=%d", retval );

    return retval;
    }
TMTPResponseCode CMTPMoveObject::CheckRequestL()
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_CHECKREQUESTL_ENTRY );
    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    if (EMTPRespCodeOK != result)
    {
        OstTraceFunctionExit0( CMTPMOVEOBJECT_CHECKREQUESTL_EXIT );
        return result;
    }

    const TUint32 KObjectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    //not taking owernship
    iObjectInfo = iRequestChecker->GetObjectInfo(KObjectHandle);
    __ASSERT_DEBUG(iObjectInfo, Panic(EMTPDpObjectNull));
    if(!iSingletons.StorageMgr().IsReadWriteStorage(iObjectInfo->Uint(CMTPObjectMetaData::EStorageId)))
    {
        result = EMTPRespCodeStoreReadOnly;
    }

    if ( (EMTPRespCodeOK == result) && (!iSingletons.StorageMgr().IsReadWriteStorage(Request().Uint32(TMTPTypeRequest::ERequestParameter2))) )
    {
        result = EMTPRespCodeStoreReadOnly;
    }

    if(result == EMTPRespCodeOK)
    {
        const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
        iIsFolder = EFalse;
        LEAVEIFERROR(BaflUtils::IsFolder(iFramework.Fs(), suid, iIsFolder),
                     OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_CHECKREQUESTL, "can't judge whether %S is folder", suid));

        if(!iIsFolder)
        {
            if(iDpSingletons.MovingBigFileCache().IsOnGoing())
            {
                OstTrace0( TRACE_NORMAL, CMTPMOVEOBJECT_CHECKREQUESTL,
                           "CheckRequestL - A big file moving is ongoing, respond with access denied" );
                result = EMTPRespCodeAccessDenied;
            }
        }
    }

    OstTraceFunctionExit0( DUP1_CMTPMOVEOBJECT_CHECKREQUESTL_EXIT );
    return result;
}
CCdcDataInterface* CCdcDataInterface::NewL(const TDesC16& aIfcName)
/**
 * Create a new CCdcDataInterface object and construct it using interface name
 * This call will return an object with a valid USB configuration
 *
 * @param aParent Observer.
 * @param aIfcName Contains the interface name
 * @return A pointer to the new object
 */
	{
	OstTraceFunctionEntry0( CCDCDATAINTERFACE_NEWL_ENTRY );
	OstTraceExt1( TRACE_NORMAL, CCDCDATAINTERFACE_NEWL, "CCdcDataInterface::NewL;\tData Ifc Name = %S", aIfcName );
	CCdcDataInterface* self = new (ELeave) CCdcDataInterface(aIfcName);
	CleanupStack::PushL(self);
	self->ConstructL();
	CLEANUPSTACK_POP(self);
	OstTraceFunctionExit0( CCDCDATAINTERFACE_NEWL_EXIT );
	return self;
	}
/**
Add a file entry to the object store
@param aEntry    The file Entry to be added
@param aPath    The full path name of the entry
@return MTP object handle, or KMTPHandleNone if entry was not accepted
*/
void CMTPFSEnumerator::AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry, TUint32 aStorageId, TUint32 aParentHandle)
{
    OstTraceFunctionEntry0( CMTPFSENUMERATOR_ADDENTRYL_ENTRY );
#ifdef OST_TRACE_COMPILER_IN_USE
    TBuf8<KMaxFileName> tmp;
    tmp.Copy(aPath);

    OstTraceExt1( TRACE_NORMAL, CMTPFSENUMERATOR_ADDENTRYL, "entry: %s", tmp );
#endif // OST_TRACE_COMPILER_IN_USE

    TUint16 assoc;
    TPtrC name;
    if (format == EMTPFormatCodeAssociation)
    {
        assoc = EMTPAssociationTypeGenericFolder;
        TParsePtrC pathParser(aPath.Left(aPath.Length() - 1)); // Ignore the trailing "\".
        name.Set(aEntry.iName);
    }
    else
    {
        assoc = EMTPAssociationTypeUndefined;
        TParsePtrC pathParser(aPath);
        name.Set(pathParser.Name());
    }

    //if(iExclusionMgr.IsFormatValid(format))
    {
        aHandle = KMTPHandleNone;

        iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId);
        iObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
        iObject->SetUint(CMTPObjectMetaData::EStorageId, aStorageId);
        iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath);
        iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);
        iObject->SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle);
        iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable);
        iObject->SetDesCL(CMTPObjectMetaData::EName, name);
        iFramework.ObjectMgr().InsertObjectL(*iObject);
        aHandle = iObject->Uint(CMTPObjectMetaData::EHandle);

    }
    OstTraceFunctionExit0( CMTPFSENUMERATOR_ADDENTRYL_EXIT );
}
/*!
   Process SSID validation.
 
   @param [in] ssid to be validated.
   
   @return Following values are possible
   - SsidStatusOk
   - SsidStatusInvalidLength
 */
WlanWizardUtils::SsidStatus WlanWizardUtils::validateSsid(const QString &ssid)
{
    OstTraceFunctionEntry0( WLANWIZARDUTILS_VALIDATESSID_ENTRY );
    TPtrC tmp(ssid.utf16(), ssid.length() );
    OstTraceExt1( TRACE_NORMAL, WLANWIZARDUTILS_VALIDATESSID, 
        "WlanWizardUtils::validateSsid;ssid=%S", tmp );
        
    SsidStatus ret = SsidStatusOk;
    
    int len = ssid.length();
    if (len < SsidMinLength || len > SsidMaxLength) {
        ret = SsidStatusInvalidLength;
    }
    OstTrace1( 
        TRACE_NORMAL, WLANWIZARDUTILS_VALIDATESSID_RETURN, 
        "WlanWizardUtils::validateSsid - Return;ret=%{SsidStatus}", ret );
    OstTraceFunctionExit0( WLANWIZARDUTILS_VALIDATESSID_EXIT );
    return ret;
}
TBool CMTPProxyDpConfigMgr::GetFileName(const TDesC& aFileName,TInt& aIndex)
	{
    OstTraceFunctionEntry0( CMTPPROXYDPCONFIGMGR_GETFILENAME_ENTRY );
    OstTraceExt1( TRACE_NORMAL, CMTPPROXYDPCONFIGMGR_GETFILENAME, "aFileName = %S",  aFileName);
        
	TInt count = iMappingStruct.Count();
    OstTrace1( TRACE_NORMAL, DUP1_CMTPPROXYDPCONFIGMGR_GETFILENAME, "count = %d", count );    
	for(TInt i=0 ; i<count ; i++)
		{
		TInt err=iMappingStruct[i].iFileArray->Find(aFileName,aIndex);
		if(err == KErrNone)
			{
			aIndex=i;
		    OstTrace1( TRACE_NORMAL, DUP2_CMTPPROXYDPCONFIGMGR_GETFILENAME, "aIndex = %d", aIndex );    
			OstTraceFunctionExit0( CMTPPROXYDPCONFIGMGR_GETFILENAME_EXIT );
			return ETrue;			
			}
		}
	
	OstTraceFunctionExit0( DUP1_CMTPPROXYDPCONFIGMGR_GETFILENAME_EXIT );
	return EFalse;
	}
/**
Opens the specified database configuration file and executes those operations that 
are specified in it which are currently supported (currently only 'CREATE INDEX' 
operations are supported and will be executed).

@param aFs The server's file server session
@param aConfigFilePath The configuration file path
@param aDbName Logical database name: "main" for the main database or attached database name

@leave KErrNoMemory, if an out of memory condition occurs.
       One of the other system-wide error codes if the configuration
       file fails to be opened or read

@panic SqlDb 2 In _DEBUG mode if iDbHandle is NULL (uninitialized TSqlDbSysSettings object).
*/
void TSqlDbSysSettings::DoExecuteDbConfigFileOpsL(RFs& aFs, const TDesC& aConfigFilePath, const TDesC& aDbName)
	{
	__ASSERT_DEBUG(iDbHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));
	
	//Open the config file and read it into a buffer
	RFile64 file;
	__SQLLEAVE_IF_ERROR(file.Open(aFs, aConfigFilePath, EFileRead)); 
	CleanupClosePushL(file);
	TInt64 size = 0;
	__SQLLEAVE_IF_ERROR(file.Size(size));
	if(size == 0)
		{
		//Config file is empty so just return
		SQL_TRACE_INTERNALS(OstTraceExt1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_DOEXECUTEDBCONFIGFILEOPSL, "0;TSqlDbSysSettings::DoExecuteDbConfigFileOpsL();Config file %S is empty", __SQLPRNSTR(aConfigFilePath)));	
		CleanupStack::PopAndDestroy(); // file
		return;
		}
	HBufC8* buffer = HBufC8::NewLC(size);
	TPtr8 bufPtr = buffer->Des();
	__SQLLEAVE_IF_ERROR(file.Read(bufPtr));

	//Convert buffer to Unicode for processing (the configuration file is expected to be ASCII or UTF-8)
	HBufC16* buf16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(bufPtr);
	CleanupStack::PushL(buf16);			
	TPtrC16 ptr16 = buf16->Des();
	
	//Skip the BOM (byte ordering mark) at the start if there is one
	if((ptr16.Locate(TChar(0xFEFF)) == 0) || (ptr16.Locate(TChar(0xFFFE)) == 0))
		{
		ptr16.Set(ptr16.Mid(1));	
		}
	 
	//Parse the file contents and execute the specified
	//config statements that are supported
	ParseFileL(ptr16, aDbName);

	CleanupStack::PopAndDestroy(3); // buf16, buffer, file
	}
void CMTPMoveObject::DoOnTimeoutL()
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_DOONTIMEOUTL_ENTRY );

    if (iTimer)
    {
        if (iTimer->IsActive())
        {
            iTimer->Cancel();
        }
        delete iTimer;
        iTimer = NULL;
    }

    const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
    TEntry fileEntry;
    LEAVEIFERROR(iFramework.Fs().Entry(suid, fileEntry),
                 OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_DOONTIMEOUTL, "Gets the entry details for %S failed!", suid));
    TUint32 handle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);

    iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName);
    iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
    iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
    iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);

    CMTPFSEntryCache& aCache = iDpSingletons.MovingBigFileCache();

    // Cache the target file entry info, which is used to send response to getobjectproplist and getobjectinfo
    aCache.SetOnGoing(ETrue);
    aCache.SetTargetHandle(handle);
    aCache.SetFileEntry(fileEntry);

    OstTrace0( TRACE_NORMAL, CMTPMOVEOBJECT_DOONTIMEOUTL,
               "UpdateFSEntryCache, sending response with respond code OK for a big file move" );
    SendResponseL(EMTPRespCodeOK);

    OstTraceFunctionExit0( CMTPMOVEOBJECT_DOONTIMEOUTL_EXIT );
}
Beispiel #19
0
void CTestEngine::GetNumericInput(TInt &aNumber)
	{
	TUint value(0);
	TUint digits(0);
	TKeyCode key = (TKeyCode) 0;

	aNumber = -1;
	while ( key != EKeyEnter )
		{
		key = test.Getch();

		if ( ( key >= '0' ) && ( key <= '9' ) )
			{
			test.Printf(_L("%c"),key);
			OstTraceExt1(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT, "%c",key);
			
			value = ( 10 * value ) + ( key - '0' );
			digits++;
			} else 
			{ // very basic keyboard processing, backspace
				if (key == EKeyBackspace)
				{
				value = value/10;
				digits--;
				test.Printf(_L("\r    \r%d"), value);
				OstTrace1(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT_DUP01, "\r    \r%d", value);
				}
			}
		}

	if (digits > 0)
		{
		aNumber = value;
		}
	test.Printf(_L("\n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT_DUP02, "\n");
	}
/**
Check the GetPartialObject reqeust
@return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
*/  
TMTPResponseCode CMTPGetPartialObject::CheckRequestL()
    {
    OstTraceFunctionEntry0( CMTPGETPARTIALOBJECT_CHECKREQUESTL_ENTRY );
    TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    if(result == EMTPRespCodeOK)
        {
        TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
        iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
        iLength = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
        
        //does not take ownership
        iObjectInfo = iRequestChecker->GetObjectInfo(objectHandle);
        if (!iObjectInfo)
            {
            // The object handle has already been checked, so an invalid handle can
            // only occur if it was invalidated during a context switch between
            // the validation time and now.
            result = EMTPRespCodeInvalidObjectHandle;
            }
        else
            {
            TEntry fileEntry;
            LEAVEIFERROR(iFramework.Fs().Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry),
                    OstTraceExt1(TRACE_ERROR, CMTPGETPARTIALOBJECT_CHECKREQUESTL, 
                            "can't get entry details for %S!", iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));

            if((iOffset >= fileEntry.FileSize())) 
                {
                result = EMTPRespCodeInvalidParameter;
                }
            }
        }

    OstTraceFunctionExit0( CMTPGETPARTIALOBJECT_CHECKREQUESTL_EXIT );
    return result;  
    }
void CMTPDeviceDataProvider::AddFolderRecursiveL( const TMTPNotificationParamsFolderChange& aFolder )
    {
    OstTraceFunctionEntry0( CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL_ENTRY );
    
    TPtrC folderRight( aFolder.iFolderChanged );
    OstTraceExt1(TRACE_NORMAL, CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, 
            "Folder Addition - DriveAndFullPath:%S", folderRight);
    
    if ( !BaflUtils::FolderExists( Framework().Fs(), folderRight ))
    	{
        OstTrace0(TRACE_NORMAL, DUP1_CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, 
                "Folder not exist in file system");
    	User::Leave( KErrArgument );
    	}
    
    TUint32 parentHandle( KMTPHandleNoParent );
    TUint32 handle( KMTPHandleNoParent );
    TInt pos( KErrNotFound );
    TInt lengthOfRight( folderRight.Length());
    TFileName folderLeft;
    
    // get root path of storage
    TInt driveNumber;
    User::LeaveIfError(Framework().Fs().CharToDrive(folderRight[0], driveNumber));
    RBuf rootDirPath;
    rootDirPath.CreateL(KMaxFileName);
    rootDirPath.CleanupClosePushL();
    iDevDpSingletons.ConfigMgr().GetRootDirPathL(driveNumber, rootDirPath);
    rootDirPath.Insert(0, folderRight.Mid(0, 2));// get drive:
    
    /*
    Go through from beginning.
    when this while end, folderLeft keeps the top
    layer folder which has no handle
    */
    do 
        {
        pos = folderRight.Locate( KPathDelimiter );
        if ( KErrNotFound == pos )
            {
            break;
            }
        folderLeft.Append( folderRight.Left( pos + 1 ));
        lengthOfRight = folderRight.Length()-pos -1;
        folderRight.Set( folderRight.Right( lengthOfRight ));
        
        if ( rootDirPath.FindF(folderLeft) != KErrNotFound)
        	{
        	//first time, root folder
        	//continue
        	continue;
        	}
        parentHandle = handle;
        handle = Framework().ObjectMgr().HandleL( folderLeft );
        }
    while( KMTPHandleNone != handle );
    CleanupStack::PopAndDestroy(&rootDirPath);

    if ( KMTPHandleNone == handle )
        {
        OstTrace0(TRACE_NORMAL, DUP2_CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL, 
                "need to add entry into mtp database");
        
        CMTPObjectMetaData* folderObject = CMTPObjectMetaData::NewL();
        TUint32 storageId = GetStorageIdL( folderLeft );
        
        while( 1 )
            {
            parentHandle = AddEntryL( folderLeft, parentHandle, storageId, *folderObject );
            OnDeviceFolderChangedL( EMTPEventCodeObjectAdded, *folderObject );

            pos = folderRight.Locate( KPathDelimiter );
            lengthOfRight = folderRight.Length()-pos -1;
            if ( KErrNotFound == pos )
            	{
            	break;
            	}
            folderLeft.Append( folderRight.Left( pos + 1  ));
            folderRight.Set( folderRight.Right( lengthOfRight ));
            }
            
        delete folderObject;
        }
    
    OstTraceFunctionExit0( CMTPDEVICEDATAPROVIDER_ADDFOLDERRECURSIVEL_EXIT );
    }
// ---------------------------------------------------------
// CDpMif::SendNameAddReqL
// This method sends name add request to Name Service.
// ---------------------------------------------------------
//
void CDpMif::SendNameAddReqL(
    const TUint aUnit )
    {
    OstTrace0( TRACE_NORMAL, CDPMIF_SENDNAMEADDREQL, "CDpMif::SendNameAddReqL" );
    LOGM(" CDpMif::SendNameAddReq");

    __ASSERT_ALWAYS( aUnit <= KDataPortCommHighUnit,
        User::Leave( KErrNotSupported ) );

    TBuf8<SIZE_PNS_NAME_ADD_REQ> messageData;

    // Add reserved bytes
    messageData.Append( KDpPadding );
    messageData.Append( KDpPadding );

    // Add 32bit name (Big-endian)
    switch ( aUnit )
        {
        case KDpCsdPort:
        case KDpPort6:
            {
            messageData.Append( aUnit );                //name
            messageData.Append( PN_PEP_SUB_TYPE_SYMBIAN_INTERNAL ); //name
            messageData.Append( PN_PEP_TYPE_COMM );     //name
            messageData.Append( PN_PIPE );              //name
            break;
            }
        case KDpDialUpPort:
        case KDpPort4:
        case KDpPort5:
            {
            messageData.Append( aUnit );                //name
            messageData.Append( KDpPadding );           //name
            messageData.Append( PN_PEP_TYPE_COMM );     //name
            messageData.Append( PN_PIPE );              //name
            break;
            }
        case KDpBtAccHfPort:
            {
            messageData.Append( KDpPadding );           //name
            messageData.Append( PN_PEP_SUB_TYPE_BT_ACC_HF ); //name
            messageData.Append( PN_PEP_TYPE_BT_ACC );   //name
            messageData.Append( PN_PIPE );              //name
            break;
            }
        case KDpBtAccHsPort:
            {
            messageData.Append( KDpPadding );           //name
            messageData.Append( PN_PEP_SUB_TYPE_BT_ACC_HS ); //name
            messageData.Append( PN_PEP_TYPE_BT_ACC );   //name
            messageData.Append( PN_PIPE );              //name
            break;
            }
        default:
            {
            User::Leave( KErrGeneral );
            }
        }

    // Add Device id
    messageData.Append( THIS_DEVICE );

    // Create Object id
    TUint8 channelId( 0 );

    switch ( aUnit )
        {
        case KDpCsdPort:
            {
            channelId = EIscNokiaDataport1;
            break;
            }
        case KDpDialUpPort:
            {
            channelId = EIscNokiaDataport2;
            break;
            }
        case KDpBtAccHfPort:
        case KDpBtAccHsPort:
            {
            channelId = EIscNokiaBtAppl;
            break;
            }
        case KDpPort4:
            {
            channelId = EIscNokiaDataport3;
            break;
            }
        case KDpPort5:
            {
            channelId = EIscNokiaDataport4;
            break;
            }
        case KDpPort6:
            {
            channelId = EIscNokiaDataport5;
            break;
            }
        default:
            {
            //Do nothing
            break;
            }
        }

    TBuf8<2> data;
    TInt ret( iDataPort.ISAHandle().GetChannelInfo( channelId, data ) );

    _LIT(KPanicStr, "Dataport::SendNameAddReqL");
    __ASSERT_ALWAYS( KErrNone == ret, User::Panic( KPanicStr, 0 ) );

    // Set obj id
    TUint16 obj( static_cast<TUint16>(
        ( static_cast<TUint16>( data[0] ) << 8 ) + data[1] ) );

    LOG1(" Dataport::SendNameAddReqL obj = 0x%x", obj );
    OstTraceExt1( TRACE_NORMAL, DUP1_CDPMIF_SENDNAMEADDREQL, "CDpMif:: obj = 0x%hx", obj );

    // Add Object id
    messageData.Append( obj );
    // Add Record flags
    messageData.Append( PN_NAME_UNDEF/**PN_NAME_CLEARED**/ );
    //fill
    messageData.Append( KDpPadding );

#if defined(_DEBUG)
    ret =
#endif
    SendMessage(
        PN_NAMESERVICE,
        iDataPort.CreateTransactionId(),
        PNS_NAME_ADD_REQ,
        messageData );

    LOG1("  <== PNS_NAME_ADD_REQ req sent, obj id: %x", obj );
    OstTraceExt1( TRACE_NORMAL, DUP2_CDPMIF_SENDNAMEADDREQL, "CDpMif:: <== PNS_NAME_ADD_REQ req sent, obj id: %hx", obj );

#if defined(_DEBUG)
    if (KErrNone != ret )
        {
        LOG1("  Error isc api send %d", ret );
        OstTrace1( TRACE_NORMAL, DUP3_CDPMIF_SENDNAMEADDREQL, "CDpMif:: Error isc api send %d", ret );
        }
    //no else
#endif
    }
// -----------------------------------------------------------------------------
// CMmConferenceCallMessHandler::CallControlInd
// Breaks a CALL_CONTROL_IND ISI-message. Completes failed
// CreateConference, AddCall or Swap API request if there is a cause sub
// block in this response. In case that this message contains Split operation
// sub block, inform ConferenceCallTsy that GoOneToOne handling has started
// -----------------------------------------------------------------------------
//
void CMmConferenceCallMessHandler::CallControlInd(
    const TIsiReceiveC& aIsiMsg )
    {
TFLOGSTRING("TSY: CMmConferenceCallMessHandler::CallControlInd");
OstTrace0( TRACE_NORMAL,  CMMCONFERENCECALLMESSHANDLER_CALLCONTROLIND_TD, "CMmConferenceCallMessHandler::CallControlInd" );

    TUint sbStartOffSet( 0 );

    // Try to find CALL_MODEM_SB_CAUSE subblock. If found something has gone wrong
    if( KErrNone == aIsiMsg.FindSubBlockOffsetById(
        ISI_HEADER_SIZE + SIZE_CALL_MODEM_CONTROL_IND,
        CALL_MODEM_SB_CAUSE,
        EIsiSubBlockTypeId8Len8,
        sbStartOffSet ) )
        {
        // CALL_MODEM_SB_CAUSE sub block found, something has gone wrong.
        // Get cause type
        TUint8 causeType( aIsiMsg.Get8bit(
            sbStartOffSet + CALL_MODEM_SB_CAUSE_OFFSET_CAUSETYPE ) );
        // Get cause value
        TUint8 causeValue( aIsiMsg.Get8bit(
            sbStartOffSet + CALL_MODEM_SB_CAUSE_OFFSET_CAUSE ) );

        // Get Symbian OS error value
        TInt result( CMmStaticUtility::CSCauseToEpocError(
            PN_MODEM_CALL,
            causeType,
            causeValue ) );

        // If last operation was build, CreateConference or AddCall was asked
        if ( CALL_MODEM_OP_CONFERENCE_BUILD == iLastOperation )
            {
            // Has CreateConference been requested last.
            if ( iIsCreateConference )
                {
                // Complete with error
                iMessageRouter->Complete(
                    EMobileConferenceCallCreateConference,
                    result);
                // Reset flag
                iIsCreateConference = EFalse;
                }
            else
                {
                // Must be response to AddCall request
                iMessageRouter->Complete(
                    EMobileConferenceCallAddCall,
                    result );
                }
            iLastOperation = 0;
            }
        // if last operation was hold or retrieve
        else if ( CALL_MODEM_OP_HOLD == iLastOperation ||
            CALL_MODEM_OP_RETRIEVE == iLastOperation )
            {
            // Complete swap with error
            iMessageRouter->Complete(
                EMobileConferenceCallSwap,
                result );
            }
        // No else
        }
    // Successful operation handling for operations
    // Initiated bypassing the ETel (ghost operetion).
    else if ( !iIsCreateConference && 0 == iLastOperation )
        {
        TUint8 callOperation( 0 );
        // Get call Id (three bits (1-3) contain unique call ID)
        TInt uniqueCallId( static_cast<TInt>( aIsiMsg.Get8bit(
            ISI_HEADER_SIZE + CALL_MODEM_CONTROL_IND_OFFSET_CALLID )
            & KMaskBits1to3 ) );

        // Get call operation sub block
        if ( KErrNone == aIsiMsg.FindSubBlockOffsetById(
            ISI_HEADER_SIZE + CALL_MODEM_CONTROL_IND_OFFSET_OPERATION,
            CALL_MODEM_SB_OPERATION,
            EIsiSubBlockTypeId8Len8,
            sbStartOffSet ) )
            {
            TInt symbianConferenceEvent( -1 );
            // Get call operation
            callOperation = aIsiMsg.Get8bit(
                sbStartOffSet + CALL_MODEM_SB_OPERATION_OFFSET_OPERATION );

TFLOGSTRING2("TSY: CMmConferenceCallMessHandler::CallControlInd - Call operation: %d", callOperation);
OstTraceExt1( TRACE_NORMAL,  DUP1_CMMCONFERENCECALLMESSHANDLER_CALLCONTROLIND_TD, "CMmConferenceCallMessHandler::CallControlInd;callOperation=%hhu", callOperation );
            // Purpose of this case is to prepare handling of externally
            // controlled conference call
            switch ( callOperation )
                {
                case CALL_MODEM_OP_CONFERENCE_BUILD:
                    {
                    symbianConferenceEvent =
                        RMobileConferenceCall::EConferenceBuilt;
                    break;
                    }
                case CALL_MODEM_OP_HOLD:
                case CALL_MODEM_OP_SWAP:
                    {
                    symbianConferenceEvent =
                        RMobileConferenceCall::EConferenceSwapped;
                    break;
                    }
                case CALL_MODEM_OP_CONFERENCE_SPLIT:
                    {
                    symbianConferenceEvent =
                        RMobileConferenceCall::EConferenceSplit;
                    break;
                    }
                default:
                    {
                    // Nothing to do
                    break;
                    }
                }

            // Update the information to Conference call
            if ( 0 <= symbianConferenceEvent )
                {
                // Create call package
                CCallDataPackage callData;
                // Pack the data for sending to the manager
                callData.SetCallIdAndMode(
                    uniqueCallId,
                    RMobilePhone::EVoiceService );
                // Pack conference event
                callData.PackData( &symbianConferenceEvent );
                // Pass call information to the Symbian OS layer
                // complete mobile call info change
                iMessageRouter->Complete(
                    EMobileConferenceCallNotifyConferenceEvent,
                    &callData,
                    KErrNone );
                }
            // No else
            }
        // No else
        }
    // No else

    iIsCreateConference = EFalse;
    iLastOperation = 0;
    }
// ---------------------------------------------------------
// CDpMif::RunL
// This method handles received message from Isc Api and
// renews read from Isc Api.
// ---------------------------------------------------------
//
void CDpMif::RunL()
    {
    OstTrace0( TRACE_NORMAL, CDPMIF_RUNL, "CDpMif::RunL" );
    LOGM1("CDpMif::RunL - Port %d", iDataPort.PortUnit() );

    // we are always signaled from PhoNet ReceiveMessage
    if ( KErrNoMemory == iStatus.Int() )
        {
        LOGM(" ==> KErrNoMemory");
        OstTrace0( TRACE_NORMAL, DUP1_CDPMIF_RUNL, "CDpMif:: ==> KErrNoMemory" );

        // deallocate current message
        if ( iMsgReceiveBuffer )
            {
            delete iMsgReceiveBuffer;
            iMsgReceiveBuffer = NULL;
            iReceiveMessage.Set( NULL, 0, 0 );
            }
        //no else

        // ISA Handle receive
        // Trying to allocate a new message
        iMsgReceiveBuffer = HBufC8::NewL( ISI_HEADER_SIZE + iLen );
        _LIT( KPanicStr, "Dataport - CDpMif::RunL" );
        __ASSERT_ALWAYS( iMsgReceiveBuffer,
            User::Panic( KPanicStr, KErrNoMemory ) );
        iReceiveMessage.Set( iMsgReceiveBuffer->Des() );
        iLen = 0;

        if ( !IsActive() )
            {
            iDataPort.ISAHandle().Receive(
                iStatus, iReceiveMessage, iLen );

            SetActive();
            }
        //no else
        }
     else
        {
        OstTrace0( TRACE_NORMAL, DUP2_CDPMIF_RUNL, "CDpMif:: ==> ISI-message received" );
        OstPrintIsiMessage( iReceiveMessage );

        LOGM(" ==> ISI-message received");
        LOGMESSAGE( iReceiveMessage );

        TIsiReceiveC receivedMsg( iReceiveMessage );

        TUint8 resource_id( receivedMsg.Get8bit(
            ISI_HEADER_OFFSET_RESOURCEID ) );
        TUint8 message_id( receivedMsg.Get8bit(
            ISI_HEADER_OFFSET_MESSAGEID ) );

        switch ( resource_id )
            {
            case PN_NAMESERVICE:
                {
                switch ( message_id )
                    {
                    case PNS_NAME_ADD_RESP:
                        {
                        LOG(" ==> PNS_NAME_ADD_RESP received");
                        OstTrace0( TRACE_NORMAL, DUP4_CDPMIF_RUNL, "CDpMif:: ==> PNS_NAME_ADD_RESP received" );

                        TUint8 reason( receivedMsg.Get8bit( ISI_HEADER_SIZE +
                            PNS_NAME_ADD_RESP_OFFSET_REASON ) );
                        TInt error( KErrNone );

                        switch ( reason )
                            {
                            case PN_NAME_OK:
                                {
                                LOG(" ==> PN_NAME_OK");
                                OstTrace0( TRACE_NORMAL, DUP5_CDPMIF_RUNL, "CDpMif:: ==> PN_NAME_OK" );

                                error = KErrNone;
                                break;
                                }
                            default:
                                {
                                LOG1(" ==> reason: %d", reason );
                                OstTraceExt1( TRACE_NORMAL, DUP6_CDPMIF_RUNL, "CDpMif:: ==> reason: %hhu", reason );

                                error = KErrGeneral;
                                }
                            }
                            iDataPort.SignalPif( error );
                        break;
                        }
                    case PNS_NAME_REMOVE_RESP:
                        {
                        LOG(" ==> PNS_NAME_REMOVE_RESP received");
                        OstTrace0( TRACE_NORMAL, DUP7_CDPMIF_RUNL, "CDpMif:: ==> PNS_NAME_REMOVE_RESP received" );
                        break;
                        }
                    default:
                        {
                        LOG1(" ==> Unknown message received. ID: %d",
                            message_id );
                        OstTraceExt1( TRACE_NORMAL, DUP8_CDPMIF_RUNL, "CDpMif:: ==> Unknown message received. ID: %hhu", message_id );
                        }
                    }
                break;
                }
            case PN_PIPE:
                {
                switch ( message_id )
                    {
                    case PNS_PEP_CTRL_REQ:
                        {
                        LOG(" ==> PNS_PEP_CTRL_REQ received");
                        OstTrace0( TRACE_NORMAL, DUP9_CDPMIF_RUNL, "CDpMif:: ==> PNS_PEP_CTRL_REQ received" );

                        HandlePepCtrlReq( receivedMsg );
                        break;
                        }
                    case PNS_PEP_STATUS_IND:
                        {
                        LOG(" ==> PNS_PEP_STATUS_IND received");
                        OstTrace0( TRACE_NORMAL, DUP10_CDPMIF_RUNL, "CDpMif:: ==> PNS_PEP_STATUS_IND received" );

                        HandlePepStatusInd( receivedMsg );
                        break;
                        }
                    default:
                        {
                        LOG1(" ==> Unknown message received. ID: %d",
                            message_id );
                        OstTraceExt1( TRACE_NORMAL, DUP11_CDPMIF_RUNL, "CDpMif:: ==> Unknown message received. ID: %hhu", message_id );
                        }
                    }
                break;
                }
            default:
                {
                LOG1(" ==> Unknown message received. ID: %d", message_id );
                OstTraceExt1( TRACE_NORMAL, DUP12_CDPMIF_RUNL, "CDpMif:: ==> Unknown message received. ID: %hhu", message_id );
                }
            }

        iReceiveMessage.Zero();

        // Check if pipe is removed
        if ( PNS_NAME_REMOVE_RESP == message_id &&
            CDpPif::EDpPipeDisconnected == iPifDcs.PipeState() )
            {
            // Check if DataPort is ready to be deleted
            if ( iDataPort.IsReadyToDestruct() )
                {
                iDataPort.DeleteDataPort();
                }
            //no else
            }
        else
            {
            // Renew read
            User::LeaveIfError( Read() );
            }
        }
    }
// ---------------------------------------------------------
// CDpMif::HandlePepCtrlReq
// Handles PepCtrlReq messages
// ---------------------------------------------------------
//
void CDpMif::HandlePepCtrlReq(
    TIsiReceiveC& aIsiMessage )
    {
    OstTrace0( TRACE_NORMAL, CDPMIF_HANDLEPEPCTRLREQ, "CDpMif::HandlePepCtrlReq" );
    LOGM(" CDpMif::HandlePepCtrlReq");

    // Transaction id
    TUint8 transactionId( aIsiMessage.Get8bit(
        ISI_HEADER_OFFSET_TRANSID ) );

    // Pipe Handle
    if ( PN_PIPE_INVALID_HANDLE == iPifDcs.PipeHandle() )
        {
        TUint8 pipeHandle( aIsiMessage.Get8bit(
            ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PIPEHANDLE) );
        iPifDcs.SetPipeHandle( pipeHandle );
        }

    // PEP Type
    TUint8 pepType( aIsiMessage.Get8bit(
        ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PEPTYPE ) );
    // PEP Control ID
    TUint8 ctrlId( aIsiMessage.Get8bit(
        ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PEPCTRLID ) );
    // PEP Control Data
    TPtrC8 ctrlData;
    // Check if there is data (there is no data for all control id's)
    if ( ( ISI_HEADER_SIZE + SIZE_PNS_PEP_CTRL_REQ ) <=
         aIsiMessage.GetBuffer().Length() )
        {
        // Control Data length is 1 byte
        TInt ctrlDataLen( 1 );
        ctrlData.Set( aIsiMessage.GetData(
            ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PEPCTRLDATA,
            ctrlDataLen ) );
        }
    // Get sender device
    TUint8 senderDevice( aIsiMessage.Get8bit(
        ISI_HEADER_OFFSET_SENDERDEVICE ) );
    // Get sender object
    TUint8 senderObject( aIsiMessage.Get8bit(
        ISI_HEADER_OFFSET_SENDEROBJECT ) );
#ifdef PIPECAMP_DATAPORT_PNS_PEP_STATUS_IND_PHONET_ADDRESS_FROM_PNS_PEP_CTRL_REQ
    iPifDcs.SetPipeControllerDeviceIdentifier( senderDevice );
    iPifDcs.SetPipeControllerObjectIdentifier( senderObject );
#endif
    // E32 return value
    TInt return_E32( KErrNone );
    // PN_PIPE return value
    TInt ret( KErrNone );

    switch ( pepType )
        {
        case PN_PEP_TYPE_COMM:
        case PN_PEP_TYPE_BT_ACC:
            {
            // comm_pep handles ctrl_req
            // Something can go wrong in here. Leaving is not the best case in here.
            // We can send an response message with error value to NOS side and
            // hope for the best.
            return_E32 = iCommPep.HandlePepCtrlReq( ctrlId, ctrlData );
            break;
            }

        default: // Not supported pepType
            {
            LOG1("  ERROR - Unsupported pep type: %d", pepType );
            OstTraceExt1( TRACE_NORMAL, DUP1_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Unsupported pep type: %hhu", pepType );

            return_E32 = KErrArgument;
            break;
            }
        }

    // do mapping from E32 error codes => PN_PIPE error codes
    switch ( return_E32 )
        {
        case KErrNone:
            {
            ret = PN_PIPE_NO_ERROR;
            break;
            }
        case KErrNotSupported:
            {
            // this error code should NOT be used according to specification
            LOG("  ERROR - Unsupported config (KErrNotSupported)");
            OstTrace0( TRACE_NORMAL, DUP2_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Unsupported config (KErrNotSupported)" );

            ret = PN_PIPE_ERR_NOT_SUPPORTED;
            break;
            }
        case KErrArgument:
            {
            // this error code should NOT be used according to specification
            LOG("  ERROR - Invalid argument (KErrArgument)");
            OstTrace0( TRACE_NORMAL, DUP3_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Invalid argument (KErrArgument)" );

            ret = PN_PIPE_ERR_INVALID_PARAM;
            break;
            }
        case KErrGeneral:
            {
            LOG("  ERROR - Invalid parameter (KErrGeneral)");
            OstTrace0( TRACE_NORMAL, DUP4_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Invalid parameter (KErrGeneral)" );

            ret = PN_PIPE_ERR_INVALID_CTRL_ID;
            break;
            }
        default:
            {
            // this error code should NOT be used according to specification
            LOG1("  ERROR - Other error: %d", return_E32 );
            OstTrace1( TRACE_NORMAL, DUP5_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Other error: %d", return_E32 );

            ret = PN_PIPE_ERR_GENERAL;
            break;
            }
        }

    // Create PNS_PEP_CTRL_RESP response
    TBuf8<SIZE_PNS_PEP_CTRL_RESP> messageData;
    // Pipe Handle
    messageData.Append( iPifDcs.PipeHandle() );
    // PEP Control ID
    messageData.Append( ctrlId );
    // PEP Type
    messageData.Append( pepType );
    // Error Code
    messageData.Append( static_cast<TUint8>( ret  ) );
    // Filler bytes
    messageData.Append( KDpPadding );
    messageData.Append( KDpPadding );

    // Send message, respond to sender
    return_E32 = SendMessage(
        senderDevice,
        senderObject,
        PN_PIPE,
        transactionId,
        PNS_PEP_CTRL_RESP,
        messageData );

    LOG1("  <== PNS_PEP_CTRL_RESP resp sent, error code = %d", ret );
    OstTrace1( TRACE_NORMAL, DUP6_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: <== PNS_PEP_CTRL_RESP resp sent, error code = %d", ret );

#if defined(_DEBUG)
    if (KErrNone != return_E32 )
        {
        LOG1("  Error isc api send %d", return_E32 );
        OstTrace1( TRACE_NORMAL, DUP7_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: Error isc api send %d", return_E32 );
        }
    //no else
#endif

    }
// -----------------------------------------------------------------------------
// CSatTimer::Tick
// Static callback method for CPeriodic timer.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CSatTimer::Tick
        (
        TAny* aSatTimer
        )
    {
    // Logging omitted to avoid excessive log output

    // This is a static method, we need a pointer to parent class in
    // order to utilize it's method and members
    CSatTimer* satTimer = static_cast<CSatTimer*>( aSatTimer );

    // Invert boolean value of half second boolean
    satTimer->iHalfSecondTick = !satTimer->iHalfSecondTick;

    // Update second counter and check timers only when there are active
    // timers and whole second has passed since last update.
    TInt tableSize( satTimer->iTimerTable->Count() );
    if ( KZero != tableSize && !satTimer->iHalfSecondTick )
        {
        satTimer->iSecondsPassed++;

        TFLOGSTRING2("TSY: CSatTimer::Tick, seconds %d",
            satTimer->iSecondsPassed );
        OstTrace1( TRACE_INTERNALS,  CSATTIMER_TICK_TD, "CSatTimer::Tick, seconds %u", satTimer->iSecondsPassed );

        for( TInt i = tableSize - 1; KZero <= i; i-- )
            {
            // Get reference to a timer in TimerTable
            TTimer& timer = ( *satTimer->iTimerTable )[i];

            // Send timer expiration envelope if:
            // 1) Enough time has passed
            // 2) Timer is active
            // 3) Proactive command is not ongoing
            if ( timer.TimeStamp() <= satTimer->iSecondsPassed
                 && TTimer::ETicking == timer.State() )
                {
                // Deactive timer to avoid multiple envelopes
                timer.SetState( TTimer::EBeingSent);

                // Elapsed time
                TInt time( satTimer->iSecondsPassed - timer.StartTime() );

                satTimer->iSatMessaging->TimerExpiration( timer.Id(), time );
                }
            }
        }


    // Handle the stored envelopes. Look for envelopes activated for resending.
    // Resend the oldest envelope if delay criteria has been met.
    tableSize = satTimer->iEnvelopeTable->Count();
    TBool done( EFalse );

    if ( KZero != tableSize )
        {
        for ( TInt i = 0 ; i < tableSize && done == EFalse ; i++ )
            {
            TSatEnvelope& current = ( *satTimer->iEnvelopeTable )[i];

            if ( current.iActive )
                {
                // Active envelope found. Decrease delay and send envelope
                // if zero.
                current.iDelay--;

                if ( KZero >= current.iDelay )
                    {
                    TFLOGSTRING2("TSY: CSatTimer::Tick: \
                        Resending type %x envelope", current.iType );
                    OstTraceExt1( TRACE_INTERNALS,  DUP1_CSATTIMER_TICK_TD, "CSatTimer::Tick Resending type %hhu envelope", current.iType );

                    // Deactivate envelope just in case. Get new transaction
                    // if for envelope and resend it. Finally remove the
                    // envelope from table.
                    current.iActive = EFalse;

                    satTimer->iSatMessHandler->UiccCatReqEnvelope(
                        current.iTId, current.iEnvelope, EFalse );

                    satTimer->RemoveEnvelope( current.iTId );
                    tableSize = satTimer->iEnvelopeTable->Count();

                    // Exit resending loop, only one resent envelope per tick
                    done = ETrue;
                    }
                } // If active
            } // For-loop
Beispiel #27
0
TBool CheckAttribute (CConsoleBase* iConsole, ConfigPtrsPtr cpPtr,TInt aKeyIndex, TPtrC aDes)
	{
	TBool retValue = ETrue;
	TBuf<50> attrib = aDes;
	TInt typePos;
	TInt dirPos;
	TInt typeLen;
	TInt dirLen;
	TUint epType = 0;
	TUint epDir = 0;
	TUint ifNumber = 0;

	_LIT (KQuote,"\"");

	switch (aKeyIndex)
		{
		// level 0 index LDD
		case ExiLdd :
			if (attrib.Find(KAttributeName) == 0)
				{
				attrib.Delete(0,((TDesC&)KAttributeName).Length());
				if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0])
					{
					TUSB_VERBOSE_PRINT1 ("LDD with attribute name %s",attrib.PtrZ());
					if(gVerbose)
					    {
					    OstTraceExt1 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP17, "LDD with attribute name %s",attrib);
					    }
					cpPtr->iThisLDDPtr = new LDDConfig (attrib.MidTPtr(1,attrib.Length()-2));
					*cpPtr->iNextLDDPtrPtr = cpPtr->iThisLDDPtr;
					cpPtr->iNextLDDPtrPtr = &(cpPtr->iThisLDDPtr->iPtrNext);
					cpPtr->iNextIFPtrPtr = &(cpPtr->iThisLDDPtr->iIFPtr);
					}
				else
					retValue = EFalse;
				}
			else
				{
				retValue = EFalse;
				}
			break;

		//	level 1 index INTERFACE
		case ExiInterface :
			if (attrib.Find(KAttributeNumber) == 0)
				{
				attrib.Delete(0,((TDesC&)KAttributeNumber).Length());
				if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0])
					{
					if (TDesToTUint(attrib.MidTPtr(1,attrib.Length()-2), &ifNumber))
						{
						if (cpPtr->iThisLDDPtr == NULL)
							{
							TUSB_PRINT ("No LDD container for interface");
							OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP18, "No LDD container for interface");
							retValue = EFalse;
							}
						}
					else
						{
						TUSB_PRINT2 ("Number conversion error %s %d",attrib.PtrZ(),ifNumber);
						OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP19, "Number conversion error %S %u",attrib,ifNumber);
						retValue = EFalse;
						}
					}
				else
					{
					TUSB_PRINT1 ("Attribute number not in \"\" %s",attrib.PtrZ());
					OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP20, "Attribute number not in \"\" %s",attrib);
					retValue = EFalse;
					}
				}
			if (retValue)
				{
	 			TUSB_VERBOSE_PRINT1 ("Interface number %d",ifNumber);
	 			if(gVerbose)
	 			    {
	 			    OstTrace1 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP21, "Interface number %d",ifNumber);
	 			    }
				cpPtr->iThisIFPtr = new IFConfig ((TUint8)ifNumber);
				* cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr;
				cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext;
				cpPtr->iThisLDDPtr->iNumChannels++;
				}
			break;


		//	level 1 index Setting
		case ExiSetting :
			if (aDes.Length() != 0)
				{
				retValue = EFalse;
				}
			else
				{
				if (cpPtr->iThisLDDPtr == NULL)
					{
					TUSB_PRINT ("No LDD container for interface");
					OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP22, "No LDD container for interface");
					retValue = EFalse;
					}
				else
					{
					TUSB_VERBOSE_PRINT ("Alternate Interface Setting");
					if(gVerbose)
					    {
					    OstTrace0 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP23, "Alternate Interface Setting");
					    }
					cpPtr->iThisIFPtr = new IFConfig (0);
					* cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr;
					cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext;
					cpPtr->iThisIFPtr->iAlternateSetting = ETrue;
					}
				}
			break;

		//	level 2 index ENDPOINT
		case ExiEndpoint :
			typePos = attrib.Find(KAttributeType);
			dirPos = attrib.Find(KAttributeDirection);

			if (typePos == KErrNotFound || dirPos == KErrNotFound)
				{
				retValue = EFalse;
				}
			else
				{
				if (typePos < dirPos)
					{
					typePos += ((TDesC&)KAttributeType).Length();
					typeLen = dirPos - typePos;
					dirPos += ((TDesC&)KAttributeDirection).Length();
					dirLen = attrib.Length() - dirPos;
					}
				else
					{
					dirPos += ((TDesC&)KAttributeDirection).Length();
					dirLen = typePos - dirPos;
					typePos += ((TDesC&)KAttributeType).Length();
					typeLen = attrib.Length() - typePos;
					}
				TPtr attribPtr = attrib.MidTPtr(typePos,typeLen);
				attribPtr.UpperCase();
				attribPtr.TrimAll();
				if (attribPtr == KEpBulk)
					{
					epType = KUsbEpTypeBulk;
					}
				else
					{
					if (attribPtr == KEpInterrupt)
						{
						epType = KUsbEpTypeInterrupt;
						}
					else
						{
						if (attribPtr == KEpIsochronous)
							{
							epType = KUsbEpTypeIsochronous;
							}
						else
							{
							retValue = EFalse;
							}
						}
					}
				attribPtr = attrib.MidTPtr(dirPos,dirLen);
				attribPtr.UpperCase();
				attribPtr.TrimAll();
				if (attribPtr == KEpIn)
					{
					epDir = KUsbEpDirIn;
					}
				else
					{
					if (attribPtr == KEpOut)
						{
						epDir = KUsbEpDirOut;
						}
					else
						{
						retValue = EFalse;
						}
					}
				if (retValue)
					{
					if (cpPtr->iThisIFPtr == NULL)
						{
						TUSB_PRINT ("No Interface container for Endpoint");
						OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP24, "No Interface container for Endpoint");
						retValue = EFalse;
						}
					else
						{
						TUint epIndex = cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed;
						TUSB_VERBOSE_PRINT2 ("Endpoint with type %d %d",epType,epDir);
						if(gVerbose)
						    {
						    OstTraceExt2 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP25, "Endpoint with type %u %u",(TUint32)epType,(TUint32)epDir);
						    }
						cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType = epType;
						cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iDir = epDir;
						#ifdef USB_SC
						cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iBufferSize = 65536;
						cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iReadSize = 4096;
						#endif
						cpPtr->iThisIFPtr->iEpDMA[epIndex] = EFalse;
						cpPtr->iThisIFPtr->iEpDoubleBuff[epIndex] = EFalse;
						cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed++;
						}
					}
				}
			break;

		default :
			if (aDes.Length() != 0)
				{
				retValue = EFalse;
				}
		}

	return retValue;
	}
void CMTPFSEnumerator::ProcessEntriesL()
{
    // Start looping through entries at where we left off
    TInt count = iEntries.Count() - iFirstUnprocessed;
    // Process no more than KProcessLimit entries
    count = Min(count, iProcessLimit);
    iFirstUnprocessed += count;

    for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i)
    {
        const TEntry& entry = iEntries[i];
        TInt len = entry.iName.Length();
        if(iCurrentPath.Length()  + len > KMaxFileName)
        {
            OstTrace0( TRACE_WARNING, CMTPFSENUMERATOR_PROCESSENTRIESL, "Full name exceeds KMaxFileName, ignored." );
            continue;
        }

        iCurrentPath.Append(entry.iName);

        OstTraceExt2( TRACE_NORMAL, DUP1_CMTPFSENUMERATOR_PROCESSENTRIESL,
                      "Process path %S name %S", iCurrentPath, entry.iName );

#ifdef  OST_TRACE_COMPILER_IN_USE
        TBuf8<KMTPMaxFullFileName> tmp;
        tmp.Copy(iCurrentPath);
        TInt pathLen=iCurrentPath.Length();
        if(pathLen > KLogBufferSize)
        {
            TBuf8<KLogBufferSize> tmp1;
            tmp1.Copy(tmp.Ptr(),KLogBufferSize);
            OstTrace0( TRACE_NORMAL, DUP2_CMTPFSENUMERATOR_PROCESSENTRIESL, "Entry - " );
            OstTraceExt1( TRACE_NORMAL, DUP3_CMTPFSENUMERATOR_PROCESSENTRIESL, "%s", tmp1);


            tmp1.Copy(tmp.Ptr()+KLogBufferSize, pathLen-KLogBufferSize);
            OstTraceExt1( TRACE_NORMAL, DUP4_CMTPFSENUMERATOR_PROCESSENTRIESL, "%s", tmp1);
        }
        else
        {
            OstTrace0( TRACE_NORMAL, DUP5_CMTPFSENUMERATOR_PROCESSENTRIESL, "Entry - " );
            OstTraceExt1( TRACE_NORMAL, DUP6_CMTPFSENUMERATOR_PROCESSENTRIESL, "%s", tmp);
        }
#endif // OST_TRACE_COMPILER_IN_USE

        TUint32 handle = 0;
        TMTPFormatCode format;
        if(-- iObjectNeedToScan <=0 && iAllRootScaned)
        {
            iSkipCurrentStorage = ETrue;
            return;
        }
        if (entry.IsDir())
        {
            if (iExclusionMgr.IsFolderAcceptedL(iCurrentPath, iStorages[iScanPos]))
            {
                iCurrentPath.Append('\\');
                ++len;
                format = EMTPFormatCodeAssociation;
                AddEntryL(iCurrentPath, handle, format, KMTPDeviceDPID, entry, iStorages[iScanPos], iParentHandle);
                iDirStack.AppendL(TStackItem(iCurrentPath, handle));
            }
        }
        else
        {
            if ( iExclusionMgr.IsFileAcceptedL(iCurrentPath,iStorages[iScanPos]) )
            {
                format = EMTPFormatCodeUndefined;
                AddEntryL(iCurrentPath, handle, format, iDpID, entry, iStorages[iScanPos], iParentHandle);
            }
            else
            {
                TParsePtrC parse(iCurrentPath);
                if ( parse.ExtPresent() )
                {
                    switch(iDpSingletons.MTPUtility().GetEnumerationFlag(parse.Ext().Mid(1)))
                    {
                    case MISSED_FILES_OWNED_BY_FILE_DP:
                        if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(iCurrentPath))
                        {
                            format = EMTPFormatCodeUndefined;
                            AddEntryL(iCurrentPath, handle, format, iDpID, entry, iStorages[iScanPos], iParentHandle);
                        }
                        break;

                    case MISSED_FILES_OWNED_BY_OTHER_DP:
                        if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(iCurrentPath))
                        {
                            format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));
                            TUint32 DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1), KNullDesC);
                            AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle);
                        }
                        break;

                    case FILES_OWNED_BY_OTHER_DP:
                    {
                        _LIT( KTxtExtensionODF, ".odf" );
                        TUint32 DpId = iFramework.DataProviderId();
                        if (parse.Ext().CompareF(KTxtExtensionODF)==0)
                        {
                            HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iCurrentPath);
                            CleanupStack::PushL(mime);
                            if ( mime != NULL )
                            {
                                OstTraceExt1( TRACE_NORMAL, DUP7_CMTPFSENUMERATOR_PROCESSENTRIESL, "mime %S", *mime );
                                DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1),*mime);
                                OstTrace1( TRACE_NORMAL, DUP8_CMTPFSENUMERATOR_PROCESSENTRIESL, "DpId find %d", DpId );

                                format = iDpSingletons.MTPUtility().GetFormatCodeByMimeTypeL(parse.Ext().Mid(1),*mime);
                                AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos],
                                                        iParentHandle, iDpSingletons.MTPUtility().GetSubFormatCodeL(parse.Ext().Mid(1),*mime));
                            }
                            else
                            {
                                AddEntryL(iCurrentPath, handle, EMTPFormatCodeUndefined, iDpID, entry, iStorages[iScanPos], iParentHandle);
                            }

                            CleanupStack::PopAndDestroy(mime);
                        }
                        else
                        {
                            format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));
                            TUint32 DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1), KNullDesC);
                            AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle);
                        }
                    }
                    break;

                    //          case FILES_OWNED_BY_NONE:
                    default:
                        //nothing to do
                        break;
                    }
                }
            }
        }
        // Remove filename part
        iCurrentPath.SetLength(iCurrentPath.Length() - len);
    }

}
// -----------------------------------------------------------------------------
// CDpPn2Rx::Read
// Reserves space from rx buffer and makes new PipeReceive
// to Isc Api. Checks if flow control high water mark is reached.
// Extracts paritybits if 7-bit data.Signals Rx2Dte.
// -----------------------------------------------------------------------------
//
TInt CDpPn2Rx::Read()
    {
    OstTrace0( TRACE_NORMAL, CDPPN2RX_READ, "CDpPn2Rx::Read" );
    OstTrace1( TRACE_NORMAL, DUP1_CDPPN2RX_READ, "CDpPn2Rx::Read %x", &iDataPort );
    OstTraceExt2( TRACE_NORMAL, DUP2_CDPPN2RX_READ, "CDpPn2Rx:: (Read from ISC) - Port: %u, iRx.Length: %d", iDataPort.PortUnit(), iRx.Length() );

    LOGM1("CDpPn2Rx::Read %x", &iDataPort);
    LOGM2("CDpPn2Rx::Read (Read from ISC) - Port %d, iRx.Length: %d",
     iDataPort.PortUnit(), iRx.Length() );

    TInt ret( KErrNone );

    // We've been listening pn_pipe
    if ( EDpReadWait == iState )
        {
        LOGHEX(iRx, EFalse);
        OstTraceExt1( TRACE_NORMAL, DUP10_CDPPN2RX_READ, "CDpPn2Rx:: RX = %s", iRx );

        ret = iBufferRx.WriteElement().Release( iRx.Length() );

        if ( KErrNone == ret )
            {
#ifdef USE_FILE_SERIAL_TRUST_DEBUG
            iDataPort.DebugBytesFromPn( iRx.Length() );
#endif
            if ( 0 < iRx.Length() )
                {
                // 7-bit data extract parity bits
                if ( EData7 == iDataConfig.DataBits() )
                    {
                    iParityHandler.ExtractParityBits( iRx );
                    }
                //no else

                if ( iDataPort.IsRx2DteReadPending() )
                    {
                    // Signal RX2DTE
                    iDataPort.SignalRx2Dte();
                    }
                //no else

                // New data is available. is client interested about that
                if ( iInBufHasDataNotify )
                    {
                    // We should notify client
                    iInBufHasDataNotify = EFalse;
                    iDataPort.NotifyDataAvailableCompleted( KErrNone );
                    }
                //no else
                }
            //no else
            }
        //no else
        }
    //no else

    // Check pipe state
    if ( KErrNone == ret && CDpPif::EDpPipeEnabled != iPifDcs.PipeState() )
        {
        ret = KErrNotReady;
        }
    else if ( KErrNone == ret )
        {
        // Try reserve element for writing
        TPtr8 nullPtr( 0, 0 );

        // Check if reserved buffer was too small
        // => override MaxReservationSize for next read request.
        if ( KErrNoMemory == iStatus.Int() &&
            iLen > iBufferRx.MaxReservationSize() )
            {
            OstTrace0( TRACE_NORMAL, DUP4_CDPPN2RX_READ, "CDpPn2Rx::KErrNoMemory from ISC =>" );
            OstTraceExt1( TRACE_NORMAL, DUP5_CDPPN2RX_READ, "CDpPn2Rx:: -- Try to read more than MaxReservationSize, %hu --", iLen );

            LOG("  CDpPn2Rx::Read, KErrNoMemory from ISC =>");
            LOG1("  -- Try to read more than MaxReservationSize, %d --", iLen );

            ret = iBufferRx.WriteElement().Reserve(
                iLen, iRx, nullPtr, ETrue );
            // Set iLen to zero (required buffer lenght for read,
            // received from ISC if buffer was too small)
            iLen = 0;
            }
        else
            {
            ret = iBufferRx.WriteElement().Reserve(
                iBufferRx.MaxReservationSize(), iRx, nullPtr );
            }

        // Is flowctrl off and rx "high watermark" reached
        if ( EFlowControlOff == iFlowCtrl.FlowCtrlDcs2Dp() )
            {
            if ( IsHighWaterMarkReached() )
                {
                // Buffer is almost full set flowcontrol on
                LOG("  CDpPn2Rx::Read, Rx High WaterMarkReached");
                OstTrace0( TRACE_NORMAL, DUP6_CDPPN2RX_READ, "CDpPn2Rx:: Rx High WaterMark reached" );

                iFlowCtrl.WaterMarkHighReached();
                }
            //no else
            }
        //no else

        switch ( ret )
            {
            // Reservation successed
            case KErrNone:
                {
                LOG1("  CDpPn2Rx::Read, ISAHandle Pipe Receive. iRx.MaxLength: %d",
                    iRx.MaxLength() );
                OstTrace1( TRACE_NORMAL, DUP7_CDPPN2RX_READ, "CDpPn2Rx:: ISAHandle Pipe Receive. iRx.MaxLength: %d", iRx.MaxLength() );

                // Set pipe receive
                if ( !IsActive() )
                    {
                    iDataPort.ISAHandle().DataReceive( iStatus, iRx, iLen );

                    iRequestActive = ETrue;
                    // Change state
                    iState = EDpReadWait;

                    SetActive();
                    }
                //no else
                break;
                }
            // Reservation failed
            case KErrNotReady:
                {
                LOG("  ERROR, CDpPn2Rx::Read, Element reservation failed (KErrNotReady).");
                OstTrace0( TRACE_NORMAL, DUP8_CDPPN2RX_READ, "ERROR, CDpPn2Rx::Read, Element reservation failed (KErrNotReady)" );

                // Change state
                iState = EElementWait;
                // Better done here
                if ( !IsActive() )
                    {
                    iStatus = KRequestPending;
                    SetActive();
                    }
                //no else
                iRequestActive = ETrue;

                ret = KErrNone;

                break;
                }
            default:
                {
                // An error value returned
                LOG1("  ERROR, CDpPn2Rx::Read, Fail to reserve Element, error code: %d",
                    ret );
                OstTrace1( TRACE_NORMAL, DUP9_CDPPN2RX_READ, "CDpPn2Rx:: ERROR, CDpPn2Rx::Read, Fail to reserve Element, error code: %d", ret );
                }
            }
        }
    //no else

    return ret;
    }
/**
 * Callback function for Trace Activation
 * 
 * @param aComponentId
 * @param aGroupId         
 */   
void DTraceCompilerTesterAdvanced::TraceActivated( TUint32 aComponentId, TUint16 aGroupId  )
    {
    
    Kern::Printf( "DTraceCompilerTesterAdvanced::TraceActivated - ComponentId = 0x%x, GroupId = 0x%x", aComponentId, aGroupId ); 
    
    if (aGroupId == POINTER_PARAMETER_TEST)
        {
        // Print out pointer values of two NTimers by using %p tag 
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Pointer Parameter Test START----------------" ); 
        NTimer* myNTimer1 = new NTimer();
        NTimer* myNTimer2 = new NTimer();
        const NTimer* myNTimer3 = new NTimer();
        OstTraceExt2( POINTER_PARAMETER_TEST, POINTER_PARAMETER_TRACE1, "Print out pointer values of two NTimers;myNTimer1=%p;myNTimer2=%p", myNTimer1, myNTimer2 );
        OstTraceExt1( POINTER_PARAMETER_TEST, POINTER_PARAMETER_TRACE2, "Print out pointer values of one const NTimers;myNTimer3=%p", myNTimer3 );
        delete myNTimer1;
        delete myNTimer2;
        delete myNTimer3;
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Pointer Parameter Test END----------------" ); 
        }
    else if (aGroupId == LONG_TRACE_TEST)
        {
        // Print out n times traces those lengths are 60, 300, 512 and 600 characters.
		// Print out also some traces those parameter total length is more than 512
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test START----------------" ); 
        
        TInt i=0;
	    TUint numberOfTraces = 1;
	    TInt32 freq = NKern::FastCounterFrequency();
        TUint32 startTime;
	    TUint32 endTime;
	    TUint32 time;
	    
	    TUint timeTestNumber1 = 0;
        TUint timeTestNumber2 = 0;
        TUint timeTestNumber3 = 0;
        TUint timeTestNumber4 = 0;
        TUint timeTestNumber5 = 0;
        TUint timeTestNumber6 = 0;
        TUint timeTestNumber7 = 0;
        // ---------------------------- Ascii60 ----------------------------	    
	    startTime = NKern::FastCounter();
	    Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii60----------------" ); 	    
	    for (i=0; i < numberOfTraces; i++)
	        {
            OstTraceExt1( LONG_TRACE_TEST, ASCII60, "Ascii60: %s", buf60);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber1 = time;
        // ---------------------------- Ascii60 ----------------------------
        
	    // ---------------------------- Ascii300 ----------------------------	    
	    startTime = NKern::FastCounter();
	    Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii300----------------" ); 
	    for (i=0; i < numberOfTraces; i++)
	        {
            OstTraceExt1( LONG_TRACE_TEST, ASCII300, "Ascii300: %s", buf300);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber2 = time;
        // ---------------------------- Ascii300 ----------------------------
        
        // ---------------------------- Ascii512 ----------------------------	    
	    startTime = NKern::FastCounter();
	    Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii512----------------" ); 
	    for (i=0; i < numberOfTraces; i++)
	        {
            OstTraceExt1( LONG_TRACE_TEST, ASCII512, "Ascii512: %s", buf512);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber3 = time;
        // ---------------------------- Ascii512 ----------------------------            

	    // ---------------------------- Ascii600 ----------------------------	    
	    startTime = NKern::FastCounter();
	    Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii600----------------" ); 
	    for (i=0; i < numberOfTraces; i++)
	        {
            OstTraceExt1( LONG_TRACE_TEST, ASCII600, "Ascii600: %s", buf600);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber4 = time;
        // ---------------------------- Ascii600 ----------------------------    

        // ---------------------------- Ascii300 + Ascii512 ----------------------------       
        startTime = NKern::FastCounter();
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii300 + Ascii512----------------" ); 
        for (i=0; i < numberOfTraces; i++)
            {
            OstTraceExt2( LONG_TRACE_TEST, ASCII300_ASCII512, "Ascii300: %s Ascii512: %s", buf300, buf512);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber5 = time;
        // ---------------------------- Ascii300 + Ascii512 ----------------------------            
 
        // ---------------------------- Ascii600 + Ascii300 ----------------------------       
        startTime = NKern::FastCounter();
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii600 + Ascii300----------------" ); 
        for (i=0; i < numberOfTraces; i++)
            {
            OstTraceExt2( LONG_TRACE_TEST, ASCII600_ASCII300, "Ascii600: %s Ascii300: %s", buf600, buf300);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber6 = time;
        // ---------------------------- Ascii600 + Ascii300 ----------------------------
        
        // ---------------------------- Ascii333 + Ascii333 ----------------------------       
        startTime = NKern::FastCounter();
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test : Ascii333 + Ascii333----------------" ); 
        for (i=0; i < numberOfTraces; i++)
            {
            OstTraceExt2( LONG_TRACE_TEST, ASCII333_ASCII333, "Ascii333: %s Ascii333: %s", buf333, buf333);
            }
        endTime = NKern::FastCounter();
        time = (endTime - startTime) * 1000 / freq;

        timeTestNumber7 = time;
        // ---------------------------- Ascii333 + Ascii333 ----------------------------       
        
		Kern::Printf( "--------------TraceCompilerTesterAdvanced----------------" ); 
        Kern::Printf( "Ascii60: %d", timeTestNumber1 );
        Kern::Printf( "Ascii300: %d", timeTestNumber2 ); 
        Kern::Printf( "Ascii512: %d", timeTestNumber3 ); 
        Kern::Printf( "Ascii600: %d", timeTestNumber4 );
        Kern::Printf( "Ascii300 + Ascii512: %d", timeTestNumber5 );
        Kern::Printf( "Ascii600 + Ascii300: %d", timeTestNumber6 );
        Kern::Printf( "Ascii333 + Ascii333: %d", timeTestNumber7 );
		Kern::Printf( "--------------TraceCompilerTesterAdvanced----------------" );         
      
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Long Trace Test END----------------" ); 
        }
    else if (aGroupId == SHORT_TRACE_TEST)
        {
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test START----------------" ); 
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test : Ascii1----------------" ); 
        OstTraceExt1( SHORT_TRACE_TEST, ASCII1, "Ascii1: %s", buf1);
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test : Ascii2----------------" ); 
        OstTraceExt1( SHORT_TRACE_TEST, ASCII2, "Ascii2: %s", buf2);
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test : Ascii3----------------" ); 
        OstTraceExt1( SHORT_TRACE_TEST, ASCII3, "Ascii3: %s", buf3);
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test : Ascii4----------------" ); 
        OstTraceExt1( SHORT_TRACE_TEST, ASCII4, "Ascii4: %s", buf4);
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test : Ascii1 + Acii2----------------" ); 
        OstTraceExt2( SHORT_TRACE_TEST, ASCII5, "Ascii1: %s Ascii2: %s", buf1, buf2);

        Kern::Printf( "--------------TraceCompilerTesterAdvanced Short Trace Test END----------------" ); 
        }
    else if (aGroupId == INCLUDED_NON_SOURCE_FILE_TEST)
        {
        // Print out traces from included non-source file that is defined in trace.properties file
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Included Non-Source File Test START----------------" );
        
        this->HelloWorld();
        this->HelloMoon();
        
        TUint32 value3 = GetBigValue1000();
        TUint32 value4 = GetBigValue2000();
        
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Included Non-Source File Test END----------------" );
                          
        }
    else if (aGroupId == TRACE_FLOW)
        {
        OstTrace0(TRACE_FLOW, TEST_TRACE_2, "Test OLD TraceCompiler");
        // This test can also use to test function parameters
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Common Source File Test START----------------");
        DTraceCompilerTesterCommon1* common1 = new DTraceCompilerTesterCommon1();
        TInt32 sum = common1->SumValues(-1, -2, 100, 200);
        delete common1;        
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Common Source File Test END----------------");
        }
    else if (aGroupId == KEKKONEN)
        {
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Kekkonen START----------------");
        DTraceCompilerTesterCommon2* common2 = new DTraceCompilerTesterCommon2();
        common2->Kekkonen();
        delete common2;
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Kekkonen END----------------");
        }
    else if (aGroupId == TRACE_STATE)
        {
        Kern::Printf( "--------------TraceCompilerTesterAdvanced State Trace Test START----------------");
        OstTraceState0(STATE_TRACE_0, "Kone1", "Running");
        OstTraceState1(STATE_TRACE_1, "Kone2", "Stopped", this);
        Kern::Printf( "--------------TraceCompilerTesterAdvanced  State Trace Test  END----------------");
        }
    else if (aGroupId == TRACE_DATA)
        {
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Data Trace Test START----------------");
        
        TBuf8<601> data(buf600);
        OstTraceData( TRACE_DATA, TRACE_DATA_TRACE,
                    "DTraceCoreXtiIf::DebugPrintMsg - Msg via XTI IF 0x%{hex8[]}", data.Ptr(), data.Size() );
        Kern::Printf( "--------------TraceCompilerTesterAdvanced Data Trace Test  END----------------");
        }
    else if (aGroupId == POST_CODE_TEST)
        {
        Kern::Printf( "--------------TraceCompilerTesterAdvanced POST Code Trace Test START----------------");
        OstTrace0(POST_CODE_TEST, POST1, "Print some POST code traces");
        Kern::Printf("[POST][X-Loader][Started][OK]");
        Kern::Printf("[POST][BootUp][Reset reason][PowerOn]");
        Kern::NanoWait(50000000);
        Kern::Printf("[POST][X-Loader][Authenticate][OK]");
        Kern::NanoWait(100000000);
        Kern::Printf("[POST][X-Loader][load][OK]");
        Kern::NanoWait(100000000);
        Kern::Printf("[POST][X-Loader][Authenticate][OK]");
        Kern::NanoWait(700000000);
        Kern::Printf("[POST][X-Loader][load][OK]");
        Kern::NanoWait(50000000);
        Kern::Printf("[POST][X-Loader][load][OK]");
        Kern::NanoWait(50000000);
        Kern::Printf("[POST][X-Loader][load][OK]");
        Kern::NanoWait(50000000);
        Kern::Printf("[POST][X-Loader][Authenticate][OK]");
        Kern::NanoWait(200000000);
        Kern::Printf("[POST][Boot strap][Started][OK]");
        Kern::NanoWait(10000000);
        Kern::Printf("[POST][Estart][started][OK]");
        Kern::NanoWait(10000000);
        Kern::Printf("[POST][Estart][CompositeFileSys.][OK]");
        Kern::NanoWait(500000000);
        Kern::Printf("[POST][Mount][Drive][OK]");
        Kern::NanoWait(200000000);
        Kern::Printf("[POST][Mount][Drive][OK]");
        Kern::NanoWait(200000000);
        Kern::Printf("[POST][Estart][ISC API start][OK]");
        Kern::NanoWait(300000000);
        Kern::Printf("[POST][Estart][userdisk format][No]");
        Kern::NanoWait(10000000);
        Kern::Printf("[POST][Estart][secenv start][OK]");
        Kern::NanoWait(20000000);
        Kern::Printf("[POST][Estart][startup mode][Local]");
        Kern::NanoWait(10000000);
        Kern::Printf("[POST][Estart][Language selection][OK]");
        Kern::NanoWait(200000000);
        Kern::Printf("[POST][SelfTest][Started][FAIL][KErrOutOfMemory]");
        Kern::NanoWait(200000000);
        Kern::Printf("[POST][BT][Started][OK]");
        Kern::NanoWait(800000000);
        Kern::Printf("[POST][WLAN][Started][OK]");
        Kern::NanoWait(800000000);
        Kern::Printf("[POST][Display][Started][OK]");
        Kern::NanoWait(800000000);
        Kern::Printf("[POST][Camera][Started][OK]");
        Kern::NanoWait(80000000);
        Kern::Printf("[POST][mc_kernelagent][ExtensionInit0][OK]");
        Kern::NanoWait(100000000);
        Kern::Printf("[POST][mc_sender][Pre-init][OK]");
        Kern::NanoWait(100000000);
        Kern::Printf("[POST][mc_useragent][MobileCrashWriter init][OK]");        
        Kern::Printf( "--------------TraceCompilerTesterAdvanced POST Code Trace Test END----------------");
        }
    }