TInt CSatNotifySendSs::CheckSsStringValidity
		(
    	TPtrC8 aSsString 
    	)
    {
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKSSSTRINGVALIDITY_1, "CSAT:: CSatNotifySendSs::CheckSsStringValidity");
    TInt ret( KErrNone );
    
    if ( !aSsString.Length() )
        {
        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKSSSTRINGVALIDITY_2, "CSAT:: CSatNotifySendSs::CheckSsStringValidity, String length is NULL");
        // If length is zero
        ret = KErrCorrupt;
        }
    
    _LIT8( KDtmf,            "p");
    _LIT8( KWild,            "w");
    _LIT8( KExpansionDigit,  ".");

    // SS string can contain only digits, star '*' and dash '#' characters.
    if ( ( KErrNotFound != aSsString.Find( KDtmf ) )
        || ( KErrNotFound != aSsString.Find( KWild ) )
        || ( KErrNotFound != aSsString.Find( KExpansionDigit ) ) )
        {
        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKSSSTRINGVALIDITY_3, "CSAT:: CSatNotifySendSs::CheckSsStringValidity, Incompatible character found");
        ret = KErrCorrupt;
        }
    return ret;
    }
TInt CVBookmarkConverter::ReadAssignment( const TDesC8& aBuffer,
    TInt& aPosition, TPtrC8& aTag, TPtrC8& aValue )
    {
    LOGGER_ENTERFN( "CVBookmarkConverter::ReadAssignment" );    
        
    TPtrC8 start = aBuffer.Mid( aPosition );
    TInt assignment = start.Find( KVBMKAssignment );
    TInt linefeed = start.Find( KVBMKLinefeed );
    
    // Did we find the delimeter and the linefeed
    if ( ( assignment == KErrNotFound) || ( linefeed == KErrNotFound ) )
        {
        return KErrNotFound;
        }
    // Linefeed must reside behind the delimeter
    if ( linefeed <= assignment )
        {
        return KErrNotFound;
        }
    // Extract tag
    aTag.Set( start.Left( assignment ) );
    IgnoreSpaces( aTag );

    // Extract value
    aValue.Set( start.Mid( assignment + 1, ( linefeed - 1 ) - assignment ) );
    IgnoreSpaces( aValue );
    
    // update position
    aPosition += ( linefeed + KVBMKLinefeed().Length() );

    LOGGER_LEAVEFN( "CVBookmarkConverter::ReadAssignment" );        
    return KErrNone;
    }
void
CContentWindowContainer::DataReceived(class MBrCtlLinkContent* aLinkContent,
      const isab::DataGuiMess* aMess, const char *aUrl)
{
   HBufC8* data = NULL;
   HBufC* contentType = NULL;
   HBufC* url = WFTextUtil::AllocLC(aUrl);
   TPtr8 ptr(const_cast<unsigned char*>(aMess->getData()), aMess->getSize(), aMess->getSize());

   TInt neck = ptr.Find(KNeck());
   if (neck == KErrNotFound) {
      data = HBufC8::NewLC( ptr.Length());
      data->Des().Copy(ptr);
      contentType = WFTextUtil::AllocLC("text/html");

   } else {
      TPtrC8 header = ptr.Left(neck);
      TPtrC8 body = ptr.Mid(neck+4);

      data = HBufC8::NewLC( body.Length());
      data->Des().Copy(body);

      TInt pos = header.Find(KLineEnd);
      TPtrC8 rest = header;
      while (pos != KErrNotFound) {
         TPtrC8 tmp = rest.Left(pos);
         rest.Set(rest.Mid(pos+2));
         pos = rest.Find(KLineEnd);
         TInt ctpos = tmp.FindF(KContentTypeMarker);
         if (ctpos != KErrNotFound) {
            TPtrC8 tmp2 = tmp.Mid(ctpos+KContentTypeMarker().Length());
            TInt scpos = tmp2.Find(KSemiColon);
            if (scpos == KErrNotFound) {
               contentType = HBufC::NewLC(tmp2.Length());
               contentType->Des().Copy(tmp2);
            } else {
               contentType = HBufC::NewLC(tmp2.Left(scpos).Length());
               contentType->Des().Copy(tmp2.Left(scpos));
            }
            break;
         }
      }

      if (!contentType) {
         contentType = WFTextUtil::AllocLC("text/html");
      }
   }

/*    contentType = RecognizeLC(*url, ptr); */
/*    contentType = WFTextUtil::AllocLC("text/html"); */


   aLinkContent->HandleResolveComplete(*contentType, KCharSet, data);

   CleanupStack::PopAndDestroy(contentType);
   CleanupStack::PopAndDestroy(data);
   CleanupStack::PopAndDestroy(url);
}
// -----------------------------------------------------------------------------
// CUpnpDevice::DescriptionUrlPort
// Retrun description URL port.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt CUpnpDevice::DescriptionUrlPort() const
    {
    if ( iAddress != TInetAddr( INET_ADDR( 0,0,0,0 ), 0) )
        {
        return iAddress.Port();
        }

    const TDesC8& url = DescriptionUrl();

    if ( url.Length()> KHttp().Length() )
        {
        TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() );

        TInt separIndex = addrAndPath.Find( KSepar() );

        if ( separIndex == KErrNotFound )
            {
            return KDefaultDescriptionUrlPort;
            }

        TInt slashIndex = addrAndPath.Find( KSlash8() );

        if ( slashIndex != KErrNotFound )
            {
            TPtrC8 port = addrAndPath.Mid(
                    separIndex + 1, slashIndex - separIndex
            );

            TLex8 lex( port );
            TInt prt;
            TInt err = lex.Val( prt );
            if( KErrNone != err )
                {
                return KErrNotFound;
                }

            return prt;
            }
        else
            {
            TPtrC8 port = addrAndPath.Right(
                    addrAndPath.Length() - ( separIndex + 1 )
            );

            TLex8 lex( port );
            TInt prt;
            TInt err = lex.Val( prt );
            if( KErrNone != err )
                {
                return KErrNotFound;
                }

            return prt;
            }
        }

    return KDefaultDescriptionUrlPort;
    }
