예제 #1
0
EXPORT_C TInt RRtaContent::SearchL(RStreamablePtrArray< CEmbeddedObject > &aArray, const TDesC8 &aMimeType, TBool aRecursive) const
	{
	// arbitary length for array of embedded objects
	TInt length = 40 * KMaxPath;
	TPckg<TInt> lengthPckg(length);
	TPckg<TBool> recursivePckg(aRecursive);
	TInt err = KErrOverflow;
	
	while(err == KErrOverflow)
		{
		HBufC8* transferBuffer = HBufC8::NewLC(length);
		TPtr8 transferPtr = transferBuffer->Des();
	
		// attempt to retrieve the attributes
		err = SendReceive(EGetEmbeddedObjects1, TIpcArgs(&transferPtr, &aMimeType, &recursivePckg));	
		if(err == KErrOverflow)
			{
			// Find out the length required to receive the resulting attribute set
			lengthPckg.Copy(transferPtr.Left(lengthPckg.MaxLength()));	
			}
		else if(err == KErrNone)
			{
			// read in the attribute values from the buffer
			RDesReadStream readStream(transferPtr);
			CleanupClosePushL(readStream);
			aArray.InternalizeL(readStream);
			CleanupStack::PopAndDestroy(&readStream);
			}
		CleanupStack::PopAndDestroy(transferBuffer);	
		}
		
	return err;
	}
예제 #2
0
EXPORT_C void RRtaContent::GetEmbeddedObjectsL(RStreamablePtrArray< CEmbeddedObject > &aArray) const
	{
	TInt err = KErrOverflow;
	
	// arbitary length for array of embedded objects
	TInt length = 40 * KMaxPath;
	TPckg<TInt> lengthPckg(length);
	
	while(err == KErrOverflow)
		{
		HBufC8* transferBuffer = HBufC8::NewLC(length);
		TPtr8 transferPtr = transferBuffer->Des();
	
		// attempt to retrieve the attributes
		err = SendReceive(EGetEmbeddedObjects1, TIpcArgs(&transferPtr));	
		if(err == KErrOverflow)
			{
			// Find out the length required to receive the resulting attribute set
			lengthPckg.Copy(transferPtr.Left(lengthPckg.MaxLength()));	
			}
		else if(err == KErrNone)
			{
			// read in the attribute values from the buffer
			RDesReadStream readStream(transferPtr);
			CleanupClosePushL(readStream);
			aArray.InternalizeL(readStream);
			CleanupStack::PopAndDestroy(&readStream);
			}
		CleanupStack::PopAndDestroy(transferBuffer);	
		}
		
	// if any other error occured, leave
	User::LeaveIfError(err);
	}
예제 #3
0
EXPORT_C TInt RRtaContent::GetStringAttributeSetL(const TDesC& aUniqueId, RStringAttributeSet &aStringAttributeSet) const
	{
	TInt err = KErrOverflow;
	TInt length = 0;
	TPckg <TInt> lengthPckg(length);
	
	// Write the object out to a buffer, send to client
	CBufFlat* buf = CBufFlat::NewL(50);
	CleanupStack::PushL(buf);
	
	// create write stream
	RBufWriteStream writeStream(*buf);
	CleanupClosePushL(writeStream);

	// write the directory to the stream
	aStringAttributeSet.ExternalizeL(writeStream);
	CleanupStack::PopAndDestroy(&writeStream);
	
	
	TPtr8 bufPtr = buf->Ptr(0);
	// allocate arbitary receive buffer much larger than the size of the source buffer
	length = bufPtr.Length() * 15;
	
	while(err == KErrOverflow)
		{
		HBufC8* transferBuffer = HBufC8::NewLC(length);
		transferBuffer->Des().Copy(bufPtr);
		TPtr8 transferPtr = transferBuffer->Des();
	
		// attempt to retrieve the attributes
		err = SendReceive(EGetStringAttributeSet, TIpcArgs(&aUniqueId, &transferPtr));	
		if(err == KErrOverflow)
			{
			// Find out the length required to receive the resulting attribute set
			lengthPckg.Copy(transferPtr.Left(lengthPckg.MaxLength()));	
			}
		else if(err == KErrNone)
			{
			// read in the attribute values from the buffer
			RDesReadStream readStream(transferPtr);
			CleanupClosePushL(readStream);
			aStringAttributeSet.InternalizeL(readStream);
			CleanupStack::PopAndDestroy(&readStream);
			}
		CleanupStack::PopAndDestroy(transferBuffer);	
		}

	CleanupStack::PopAndDestroy(buf);
	return err;
	}