void CTestFilter::DoSubmitL( RHTTPTransaction aTransaction )
{
	RHTTPHeaders hdr = aTransaction.Request().GetHeaderCollection();
	
	RStringF fieldname = aTransaction.Session().StringPool().StringF(HTTP::EUserAgent,RHTTPSession::GetTable());
	
	TBool found = EFalse;
	TPtrC8 rawFieldData;
	
	hdr.GetRawField(fieldname, rawFieldData);
	
	found = rawFieldData.Find(iUserAgent.DesC()) != KErrNotFound;
	
	if(!found)
	    hdr.SetFieldL(fieldname, iUserAgent);
	
    if( iHaveCredentials )
        {
        TBuf8<KB64KeySize> keyBase64(_L8("Aladdin")); 
        TBuf8<KB64KeySize> keyBase64Username(_L8("open sesame"));;
        RString username = iStringPool.OpenStringL( keyBase64 );
        CleanupClosePushL<RString>( username );
        RString password = iStringPool.OpenStringL( keyBase64Username );
        CleanupClosePushL<RString>( password );
		EncodeBasicAuthL(username, password, aTransaction);
        CleanupStack::PopAndDestroy(&password);
        CleanupStack::PopAndDestroy(&username);
        	
        }
}
EXPORT_C HBufC8* CTestConfig::ReplaceLC(const TDesC8& aOld, const TDesC8& aNew, const TDesC8& aOldString)
	{
	HBufC8* rString = aOldString.AllocLC();
	TInt oldLen = aOld.Length();
	TInt newLen = aNew.Length();

	if (!oldLen)
		return rString;

	for (TInt pos = 0; pos < rString->Length(); pos += newLen)
		{
		TPtrC8 ptrC = rString->Mid(pos);
		TInt find = ptrC.Find(aOld);

		if (find == KErrNotFound)
			return rString;
	
		pos += find;

		if (newLen > oldLen)
			{
			rString = rString->ReAllocL(rString->Length() + newLen - oldLen);
			CleanupStack::Pop();
			CleanupStack::PushL(rString);
			}

		TPtr8 ptr(rString->Des());
		ptr.Replace(pos, oldLen, aNew);
		}

	return rString;
	}
// -----------------------------------------------------------------------------
// Get value for given id.
// -----------------------------------------------------------------------------
//
HBufC8* CConfigurationHandler::GetTokenValue( const TDesC8& aData, 
											  const TDesC8& aKey )
	{
	if( aData.Find(aKey)==KErrNotFound )
		{
		return NULL;
		}

	// id is in the string
	TLex8 lex(aData);

	while( !lex.Eos() )
		{
		TPtrC8 token = lex.NextToken();

		TInt spos = token.Find(aKey);
		if( spos==KErrNotFound )
			{
			continue;
			}

		// key was found return value		
		
		TPtrC8 value = token.Right(token.Length()-aKey.Length()); 

		HBufC8* retval = HBufC8::NewL(value.Length());
		TPtr8 des = retval->Des();
		des.Append(value);
		return retval;
		}
		
	return NULL;
	}
TBool CPolicyNormalizer::ValidateElementNsL(CSenElement* aAssertion)
{
  
  CSenElement& element = AsElement();
  RPointerArray<CSenNamespace>& namespaces = element.NamespacesL();
  
  if(aAssertion->NamespaceURI().Length() < 1 )
  {
  
   TPtrC8 elementName = aAssertion->LocalName();
   TInt location = elementName.Find(KColon);
   
   if (location)
       {
        TPtrC8 nsPrefix = elementName.Left(location);
          
        CSenNamespace* ns = NULL;
        TInt count = namespaces.Count();
        for (TInt i=0; i < count; i++)
            {
            ns = (namespaces)[i];
            if(ns->Prefix().Compare(nsPrefix) == 0)
                {
                aAssertion->SetNamespaceL(ns->Prefix(),ns->URI());
                return ETrue;
                }
            }
        }
    }
    return EFalse;
}
TBool CExampleResolver::Match(const TDesC8& aImplementationType, 
	const TDesC8& aMatchType, 
	TBool aUseWildcards) const
	{
	TInt matchPos = KErrNotFound;

	_LIT8(dataSeparator, "||");
	const TInt separatorLength = dataSeparator().Length();

	// Look for the section separator marker '||'
	TInt separatorPos = aImplementationType.Find(dataSeparator);
	if(separatorPos == KErrNotFound)
		{
		// Match against the whole string
		if(aUseWildcards)
			matchPos = aImplementationType.Match(aMatchType);
		else
			matchPos = aImplementationType.Compare(aMatchType);
		}
	else
		{
		// Find the first section, up to the separator
		TPtrC8 dataSection = aImplementationType.Left(separatorPos);
		TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
		// Match against each section in turn
		while(separatorPos != KErrNotFound)
			{
			// Search this section
			if(aUseWildcards)
				matchPos = dataSection.Match(aMatchType);
			else
				matchPos = dataSection.Compare(aMatchType);

			// If we found it then no need to continue, so return
			if(matchPos != KErrNotFound)
				return ETrue;

			// Move on to the next section
			separatorPos = remainingData.Find(dataSeparator);
			if(separatorPos != KErrNotFound)
				{
				dataSection.Set(remainingData.Left(separatorPos));
				remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
				}
			else
				dataSection.Set(remainingData);
			}

		// Check the final part
		if(aUseWildcards)
			matchPos = dataSection.Match(aMatchType);
		else
			matchPos = dataSection.Compare(aMatchType);

		}
	return matchPos != KErrNotFound;
	}
// -----------------------------------------------------------------------------
// CUpnpDevice::DescriptionUrlAddressL
// Return description URL address.
// -----------------------------------------------------------------------------
//
EXPORT_C TInetAddr CUpnpDevice::DescriptionUrlAddressL() const
    {
    if ( iAddress == TInetAddr( INET_ADDR( 0,0,0,0 ), 0) )
        {

        const TDesC8& url = DescriptionUrl();

        if ( url.Length()> KHttp().Length() )
            {
            TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() );

            TInt index = addrAndPath.Find( KSepar() );

            if ( index == KErrNotFound )
                {
                index = addrAndPath.Find( KSlash8() );
                }

            if ( index == KErrNotFound )
                {
                return TInetAddr( INET_ADDR( 0,0,0,0 ), 0 );
                }

            TPtrC8 addr = addrAndPath.Left( index );

            TInetAddr address;

            HBufC* addrBuf = HBufC::NewLC(addr.Length());
            addrBuf->Des().Copy(addr);
            address.Input(*addrBuf);
            CleanupStack::PopAndDestroy(addrBuf);

            return address;
            }

        return TInetAddr(INET_ADDR( 0,0,0,0 ), 0 );
        }

    return iAddress;
    }
TBool CTestConfig::IsNewSection(const TDesC8& aSource, const TLex8& aInput) const
/**
 * Checks whether the current marked token in aInput starts with a '[' and ends with a ']',
 * and checks that this token is at the start of a line.
 *
 * @returns Whether this is a new section in the script file
 */
	{
	const TPtrC8 token(aInput.MarkedToken());
	const TInt offset(aInput.MarkedOffset());

	TBool ret = token.Length() > 2 && token.Find(KScriptSectionStart) == 0;
	ret = ret && token.Find(KScriptSectionEnd) != KErrNotFound;

	if (ret && offset > 0)
		{
		const TPtrC8 lastChar(aSource.Mid(offset-1, 1));
		ret = ret && (lastChar == KScriptLF || lastChar == KScriptCR);
		}

	return ret;
	}
TBool CAiwResolver::MatchServiceCmd(const TDesC8& aOpaqueData, const TDesC8& aServiceCmd) const
    {
    _LIT8(dataSeparator, "||");
    const TInt separatorLength = dataSeparator().Length();

    // Look for the section separator marker '||'
    TInt separatorPos = aOpaqueData.Find(dataSeparator);

    if (separatorPos == KErrNotFound)
        {
         if (aServiceCmd.Compare(aOpaqueData) == 0)
            {
            return ETrue;   
            }
        }
    else
        {
         // Find the first section, up to the separator
        TPtrC8 dataSection = aOpaqueData.Left(separatorPos);
        TPtrC8 remainingData = aOpaqueData.Mid(separatorPos + separatorLength);

        // Match against each section in turn
        while (separatorPos != KErrNotFound)
            {
            if (dataSection.Compare(aServiceCmd) == 0)
                {
                return ETrue;
                }

            // Move on to the next section
            separatorPos = remainingData.Find(dataSeparator);

            if (separatorPos != KErrNotFound)
                {
                dataSection.Set(remainingData.Left(separatorPos));
                remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
                }
            else
                {
                dataSection.Set(remainingData);
                }   
            }

        if (dataSection.Compare(aServiceCmd) == 0)
            {
            return ETrue;   
            }       
        }

    return EFalse;
    }
Exemple #13
0
// ---------------------------------------------------------
// CDdEng::ParseLicenseL()
// ---------------------------------------------------------
//
void CDdEng::ParseLicenseL()
{
	HBufC8* descriptorBuf = CodUtil::ConvertLC( iCodBuf->Des());
	TPtrC8 license;
	TPtrC8 descriptor (descriptorBuf->Ptr());
	TInt startTag = descriptor.Find(KLicenseStartTag); // "<license"
	if (startTag != KErrNotFound)
	{
		descriptor.Set(descriptor.Right(descriptor.Length()- startTag -1));
		TInt endTag = descriptor.Locate(KElementEnd); //'>'
		if (endTag != KErrNotFound)
		{
			license.Set(descriptor.Right(descriptor.Length()-endTag-1));
			TInt licenseTagEnd = license.Find(KLicenseEndTag); // "</license"
			if (licenseTagEnd != KErrNotFound)
			{
				license.Set(license.Left(licenseTagEnd));
			}
		}
	}
	iSaver->AppendData( license );
	CleanupStack::PopAndDestroy( descriptorBuf );
}
TInt CSenPropertiesElement::ValueTokensL(const TDesC8& aDelimiter,
                                         RPointerArray<TPtrC8>& aTokens)
    {
    TPtrC8 content = this->Content();
    TInt delim = content.Find(aDelimiter);
    while ( delim != KErrNotFound )
        {
        TPtrC8* piece = new (ELeave) TPtrC8();
        piece->Set(content.Mid(0,delim));
        aTokens.Append(piece);
        
        content.Set(content.Mid(delim+aDelimiter.Length(),
                                content.Length()-(delim+aDelimiter.Length())));

        delim = content.Find(aDelimiter);
        }

    if(!(this->Content()!=KNullDesC8 && content==KNullDesC8))
        {
        // If this property does NOT zero-length content
        // and the "last" (or first) token is KNullDesC8
        // it means that the string ends with delimiter;
        // Therefore, KNullDesC8 must NOT be added as a
        // result of "tailing delimiter".

        // Add all other tokens here; even KNullDesC8
        // gets added, if it is eiher first or 
        TPtrC8* token = new (ELeave) TPtrC8();
        token->Set(content);
        aTokens.Append(token);
        }    
    if (aTokens.Count() == 0)
        {
        return KErrNotFound;
        }
    return KErrNone;
    }
void CSatNotifySendSs::CheckCallForwarding
		( 
    	TPtrC8 aSource,               
    	RSat::TSsString& aSsString 
    	)
    {
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKCALLFORWARDING_1, "CSAT:: CSatNotifySendSs::CheckCallForwarding");
    _LIT8(KCFU,"*21*");    // Call forwarding unconditional (CFU)
    _LIT8(KCFB,"*67*");    // Call forwarding on Mobile Subscriber Busy(CFB)
    _LIT8(KCFNRy, "*61*"); // Call forwarding on No Reply (CFNRy)
    _LIT8(KCFNRc, "*62*"); // Call forwarding on Mobile Subscriber Not 
                           // Reachable (CFNRc)    
    // Try to find call forwarding string
    TInt pos( aSource.Find( KCFU ) );
    if ( KErrNotFound == pos )
        {
        pos = aSource.Find( KCFB );
        }
    if ( KErrNotFound == pos )
        {
        pos = aSource.Find( KCFNRy );
        }
    if ( KErrNotFound == pos )
        {
        pos = aSource.Find( KCFNRc );
        }
    if ( KErrNotFound != pos )
        {
        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CHECKCALLFORWARDING_2, "CSAT:: CSatNotifySendSs::CheckCallForwarding, String is for call forwarding");
        aSsString.iSsString.Zero();
        aSsString.iSsString.Append( aSource.Left( pos + 4 ) );
        aSsString.iSsString.Append( KPlusMarkCharacterCode );
        aSsString.iSsString.Append( 
            aSource.Right( aSource.Length() - ( pos + 4) ) );
        }
    }