예제 #4
0
// -----------------------------------------------------------------------------
// MceSip::HeaderValueL
// -----------------------------------------------------------------------------
// 
TUint MceSip::HeaderValueL( TPtr8 aHeader )
    {
	TUint value;
	aHeader.Trim();
	
	TInt index = aHeader.Locate( KMceSipHeaderSeparator );
	if( index != KErrNotFound )
		{
		TLex8 lexValue( aHeader.Left( index ) );
		User::LeaveIfError ( lexValue.Val( value, EDecimal ) );
		}
	else
		{
		TLex8 lexValue( aHeader );
		User::LeaveIfError ( lexValue.Val( value, EDecimal ) );
		}
		
    return value;
    
    }
// ----------------------------------------------------------------------------
// TNATFWUNSAFMsgStateHeaderEnd::DataReceivedL
// ----------------------------------------------------------------------------
//
TBool TNATFWUNSAFMsgStateHeaderEnd::DataReceivedL( TPtr8 aData,
    TUint& aNextLength )
    {
    __ASSERT_ALWAYS( aData.Length() >= iMsgAssembler.MessageLength(),
                     User::Leave( KErrUnderflow ) );

    TPtrC8 headerDescriptor = aData.Left( iMsgAssembler.MessageLength() );

    CNATFWUNSAFMessage* message =
        iMsgAssembler.MsgFactory().DecodeL( headerDescriptor );

    iMsgAssembler.SetMessage( message );
    message = 0;

    // delete the header part from the received data,
    aData.Delete( 0, iMsgAssembler.MessageLength() );

    iMsgAssembler.ChangeState( TNATFWUNSAFMsgStateBase::EMsgComplete );
    return iMsgAssembler.CurrentState().DataReceivedL( aData, aNextLength );
    }
예제 #6
0
void CIniFileParser::DoParseIniFileL(TDesC& aIniFile)
/*
 * 
 * The force flush state is only updated if it is not already set to something other
 * than ENoValue. If force flush option is not found in ini file, force flush is set
 * to off.
 */
	{

	TInt fileLength;
	TInt ret = KErrNone;
	RFile iniFile;

	// Open file
	User::LeaveIfError(iniFile.Open(iFs, aIniFile, EFileShareAny));
		
	CleanupClosePushL(iniFile);
	
	// as we have been able to open the file, set the media to default.
	// If the ini file is parsed correctly, this then gets overwritten.
	// Otherwise the caller should pass thru a mesg to get the default enabled.
	if (iLoggingMediaString.Length() == 0)
		{
		iLoggingMediaString = KDefaultMedia;
		}
		
	

	User::LeaveIfError(iniFile.Size(fileLength));

	HBufC8* iniContents = HBufC8::NewLC(fileLength);
	TPtr8 hbufPtr = iniContents->Des();
	User::LeaveIfError(iniFile.Read(hbufPtr));
	TLex8 lex(*iniContents);

	//OK, file is open and ready for parsing. Make a tempory array and if there is a
	//problem in the ini file leave settings as they were, leave, and
	//the error will get picked up.

	delete iIniSettings;
	iIniSettings = NULL;
	CIniLoggingPairs* iniSettings = CIniLoggingPairs::NewL();
	CleanupStack::PushL(iniSettings);
	TNameTag tempTag;
	TNameTag tempTag2;
	TChar  tempChar;

	FOREVER
		{
		ret = GetNextTokenAndCheck(lex,hbufPtr);
		if (ret != KErrNone)
			{
			break;
			}
		if (hbufPtr.Find(KCommentKeyword)!=KErrNotFound)		//found a Comment
			{
			tempChar = lex.Get();
			while (!lex.Eos() && TUint(tempChar) != KCarriageReturn && TUint(tempChar) != KLineFeed)
				{
				tempChar = lex.Get();
				}
			}
		else if (hbufPtr.CompareF(KMediaKeyword)==0)		//MediaSetting
			{
			User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr));
			if (hbufPtr.Length()>KMaxMediaStringLength)
				{
				User::Leave(KErrGeneral);
				}
			iLoggingMediaString = hbufPtr;
			}
		else if (hbufPtr.CompareF(KLogKeyword)==0)		//LOG
			{
			User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr));

			if (hbufPtr.Length()>KMaxTagLength)
				{
				tempTag = hbufPtr.Left(KMaxTagLength);
				}
			else
				{
				tempTag = hbufPtr;
				}
			User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr));
			if (hbufPtr.Length()>KMaxTagLength)
				{
				tempTag2 = hbufPtr.Left(KMaxTagLength);
				}
			else
				{
				tempTag2 = hbufPtr;
				}
			iniSettings->AddSettingL(tempTag, tempTag2);
			}
		else if (hbufPtr.CompareF(KForceFlushKeyword)==0)		//ForceFlush
			{
			if (iForceFlushState == ENoValue)
				{
				iForceFlushState = EFlushOn;
				}
			}
		else if (hbufPtr.CompareF(KLogPathKeyword) == 0)		//LogPath
			{
			User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr));
			if (hbufPtr.Length()>KMaxName)
				{
				User::Leave(KErrOverflow);
				}
			iLoggingPathString.Copy(hbufPtr);
			}
		else if (hbufPtr.CompareF(KWin32DbgPortKeyword)==0)		//Win32DebugPort
			{
			iWin32DebugEnabled = ETrue;
			}
		else
			User::Leave(KErrBadName);

		if (lex.Eos())
			{
			break;
			}
		}
	iIniSettings = iniSettings;
	CleanupStack::Pop(iniSettings);
	CleanupStack::PopAndDestroy();	//iniContents
	CleanupStack::PopAndDestroy();	//iniFile

	if (iForceFlushState == ENoValue)
		{
		iForceFlushState = EFlushOff;
		}
	}