// -----------------------------------------------------------------------------
// CUpnpSoapMessage::ServiceType
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C const TPtrC8 CUpnpSoapMessage::ServiceType()
{
    const TPtrC8 soap = SoapAction();
    
    if (soap.Length() > 0)
    {
        TInt servStart = soap.Find(KService());
        
        TInt servEnd = soap.Find(KCross());
        if( ( servStart < 0 ) ||
            ( servEnd   < 0 ) )
        {
            return KNullDesC8();
        }

        servStart += KService().Length();
        
        TInt length = (servEnd - servStart);
        
        return soap.Mid(servStart, length);
    }
    
    return KNullDesC8();
}
TBookmarkEncoding CVBookmarkConverter::Encoding( TPtrC8& aProperties )
    {
    TBookmarkEncoding encoding = ENoEncoding;
    
    TInt length = aProperties.Length();
    
    if ( aProperties.Length() > 0 )
        {
        if ( aProperties.Find( KVBMKPrintable ) > 0 )
            {
            encoding = EQuotedPrintable;
            }    
        }
    
    return encoding;
    }
// -----------------------------------------------------------------------------
// CUpnpSoapMessage::ActionName
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C const TPtrC8 CUpnpSoapMessage::ActionName()
{
    const TPtrC8 soap = SoapAction();
    
    if (soap.Length() > 0)
    {
        TInt crossIndex = soap.Find( KCross() );
        
        if ( 0 <= crossIndex )
        {
            return soap.Mid(crossIndex + 1, soap.Length() - (crossIndex + 2));
        }
    }
    // If soap is zero or KCross is not found, return KNullDesC8
    return KNullDesC8();
}
// -----------------------------------------------------------------------------
// CUpnpDevice::RemoveIpAddress
// Removes IP address in front of the url leaving only path to file.
//  (12.34.56.78/folder/file.ext -> /folder/file )
// -----------------------------------------------------------------------------
//
TPtrC8 CUpnpDevice::RemoveIpAddress( const TDesC8 &aAddress )
    {
    if ( aAddress.Length() > KHttp().Length() )
        {
        if ( aAddress.Left( KHttp().Length() ) == KHttp() )
            {
            TPtrC8 newContent = aAddress.Mid( KHttp().Length() );

            TInt slashIndex = newContent.Find( UpnpString::KSlash() );

            if ( slashIndex != KErrNotFound )
                {
                return newContent.Mid( slashIndex );
                }
            }
        }
    return TPtrC8( aAddress );
    }
// -----------------------------------------------------------------------------
// CUpnpDevice::DescriptionUrlPath
// Return description URL path.
// -----------------------------------------------------------------------------
//
EXPORT_C const TPtrC8 CUpnpDevice::DescriptionUrlPath() const
    {

    const TDesC8& url = DescriptionUrl();

    if ( url.Length()> KHttp().Length() )
        {
        TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() );

        TInt index = addrAndPath.Find( KSlash8() );

        if ( index != KErrNotFound )
            {
            TPtrC8 addr = addrAndPath.Right( addrAndPath.Length() - index );
            return addr;
            }
        }
    return TPtrC8( KNullDesC8 );
    }
// buf to array
EXPORT_C TInt CRpsMsg::InternalizeL(const TDesC8& aBufIn)
	{
	TInt length(aBufIn.Length());
	if(length <= 0)
		{
		return KErrCorrupt;
		}
		
	if(iMsgDataArray != NULL)
		iMsgDataArray->Reset();
	
	TBuf8<KMaxElementSize> buf;
	
	// Dismantle msg into data elements first 
	TBool stop(EFalse);
	while (stop == EFalse)
		{
		TPtrC8 ptr = aBufIn.Right(length);
		
		TInt offset = ptr.Find(KComma);
		
		if(offset == KErrNotFound)
			{
			if(length > 0)
				{
				buf.Copy(ptr);
				iMsgDataArray->AppendL(buf);
				break;
				}	
			}

		buf.Copy(ptr.Left(offset));
		iMsgDataArray->AppendL(buf);
		length -= ++offset;
		if(length <= 0)
			{
			stop = ETrue;
			}
		}
	
	return KErrNone;
	}
// ---------------------------------------------------------
// CMmsAttachmentHandler::CreateUTF8TextAttachmentFromFileL
// ---------------------------------------------------------
EXPORT_C void CMmsAttachmentHandler::CreateUTF8TextAttachmentFromFileL(
    CMsvStore& aStore,
    TMsvAttachmentId& aAttachmentId,
    RFile& aFile,
    RFs& aFs,
    TDriveUnit aMessageDrive )
    {
    
    _LIT8 ( KMmsCrLf8, "\x00D\x00A" ); // 8 bit line feed
    TInt size = 0;
    TInt error = KErrNone;
    error = aFile.Size( size );
    
    User::LeaveIfError( error ); // if can't get file size, we are in trouble

    TFileName* filename = new( ELeave ) TFileName;
    CleanupStack::PushL( filename );
    
    // 256 characters for each read
    HBufC* textBuffer = HBufC::NewL( KMmsTextBufferSize );
    CleanupStack::PushL( textBuffer );
    TPtr textPtr = textBuffer->Des();

    HBufC8* buffer = HBufC8::NewL( KMmsTextBufferSize * KMmsMaxBytesPerCharacter ); // paranoid.
    TInt fileSize = 0; // we don't know how big the file will be after conversion
    CleanupStack::PushL( buffer );
    TPtr8 buf8 = buffer->Des();

    CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
    CleanupStack::PushL( mimeHeaders );

    // attaInfo must be on top of stack because the ownership will be transferred
    // to attacment manager.    
    CMsvAttachment* attaInfo = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
    CleanupStack::PushL( attaInfo );
    
    TPtrC8 contentType;
    contentType.Set( KMmsTextPlain );
    
    TInt position = contentType.Find( KMmsSlash8 );
    mimeHeaders->SetContentTypeL( contentType.Left( position ) );
    mimeHeaders->SetContentSubTypeL( contentType.Mid( position + 1 ) );
    attaInfo->SetMimeTypeL( contentType );
    
    filename->Copy( TPtrC() );
  	aFile.Name( *filename ); // if this returns error, filename should be empty - no suggestion.
    attaInfo->SetAttachmentNameL( *filename );
    mimeHeaders->SetSuggestedFilenameL( *filename );
    mimeHeaders->SetMimeCharset( KMmsUtf8 );
    
    if ( TMmsGenUtils::DiskSpaceBelowCriticalLevelL( 
        &aFs,
        size * KMmsUnicodeToUtf2MaxIncrease + mimeHeaders->Size() + KMmsIndexEntryExtra,
        aMessageDrive ) )
        {
        // we use standard error code here
        User::Leave( KErrDiskFull );
        }
       
    mimeHeaders->StoreL( *attaInfo ); // Mime headers are streamed into atta info

    MMsvAttachmentManagerSync& attaManSync = aStore.AttachmentManagerExtensionsL();
    
    RFile attaFile;
    attaManSync.CreateAttachmentL( *filename, attaFile, attaInfo );
    CleanupStack::Pop( attaInfo ); // attaInfo ownership was transferred.
    aAttachmentId = attaInfo->Id();

    // Now our file handle is open for writing
    
    error = KErrNone;
    TMmsFileText textFile;
    textFile.Set( aFile );

    while ( error == KErrNone || error == KErrTooBig )
        {
        error = textFile.Read( textPtr );
        TBool appendCRLF = ETrue;
        if ( error == KErrTooBig )
            {
            appendCRLF = EFalse;
            error = KErrNone;
            }
        if ( error != KErrEof )
            {
            // if conversion fails, something is really seriously wrong
            error = CnvUtfConverter::ConvertFromUnicodeToUtf8( buf8, textPtr );
            }
        if ( error == KErrNone )
            {
            error = attaFile.Write( buf8 );
            if ( error == KErrNone )
                {
                fileSize += buf8.Length();
                if ( appendCRLF )
                    {
                    error = attaFile.Write( KMmsCrLf8 );
                    fileSize += KMmsLengthOfCRlf; // add length of carriage return/line feed
                    }
                }
            }
        }
        
    if ( error == KErrEof )
        {
        // end of file has been reached successfully
        error = KErrNone;
        }

    if ( error == KErrNone )
        {
        error = attaFile.Flush();
        }
    attaFile.Close();
    
    if ( error != KErrNone )
        {
        // Something went wrong when we tried to write our data.
        // We must delete the attachment as it does not contain the
        // intended data.
        RemoveAttachmentL( aAttachmentId, aStore );
        aAttachmentId = 0;
        }
    else
        {
        // If data writing was successful, the amount of data written
        // is now stored in fileSize.
        // Attachment info structure must be updated
        MMsvAttachmentManager& attaMan = aStore.AttachmentManagerL();
        attaInfo = attaMan.GetAttachmentInfoL( aAttachmentId );
        CleanupStack::PushL( attaInfo );
        attaInfo->SetSize( fileSize );
        attaManSync.ModifyAttachmentInfoL( attaInfo );
        // attachment manager now owns the attachment info
        CleanupStack::Pop( attaInfo ); // attaInfo
        }
        
    CleanupStack::PopAndDestroy( mimeHeaders );
    CleanupStack::PopAndDestroy( buffer );
    CleanupStack::PopAndDestroy( textBuffer );
    CleanupStack::PopAndDestroy( filename );
    
    User::LeaveIfError( error );
    
    }
Exemple #23
0
void CPolicyTest::ProcessResultsL(TRequestStatus& aStatus)
	{
	_LIT8(KSummaryLine, " tests failed out of ");
	_LIT8(KNewLine, "\r\n");

	TInt failCount = KErrNotFound, runCount;
	
	// Read entire log file into memory to process
	RFile file;
	TDriveUnit sysDrive (RFs::GetSystemDrive());
	TBuf<128> logTmpFile (sysDrive.Name());
	logTmpFile.Append(KLogTmpPath);
	User::LeaveIfError(file.Open(iFs, logTmpFile, EFileShareReadersOnly | EFileRead));
	CleanupClosePushL(file);

	TInt size;
	User::LeaveIfError(file.Size(size));
	HBufC8* buffer = HBufC8::NewLC(size);
	TPtr8 ptr = buffer->Des();

	User::LeaveIfError(file.Read(ptr));

	iOut.writeString(_L("Child test output:\n"));

	TInt pos = 0;
	while (pos < size)
		{
		TInt nextNewline = buffer->Mid(pos).Find(KNewLine);

		// Split buffer into lines
		TPtrC8 line;
		if (nextNewline == KErrNotFound)
			{
			line.Set(buffer->Mid(pos));
			}
		else
			{
			line.Set(buffer->Mid(pos, nextNewline + KNewLine().Length()));
			}
		pos += line.Length();

		// Search for summary line
		TInt pos2 = line.Find(KSummaryLine);
		if (pos2 != KErrNotFound)
			{
			// Parse the summary line to work out if the test passed
			TLex8 lex1(line.Left(pos2));
			TInt err1 = lex1.Val(failCount);
			TLex8 lex2(line.Mid(pos2 + KSummaryLine().Length()));
			TInt err2 = lex2.Val(runCount);

			if (err1 != KErrNone || err2 != KErrNone)
				{
				iOut.writeString(_L("Failed to parse summary line\n"));
				User::LeaveIfError(err1);
				User::LeaveIfError(err2);
				}
			}
		else
			{
			// Don't print the summary line as this will confuse whatever parsed
			// the main log
			iOut.writeString(_L("> "));
			iOut.writeString(line);
			}		
		}
	
	if (failCount == KErrNotFound)
		{
		iOut.writeString(_L("Couldn't find summary line in test output\n"));
		User::Leave(KErrNotFound);
		}
	iFailCount += failCount;

	// Print results in different format
	iOut.write(_L("Tests run: %d\n"), runCount);
	iOut.write(_L("Tests failed: %d\n"), failCount);
	iOut.writeNewLine();
	
	CleanupStack::PopAndDestroy(2, &file);

	TRequestStatus* status = &aStatus;
	User::RequestComplete(status, KErrNone);
	}