// ----------------------------------------------------------------------------
// TTCPMsgContentStart::HandleComplementingSigCompDataL
// ----------------------------------------------------------------------------
//
TBool TTCPMsgContentStart::HandleComplementingSigCompDataL( 
    TPtr8 aData, 
    TUint& aNextLength,
    TInt aAnnouncedContentLen )
    {
    // If still receiving compressed data, current contents have to be
    // stored until we come back from comp states, in sigcomp point of
    // view message can be complete but it ain't necessary complete
    // in sip point of view. All data in aData or msgbuffer are not 
    // necessarily decompressed - these have to be taken with us when 
    // going back to decompression states
    
    TInt unconsumedBytes( iMsgAssembler.UnConsumedBytes() );
    
    TPtr8 msgBufPtr( iMsgAssembler.MsgBuffer().Ptr( 0 ) );
    HBufC8* content = NULL;
    
    TInt decompressedDataLen = aData.Length() - unconsumedBytes;
    
   	__SIP_ASSERT_LEAVE( decompressedDataLen > 0, KErrGeneral );
   	
   	TInt msgBufLen( msgBufPtr.Length() );
    TInt decompressedLen( msgBufLen + decompressedDataLen );
   	if ( aAnnouncedContentLen <= decompressedLen )
   	    {
   	    // Enough decompressed content data
   	    return EFalse;
   	    }
      
    // Store decompressed data to message content
    if ( msgBufLen > 0 )
        {
        content = HBufC8::NewL( decompressedLen );
        TPtr8 contentPtr( content->Des() );
        contentPtr.Copy( msgBufPtr );
        contentPtr.Append( aData.Left( decompressedDataLen ) );
        }
    else
        {
        content = aData.Left( decompressedDataLen ).AllocL();
        }
    
    // Remove decompressed data which was stored to content   
    aData.Delete( 0, decompressedDataLen ); 
        
     // Clean msgbuffer
   	iMsgAssembler.MsgBuffer().Reset();
    iMsgAssembler.MsgBuffer().Compress();
    	   
    iMsgAssembler.SetUnConsumedBytes( 0 );
    
    CSIPMessage* message = iMsgAssembler.Message();
    message->SetContent( content ); // ownership is transferred
	content = NULL;
	
	aNextLength = CSIPMsgAssembler::EMsgBufferSize;
	
	iMsgAssembler.ChangeState( MMsgAssemblerContext::ECompMsgStart );
	iMsgAssembler.CurrentState().DataReceivedL( aData, aNextLength );
	
	return ETrue;
    }