TInt CFloggerTest028_Sync_Static_Multiple2::DoTestCheckWriteL()
	{
	RFile logFile;
	HBufC8* hBuffer;
	TInt listfilesize,returnCode;
	RFs fileSystem; //For file operation create a file system
	TInt numSuccessful = 0;

	User::LeaveIfError(fileSystem.Connect());
	
	//Open the file in the read mode
	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));

	CleanupClosePushL(logFile);

	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
	
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
	CleanupStack::PushL(hBuffer);

	TPtr8 ptrString = hBuffer->Des();  //To access the buffer

	// Read from position 0: start of file
	User::LeaveIfError(returnCode = logFile.Read(ptrString));
	
	
	// the test case writes 5 elements 100 times, but we only check these things:
	// 1. that the long test message with one parameter is written 100 times
	// 2. that the test message with one param is written 100 times
	// 3. that the end of test message has been written
	
	TPtrC8 ptrStringOffsetForSearching;
	returnCode = ptrString.Find(KTestMessageOneParamExpected);

	if (returnCode > 0)
		{
		numSuccessful++;
		}
		
	TInt newLength;   // allow length to be watched during debugging
	TInt loop;
	
	ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length()));
	for (loop=0; loop < KMultipleWriteStressTimes; loop++)
		{
		returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance
		if (returnCode > 0)
			{
			numSuccessful++;
			}
			
		newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length();
	 	if (newLength < 0)
	 		{
	 		User::Leave(KErrUnknown);
	 		}

		ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength));
		
		}


	returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected);

	if (returnCode > 0)
		{
		numSuccessful++;
		}
		
	newLength = ptrString.Length()-returnCode-KTestTooLongMessageOneParamExpected().Length();
	ptrStringOffsetForSearching.Set(ptrString.Right(newLength));
	for (loop=0; loop < KMultipleWriteStressTimes; loop++)
		{
		returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance
		if (returnCode > 0)
			{
			numSuccessful++;
			}
			
		if (loop < (KMultipleWriteStressTimes - 1))
			{
			newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongMessageOneParamExpected().Length();
	 		if (newLength < 0)
	 			{
	 			User::Leave(KErrUnknown);
	 			}
			ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength));
			}
		
		}

	returnCode = ptrString.Find(KTestEndMessage8); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	
	CleanupStack::PopAndDestroy(hBuffer);
	CleanupStack::PopAndDestroy();	//logFile
	if ( numSuccessful == 201 )
		return KErrNone;
	else
		return KErrUnknown;
	}
TInt CFloggerTest028_Sync_ConMultiple2::DoTestCheckWriteL()
	{
	RFile logFile;
	HBufC8* hBuffer;
	TInt listfilesize,returnCode;
	RFs fileSystem; //For file operation create a file system
	TInt numSuccessful = 0;
	TInt loop = 0;

	User::LeaveIfError(fileSystem.Connect());
	
	//Open the file in the read mode
	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));

	CleanupClosePushL(logFile);

	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
	
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer. This is about 176K in size
	CleanupStack::PushL(hBuffer);

	TPtr8 ptrString = hBuffer->Des();  //To access the buffer

	// Read from position 0: start of file
	User::LeaveIfError(returnCode = logFile.Read(ptrString));
	
	// the test case writes 6 elements 100 times, but we only check these things:
	// 1. that the test message with one parameter is written 100 times
	// 2. that the long message is written 100 times
	// 3. that the end of test message has been written
	// 4. that the file is suitably big enough to be expected to contain the
	//    1K data segment 100 times in it.
	
	TPtrC8 ptrStringOffsetForSearching;
	returnCode = ptrString.Find(KTestMessageOneParamExpected);

	if (returnCode > 0)
		{
		numSuccessful++;
		}
		
	TInt newLength;
	ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length()));
	for (loop=0; loop < KMultipleWriteStressTimes; loop++)
		{
		returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance
		if (returnCode > 0)
			{
			numSuccessful++;
			}
			
		newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length();
		if (newLength < 0)
			{
			User::Leave(KErrUnknown);
			}
		ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength));
		
		}

	returnCode = ptrString.Find(KTestTooLongExpectedMessage); 
	
	if (returnCode > 0)
		{
		numSuccessful++;
		}
		
	ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestTooLongExpectedMessage().Length()));

	for (loop=0; loop < KMultipleWriteStressTimes; loop++)
		{

		returnCode = ptrStringOffsetForSearching.Find(KTestTooLongExpectedMessage); //find the next occurance
		if (returnCode > 0)
			{
			numSuccessful++;
			}
		newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongExpectedMessage().Length();
		if (newLength <0)
			{
			User::Leave(KErrUnknown);
			}
		ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength));
			
		}


	returnCode = ptrString.Find(KTestEndMessage8); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}
		

	// we don't check that all the binary data is there - just that the file is nice and long		
	if ( listfilesize > (K1KilobyteOfDataSize * KMultipleWriteStressTimes))
		{
		numSuccessful++;
		}
	


	CleanupStack::PopAndDestroy(hBuffer);
	CleanupStack::PopAndDestroy();	//logFile
	if ( numSuccessful == 202 )
		return KErrNone;
	else
		return KErrUnknown;
	}
TInt CFloggerTest028_Sync_Static_Multiple::DoTestCheckWriteL()
	{
	RFile logFile;
	HBufC8* hBuffer;
	TInt listfilesize,returnCode;
	RFs fileSystem; //For file operation create a file system
	TInt numSuccessful = 0;

	User::LeaveIfError(fileSystem.Connect());
	
	//Open the file in the read mode
	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));

	CleanupClosePushL(logFile);

	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
	
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
	CleanupStack::PushL(hBuffer);

	TPtr8 ptrString = hBuffer->Des();  //To access the buffer

	// Read from position 0: start of file
	User::LeaveIfError(returnCode = logFile.Read(ptrString));
	
	returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
											//from the file
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	// search for the occurance that the VA_LIST put in
	// when testing serial, the length will be negative, so skip
	TInt len;
	len = (ptrString.Length()-returnCode)-KTestTooLongMessageOneParamExpected().Length();
	if (len > 0)
		{
		TPtrC8 ptrStringOffsetForSearching = ptrString.Right(len);
		
		returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance
		if (returnCode > 0)
			{
			numSuccessful++;
			}
		}


	returnCode = ptrString.Find(KTestMessageOneParamExpected); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	returnCode = ptrString.Find(KTestMessageAsHex8); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	
	CleanupStack::PopAndDestroy(hBuffer);
	CleanupStack::PopAndDestroy();	//logFile
	if ( numSuccessful == 5 )
		return KErrNone;
	else
		return KErrUnknown;
	}
TInt CFloggerTest028_Sync_ConMultiple::DoTestCheckWriteL()
	{
	RFile logFile;
	HBufC8* hBuffer;
	TInt listfilesize,returnCode;
	RFs fileSystem; //For file operation create a file system
	TInt numSuccessful = 0;

	User::LeaveIfError(fileSystem.Connect());
	
	//Open the file in the read mode
	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));

	CleanupClosePushL(logFile);

	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
	
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
	CleanupStack::PushL(hBuffer);

	TPtr8 ptrString = hBuffer->Des();  //To access the buffer

	// Read from position 0: start of file
	User::LeaveIfError(returnCode = logFile.Read(ptrString));
	
	returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
											//from the file
	if (returnCode > 0)
		{
		numSuccessful++;
		}


	returnCode = ptrString.Find(KTestMessageOneParamExpected); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	TPtrC8 ptrStringOffsetForSearching = ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length());

	returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	returnCode = ptrString.Find(KTestTooLongExpectedMessage); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}
		
	returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); 
	if (returnCode > 0)
		{
		numSuccessful++;
		}

	// we don't check that all the binary data is there - just that the file is nice and long		
	if ( listfilesize > K1KilobyteOfDataSize)
		{
		numSuccessful++;
		}



	CleanupStack::PopAndDestroy(hBuffer);
	CleanupStack::PopAndDestroy();	//logFile
	if ( numSuccessful == 6 )
		return KErrNone;
	else
		return KErrUnknown;
	}
// -----------------------------------------------------------------------------
// CUpnpSsdpServer::UdpMessageReceivedL
// UDP message received.
// -----------------------------------------------------------------------------
//
void CUpnpSsdpServer::UdpMessageReceivedL( CUdpMessage* aMessage )
    {
    if ( !aMessage )
        {
        return;
        }
    CUpnpSsdpMessage* message = ( CUpnpSsdpMessage* ) aMessage;
   
       // Unless it's response, check if HOST header has explicitly specified port number - 1900
       // If not, then add this port
       if ( !message->IsSsdpResponse() )
           {
           TPtrC8 host = message->GetHeaderValue( KHdrHost );
           
           // : Not found so port is not specified
           if( host.Find( UpnpString::KColon() ) == KErrNotFound )
            {
            TBuf8<KMaxIntegerLength> defaultPort;
               defaultPort.Num( KMulticastPort );
               
               HBufC8* newHost = HBufC8::NewLC( host.Length() +
                                       UpnpString::KColon().Length() +
                                       defaultPort.Length() );
               
               newHost->Des().Zero();
               newHost->Des().Append( host );
               newHost->Des().Append( UpnpString::KColon() );
               newHost->Des().Append( defaultPort );
                   
               message->AddHostL( *newHost );
               CleanupStack::PopAndDestroy(newHost);
            }
           }
   
    if ( iMasterServer )
        {
        iMasterServer->MessageFromMulticastL( message );
        }
    else
        {
        if ( message->IsSsdpMSearch() )
            {
            LOGS( "SSDP *** Search received");
            ResponseL( message );
            // add additional notification to upper-layer 
            // used for detection IP address change
            iSsdpServerObserver->SsdpEventL( message );
            }
        else if (message->IsSsdpNotify())
            {
            LOGS( "SSDP *** Notify received");
            iSsdpServerObserver->SsdpEventL( message );
            }
        else if (message->IsSsdpResponse())
            {
            LOGS( "SSDP *** Response received");
            iSsdpServerObserver->SsdpEventL( message );
            }
        else
            {
            LOGS( "SSDP *** UNKNOWN MESSAGE RECEIVED");
            }
        }
    }
// ----------------------------------------------------------
// CSimplePresenceList::DoConstructL
// ----------------------------------------------------------
//    
void CSimplePresenceList::DoConstructL( 
    RPointerArray<CBodyPart>& aParts, const TDesC8& aStart )
    {
    
    _LIT8( KMyContentType, "Content-Type: multipart/related;");  
    _LIT8( KMyBoundary, "boundary="); 
    
    const TInt myBoundaryLen = 9;   // boundary=  9 characters         
       
    // Handle body parts one by one
    TInt size = aParts.Count();
    TInt i;
    CBodyPart* cp = NULL;
    TPtrC8 boundary;
    TPtrC8 start;
    
    // remove "..." quoted marks when needed
    TPtrC8 pStartUnquoted( KNullDesC8 );
    if ( aStart.Locate( '"') == 0 )
        {
        pStartUnquoted.Set( aStart.Mid( 1, aStart.Length() - 2 ));
        }
    else
        {
        pStartUnquoted.Set( aStart );        
        } 

    // remove <...> marks when needed
    if ( pStartUnquoted.Locate( '<') == 0 )
        {
        pStartUnquoted.Set( pStartUnquoted.Mid( 1, pStartUnquoted.Length() - 2 ));
        } 
    
    TPtrC8 p8;
    p8.Set( KSimpleDocumentType );
    TInt mySize = p8.Length();
    p8.Set( KSimpleMultipartType );
    TInt mySize2 = p8.Length();    
          
#ifdef _DEBUG                
    TPtrC p16b; // notice: for debug
    TPtrC8 p8b;
#endif 

// Make this handle direct content too in the RLMI list, i.e. 
// content-type: multipart/related; type="application/pidf+xml"; boundary=...;
    for (i = 0; i < size; i++)
        {
        cp = aParts[i];
        // inline const TDesC8& Headers() { return iHeaders; }
        TPtrC8 allHeaders = cp->Headers();
        HBufC8* headersBuff = allHeaders.AllocL();
        CleanupStack::PushL( headersBuff );
               
#ifdef _DEBUG        
        p16b.Set( cp->Url() ); // debug only
        p8b.Set( cp->ContentType() ); // debug only
        p8b.Set( cp->ContentID() ); // debug only
#endif                         
        if ( !pStartUnquoted.Compare( cp->ContentID()) &&
             !cp->ContentType().Left(sizeof(KSimpleListType)).CompareF( KSimpleListType ))
            {
            // Meta data is the root         
            iMeta = CSimpleMeta::NewL( cp->Body() );                               
            }
        else if ( !cp->ContentType().CompareF( KSimpleDocumentType ))
            {
            // Ordinary presence element                    
            CSimpleDocument* cd = CSimpleDocument::NewL( cp->Body() );             
            CleanupStack::PushL( cd );           
            User::LeaveIfError( iDocuments.Append( cd ) );
            CleanupStack::Pop( cd );
            }             
        else if ( (!cp->ContentType().Left(mySize2).CompareF( KSimpleMultipartType ))) 
            {
            // multipart for user's direct content data
            // get boundary from headers
            TPtrC8 pStart(KNullDesC8);
            TPtrC8 pBoundary(KNullDesC8);          
            
            TPtrC8 pHeaders = headersBuff->Des();
            TPtrC8 pContentType;
            TInt pos1 = pHeaders.Find( KMyContentType );
            if ( pos1 >= 0 )
                {
                TPtrC8 h2 = pHeaders.Mid( pos1 );
                TInt pos2 = h2.Locate( '\r');
                if ( pos2 < 0 )
                    {
                    pContentType.Set( h2 );
                    }
                else
                    {
                    pContentType.Set( h2.Left( h2.Length() - pos2 ));                    
                    }    
                                                                
                // search boundary 
                TInt posx = pContentType.Find( KMyBoundary );
                if ( posx >= 0 )
                    {                    
                    TPtrC8 h5 = pContentType.Mid( posx );
                    TInt pos5 = h5.Locate( ';');
                    if ( pos5 < 0 )
                        {
                        // There are no more parameters
                        pBoundary.Set( h5.Mid( myBoundaryLen )); 
                        }
                    else
                        {
                        // There are more in the line, has to cut off                        
                        pBoundary.Set( h5.Mid( myBoundaryLen, pos5 - myBoundaryLen ));                        
                        }    
                    }                 
                }
            
            // "..." characters are removed later from boundary in NewInMultiPartL(
            CSimpleDocument* cd = CSimpleDocument::NewInMultiPartL( cp->Body(), pBoundary, pStart );
            CleanupStack::PushL( cd );           
            User::LeaveIfError( iDocuments.Append( cd ) );
            CleanupStack::Pop( cd );            
                        
            }        
        /* notice: later nested multiparts if type = rlmi   */
        else
            {
            // This is something that should not be in the document.
            // Ignore it.
            } 
        CleanupStack::PopAndDestroy( headersBuff );                             
        }    
    }
TInt CVBookmarkConverter::ReadTagAndValue( const TDesC8& aBuffer, TInt& aPosition, 
    TPtrC8& aTag, TPtrC8& aValue, TPtrC8& aProperties )
    {
    LOGGER_ENTERFN( "CVBookmarkConverter::ReadTagAndValue" );   
    
    TPtrC8 start = aBuffer.Mid( aPosition );
    TInt delimeter = start.Find( KVBMKColon );
    TInt linefeed = start.Find( KVBMKLinefeed );
    TInt semicolon = start.Find( KVBMKSemicolon );
    
    
    // Did we find a linefeed?
    if ( linefeed == KErrNotFound )
        {
        // Check whether file ends without newline
        if( aBuffer.Length() <= ( aPosition + start.Length() ) )
            {
            // Set linefeed at the end of the file
            linefeed = start.Length();
            }
        else
            { 
            return KErrNotFound;
            }
        }

    // Did we find a semicolon?
    if ( semicolon != KErrNotFound )
        {
        // It must be before the delimeter (property identifiers reside in this block)
        if ( semicolon >= delimeter || semicolon < 0 )
            {
            semicolon = KErrNotFound;
            }
        }
    
    // Did we find the delimeter
    if( delimeter == KErrNotFound )
        {
        return KErrNotFound;
        }

    // Linefeed must reside behind the delimeter
    if ( linefeed <= delimeter )
        {
        return KErrNotFound;
        }
    
    aTag.Set( start.Left( semicolon != KErrNotFound ? semicolon : delimeter ) );
    IgnoreSpaces( aTag );

    // Extract value
    aValue.Set( start.Mid( delimeter + 1, (linefeed - 1) - delimeter ) );
    IgnoreSpaces( aValue );
    
    // Extract properties if found
    if ( semicolon != KErrNotFound )
        {
        aProperties.Set( start.Mid( semicolon, delimeter - semicolon ) );
        IgnoreSpaces( aProperties );
        }
    else
        {
        aProperties.Set( KVBMKNone() );
        }     
    
    // update position
    aPosition += ( linefeed + KVBMKLinefeed().Length() );
    
    LOGGER_LEAVEFN( "CVBookmarkConverter::ReadTagAndValue" );       
    return KErrNone;
    }